summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiago Santos <thiagoss@osg.samsung.com>2015-11-27 18:05:23 -0300
committerThiago Santos <thiagoss@osg.samsung.com>2015-12-04 19:03:53 -0300
commitee7cb88d02a8e16402458b2c3e2ad97c3e510559 (patch)
tree8a67568300907897145b5d83e5027cfaa1499dca
parent84dd10b6284bc0b0f883e1f24ebe30ac555a539e (diff)
media-descriptor: check if frame data matches
When comparing media descriptors, also check if the frames match https://bugzilla.gnome.org/show_bug.cgi?id=758855
-rw-r--r--validate/gst/validate/gst-validate-report.c2
-rw-r--r--validate/gst/validate/gst-validate-report.h1
-rw-r--r--validate/gst/validate/media-descriptor.c67
3 files changed, 69 insertions, 1 deletions
diff --git a/validate/gst/validate/gst-validate-report.c b/validate/gst/validate/gst-validate-report.c
index ac850a4..48e1b84 100644
--- a/validate/gst/validate/gst-validate-report.c
+++ b/validate/gst/validate/gst-validate-report.c
@@ -299,6 +299,8 @@ gst_validate_report_load_issues (void)
_("resulting file stream profiles didn't match expected values"), NULL);
REGISTER_VALIDATE_ISSUE (ISSUE, FILE_TAG_DETECTION_INCORRECT,
_("detected tags are different than expected ones"), NULL);
+ REGISTER_VALIDATE_ISSUE (CRITICAL, FILE_FRAMES_INCORRECT,
+ _("resulting file frames are not as expected"), NULL);
REGISTER_VALIDATE_ISSUE (WARNING, FILE_NO_STREAM_INFO,
_("the discoverer could not determine the stream info"), NULL);
REGISTER_VALIDATE_ISSUE (WARNING, FILE_NO_STREAM_ID,
diff --git a/validate/gst/validate/gst-validate-report.h b/validate/gst/validate/gst-validate-report.h
index 5a32e97..87d0e00 100644
--- a/validate/gst/validate/gst-validate-report.h
+++ b/validate/gst/validate/gst-validate-report.h
@@ -98,6 +98,7 @@ typedef enum {
#define FILE_DURATION_INCORRECT _QUARK("file-checking::duration-incorrect")
#define FILE_SEEKABLE_INCORRECT _QUARK("file-checking::seekable-incorrect")
#define FILE_PROFILE_INCORRECT _QUARK("file-checking::profile-incorrect")
+#define FILE_FRAMES_INCORRECT _QUARK("file-checking::frames-incorrect")
#define ALLOCATION_FAILURE _QUARK("runtime::allocation-failure")
#define MISSING_PLUGIN _QUARK("runtime::missing-plugin")
diff --git a/validate/gst/validate/media-descriptor.c b/validate/gst/validate/media-descriptor.c
index 0669d32..37e70e2 100644
--- a/validate/gst/validate/media-descriptor.c
+++ b/validate/gst/validate/media-descriptor.c
@@ -337,6 +337,69 @@ stream_id_is_equal (const gchar * uri, const gchar * rid, const gchar * cid)
return FALSE;
}
+static gboolean
+compare_frames (GstMediaDescriptor * ref, StreamNode * rstream,
+ FrameNode * rframe, FrameNode * cframe)
+{
+ if (rframe->id != cframe->id) {
+ GST_VALIDATE_REPORT (ref, FILE_FRAMES_INCORRECT,
+ "Stream frame %s ids mismatch: %" G_GUINT64_FORMAT " != %"
+ G_GUINT64_FORMAT, rstream->id, rframe->id, cframe->id);
+ return FALSE;
+ }
+#define CHECK_FRAME_FIELD(fieldname, format) \
+ if (rframe->fieldname != cframe->fieldname) { \
+ GST_VALIDATE_REPORT (ref, FILE_FRAMES_INCORRECT, \
+ "Stream %s frames with id %" G_GUINT64_FORMAT " have " #fieldname \
+ " mismatch. Expected " format ", got " format, rstream->id, \
+ rframe->id, rframe->fieldname, cframe->fieldname); \
+ return FALSE; \
+ }
+
+ CHECK_FRAME_FIELD (pts, "%" G_GUINT64_FORMAT);
+ CHECK_FRAME_FIELD (dts, "%" G_GUINT64_FORMAT);
+ CHECK_FRAME_FIELD (duration, "%" G_GUINT64_FORMAT);
+ CHECK_FRAME_FIELD (offset, "%" G_GUINT64_FORMAT);
+ CHECK_FRAME_FIELD (offset_end, "%" G_GUINT64_FORMAT);
+ CHECK_FRAME_FIELD (is_keyframe, "%d");
+
+ return TRUE;
+}
+
+static gboolean
+compare_frames_list (GstMediaDescriptor * ref, StreamNode * rstream,
+ StreamNode * cstream)
+{
+ GList *rframes, *cframes;
+
+ if (g_list_length (rstream->frames) != g_list_length (cstream->frames)) {
+ GST_VALIDATE_REPORT (ref, FILE_FRAMES_INCORRECT,
+ "Stream reference has %i frames, compared one has %i frames",
+ g_list_length (rstream->frames), g_list_length (cstream->frames));
+ return FALSE;
+ }
+
+ for (rframes = rstream->frames, cframes = cstream->frames; rframes;
+ rframes = g_list_next (rframes), cframes = g_list_next (cframes)) {
+ FrameNode *rframe, *cframe;
+
+ if (cframes == NULL) {
+ /* The list was checked to be of the same size */
+ g_assert_not_reached ();
+ return FALSE;
+ }
+
+ rframe = rframes->data;
+ cframe = cframes->data;
+
+ if (!compare_frames (ref, rstream, rframe, cframe)) {
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+}
+
/* Return -1 if not found 1 if OK 0 if an error occured */
static gint
compare_streams (GstMediaDescriptor * ref, StreamNode * rstream,
@@ -358,7 +421,9 @@ compare_streams (GstMediaDescriptor * ref, StreamNode * rstream,
/* We ignore the return value on purpose as this is not critical */
compare_tags (ref, rstream, cstream);
- return 1;
+ if (compare_frames_list (ref, rstream, cstream))
+ return 1;
+ return 0;
}
return -1;