Commit 3231ea62 authored by Tim-Philipp Müller's avatar Tim-Philipp Müller 🐠

taglist: gst_tag_list_get_buffer*() => gst_tag_list_get_sample*()

Image tags and other tags are now of GstSample type.
parent 280ac5c5
......@@ -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
......
......@@ -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);
}
......@@ -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 */
/**
......
......@@ -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);
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);
s1 = gst_sample_new (buf1, NULL, NULL, NULL);
gst_buffer_unref (buf1);
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));
buf2 = gst_buffer_new_and_alloc (100);
s2 = gst_sample_new (buf2, NULL, NULL, NULL);
gst_buffer_unref (buf2);
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_tag_list_add (tags, GST_TAG_MERGE_APPEND, GST_TAG_IMAGE, s1,
GST_TAG_PREVIEW_IMAGE, s2, NULL);
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);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment