From 3deaa582d9b23e83c461dc513e1b8a0a8db65cd3 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 1 Dec 2011 18:51:51 +0100 Subject: [PATCH] tags: make the tag functions return GstSample gst_tag_image_data_to_image_buffer() -> gst_tag_image_data_to_image_sample() And make it return a GstSample. Store the image-type into the extra sample info. Remove a deprecated tag --- gst-libs/gst/tag/gstid3tag.c | 8 ++++---- gst-libs/gst/tag/gstvorbistag.c | 6 +++--- gst-libs/gst/tag/tag.h | 16 ++-------------- gst-libs/gst/tag/tags.c | 29 +++++++++++++++-------------- 4 files changed, 24 insertions(+), 35 deletions(-) diff --git a/gst-libs/gst/tag/gstid3tag.c b/gst-libs/gst/tag/gstid3tag.c index 021bffa1f4..2a8b6b7ce6 100644 --- a/gst-libs/gst/tag/gstid3tag.c +++ b/gst-libs/gst/tag/gstid3tag.c @@ -334,7 +334,7 @@ gst_tag_id3_genre_get (const guint id) * the APIC frame (0 = unknown/other) * * Adds an image from an ID3 APIC frame (or similar, such as used in FLAC) - * to the given tag list. Also see gst_tag_image_data_to_image_buffer() for + * to the given tag list. Also see gst_tag_image_data_to_image_sample() for * more information on image tags in GStreamer. * * Returns: %TRUE if the image was processed, otherwise %FALSE @@ -347,7 +347,7 @@ gst_tag_list_add_id3_image (GstTagList * tag_list, const guint8 * image_data, { GstTagImageType tag_image_type; const gchar *tag_name; - GstBuffer *image; + GstSample *image; g_return_val_if_fail (GST_IS_TAG_LIST (tag_list), FALSE); g_return_val_if_fail (image_data != NULL, FALSE); @@ -369,13 +369,13 @@ gst_tag_list_add_id3_image (GstTagList * tag_list, const guint8 * image_data, tag_image_type = GST_TAG_IMAGE_TYPE_UNDEFINED; } - image = gst_tag_image_data_to_image_buffer (image_data, image_data_len, + image = gst_tag_image_data_to_image_sample (image_data, image_data_len, tag_image_type); if (image == NULL) return FALSE; gst_tag_list_add (tag_list, GST_TAG_MERGE_APPEND, tag_name, image, NULL); - gst_buffer_unref (image); + gst_sample_unref (image); return TRUE; } diff --git a/gst-libs/gst/tag/gstvorbistag.c b/gst-libs/gst/tag/gstvorbistag.c index 8f9a81b5e1..1e6efad079 100644 --- a/gst-libs/gst/tag/gstvorbistag.c +++ b/gst-libs/gst/tag/gstvorbistag.c @@ -318,7 +318,7 @@ static void gst_vorbis_tag_add_coverart (GstTagList * tags, gchar * img_data_base64, gint base64_len) { - GstBuffer *img; + GstSample *img; gsize img_len; if (base64_len < 2) @@ -332,7 +332,7 @@ gst_vorbis_tag_add_coverart (GstTagList * tags, gchar * img_data_base64, goto decode_failed; img = - gst_tag_image_data_to_image_buffer ((const guint8 *) img_data_base64, + gst_tag_image_data_to_image_sample ((const guint8 *) img_data_base64, img_len, GST_TAG_IMAGE_TYPE_NONE); if (img == NULL) @@ -341,7 +341,7 @@ gst_vorbis_tag_add_coverart (GstTagList * tags, gchar * img_data_base64, gst_tag_list_add (tags, GST_TAG_MERGE_APPEND, GST_TAG_PREVIEW_IMAGE, img, NULL); - gst_buffer_unref (img); + gst_sample_unref (img); return; /* ERRORS */ diff --git a/gst-libs/gst/tag/tag.h b/gst-libs/gst/tag/tag.h index 69a3ba4d94..c6f2013e77 100644 --- a/gst-libs/gst/tag/tag.h +++ b/gst-libs/gst/tag/tag.h @@ -59,18 +59,6 @@ G_BEGIN_DECLS */ #define GST_TAG_MUSICBRAINZ_TRMID "musicbrainz-trmid" -/* FIXME 0.11: remove GST_TAG_MUSICBRAINZ_SORTNAME */ -#ifndef GST_DISABLE_DEPRECATED -/** - * GST_TAG_MUSICBRAINZ_SORTNAME - * - * MusicBrainz artist sort name - * - * Deprecated. Use GST_TAG_ARTIST_SORTNAME instead. - */ -#define GST_TAG_MUSICBRAINZ_SORTNAME GST_TAG_ARTIST_SORTNAME -#endif - /** * GST_TAG_CMML_STREAM * @@ -388,7 +376,7 @@ G_BEGIN_DECLS /** * GstTagImageType: * @GST_TAG_IMAGE_TYPE_NONE : No image type. Can be used to - * tell functions such as gst_tag_image_data_to_image_buffer() that no + * tell functions such as gst_tag_image_data_to_image_sample() that no * image type should be set. (Since: 0.10.20) * @GST_TAG_IMAGE_TYPE_UNDEFINED : Undefined/other image type * @GST_TAG_IMAGE_TYPE_FRONT_COVER : Cover (front) @@ -536,7 +524,7 @@ gchar * gst_tag_freeform_string_to_utf8 (const gchar * data, gint size, const gchar ** env_vars); -GstBuffer * gst_tag_image_data_to_image_buffer (const guint8 * image_data, +GstSample * gst_tag_image_data_to_image_sample (const guint8 * image_data, guint image_data_len, GstTagImageType image_type); diff --git a/gst-libs/gst/tag/tags.c b/gst-libs/gst/tag/tags.c index ed05e1bd13..5757576b61 100644 --- a/gst-libs/gst/tag/tags.c +++ b/gst-libs/gst/tag/tags.c @@ -527,14 +527,14 @@ beach: } /** - * gst_tag_image_data_to_image_buffer: + * gst_tag_image_data_to_image_sample: * @image_data: the (encoded) image * @image_data_len: the length of the encoded image data at @image_data * @image_type: type of the image, or #GST_TAG_IMAGE_TYPE_UNDEFINED. Pass * #GST_TAG_IMAGE_TYPE_NONE if no image type should be set at all (e.g. * for preview images) * - * Helper function for tag-reading plugins to create a #GstBuffer suitable to + * Helper function for tag-reading plugins to create a #GstSample suitable to * add to a #GstTagList as an image tag (such as #GST_TAG_IMAGE or * #GST_TAG_PREVIEW_IMAGE) from the encoded image data and an (optional) image * type. @@ -546,9 +546,9 @@ beach: * back cover, artist, etc.). The image data may also be an URI to the image * rather than the image itself. * - * In GStreamer, image tags are #GstBuffers containing the raw image - * data, with the buffer caps describing the content type of the image - * (e.g. image/jpeg, image/png, text/uri-list). The buffer caps may contain + * In GStreamer, image tags are #GstSamples containing the raw image + * data, with the sample caps describing the content type of the image + * (e.g. image/jpeg, image/png, text/uri-list). The sample info may contain * an additional 'image-type' field of #GST_TYPE_TAG_IMAGE_TYPE to describe * the type of image (front cover, back cover etc.). #GST_TAG_PREVIEW_IMAGE * tags should not carry an image type, their type is already indicated via @@ -557,18 +557,20 @@ beach: * This function will do various checks and typefind the encoded image * data (we can't trust the declared mime type). * - * Returns: a newly-allocated image buffer for use in tag lists, or NULL + * Returns: a newly-allocated image sample for use in tag lists, or NULL * * Since: 0.10.20 */ -GstBuffer * -gst_tag_image_data_to_image_buffer (const guint8 * image_data, +GstSample * +gst_tag_image_data_to_image_sample (const guint8 * image_data, guint image_data_len, GstTagImageType image_type) { const gchar *name; GstBuffer *image; + GstSample *sample; GstCaps *caps; guint8 *data; + GstStructure *info = NULL; g_return_val_if_fail (image_data != NULL, NULL); g_return_val_if_fail (image_data_len > 0, NULL); @@ -612,15 +614,14 @@ gst_tag_image_data_to_image_buffer (const guint8 * image_data, if (image_type != GST_TAG_IMAGE_TYPE_NONE) { GST_LOG ("Setting image type: %d", image_type); - caps = gst_caps_make_writable (caps); - gst_caps_set_simple (caps, "image-type", GST_TYPE_TAG_IMAGE_TYPE, - image_type, NULL); + info = gst_structure_new ("GstTagImageInfo", + "image-type", GST_TYPE_TAG_IMAGE_TYPE, image_type, NULL); } - - g_warning ("extra image data can't be set"); + sample = gst_sample_new (image, caps, NULL, info); + gst_buffer_unref (image); gst_caps_unref (caps); - return image; + return sample; /* ERRORS */ no_type: