diff --git a/ChangeLog b/ChangeLog index 6fa7b5f0f9..c6810ee45b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2006-08-22 Tim-Philipp Müller + + * 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 * configure.ac: diff --git a/gst-libs/gst/tag/gstvorbistag.c b/gst-libs/gst/tag/gstvorbistag.c index c6b02d3f9f..0382192aad 100644 --- a/gst-libs/gst/tag/gstvorbistag.c +++ b/gst-libs/gst/tag/gstvorbistag.c @@ -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); diff --git a/tests/check/libs/tag.c b/tests/check/libs/tag.c index ddeb462a94..596b97d5ec 100644 --- a/tests/check/libs/tag.c +++ b/tests/check/libs/tag.c @@ -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