update for tag API changes

This commit is contained in:
Wim Taymans 2011-12-01 18:55:45 +01:00
parent 47182ca61f
commit f1558baf83
3 changed files with 39 additions and 29 deletions

View file

@ -8132,7 +8132,7 @@ qtdemux_tag_add_covr (GstQTDemux * qtdemux, const char *tag1, const char *dummy,
GNode *data; GNode *data;
int len; int len;
int type; int type;
GstBuffer *buf; GstSample *sample;
data = qtdemux_tree_get_child_by_type (node, FOURCC_data); data = qtdemux_tree_get_child_by_type (node, FOURCC_data);
if (data) { if (data) {
@ -8140,12 +8140,13 @@ qtdemux_tag_add_covr (GstQTDemux * qtdemux, const char *tag1, const char *dummy,
type = QT_UINT32 ((guint8 *) data->data + 8); type = QT_UINT32 ((guint8 *) data->data + 8);
GST_DEBUG_OBJECT (qtdemux, "have covr tag, type=%d,len=%d", type, len); GST_DEBUG_OBJECT (qtdemux, "have covr tag, type=%d,len=%d", type, len);
if ((type == 0x0000000d || type == 0x0000000e) && len > 16) { if ((type == 0x0000000d || type == 0x0000000e) && len > 16) {
if ((buf = gst_tag_image_data_to_image_buffer ((guint8 *) data->data + 16, if ((sample =
gst_tag_image_data_to_image_sample ((guint8 *) data->data + 16,
len - 16, GST_TAG_IMAGE_TYPE_NONE))) { len - 16, GST_TAG_IMAGE_TYPE_NONE))) {
GST_DEBUG_OBJECT (qtdemux, "adding tag size %d", len - 16); GST_DEBUG_OBJECT (qtdemux, "adding tag size %d", len - 16);
gst_tag_list_add (qtdemux->tag_list, GST_TAG_MERGE_REPLACE, gst_tag_list_add (qtdemux->tag_list, GST_TAG_MERGE_REPLACE,
tag1, buf, NULL); tag1, sample, NULL);
gst_buffer_unref (buf); gst_sample_unref (sample);
} }
} }
} }

View file

@ -579,7 +579,9 @@ gst_matroska_read_common_parse_attached_file (GstMatroskaReadCommon * common,
if (filename && mimetype && data && datalen > 0) { if (filename && mimetype && data && datalen > 0) {
GstTagImageType image_type = GST_TAG_IMAGE_TYPE_NONE; GstTagImageType image_type = GST_TAG_IMAGE_TYPE_NONE;
GstBuffer *tagbuffer = NULL; GstBuffer *tagbuffer = NULL;
/* GstCaps *caps; */ GstSample *tagsample = NULL;
GstStructure *info = NULL;
GstCaps *caps = NULL;
gchar *filename_lc = g_utf8_strdown (filename, -1); gchar *filename_lc = g_utf8_strdown (filename, -1);
GST_DEBUG_OBJECT (common, "Creating tag for attachment with " GST_DEBUG_OBJECT (common, "Creating tag for attachment with "
@ -605,45 +607,49 @@ gst_matroska_read_common_parse_attached_file (GstMatroskaReadCommon * common,
/* First try to create an image tag buffer from this */ /* First try to create an image tag buffer from this */
if (image_type != GST_TAG_IMAGE_TYPE_NONE) { if (image_type != GST_TAG_IMAGE_TYPE_NONE) {
tagbuffer = tagsample =
gst_tag_image_data_to_image_buffer (data, datalen, image_type); gst_tag_image_data_to_image_sample (data, datalen, image_type);
if (!tagbuffer) if (!tagsample)
image_type = GST_TAG_IMAGE_TYPE_NONE; image_type = GST_TAG_IMAGE_TYPE_NONE;
else else {
data = NULL; data = NULL;
tagbuffer = gst_buffer_ref (gst_sample_get_buffer (tagsample));
caps = gst_caps_ref (gst_sample_get_caps (tagsample));
info = gst_structure_copy (gst_sample_get_info (tagsample));
gst_sample_unref (tagsample);
}
} }
/* if this failed create an attachment buffer */ /* if this failed create an attachment buffer */
if (!tagbuffer) { if (!tagbuffer) {
tagbuffer = gst_buffer_new_wrapped (g_memdup (data, datalen), datalen); tagbuffer = gst_buffer_new_wrapped (g_memdup (data, datalen), datalen);
/* FIXME: We can't attach caps to buffers in 0.11. */ caps = gst_type_find_helper_for_buffer (NULL, tagbuffer, NULL);
/* caps = gst_type_find_helper_for_buffer (NULL, tagbuffer, NULL); */ if (caps == NULL)
/* if (caps == NULL) */ caps = gst_caps_new_empty_simple (mimetype);
/* caps = gst_caps_new_simple (mimetype, NULL); */
/* gst_buffer_set_caps (tagbuffer, caps); */
/* gst_caps_unref (caps); */
} }
/* FIXME: We can't attach caps to buffers in 0.11. */ /* Set filename and description in the info */
/* Set filename and description on the caps */ if (info == NULL)
/* caps = GST_BUFFER_CAPS (tagbuffer); */ info = gst_structure_new_empty ("GstTagImageInfo");
/* gst_caps_set_simple (caps, "filename", G_TYPE_STRING, filename, NULL); */
/* if (description) */
/* gst_caps_set_simple (caps, "description", G_TYPE_STRING, description, */
/* NULL); */
/* GST_DEBUG_OBJECT (common, */ gst_structure_set (info, "filename", G_TYPE_STRING, filename, NULL);
/* "Created attachment buffer with caps: %" GST_PTR_FORMAT, caps); */ if (description)
gst_structure_set (info, "description", G_TYPE_STRING, description, NULL);
tagsample = gst_sample_new (tagbuffer, caps, NULL, info);
GST_DEBUG_OBJECT (common,
"Created attachment sample: %" GST_PTR_FORMAT, tagsample);
/* and append to the tag list */ /* and append to the tag list */
if (image_type != GST_TAG_IMAGE_TYPE_NONE) if (image_type != GST_TAG_IMAGE_TYPE_NONE)
gst_tag_list_add (taglist, GST_TAG_MERGE_APPEND, GST_TAG_IMAGE, tagbuffer, gst_tag_list_add (taglist, GST_TAG_MERGE_APPEND, GST_TAG_IMAGE, tagsample,
NULL); NULL);
else else
gst_tag_list_add (taglist, GST_TAG_MERGE_APPEND, GST_TAG_ATTACHMENT, gst_tag_list_add (taglist, GST_TAG_MERGE_APPEND, GST_TAG_ATTACHMENT,
tagbuffer, NULL); tagsample, NULL);
} }
g_free (filename); g_free (filename);

View file

@ -231,6 +231,7 @@ static void
check_unsync_v24 (const GstTagList * tags, const gchar * file) check_unsync_v24 (const GstTagList * tags, const gchar * file)
{ {
const GValue *val; const GValue *val;
GstSample *sample;
GstBuffer *buf; GstBuffer *buf;
gchar *album = NULL; gchar *album = NULL;
gchar *title = NULL; gchar *title = NULL;
@ -255,10 +256,12 @@ check_unsync_v24 (const GstTagList * tags, const gchar * file)
val = gst_tag_list_get_value_index (tags, GST_TAG_IMAGE, 0); val = gst_tag_list_get_value_index (tags, GST_TAG_IMAGE, 0);
fail_unless (val != NULL); fail_unless (val != NULL);
fail_unless (GST_VALUE_HOLDS_BUFFER (val)); fail_unless (GST_VALUE_HOLDS_SAMPLE (val));
buf = gst_value_get_buffer (val); sample = gst_value_get_sample (val);
fail_unless (sample != NULL);
fail_unless (gst_sample_get_caps (sample) != NULL);
buf = gst_sample_get_buffer (sample);
fail_unless (buf != NULL); fail_unless (buf != NULL);
/* FIXME 0.11: image buffer fail_unless (GST_BUFFER_CAPS (buf) != NULL); */
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ); data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
fail_unless_equals_int (size, 38022); fail_unless_equals_int (size, 38022);
/* check for jpeg start/end markers */ /* check for jpeg start/end markers */