validate: media-descriptor: Add a way to specify when a field value is unknown

And this way is to set the attribute to... `unknown`
This commit is contained in:
Thibault Saunier 2018-05-23 01:11:32 +02:00
parent 3f668f3e80
commit ad6fc12b76
3 changed files with 33 additions and 23 deletions

View file

@ -128,7 +128,6 @@ deserialize_segmentnode (const gchar ** names, const gchar ** values)
node->segment.duration = g_ascii_strtoull (values[i], NULL, 0); node->segment.duration = g_ascii_strtoull (values[i], NULL, 0);
} }
return node; return node;
} }
@ -162,30 +161,35 @@ deserialize_framenode (const gchar ** names, const gchar ** values)
GstValidateMediaFrameNode *framenode = GstValidateMediaFrameNode *framenode =
g_slice_new0 (GstValidateMediaFrameNode); g_slice_new0 (GstValidateMediaFrameNode);
/* *INDENT-OFF* */
#define IF_SET_UINT64_FIELD(name,fieldname) \
if (g_strcmp0 (names[i], name) == 0) { \
if (g_strcmp0 (values[i], "unknown") == 0) \
framenode->fieldname = GST_VALIDATE_UKNOWN_UINT64; \
else\
framenode->fieldname = g_ascii_strtoull (values[i], NULL, 0); \
}
for (i = 0; names[i] != NULL; i++) { for (i = 0; names[i] != NULL; i++) {
if (g_strcmp0 (names[i], "id") == 0) IF_SET_UINT64_FIELD ("id", id)
framenode->id = g_ascii_strtoull (values[i], NULL, 0); else IF_SET_UINT64_FIELD ("offset", offset)
else if (g_strcmp0 (names[i], "offset") == 0) else IF_SET_UINT64_FIELD ("offset-end", offset_end)
framenode->offset = g_ascii_strtoull (values[i], NULL, 0); else IF_SET_UINT64_FIELD ("duration", duration)
else if (g_strcmp0 (names[i], "offset-end") == 0) else IF_SET_UINT64_FIELD ("pts", pts)
framenode->offset_end = g_ascii_strtoull (values[i], NULL, 0); else IF_SET_UINT64_FIELD ("dts", dts)
else if (g_strcmp0 (names[i], "duration") == 0) else IF_SET_UINT64_FIELD ("running-time", running_time)
framenode->duration = g_ascii_strtoull (values[i], NULL, 0);
else if (g_strcmp0 (names[i], "pts") == 0)
framenode->pts = g_ascii_strtoull (values[i], NULL, 0);
else if (g_strcmp0 (names[i], "dts") == 0)
framenode->dts = g_ascii_strtoull (values[i], NULL, 0);
else if (g_strcmp0 (names[i], "running-time") == 0)
framenode->running_time = g_ascii_strtoull (values[i], NULL, 0);
else if (g_strcmp0 (names[i], "checksum") == 0) else if (g_strcmp0 (names[i], "checksum") == 0)
framenode->checksum = g_strdup (values[i]); framenode->checksum = g_strdup (values[i]);
else if (g_strcmp0 (names[i], "is-keyframe") == 0) { else if (g_strcmp0 (names[i], "is-keyframe") == 0) {
if (!g_ascii_strcasecmp (values[i], "true")) if (!g_ascii_strcasecmp (values[i], "true"))
framenode->is_keyframe = TRUE; framenode->is_keyframe = TRUE;
else if (!g_ascii_strcasecmp (values[i], "unknown"))
framenode->is_keyframe = GST_VALIDATE_UKNOWN_BOOL;
else else
framenode->is_keyframe = FALSE; framenode->is_keyframe = FALSE;
} }
} }
/* *INDENT-ON* */
framenode->buf = gst_buffer_new_wrapped (framenode->checksum, framenode->buf = gst_buffer_new_wrapped (framenode->checksum,
strlen (framenode->checksum) + 1); strlen (framenode->checksum) + 1);

View file

@ -456,8 +456,8 @@ compare_frames (GstValidateMediaDescriptor * ref,
G_GUINT64_FORMAT, rstream->id, rframe->id, cframe->id); G_GUINT64_FORMAT, rstream->id, rframe->id, cframe->id);
return FALSE; return FALSE;
} }
#define CHECK_FRAME_FIELD(fieldname, format) \ #define CHECK_FRAME_FIELD(fieldname, format, unknown_value) \
if (rframe->fieldname != cframe->fieldname) { \ if (rframe->fieldname != unknown_value && rframe->fieldname != cframe->fieldname) { \
GST_VALIDATE_REPORT (ref, FILE_FRAMES_INCORRECT, \ GST_VALIDATE_REPORT (ref, FILE_FRAMES_INCORRECT, \
"Stream %s frames with id %" G_GUINT64_FORMAT " have " #fieldname \ "Stream %s frames with id %" G_GUINT64_FORMAT " have " #fieldname \
" mismatch. Expected " format ", got " format, rstream->id, \ " mismatch. Expected " format ", got " format, rstream->id, \
@ -465,11 +465,13 @@ compare_frames (GstValidateMediaDescriptor * ref,
return FALSE; \ return FALSE; \
} }
CHECK_FRAME_FIELD (pts, "%" G_GUINT64_FORMAT); CHECK_FRAME_FIELD (pts, "%" G_GUINT64_FORMAT, GST_VALIDATE_UKNOWN_UINT64);
CHECK_FRAME_FIELD (dts, "%" G_GUINT64_FORMAT); CHECK_FRAME_FIELD (dts, "%" G_GUINT64_FORMAT, GST_VALIDATE_UKNOWN_UINT64);
CHECK_FRAME_FIELD (duration, "%" G_GUINT64_FORMAT); CHECK_FRAME_FIELD (duration, "%" G_GUINT64_FORMAT,
CHECK_FRAME_FIELD (running_time, "%" G_GUINT64_FORMAT); GST_VALIDATE_UKNOWN_UINT64);
CHECK_FRAME_FIELD (is_keyframe, "%d"); CHECK_FRAME_FIELD (running_time, "%" G_GUINT64_FORMAT,
GST_VALIDATE_UKNOWN_UINT64);
CHECK_FRAME_FIELD (is_keyframe, "%d", GST_VALIDATE_UKNOWN_BOOL);
return TRUE; return TRUE;
} }

View file

@ -27,7 +27,11 @@
#include <gst/gst.h> #include <gst/gst.h>
#include "gst-validate-report.h" #include "gst-validate-report.h"
G_BEGIN_DECLS typedef struct G_BEGIN_DECLS
#define GST_VALIDATE_UKNOWN_UINT64 (G_MAXUINT64 - 2)
#define GST_VALIDATE_UKNOWN_BOOL (G_MAXUINT32 - 2)
typedef struct
{ {
/* Children */ /* Children */
/* GstValidateMediaTagNode */ /* GstValidateMediaTagNode */