From 65565c8a1e586585bb6ff74545d3e52d979a8e56 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Fri, 11 Mar 2011 17:45:37 +0000 Subject: [PATCH] mad: build the mad plugin even if libid3tag is not available ID3 tags are usually handled by id3demux, and should be handled by id3demux. Tag handling in mad based on libid3tag is very basic and mostly unnecessary really, so just build this plugin without ID3 tag support if libid3tag is not available. --- configure.ac | 27 +++++++++-------- ext/mad/gstmad.c | 90 ++++++++++++++++++++++++++++++++------------------------ ext/mad/gstmad.h | 1 - 3 files changed, 66 insertions(+), 52 deletions(-) diff --git a/configure.ac b/configure.ac index 3a33718..ad57804 100644 --- a/configure.ac +++ b/configure.ac @@ -326,20 +326,23 @@ AG_GST_CHECK_FEATURE(MAD, [mad mp3 decoder], mad, [ ]) fi + dnl check with pkg-config first + AG_GST_PKG_CHECK_MODULES(MAD, mad >= 0.15) + MAD_LIBS="$MAD_LIBS $ID3TAG_LIBS" + if test "x$HAVE_MAD" = "xno"; then + dnl fall back to oldskool detection + AC_CHECK_HEADER(mad.h, [ + AC_CHECK_LIB(mad, mad_decoder_finish, + HAVE_MAD="yes" MAD_LIBS="-lmad $ID3TAG_LIBS") + ]) + fi + if test "x$HAVE_ID3TAG" = "xyes"; then - dnl check with pkg-config first - AG_GST_PKG_CHECK_MODULES(MAD, mad >= 0.15) - MAD_LIBS="$MAD_LIBS $ID3TAG_LIBS" - if test "x$HAVE_MAD" = "xno"; then - dnl fall back to oldskool detection - AC_CHECK_HEADER(mad.h, [ - AC_CHECK_LIB(mad, mad_decoder_finish, - HAVE_MAD="yes" MAD_LIBS="-lmad $ID3TAG_LIBS") - ]) - fi + AC_DEFINE(HAVE_ID3TAG, 1, [defined if libid3tag is available]) else - HAVE_MAD="no" - AC_MSG_WARN([libid3tag not available, cannot build MAD MP3 decoder plugin]) + AC_MSG_WARN([libid3tag not available, MAD MP3 decoder will be built without + ID3 tag reading support (which is not a problem, since ID3 + tags are usually handled by id3demux)]) fi ]) AC_SUBST(MAD_LIBS) diff --git a/ext/mad/gstmad.c b/ext/mad/gstmad.c index 35efbb5..664ab1b 100644 --- a/ext/mad/gstmad.c +++ b/ext/mad/gstmad.c @@ -40,6 +40,10 @@ #include "gstmad.h" #include +#ifdef HAVE_ID3TAG +#include +#endif + enum { ARG_0, @@ -103,7 +107,9 @@ static GstStateChangeReturn gst_mad_change_state (GstElement * element, static void gst_mad_set_index (GstElement * element, GstIndex * index); static GstIndex *gst_mad_get_index (GstElement * element); +#ifdef HAVE_ID3TAG static GstTagList *gst_mad_id3_to_tag_list (const struct id3_tag *tag); +#endif GST_BOILERPLATE (GstMad, gst_mad, GstElement, GST_TYPE_ELEMENT); @@ -1514,50 +1520,54 @@ gst_mad_chain (GstPad * pad, GstBuffer * buffer) goto end; } else if (mad->stream.error == MAD_ERROR_LOSTSYNC) { /* lost sync, force a resync */ - signed long tagsize; - GST_INFO ("recoverable lost sync error"); - tagsize = id3_tag_query (mad->stream.this_frame, - mad->stream.bufend - mad->stream.this_frame); - - if (tagsize > mad->tempsize) { - GST_INFO ("mad: got partial id3 tag in buffer, skipping"); - } else if (tagsize > 0) { - struct id3_tag *tag; - id3_byte_t const *data; - - GST_INFO ("mad: got ID3 tag size %ld", tagsize); - - data = mad->stream.this_frame; - - /* mad has moved the pointer to the next frame over the start of the - * id3 tags, so we need to flush one byte less than the tagsize */ - mad_stream_skip (&mad->stream, tagsize - 1); - - tag = id3_tag_parse (data, tagsize); - if (tag) { - GstTagList *list; - - list = gst_mad_id3_to_tag_list (tag); - id3_tag_delete (tag); - GST_DEBUG ("found tag"); - gst_element_post_message (GST_ELEMENT (mad), - gst_message_new_tag (GST_OBJECT (mad), - gst_tag_list_copy (list))); - if (mad->tags) { - gst_tag_list_insert (mad->tags, list, GST_TAG_MERGE_PREPEND); - } else { - mad->tags = gst_tag_list_copy (list); +#ifdef HAVE_ID3TAG + { + signed long tagsize; + + tagsize = id3_tag_query (mad->stream.this_frame, + mad->stream.bufend - mad->stream.this_frame); + + if (tagsize > mad->tempsize) { + GST_INFO ("mad: got partial id3 tag in buffer, skipping"); + } else if (tagsize > 0) { + struct id3_tag *tag; + id3_byte_t const *data; + + GST_INFO ("mad: got ID3 tag size %ld", tagsize); + + data = mad->stream.this_frame; + + /* mad has moved the pointer to the next frame over the start of the + * id3 tags, so we need to flush one byte less than the tagsize */ + mad_stream_skip (&mad->stream, tagsize - 1); + + tag = id3_tag_parse (data, tagsize); + if (tag) { + GstTagList *list; + + list = gst_mad_id3_to_tag_list (tag); + id3_tag_delete (tag); + GST_DEBUG ("found tag"); + gst_element_post_message (GST_ELEMENT (mad), + gst_message_new_tag (GST_OBJECT (mad), + gst_tag_list_copy (list))); + if (mad->tags) { + gst_tag_list_insert (mad->tags, list, GST_TAG_MERGE_PREPEND); + } else { + mad->tags = gst_tag_list_copy (list); + } + if (mad->need_newsegment) + mad->pending_events = + g_list_append (mad->pending_events, + gst_event_new_tag (list)); + else + gst_pad_push_event (mad->srcpad, gst_event_new_tag (list)); } - if (mad->need_newsegment) - mad->pending_events = - g_list_append (mad->pending_events, - gst_event_new_tag (list)); - else - gst_pad_push_event (mad->srcpad, gst_event_new_tag (list)); } } +#endif /* HAVE_ID3TAG */ } mad_frame_mute (&mad->frame); @@ -1902,6 +1912,7 @@ gst_mad_change_state (GstElement * element, GstStateChange transition) return ret; } +#ifdef HAVE_ID3TAG /* id3 tag helper (FIXME: why does mad parse id3 tags at all? It shouldn't) */ static GstTagList * gst_mad_id3_to_tag_list (const struct id3_tag *tag) @@ -2075,6 +2086,7 @@ gst_mad_id3_to_tag_list (const struct id3_tag *tag) return tag_list; } +#endif /* HAVE_ID3TAG */ /* plugin initialisation */ diff --git a/ext/mad/gstmad.h b/ext/mad/gstmad.h index 3acc7e2..730911d 100644 --- a/ext/mad/gstmad.h +++ b/ext/mad/gstmad.h @@ -24,7 +24,6 @@ #include #include #include -#include G_BEGIN_DECLS -- 2.7.4