mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-19 06:46:38 +00:00
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
This commit is contained in:
parent
59113af604
commit
3deaa582d9
4 changed files with 24 additions and 35 deletions
|
@ -334,7 +334,7 @@ gst_tag_id3_genre_get (const guint id)
|
||||||
* the APIC frame (0 = unknown/other)
|
* the APIC frame (0 = unknown/other)
|
||||||
*
|
*
|
||||||
* Adds an image from an ID3 APIC frame (or similar, such as used in FLAC)
|
* 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.
|
* more information on image tags in GStreamer.
|
||||||
*
|
*
|
||||||
* Returns: %TRUE if the image was processed, otherwise %FALSE
|
* 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;
|
GstTagImageType tag_image_type;
|
||||||
const gchar *tag_name;
|
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 (GST_IS_TAG_LIST (tag_list), FALSE);
|
||||||
g_return_val_if_fail (image_data != NULL, 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;
|
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);
|
tag_image_type);
|
||||||
|
|
||||||
if (image == NULL)
|
if (image == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
gst_tag_list_add (tag_list, GST_TAG_MERGE_APPEND, tag_name, image, NULL);
|
gst_tag_list_add (tag_list, GST_TAG_MERGE_APPEND, tag_name, image, NULL);
|
||||||
gst_buffer_unref (image);
|
gst_sample_unref (image);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -318,7 +318,7 @@ static void
|
||||||
gst_vorbis_tag_add_coverart (GstTagList * tags, gchar * img_data_base64,
|
gst_vorbis_tag_add_coverart (GstTagList * tags, gchar * img_data_base64,
|
||||||
gint base64_len)
|
gint base64_len)
|
||||||
{
|
{
|
||||||
GstBuffer *img;
|
GstSample *img;
|
||||||
gsize img_len;
|
gsize img_len;
|
||||||
|
|
||||||
if (base64_len < 2)
|
if (base64_len < 2)
|
||||||
|
@ -332,7 +332,7 @@ gst_vorbis_tag_add_coverart (GstTagList * tags, gchar * img_data_base64,
|
||||||
goto decode_failed;
|
goto decode_failed;
|
||||||
|
|
||||||
img =
|
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);
|
img_len, GST_TAG_IMAGE_TYPE_NONE);
|
||||||
|
|
||||||
if (img == NULL)
|
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_list_add (tags, GST_TAG_MERGE_APPEND,
|
||||||
GST_TAG_PREVIEW_IMAGE, img, NULL);
|
GST_TAG_PREVIEW_IMAGE, img, NULL);
|
||||||
|
|
||||||
gst_buffer_unref (img);
|
gst_sample_unref (img);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* ERRORS */
|
/* ERRORS */
|
||||||
|
|
|
@ -59,18 +59,6 @@ G_BEGIN_DECLS
|
||||||
*/
|
*/
|
||||||
#define GST_TAG_MUSICBRAINZ_TRMID "musicbrainz-trmid"
|
#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
|
* GST_TAG_CMML_STREAM
|
||||||
*
|
*
|
||||||
|
@ -388,7 +376,7 @@ G_BEGIN_DECLS
|
||||||
/**
|
/**
|
||||||
* GstTagImageType:
|
* GstTagImageType:
|
||||||
* @GST_TAG_IMAGE_TYPE_NONE : No image type. Can be used to
|
* @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)
|
* image type should be set. (Since: 0.10.20)
|
||||||
* @GST_TAG_IMAGE_TYPE_UNDEFINED : Undefined/other image type
|
* @GST_TAG_IMAGE_TYPE_UNDEFINED : Undefined/other image type
|
||||||
* @GST_TAG_IMAGE_TYPE_FRONT_COVER : Cover (front)
|
* @GST_TAG_IMAGE_TYPE_FRONT_COVER : Cover (front)
|
||||||
|
@ -536,7 +524,7 @@ gchar * gst_tag_freeform_string_to_utf8 (const gchar * data,
|
||||||
gint size,
|
gint size,
|
||||||
const gchar ** env_vars);
|
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,
|
guint image_data_len,
|
||||||
GstTagImageType image_type);
|
GstTagImageType image_type);
|
||||||
|
|
||||||
|
|
|
@ -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: the (encoded) image
|
||||||
* @image_data_len: the length of the encoded image data at @image_data
|
* @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
|
* @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.
|
* #GST_TAG_IMAGE_TYPE_NONE if no image type should be set at all (e.g.
|
||||||
* for preview images)
|
* 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
|
* 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
|
* #GST_TAG_PREVIEW_IMAGE) from the encoded image data and an (optional) image
|
||||||
* type.
|
* type.
|
||||||
|
@ -546,9 +546,9 @@ beach:
|
||||||
* back cover, artist, etc.). The image data may also be an URI to the image
|
* back cover, artist, etc.). The image data may also be an URI to the image
|
||||||
* rather than the image itself.
|
* rather than the image itself.
|
||||||
*
|
*
|
||||||
* In GStreamer, image tags are #GstBuffer<!-- -->s containing the raw image
|
* In GStreamer, image tags are #GstSample<!-- -->s containing the raw image
|
||||||
* data, with the buffer caps describing the content type of the image
|
* data, with the sample caps describing the content type of the image
|
||||||
* (e.g. image/jpeg, image/png, text/uri-list). The buffer caps may contain
|
* (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
|
* 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
|
* 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
|
* 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
|
* This function will do various checks and typefind the encoded image
|
||||||
* data (we can't trust the declared mime type).
|
* 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
|
* Since: 0.10.20
|
||||||
*/
|
*/
|
||||||
GstBuffer *
|
GstSample *
|
||||||
gst_tag_image_data_to_image_buffer (const guint8 * image_data,
|
gst_tag_image_data_to_image_sample (const guint8 * image_data,
|
||||||
guint image_data_len, GstTagImageType image_type)
|
guint image_data_len, GstTagImageType image_type)
|
||||||
{
|
{
|
||||||
const gchar *name;
|
const gchar *name;
|
||||||
GstBuffer *image;
|
GstBuffer *image;
|
||||||
|
GstSample *sample;
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
|
GstStructure *info = NULL;
|
||||||
|
|
||||||
g_return_val_if_fail (image_data != NULL, NULL);
|
g_return_val_if_fail (image_data != NULL, NULL);
|
||||||
g_return_val_if_fail (image_data_len > 0, 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) {
|
if (image_type != GST_TAG_IMAGE_TYPE_NONE) {
|
||||||
GST_LOG ("Setting image type: %d", image_type);
|
GST_LOG ("Setting image type: %d", image_type);
|
||||||
caps = gst_caps_make_writable (caps);
|
info = gst_structure_new ("GstTagImageInfo",
|
||||||
gst_caps_set_simple (caps, "image-type", GST_TYPE_TAG_IMAGE_TYPE,
|
"image-type", GST_TYPE_TAG_IMAGE_TYPE, image_type, NULL);
|
||||||
image_type, NULL);
|
|
||||||
}
|
}
|
||||||
|
sample = gst_sample_new (image, caps, NULL, info);
|
||||||
g_warning ("extra image data can't be set");
|
gst_buffer_unref (image);
|
||||||
gst_caps_unref (caps);
|
gst_caps_unref (caps);
|
||||||
|
|
||||||
return image;
|
return sample;
|
||||||
|
|
||||||
/* ERRORS */
|
/* ERRORS */
|
||||||
no_type:
|
no_type:
|
||||||
|
|
Loading…
Reference in a new issue