From 3231ea620437a532f9fde210b883d1d1933deeca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Thu, 26 Jul 2012 15:51:10 +0100 Subject: [PATCH] taglist: gst_tag_list_get_buffer*() => gst_tag_list_get_sample*() Image tags and other tags are now of GstSample type. --- docs/random/porting-to-0.11.txt | 6 ++++ gst/gsttaglist.c | 54 ++++++++++++++++++--------------- gst/gsttaglist.h | 8 ++--- tests/check/gst/gsttag.c | 50 ++++++++++++++++++------------ 4 files changed, 70 insertions(+), 48 deletions(-) diff --git a/docs/random/porting-to-0.11.txt b/docs/random/porting-to-0.11.txt index 8c5ac4da31..d4b956570c 100644 --- a/docs/random/porting-to-0.11.txt +++ b/docs/random/porting-to-0.11.txt @@ -494,6 +494,12 @@ The 0.11 porting guide gst_tag_list_new_full*() have been renamed to gst_tag_list_new*(). gst_tag_list_free() has been replaced by gst_tag_list_unref(). + GST_TAG_IMAGE, GST_TAG_PREVIEW_IMAGE, GST_TAG_ATTACHMENT: many tags that + used to be of type GstBuffer are not of type GstSample (which is basically + a struct containing a buffer alongside caps and some other info). + + gst_tag_list_get_buffer() => gst_tag_list_get_sample() + * GstController: has now been merged into GstObject. It does not exists as a individual object anymore. In addition core contains a GstControlSource base class and diff --git a/gst/gsttaglist.c b/gst/gsttaglist.c index 68ecfa1dfa..b2c7516a23 100644 --- a/gst/gsttaglist.c +++ b/gst/gsttaglist.c @@ -1893,67 +1893,71 @@ gst_tag_list_get_date_time_index (const GstTagList * list, } /** - * gst_tag_list_get_buffer: + * gst_tag_list_get_sample: * @list: a #GstTagList to get the tag from * @tag: tag to read out - * @value: (out callee-allocates) (transfer full): address of a GstBuffer + * @sample: (out callee-allocates) (transfer full): address of a GstSample * pointer variable to store the result into * - * Copies the first buffer for the given tag in the taglist into the variable - * pointed to by @value. Free the buffer with gst_buffer_unref() when it is - * no longer needed. + * Copies the first sample for the given tag in the taglist into the variable + * pointed to by @sample. Free the sample with gst_sample_unref() when it is + * no longer needed. You can retrieve the buffer from the sample using + * gst_sample_get_buffer() and the associated caps (if any) with + * gst_sample_get_caps(). * - * Free-function: gst_buffer_unref + * Free-function: gst_sample_unref * - * Returns: TRUE, if a buffer was copied, FALSE if the tag didn't exist in the - * given list or if it was #NULL. + * Returns: TRUE, if a sample was returned, FALSE if the tag didn't exist in + * the given list or if it was #NULL. */ gboolean -gst_tag_list_get_buffer (const GstTagList * list, const gchar * tag, - GstBuffer ** value) +gst_tag_list_get_sample (const GstTagList * list, const gchar * tag, + GstSample ** sample) { GValue v = { 0, }; g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE); g_return_val_if_fail (tag != NULL, FALSE); - g_return_val_if_fail (value != NULL, FALSE); + g_return_val_if_fail (sample != NULL, FALSE); if (!gst_tag_list_copy_value (&v, list, tag)) return FALSE; - *value = g_value_dup_boxed (&v); + *sample = g_value_dup_boxed (&v); g_value_unset (&v); - return (*value != NULL); + return (*sample != NULL); } /** - * gst_tag_list_get_buffer_index: + * gst_tag_list_get_sample_index: * @list: a #GstTagList to get the tag from * @tag: tag to read out * @index: number of entry to read out - * @value: (out callee-allocates) (transfer full): address of a GstBuffer + * @sample: (out callee-allocates) (transfer full): address of a GstSample * pointer variable to store the result into * - * Gets the buffer that is at the given index for the given tag in the given - * list and copies it into the variable pointed to by @value. Free the buffer - * with gst_buffer_unref() when it is no longer needed. + * Gets the sample that is at the given index for the given tag in the given + * list and copies it into the variable pointed to by @smple. Free the sample + * with gst_sample_unref() when it is no longer needed. You can retrieve the + * buffer from the sample using gst_sample_get_buffer() and the associated + * caps (if any) with gst_sample_get_caps(). * - * Free-function: gst_buffer_unref + * Free-function: gst_sample_unref * - * Returns: TRUE, if a buffer was copied, FALSE if the tag didn't exist in the + * Returns: TRUE, if a sample was copied, FALSE if the tag didn't exist in the * given list or if it was #NULL. */ gboolean -gst_tag_list_get_buffer_index (const GstTagList * list, - const gchar * tag, guint index, GstBuffer ** value) +gst_tag_list_get_sample_index (const GstTagList * list, + const gchar * tag, guint index, GstSample ** sample) { const GValue *v; g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE); g_return_val_if_fail (tag != NULL, FALSE); - g_return_val_if_fail (value != NULL, FALSE); + g_return_val_if_fail (sample != NULL, FALSE); if ((v = gst_tag_list_get_value_index (list, tag, index)) == NULL) return FALSE; - *value = g_value_dup_boxed (v); - return (*value != NULL); + *sample = g_value_dup_boxed (v); + return (*sample != NULL); } diff --git a/gst/gsttaglist.h b/gst/gsttaglist.h index 5016da238f..6c91524250 100644 --- a/gst/gsttaglist.h +++ b/gst/gsttaglist.h @@ -347,13 +347,13 @@ gboolean gst_tag_list_get_date_time_index (const GstTagList * list, const gchar * tag, guint index, GstDateTime ** value); -gboolean gst_tag_list_get_buffer (const GstTagList * list, +gboolean gst_tag_list_get_sample (const GstTagList * list, const gchar * tag, - GstBuffer ** value); -gboolean gst_tag_list_get_buffer_index (const GstTagList * list, + GstSample ** sample); +gboolean gst_tag_list_get_sample_index (const GstTagList * list, const gchar * tag, guint index, - GstBuffer ** value); + GstSample ** sample); /* refcounting */ /** diff --git a/tests/check/gst/gsttag.c b/tests/check/gst/gsttag.c index a8e612e99f..1e52a22a23 100644 --- a/tests/check/gst/gsttag.c +++ b/tests/check/gst/gsttag.c @@ -345,36 +345,48 @@ GST_START_TEST (test_buffer_tags) { GstTagList *tags; GstBuffer *buf1, *buf2; + GstSample *s1, *s2; tags = gst_tag_list_new_empty (); + buf1 = gst_buffer_new_and_alloc (222); + s1 = gst_sample_new (buf1, NULL, NULL, NULL); + gst_buffer_unref (buf1); + buf2 = gst_buffer_new_and_alloc (100); - gst_tag_list_add (tags, GST_TAG_MERGE_APPEND, GST_TAG_IMAGE, buf1, - GST_TAG_PREVIEW_IMAGE, buf2, NULL); - gst_buffer_unref (buf1); + s2 = gst_sample_new (buf2, NULL, NULL, NULL); gst_buffer_unref (buf2); - buf1 = buf2 = NULL; - fail_if (!gst_tag_list_get_buffer (tags, GST_TAG_IMAGE, &buf1)); - gst_buffer_unref (buf1); - fail_if (!gst_tag_list_get_buffer (tags, GST_TAG_PREVIEW_IMAGE, &buf2)); - gst_buffer_unref (buf2); + gst_tag_list_add (tags, GST_TAG_MERGE_APPEND, GST_TAG_IMAGE, s1, + GST_TAG_PREVIEW_IMAGE, s2, NULL); - fail_if (gst_tag_list_get_buffer_index (tags, GST_TAG_IMAGE, 1, &buf1)); - fail_if (gst_tag_list_get_buffer_index (tags, GST_TAG_IMAGE, 2, &buf1)); - fail_if (gst_tag_list_get_buffer_index (tags, GST_TAG_PREVIEW_IMAGE, 1, - &buf1)); - fail_if (gst_tag_list_get_buffer_index (tags, GST_TAG_PREVIEW_IMAGE, 2, - &buf1)); + gst_sample_unref (s1); + gst_sample_unref (s2); + s1 = s2 = NULL; - fail_if (!gst_tag_list_get_buffer_index (tags, GST_TAG_IMAGE, 0, &buf1)); - fail_if (!gst_tag_list_get_buffer_index (tags, GST_TAG_PREVIEW_IMAGE, 0, - &buf2)); + fail_if (!gst_tag_list_get_sample (tags, GST_TAG_IMAGE, &s1)); + fail_unless (gst_sample_get_buffer (s1) == buf1); + gst_sample_unref (s1); + + fail_if (!gst_tag_list_get_sample (tags, GST_TAG_PREVIEW_IMAGE, &s2)); + fail_unless (gst_sample_get_buffer (s2) == buf2); + gst_sample_unref (s2); + + fail_if (gst_tag_list_get_sample_index (tags, GST_TAG_IMAGE, 1, &s1)); + fail_if (gst_tag_list_get_sample_index (tags, GST_TAG_IMAGE, 2, &s1)); + fail_if (gst_tag_list_get_sample_index (tags, GST_TAG_PREVIEW_IMAGE, 1, &s1)); + fail_if (gst_tag_list_get_sample_index (tags, GST_TAG_PREVIEW_IMAGE, 2, &s1)); + + fail_if (!gst_tag_list_get_sample_index (tags, GST_TAG_IMAGE, 0, &s1)); + fail_if (!gst_tag_list_get_sample_index (tags, GST_TAG_PREVIEW_IMAGE, 0, + &s2)); + buf1 = gst_sample_get_buffer (s1); fail_unless_equals_int (gst_buffer_get_size (buf1), 222); + buf2 = gst_sample_get_buffer (s2); fail_unless_equals_int (gst_buffer_get_size (buf2), 100); - gst_buffer_unref (buf1); - gst_buffer_unref (buf2); + gst_sample_unref (s1); + gst_sample_unref (s2); gst_tag_list_unref (tags); }