mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-13 10:55:34 +00:00
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.
This commit is contained in:
parent
253afc02c9
commit
65565c8a1e
3 changed files with 60 additions and 46 deletions
27
configure.ac
27
configure.ac
|
@ -326,20 +326,23 @@ AG_GST_CHECK_FEATURE(MAD, [mad mp3 decoder], mad, [
|
||||||
])
|
])
|
||||||
fi
|
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
|
if test "x$HAVE_ID3TAG" = "xyes"; then
|
||||||
dnl check with pkg-config first
|
AC_DEFINE(HAVE_ID3TAG, 1, [defined if libid3tag is available])
|
||||||
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
|
|
||||||
else
|
else
|
||||||
HAVE_MAD="no"
|
AC_MSG_WARN([libid3tag not available, MAD MP3 decoder will be built without
|
||||||
AC_MSG_WARN([libid3tag not available, cannot build MAD MP3 decoder plugin])
|
ID3 tag reading support (which is not a problem, since ID3
|
||||||
|
tags are usually handled by id3demux)])
|
||||||
fi
|
fi
|
||||||
])
|
])
|
||||||
AC_SUBST(MAD_LIBS)
|
AC_SUBST(MAD_LIBS)
|
||||||
|
|
|
@ -40,6 +40,10 @@
|
||||||
#include "gstmad.h"
|
#include "gstmad.h"
|
||||||
#include <gst/audio/audio.h>
|
#include <gst/audio/audio.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_ID3TAG
|
||||||
|
#include <id3tag.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
ARG_0,
|
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 void gst_mad_set_index (GstElement * element, GstIndex * index);
|
||||||
static GstIndex *gst_mad_get_index (GstElement * element);
|
static GstIndex *gst_mad_get_index (GstElement * element);
|
||||||
|
|
||||||
|
#ifdef HAVE_ID3TAG
|
||||||
static GstTagList *gst_mad_id3_to_tag_list (const struct id3_tag *tag);
|
static GstTagList *gst_mad_id3_to_tag_list (const struct id3_tag *tag);
|
||||||
|
#endif
|
||||||
|
|
||||||
GST_BOILERPLATE (GstMad, gst_mad, GstElement, GST_TYPE_ELEMENT);
|
GST_BOILERPLATE (GstMad, gst_mad, GstElement, GST_TYPE_ELEMENT);
|
||||||
|
|
||||||
|
@ -1514,50 +1520,54 @@ gst_mad_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
goto end;
|
goto end;
|
||||||
} else if (mad->stream.error == MAD_ERROR_LOSTSYNC) {
|
} else if (mad->stream.error == MAD_ERROR_LOSTSYNC) {
|
||||||
/* lost sync, force a resync */
|
/* lost sync, force a resync */
|
||||||
signed long tagsize;
|
|
||||||
|
|
||||||
GST_INFO ("recoverable lost sync error");
|
GST_INFO ("recoverable lost sync error");
|
||||||
|
|
||||||
tagsize = id3_tag_query (mad->stream.this_frame,
|
#ifdef HAVE_ID3TAG
|
||||||
mad->stream.bufend - mad->stream.this_frame);
|
{
|
||||||
|
signed long tagsize;
|
||||||
|
|
||||||
if (tagsize > mad->tempsize) {
|
tagsize = id3_tag_query (mad->stream.this_frame,
|
||||||
GST_INFO ("mad: got partial id3 tag in buffer, skipping");
|
mad->stream.bufend - mad->stream.this_frame);
|
||||||
} else if (tagsize > 0) {
|
|
||||||
struct id3_tag *tag;
|
|
||||||
id3_byte_t const *data;
|
|
||||||
|
|
||||||
GST_INFO ("mad: got ID3 tag size %ld", tagsize);
|
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;
|
||||||
|
|
||||||
data = mad->stream.this_frame;
|
GST_INFO ("mad: got ID3 tag size %ld", tagsize);
|
||||||
|
|
||||||
/* mad has moved the pointer to the next frame over the start of the
|
data = mad->stream.this_frame;
|
||||||
* 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);
|
/* mad has moved the pointer to the next frame over the start of the
|
||||||
if (tag) {
|
* id3 tags, so we need to flush one byte less than the tagsize */
|
||||||
GstTagList *list;
|
mad_stream_skip (&mad->stream, tagsize - 1);
|
||||||
|
|
||||||
list = gst_mad_id3_to_tag_list (tag);
|
tag = id3_tag_parse (data, tagsize);
|
||||||
id3_tag_delete (tag);
|
if (tag) {
|
||||||
GST_DEBUG ("found tag");
|
GstTagList *list;
|
||||||
gst_element_post_message (GST_ELEMENT (mad),
|
|
||||||
gst_message_new_tag (GST_OBJECT (mad),
|
list = gst_mad_id3_to_tag_list (tag);
|
||||||
gst_tag_list_copy (list)));
|
id3_tag_delete (tag);
|
||||||
if (mad->tags) {
|
GST_DEBUG ("found tag");
|
||||||
gst_tag_list_insert (mad->tags, list, GST_TAG_MERGE_PREPEND);
|
gst_element_post_message (GST_ELEMENT (mad),
|
||||||
} else {
|
gst_message_new_tag (GST_OBJECT (mad),
|
||||||
mad->tags = gst_tag_list_copy (list);
|
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);
|
mad_frame_mute (&mad->frame);
|
||||||
|
@ -1902,6 +1912,7 @@ gst_mad_change_state (GstElement * element, GstStateChange transition)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_ID3TAG
|
||||||
/* id3 tag helper (FIXME: why does mad parse id3 tags at all? It shouldn't) */
|
/* id3 tag helper (FIXME: why does mad parse id3 tags at all? It shouldn't) */
|
||||||
static GstTagList *
|
static GstTagList *
|
||||||
gst_mad_id3_to_tag_list (const struct id3_tag *tag)
|
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;
|
return tag_list;
|
||||||
}
|
}
|
||||||
|
#endif /* HAVE_ID3TAG */
|
||||||
|
|
||||||
/* plugin initialisation */
|
/* plugin initialisation */
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
#include <gst/tag/tag.h>
|
#include <gst/tag/tag.h>
|
||||||
#include <mad.h>
|
#include <mad.h>
|
||||||
#include <id3tag.h>
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue