From f1558baf835105dd81c74ea8a6b097f5c3b60471 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 1 Dec 2011 18:55:45 +0100 Subject: [PATCH] update for tag API changes --- gst/isomp4/qtdemux.c | 9 ++++--- gst/matroska/matroska-read-common.c | 50 +++++++++++++++++++++---------------- tests/check/elements/id3demux.c | 9 ++++--- 3 files changed, 39 insertions(+), 29 deletions(-) diff --git a/gst/isomp4/qtdemux.c b/gst/isomp4/qtdemux.c index 3d6083e..b3653b4 100644 --- a/gst/isomp4/qtdemux.c +++ b/gst/isomp4/qtdemux.c @@ -8132,7 +8132,7 @@ qtdemux_tag_add_covr (GstQTDemux * qtdemux, const char *tag1, const char *dummy, GNode *data; int len; int type; - GstBuffer *buf; + GstSample *sample; data = qtdemux_tree_get_child_by_type (node, FOURCC_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); GST_DEBUG_OBJECT (qtdemux, "have covr tag, type=%d,len=%d", type, len); 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))) { GST_DEBUG_OBJECT (qtdemux, "adding tag size %d", len - 16); gst_tag_list_add (qtdemux->tag_list, GST_TAG_MERGE_REPLACE, - tag1, buf, NULL); - gst_buffer_unref (buf); + tag1, sample, NULL); + gst_sample_unref (sample); } } } diff --git a/gst/matroska/matroska-read-common.c b/gst/matroska/matroska-read-common.c index 3c7573c..0714c70 100644 --- a/gst/matroska/matroska-read-common.c +++ b/gst/matroska/matroska-read-common.c @@ -579,7 +579,9 @@ gst_matroska_read_common_parse_attached_file (GstMatroskaReadCommon * common, if (filename && mimetype && data && datalen > 0) { GstTagImageType image_type = GST_TAG_IMAGE_TYPE_NONE; GstBuffer *tagbuffer = NULL; - /* GstCaps *caps; */ + GstSample *tagsample = NULL; + GstStructure *info = NULL; + GstCaps *caps = NULL; gchar *filename_lc = g_utf8_strdown (filename, -1); 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 */ if (image_type != GST_TAG_IMAGE_TYPE_NONE) { - tagbuffer = - gst_tag_image_data_to_image_buffer (data, datalen, image_type); + tagsample = + gst_tag_image_data_to_image_sample (data, datalen, image_type); - if (!tagbuffer) + if (!tagsample) image_type = GST_TAG_IMAGE_TYPE_NONE; - else + else { 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 (!tagbuffer) { 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); */ - /* if (caps == NULL) */ - /* caps = gst_caps_new_simple (mimetype, NULL); */ - /* gst_buffer_set_caps (tagbuffer, caps); */ - /* gst_caps_unref (caps); */ + caps = gst_type_find_helper_for_buffer (NULL, tagbuffer, NULL); + if (caps == NULL) + caps = gst_caps_new_empty_simple (mimetype); } - /* FIXME: We can't attach caps to buffers in 0.11. */ - /* Set filename and description on the caps */ - /* caps = GST_BUFFER_CAPS (tagbuffer); */ - /* gst_caps_set_simple (caps, "filename", G_TYPE_STRING, filename, NULL); */ - /* if (description) */ - /* gst_caps_set_simple (caps, "description", G_TYPE_STRING, description, */ - /* NULL); */ + /* Set filename and description in the info */ + if (info == NULL) + info = gst_structure_new_empty ("GstTagImageInfo"); + + gst_structure_set (info, "filename", G_TYPE_STRING, filename, NULL); + 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 buffer with caps: %" GST_PTR_FORMAT, caps); */ + GST_DEBUG_OBJECT (common, + "Created attachment sample: %" GST_PTR_FORMAT, tagsample); /* and append to the tag list */ 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); else gst_tag_list_add (taglist, GST_TAG_MERGE_APPEND, GST_TAG_ATTACHMENT, - tagbuffer, NULL); + tagsample, NULL); } g_free (filename); diff --git a/tests/check/elements/id3demux.c b/tests/check/elements/id3demux.c index c9099f0..6793b19 100644 --- a/tests/check/elements/id3demux.c +++ b/tests/check/elements/id3demux.c @@ -231,6 +231,7 @@ static void check_unsync_v24 (const GstTagList * tags, const gchar * file) { const GValue *val; + GstSample *sample; GstBuffer *buf; gchar *album = 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); fail_unless (val != NULL); - fail_unless (GST_VALUE_HOLDS_BUFFER (val)); - buf = gst_value_get_buffer (val); + fail_unless (GST_VALUE_HOLDS_SAMPLE (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); - /* FIXME 0.11: image buffer fail_unless (GST_BUFFER_CAPS (buf) != NULL); */ data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ); fail_unless_equals_int (size, 38022); /* check for jpeg start/end markers */ -- 2.7.4