From 595cbc2d054f57e8fc397ddae71b98a951bf6327 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Wed, 1 Oct 2003 13:14:45 +0000 Subject: [PATCH] New typefind system: bytestream is now part of the core all plugins have been modified to use this new typefind syste... Original commit message from CVS: New typefind system: * bytestream is now part of the core * all plugins have been modified to use this new typefind system * asf typefinding added * mpeg video stream typefiding removed because it's broken * duplicate typefind entries removed * extra id3 typefinding added, because we've seen 4 types of files (riff/wav, flac, vorbis, mp3) with id3 headers and each of these needs to work. Instead, I've added an id3 element and let it redo typefiding after the id3 header. this needs a hack because spider only typefinds once. We can remove this hack once spider supports multiple typefinds. * with all this, mp3 typefinding is semi-rewritten * id3 typefinding in flac/vorbis is removed, it's no longer needed * fixed spider and gst-typefind to use this, too. * Other general cleanups --- configure.ac | 3 ++- ext/Makefile.am | 5 +++-- ext/alsa/gstalsa.c | 3 --- ext/vorbis/vorbis.c | 48 +++++++++++++---------------------------- ext/vorbis/vorbisfile.c | 2 +- gst/adder/gstadder.c | 3 --- gst/adder/gstadder.h | 2 +- 7 files changed, 22 insertions(+), 44 deletions(-) diff --git a/configure.ac b/configure.ac index bf0338ee8c..5bcb93ac67 100644 --- a/configure.ac +++ b/configure.ac @@ -262,7 +262,7 @@ GST_PLUGINS_ALL="\ ac3parse adder audioscale auparse avi \ asfdemux audioconvert cdxaparse chart \ cutter debug deinterlace effectv festival \ - filter flx goom intfloat law level median mixmatrix \ + filter flx goom id3 intfloat law level median mixmatrix \ mpeg1sys mpeg1videoparse mpeg2enc mpeg2sub \ mpegaudio mpegaudioparse mpegstream mpegtypes \ monoscope oneton overlay passthrough playondemand qtdemux \ @@ -1180,6 +1180,7 @@ gst/festival/Makefile gst/filter/Makefile gst/flx/Makefile gst/goom/Makefile +gst/id3/Makefile gst/intfloat/Makefile gst/law/Makefile gst/level/Makefile diff --git a/ext/Makefile.am b/ext/Makefile.am index 2b1ab6eca2..66346eaceb 100644 --- a/ext/Makefile.am +++ b/ext/Makefile.am @@ -278,8 +278,9 @@ SUBDIRS=$(A52DEC_DIR) $(AALIB_DIR) $(ALSA_DIR) \ $(ARTS_DIR) $(ARTSC_DIR) $(AUDIOFILE_DIR) \ $(CDPARANOIA_DIR) $(DIVX_DIR) \ $(DVDREAD_DIR) $(DVDNAV_DIR) $(ESD_DIR) $(MAS_DIR) \ - $(FFMPEG_DIR) $(FLAC_DIR) $(GDK_PIXBUF_DIR) $(GNOMEVFS_DIR) $(GSM_DIR) \ - $(HERMES_DIR) $(JACK_DIR) $(JPEG_DIR) \ + $(FFMPEG_DIR) $(FLAC_DIR) $(GDK_PIXBUF_DIR) \ + $(GNOMEVFS_DIR) $(GSM_DIR) $(HERMES_DIR) \ + $(JACK_DIR) $(JPEG_DIR) \ $(LADSPA_DIR) $(LAME_DIR) $(LCS_DIR) \ $(LIBDV_DIR) $(LIBFAME_DIR) $(LIBPNG_DIR) \ $(MAD_DIR) $(MATROSKA_DIR) $(MIKMOD_DIR) \ diff --git a/ext/alsa/gstalsa.c b/ext/alsa/gstalsa.c index 1ec8e04a49..05d5f5511b 100644 --- a/ext/alsa/gstalsa.c +++ b/ext/alsa/gstalsa.c @@ -2351,9 +2351,6 @@ plugin_init (GModule * module, GstPlugin * plugin) { GstElementFactory *factory; - if (!gst_library_load ("gstbytestream")) - return FALSE; - factory = gst_element_factory_new ("alsasrc", GST_TYPE_ALSA_SRC, &gst_alsa_src_details); g_return_val_if_fail (factory != NULL, FALSE); gst_element_factory_add_pad_template (factory, gst_alsa_src_pad_factory ()); diff --git a/ext/vorbis/vorbis.c b/ext/vorbis/vorbis.c index a5faef9313..fc6b75e65c 100644 --- a/ext/vorbis/vorbis.c +++ b/ext/vorbis/vorbis.c @@ -25,7 +25,7 @@ extern GType vorbisfile_get_type(void); extern GstElementDetails vorbisfile_details; extern GstElementDetails vorbisenc_details; -static GstCaps* vorbis_type_find (GstBuffer *buf, gpointer private); +static GstCaps* vorbis_type_find (GstByteStream *bs, gpointer private); GstPadTemplate *gst_vorbisdec_src_template, *gst_vorbisdec_sink_template; GstPadTemplate *gst_vorbisenc_src_template, *gst_vorbisenc_sink_template; @@ -81,40 +81,26 @@ static GstTypeDefinition vorbisdefinition = { }; static GstCaps* -vorbis_type_find (GstBuffer *buf, gpointer private) +vorbis_type_find (GstByteStream *bs, gpointer private) { - guint32 head; - gint offset; - guint8 *data; - gint size; + GstBuffer *buf = NULL; + GstCaps *new = NULL; - data = GST_BUFFER_DATA (buf); - size = GST_BUFFER_SIZE (buf); + if (gst_bytestream_peek (bs, &buf, 4) == 4) { + guint32 head = GUINT32_FROM_BE (*((guint32 *) GST_BUFFER_DATA (buf))); - if (size < sizeof(guint32)) - return NULL; - - head = GUINT32_FROM_BE (*((guint32 *)data)); - - if (head == 0x4F676753) { - return gst_caps_new ("vorbis_type_find", "application/ogg", NULL); - } else { - /* checks for existance of vorbis identification header in case - * there's an ID3 tag */ - for (offset = 0; offset < size-7; offset++) { - if (data[offset] == 0x01 && - data[offset+1] == 'v' && - data[offset+2] == 'o' && - data[offset+3] == 'r' && - data[offset+4] == 'b' && - data[offset+5] == 'i' && - data[offset+6] == 's' ) { - return gst_caps_new ("vorbis_type_find", "application/ogg", NULL); - } + if (head == 0x4F676753) { + new = GST_CAPS_NEW ("vorbis_type_find", + "application/ogg", + NULL); } } - return NULL; + if (buf != NULL) { + gst_buffer_unref (buf); + } + + return new; } @@ -172,10 +158,6 @@ plugin_init (GModule *module, GstPlugin *plugin) gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (file)); - /* this filter needs the bytestream package */ - if (!gst_library_load ("gstbytestream")) - return FALSE; - type = gst_type_factory_new (&vorbisdefinition); gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (type)); diff --git a/ext/vorbis/vorbisfile.c b/ext/vorbis/vorbisfile.c index 8fe480e6e7..d8b6b323ac 100644 --- a/ext/vorbis/vorbisfile.c +++ b/ext/vorbis/vorbisfile.c @@ -24,7 +24,7 @@ #include #include #include -#include +#include #define GST_TYPE_VORBISFILE \ (vorbisfile_get_type()) diff --git a/gst/adder/gstadder.c b/gst/adder/gstadder.c index 60f1741319..c5f8eefe44 100644 --- a/gst/adder/gstadder.c +++ b/gst/adder/gstadder.c @@ -606,9 +606,6 @@ plugin_init (GModule *module, GstPlugin *plugin) factory = gst_element_factory_new ("adder", GST_TYPE_ADDER, &adder_details); g_return_val_if_fail (factory != NULL, FALSE); - if (! gst_library_load ("gstbytestream")) - return FALSE; - gst_element_factory_add_pad_template (factory, GST_PAD_TEMPLATE_GET (gst_adder_src_template_factory)); gst_element_factory_add_pad_template (factory, diff --git a/gst/adder/gstadder.h b/gst/adder/gstadder.h index a1d6f1d9f0..570684b034 100644 --- a/gst/adder/gstadder.h +++ b/gst/adder/gstadder.h @@ -24,7 +24,7 @@ #define __GST_ADDER_H__ #include -#include +#include #ifdef __cplusplus extern "C" {