diff options
author | Tim-Philipp Müller <tim.muller@collabora.co.uk> | 2011-11-24 13:49:12 +0000 |
---|---|---|
committer | Tim-Philipp Müller <tim.muller@collabora.co.uk> | 2011-11-27 23:19:49 +0000 |
commit | 98b9d602c1b7c9a4c7bed083f6549c481570caa7 (patch) | |
tree | 2fec6bf7b1d324dd84d40c761c63ebd33532cfb4 /gst/aiff | |
parent | 43190ea0f8537c437aaf291f7ade2cfc4241a440 (diff) | |
download | gstreamer-plugins-bad-98b9d602c1b7c9a4c7bed083f6549c481570caa7.tar.gz |
aiffparse: extract ID3 tags embedded in ID3 chunks
https://bugzilla.gnome.org/show_bug.cgi?id=664725
Diffstat (limited to 'gst/aiff')
-rw-r--r-- | gst/aiff/Makefile.am | 1 | ||||
-rw-r--r-- | gst/aiff/aiff.c | 4 | ||||
-rw-r--r-- | gst/aiff/aiffparse.c | 43 | ||||
-rw-r--r-- | gst/aiff/aiffparse.h | 3 |
4 files changed, 51 insertions, 0 deletions
diff --git a/gst/aiff/Makefile.am b/gst/aiff/Makefile.am index 8c4a1c5a1..2eb8392b8 100644 --- a/gst/aiff/Makefile.am +++ b/gst/aiff/Makefile.am @@ -7,6 +7,7 @@ libgstaiff_la_CFLAGS = \ $(GST_BASE_CFLAGS) \ $(GST_CFLAGS) libgstaiff_la_LIBADD = \ + $(GST_PLUGINS_BASE_LIBS) -lgsttag-$(GST_MAJORMINOR) \ $(GST_BASE_LIBS) \ $(LIBM) libgstaiff_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) diff --git a/gst/aiff/aiff.c b/gst/aiff/aiff.c index 1e9dfe28e..ba89e1a4a 100644 --- a/gst/aiff/aiff.c +++ b/gst/aiff/aiff.c @@ -22,6 +22,8 @@ #include "config.h" #endif +#include <gst/tag/tag.h> + #include <gst/gst-i18n-plugin.h> #include "aiffparse.h" @@ -54,6 +56,8 @@ plugin_init (GstPlugin * plugin) ret &= gst_element_register (plugin, "aiffmux", GST_RANK_PRIMARY, GST_TYPE_AIFF_MUX); + gst_tag_register_musicbrainz_tags (); + return ret; } diff --git a/gst/aiff/aiffparse.c b/gst/aiff/aiffparse.c index a286dceec..575b309b5 100644 --- a/gst/aiff/aiffparse.c +++ b/gst/aiff/aiffparse.c @@ -57,6 +57,7 @@ #include "aiffparse.h" #include <gst/audio/audio.h> +#include <gst/tag/tag.h> #include <gst/gst-i18n-plugin.h> GST_DEBUG_CATEGORY (aiffparse_debug); @@ -163,6 +164,11 @@ gst_aiff_parse_reset (GstAiffParse * aiff) gst_adapter_clear (aiff->adapter); aiff->adapter = NULL; } + + if (aiff->tags != NULL) { + gst_tag_list_free (aiff->tags); + aiff->tags = NULL; + } } static void @@ -892,6 +898,38 @@ gst_aiff_parse_stream_headers (GstAiffParse * aiff) } break; } + case GST_MAKE_FOURCC ('I', 'D', '3', ' '):{ + GstTagList *tags; + + if (aiff->streaming) { + if (!gst_aiff_parse_peek_chunk (aiff, &tag, &size)) + return GST_FLOW_OK; + + gst_adapter_flush (aiff->adapter, 8); + aiff->offset += 8; + + buf = gst_adapter_take_buffer (aiff->adapter, size); + } else { + if ((res = gst_aiff_parse_read_chunk (aiff, + &aiff->offset, &tag, &buf)) != GST_FLOW_OK) + return res; + } + + GST_LOG_OBJECT (aiff, "ID3 chunk of size %u", GST_BUFFER_SIZE (buf)); + + tags = gst_tag_list_from_id3v2_tag (buf); + gst_buffer_unref (buf); + + GST_INFO_OBJECT (aiff, "ID3 tags: %" GST_PTR_FORMAT, tags); + + if (aiff->tags == NULL) { + aiff->tags = tags; + } else { + gst_tag_list_insert (aiff->tags, tags, GST_TAG_MERGE_APPEND); + gst_tag_list_free (tags); + } + break; + } default: gst_aiff_parse_ignore_chunk (aiff, buf, tag, size); } @@ -1117,6 +1155,11 @@ iterate_adapter: gst_pad_push_event (aiff->srcpad, aiff->start_segment); aiff->start_segment = NULL; } + if (G_UNLIKELY (aiff->tags != NULL)) { + gst_element_found_tags_for_pad (GST_ELEMENT_CAST (aiff), aiff->srcpad, + aiff->tags); + aiff->tags = NULL; + } obtained = GST_BUFFER_SIZE (buf); diff --git a/gst/aiff/aiffparse.h b/gst/aiff/aiffparse.h index b773a1505..e7dda178e 100644 --- a/gst/aiff/aiffparse.h +++ b/gst/aiff/aiffparse.h @@ -113,6 +113,9 @@ struct _GstAiffParse { /* discont after seek */ gboolean discont; + + /* tags */ + GstTagList *tags; }; struct _GstAiffParseClass { |