And the same for _to_vorbiscomment_buffer(): allow id_data_len == 0 for speex.

Original commit message from CVS:
* gst-libs/gst/tag/gstvorbistag.c:
(gst_tag_list_to_vorbiscomment_buffer):
* tests/check/libs/tag.c: (GST_START_TEST):
And the same for _to_vorbiscomment_buffer(): allow
id_data_len == 0 for speex.
This commit is contained in:
Tim-Philipp Müller 2006-08-22 08:27:07 +00:00
parent 63d56aafa3
commit 31d27aa08c
3 changed files with 37 additions and 7 deletions

View file

@ -1,3 +1,11 @@
2006-08-22 Tim-Philipp Müller <tim at centricular dot net>
* gst-libs/gst/tag/gstvorbistag.c:
(gst_tag_list_to_vorbiscomment_buffer):
* tests/check/libs/tag.c: (GST_START_TEST):
And the same for _to_vorbiscomment_buffer(): allow
id_data_len == 0 for speex.
2006-08-21 Thomas Vander Stichele <thomas at apestaart dot org>
* configure.ac:

View file

@ -467,13 +467,13 @@ write_one_tag (const GstTagList * list, const gchar * tag, gpointer user_data)
* gst_tag_list_to_vorbiscomment_buffer:
* @list: tag list to convert
* @id_data: identification data at start of stream
* @id_data_length: length of identification data
* @id_data_length: length of identification data, may be 0 if @id_data is NULL
* @vendor_string: string that describes the vendor string or NULL
*
* Creates a new vorbiscomment buffer from a tag list.
*
* Returns: A new #GstBuffer containing a vorbiscomment buffer with all tags that
* could be converted from the given tag list.
* Returns: A new #GstBuffer containing a vorbiscomment buffer with all tags
* that could be converted from the given tag list.
*/
GstBuffer *
gst_tag_list_to_vorbiscomment_buffer (const GstTagList * list,
@ -489,8 +489,7 @@ gst_tag_list_to_vorbiscomment_buffer (const GstTagList * list,
int required_size;
g_return_val_if_fail (GST_IS_TAG_LIST (list), NULL);
g_return_val_if_fail (id_data != NULL, NULL);
g_return_val_if_fail (id_data_length > 0, NULL);
g_return_val_if_fail (id_data != NULL || id_data_length == 0, NULL);
if (vendor_string == NULL)
vendor_string = "GStreamer encoded vorbiscomment";
@ -500,8 +499,10 @@ gst_tag_list_to_vorbiscomment_buffer (const GstTagList * list,
required_size += 4 * my_data.count + my_data.data_count;
buffer = gst_buffer_new_and_alloc (required_size);
data = GST_BUFFER_DATA (buffer);
memcpy (data, id_data, id_data_length);
data += id_data_length;
if (id_data_length > 0) {
memcpy (data, id_data, id_data_length);
data += id_data_length;
}
*((guint32 *) data) = GUINT32_TO_LE (vendor_len);
data += 4;
memcpy (data, vendor_string, vendor_len);

View file

@ -379,6 +379,27 @@ GST_START_TEST (test_vorbis_tags)
gst_vorbis_tag_add (list, "LANGUAGE", "English");
ASSERT_TAG_LIST_HAS_STRING (list, GST_TAG_LANGUAGE_CODE, "English");
/* now, while we still have a taglist, test _to_vorbiscomment_buffer() */
{
GstBuffer *buf1, *buf2;
ASSERT_CRITICAL (gst_tag_list_to_vorbiscomment_buffer (NULL,
(const guint8 *) "x", 1, "x"));
buf1 = gst_tag_list_to_vorbiscomment_buffer (list, NULL, 0, NULL);
fail_unless (buf1 != NULL);
buf2 = gst_tag_list_to_vorbiscomment_buffer (list,
(const guint8 *) "foo", 3, NULL);
fail_unless (buf2 != NULL);
fail_unless (memcmp (GST_BUFFER_DATA (buf1), GST_BUFFER_DATA (buf2) + 3,
GST_BUFFER_SIZE (buf1)) == 0);
gst_buffer_unref (buf1);
gst_buffer_unref (buf2);
}
gst_tag_list_free (list);
/* make sure gst_tag_list_from_vorbiscomment_buffer() works with an