From 2444a6459b18d2852ed192637c93224ceeebe2f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Tue, 25 Jul 2006 16:47:04 +0000 Subject: [PATCH] tag: id3v2: Extract frames for ID3v2 versions prior to ID3v2.3.0 properly as well, and add the version to... Original commit message from CVS: * gst-libs/gst/tag/id3v2.c: (id3demux_add_id3v2_frame_blob_to_taglist): Extract frames for ID3v2 versions prior to ID3v2.3.0 properly as well, and add the version to the blob's buffer caps, since that information will be needed for deserialisation later on (#348644). --- gst-libs/gst/tag/id3v2.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/gst-libs/gst/tag/id3v2.c b/gst-libs/gst/tag/id3v2.c index 6af215d948..7e354f2a5f 100644 --- a/gst-libs/gst/tag/id3v2.c +++ b/gst-libs/gst/tag/id3v2.c @@ -338,10 +338,23 @@ id3demux_add_id3v2_frame_blob_to_taglist (ID3TagsWorking * work, guint size) GstCaps *caps; guint8 *frame_data; gchar *media_type; - guint frame_size; + guint frame_size, header_size; - frame_data = work->hdr.frame_data - ID3V2_HDR_SIZE; - frame_size = size + ID3V2_HDR_SIZE; + switch (ID3V2_VER_MAJOR (work->hdr.version)) { + case 1: + case 2: + header_size = 3 + 3; + break; + case 3: + case 4: + header_size = 4 + 4 + 2; + break; + default: + g_return_if_reached (); + } + + frame_data = work->hdr.frame_data - header_size; + frame_size = size + header_size; blob = gst_buffer_new_and_alloc (frame_size); memcpy (GST_BUFFER_DATA (blob), frame_data, frame_size); @@ -349,11 +362,14 @@ id3demux_add_id3v2_frame_blob_to_taglist (ID3TagsWorking * work, guint size) media_type = g_strdup_printf ("application/x-gst-id3v2-%c%c%c%c-frame", g_ascii_tolower (frame_data[0]), g_ascii_tolower (frame_data[1]), g_ascii_tolower (frame_data[2]), g_ascii_tolower (frame_data[3])); - caps = gst_caps_new_simple (media_type, NULL); + caps = gst_caps_new_simple (media_type, "version", G_TYPE_INT, + (gint) ID3V2_VER_MAJOR (work->hdr.version), NULL); gst_buffer_set_caps (blob, caps); gst_caps_unref (caps); g_free (media_type); + /* gst_util_dump_mem (GST_BUFFER_DATA (blob), GST_BUFFER_SIZE (blob)); */ + gst_tag_list_add (work->tags, GST_TAG_MERGE_APPEND, GST_ID3_DEMUX_TAG_ID3V2_FRAME, blob, NULL); gst_buffer_unref (blob);