mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-02 14:36:41 +00:00
validate: MediaDescriptors: Add md5sum to buffer informations
In the media descriptor files, we now have the md5sum of the actual content of encoded buffers so that we can check that the buffer content is perfectly what is was supposed to be. + Fix the check of whether a frame is a keyframe in the string comparison (g_ascii_strcasecmp return 0 if string matches) https://bugzilla.gnome.org/show_bug.cgi?id=736138
This commit is contained in:
parent
50273c42a9
commit
b3fa06c3c1
3 changed files with 24 additions and 7 deletions
|
@ -21,6 +21,7 @@
|
|||
*/
|
||||
|
||||
#include "media-descriptor-parser.h"
|
||||
#include <string.h>
|
||||
|
||||
G_DEFINE_TYPE (GstMediaDescriptorParser, gst_media_descriptor_parser,
|
||||
GST_TYPE_MEDIA_DESCRIPTOR);
|
||||
|
@ -134,15 +135,18 @@ deserialize_framenode (const gchar ** names, const gchar ** values)
|
|||
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], "checksum") == 0)
|
||||
framenode->checksum = g_strdup (values[i]);
|
||||
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;
|
||||
else
|
||||
framenode->is_keyframe = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
framenode->buf = gst_buffer_new ();
|
||||
framenode->buf = gst_buffer_new_wrapped (framenode->checksum,
|
||||
strlen (framenode->checksum) + 1);
|
||||
|
||||
GST_BUFFER_OFFSET (framenode->buf) = framenode->offset;
|
||||
GST_BUFFER_OFFSET_END (framenode->buf) = framenode->offset_end;
|
||||
|
@ -150,8 +154,11 @@ deserialize_framenode (const gchar ** names, const gchar ** values)
|
|||
GST_BUFFER_PTS (framenode->buf) = framenode->pts;
|
||||
GST_BUFFER_DTS (framenode->buf) = framenode->dts;
|
||||
|
||||
if (framenode->is_keyframe == FALSE)
|
||||
if (framenode->is_keyframe) {
|
||||
GST_BUFFER_FLAG_UNSET (framenode->buf, GST_BUFFER_FLAG_DELTA_UNIT);
|
||||
} else {
|
||||
GST_BUFFER_FLAG_SET (framenode->buf, GST_BUFFER_FLAG_DELTA_UNIT);
|
||||
}
|
||||
|
||||
return framenode;
|
||||
}
|
||||
|
@ -167,7 +174,7 @@ frame_node_compare (FrameNode * fnode, GstBuffer * buf, GstBuffer * expected)
|
|||
GST_BUFFER_PTS (expected) = fnode->pts;
|
||||
GST_BUFFER_DTS (expected) = fnode->dts;
|
||||
if (fnode->is_keyframe)
|
||||
GST_BUFFER_FLAG_SET (expected, GST_BUFFER_FLAG_DELTA_UNIT);
|
||||
GST_BUFFER_FLAG_UNSET (expected, GST_BUFFER_FLAG_DELTA_UNIT);
|
||||
}
|
||||
|
||||
if ((fnode->offset == GST_BUFFER_OFFSET (buf) &&
|
||||
|
|
|
@ -729,9 +729,16 @@ gst_media_descriptor_writer_add_frame (GstMediaDescriptorWriter
|
|||
StreamNode *streamnode = (StreamNode *) tmp->data;
|
||||
|
||||
if (streamnode->pad == pad) {
|
||||
GstMapInfo map;
|
||||
gchar *checksum;
|
||||
guint id = g_list_length (streamnode->frames);
|
||||
FrameNode *fnode = g_slice_new0 (FrameNode);
|
||||
|
||||
g_assert (gst_buffer_map (buf, &map, GST_MAP_READ));
|
||||
checksum = g_compute_checksum_for_data (G_CHECKSUM_MD5,
|
||||
(const guchar *) map.data, map.size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
fnode->id = id;
|
||||
fnode->offset = GST_BUFFER_OFFSET (buf);
|
||||
fnode->offset_end = GST_BUFFER_OFFSET_END (buf);
|
||||
|
@ -745,14 +752,16 @@ gst_media_descriptor_writer_add_frame (GstMediaDescriptorWriter
|
|||
g_markup_printf_escaped (" <frame duration=\"%" G_GUINT64_FORMAT
|
||||
"\" id=\"%i\" is-keyframe=\"%s\" offset=\"%" G_GUINT64_FORMAT
|
||||
"\" offset-end=\"%" G_GUINT64_FORMAT "\" pts=\"%" G_GUINT64_FORMAT
|
||||
"\" dts=\"%" G_GUINT64_FORMAT "\" />", fnode->duration, id,
|
||||
fnode->is_keyframe ? "true" : "false",
|
||||
fnode->offset, fnode->offset_end, fnode->pts, fnode->dts);
|
||||
"\" dts=\"%" G_GUINT64_FORMAT "\" checksum=\"%s\"/>",
|
||||
fnode->duration, id, fnode->is_keyframe ? "true" : "false",
|
||||
fnode->offset, fnode->offset_end, fnode->pts, fnode->dts, checksum);
|
||||
|
||||
fnode->str_close = NULL;
|
||||
|
||||
streamnode->frames = g_list_append (streamnode->frames, fnode);
|
||||
GST_MEDIA_DESCRIPTOR_UNLOCK (writer);
|
||||
|
||||
g_free (checksum);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,6 +108,7 @@ typedef struct
|
|||
|
||||
GstBuffer *buf;
|
||||
|
||||
gchar *checksum;
|
||||
gchar *str_open;
|
||||
gchar *str_close;
|
||||
} FrameNode;
|
||||
|
|
Loading…
Reference in a new issue