From 97bf62c74ffa0194e4803993711edf584a2147b8 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Tue, 28 Oct 2003 20:52:41 +0000 Subject: [PATCH] merge TYPEFIND branch. Major changes: Original commit message from CVS: merge TYPEFIND branch. Major changes: - totally reworked type(find) system - all typefind functions are in gst/typefind now - more typefind functions then before - some plugins might fail to compile now because I don't have them installed and they a) require bytestream or b) haven't had their typefind fixed. Please fix those plugins and put the typefind functions into gst/typefind if they don't have dependencies --- configure.ac | 6 +- ext/a52dec/gsta52dec.c | 3 + ext/a52dec/gsta52dec.h | 2 +- ext/mad/gstmad.c | 6 +- gst-libs/ext/ffmpeg/Tag | 2 +- gst/asfdemux/gstasfdemux.c | 46 +------------- gst/asfdemux/gstasfdemux.h | 2 +- gst/mpegaudioparse/Makefile.am | 1 - gst/mpegaudioparse/README | 12 ---- gst/mpegaudioparse/gstmpegaudioparse.c | 86 -------------------------- gst/mpegstream/gstmpegpacketize.h | 2 +- gst/mpegstream/gstmpegparse.h | 2 +- gst/mpegstream/gstmpegstream.c | 3 + gst/mpegstream/gstrfc2250enc.h | 2 +- gst/realmedia/rmdemux.c | 41 ++---------- gst/realmedia/rmdemux.h | 2 +- 16 files changed, 27 insertions(+), 191 deletions(-) delete mode 100644 gst/mpegaudioparse/README diff --git a/configure.ac b/configure.ac index 47c08c3547..02f2636d69 100644 --- a/configure.ac +++ b/configure.ac @@ -264,10 +264,10 @@ GST_PLUGINS_ALL="\ cutter debug deinterlace effectv festival \ filter flx goom id3 intfloat law level median mixmatrix \ mpeg1sys mpeg1videoparse mpeg2enc mpeg2sub \ - mpegaudio mpegaudioparse mpegstream mpegtypes \ + mpegaudio mpegaudioparse mpegstream \ monoscope oneton overlay passthrough playondemand qtdemux \ realmedia rtp rtjpeg silence sine smooth smpte \ - spectrum speed stereo synaesthesia tcp udp vbidec \ + spectrum speed stereo synaesthesia tcp typefind udp vbidec \ videocrop videodrop videofilter videoflip videoscale \ videotestsrc volenv volume wavenc wavparse y4m" @@ -1193,7 +1193,6 @@ gst/mpeg2sub/Makefile gst/mpegaudio/Makefile gst/mpegaudioparse/Makefile gst/mpegstream/Makefile -gst/mpegtypes/Makefile gst/modplug/Makefile gst/modplug/libmodplug/Makefile gst/monoscope/Makefile @@ -1214,6 +1213,7 @@ gst/speed/Makefile gst/stereo/Makefile gst/synaesthesia/Makefile gst/tcp/Makefile +gst/typefind/Makefile gst/udp/Makefile gst/vbidec/Makefile gst/videocrop/Makefile diff --git a/ext/a52dec/gsta52dec.c b/ext/a52dec/gsta52dec.c index e23c33e48f..57ab000590 100644 --- a/ext/a52dec/gsta52dec.c +++ b/ext/a52dec/gsta52dec.c @@ -619,6 +619,9 @@ plugin_init (GModule * module, GstPlugin * plugin) { GstElementFactory *factory; + if (!gst_library_load ("gstbytestream")) + return FALSE; + /* create an elementfactory for the a52dec element */ factory = gst_element_factory_new ("a52dec", GST_TYPE_A52DEC, &gst_a52dec_details); g_return_val_if_fail (factory != NULL, FALSE); diff --git a/ext/a52dec/gsta52dec.h b/ext/a52dec/gsta52dec.h index 6d00ca0740..d63991f675 100644 --- a/ext/a52dec/gsta52dec.h +++ b/ext/a52dec/gsta52dec.h @@ -23,7 +23,7 @@ #include #include -#include +#include G_BEGIN_DECLS diff --git a/ext/mad/gstmad.c b/ext/mad/gstmad.c index 01aac7d723..9bc75e44ed 100644 --- a/ext/mad/gstmad.c +++ b/ext/mad/gstmad.c @@ -820,14 +820,16 @@ gst_mad_get_streaminfo (GstMad *mad) klass = g_type_class_ref (GST_TYPE_MAD_MODE); value = g_enum_get_value (klass, mad->header.mode); - entry = gst_props_entry_new ("mode", GST_PROPS_STRING (value->value_nick)); + if (value) + entry = gst_props_entry_new ("mode", GST_PROPS_STRING (value->value_nick)); g_type_class_unref (klass); gst_props_add_entry (props, (GstPropsEntry *) entry); klass = g_type_class_ref (GST_TYPE_MAD_EMPHASIS); value = g_enum_get_value (klass, mad->header.emphasis); - entry = gst_props_entry_new ("emphasis", GST_PROPS_STRING (value->value_nick)); + if (value) + entry = gst_props_entry_new ("emphasis", GST_PROPS_STRING (value->value_nick)); g_type_class_unref (klass); gst_props_add_entry (props, (GstPropsEntry *) entry); diff --git a/gst-libs/ext/ffmpeg/Tag b/gst-libs/ext/ffmpeg/Tag index 01fdcac25a..f6ecaeb31a 100644 --- a/gst-libs/ext/ffmpeg/Tag +++ b/gst-libs/ext/ffmpeg/Tag @@ -1 +1 @@ -D2003.10.26.10.00.00 +2003-10-26 10:00 GMT diff --git a/gst/asfdemux/gstasfdemux.c b/gst/asfdemux/gstasfdemux.c index 223fb9460b..d8dd17c3f8 100644 --- a/gst/asfdemux/gstasfdemux.c +++ b/gst/asfdemux/gstasfdemux.c @@ -35,44 +35,6 @@ static GstElementDetails gst_asf_demux_details = { "(C) 2002", }; -static GstCaps* asf_type_find (GstByteStream *bs, gpointer private); - -/* typefactory for 'asf' */ -static GstTypeDefinition asf_type_definition = { - "asfdemux_video/asf", - "video/x-ms-asf", - /* note: asx/wax/wmx are XML files, we don't handle them */ - ".asf .wma .wmv .wm", - asf_type_find, -}; - -static GstCaps* -asf_type_find (GstByteStream *bs, gpointer private) -{ - GstCaps *new = NULL; - GstBuffer *buf = NULL; - - if (gst_bytestream_peek (bs, &buf, 16) == 16) { - guint32 uid1 = GUINT32_FROM_LE (((guint32 *) GST_BUFFER_DATA (buf))[0]), - uid2 = GUINT32_FROM_LE (((guint32 *) GST_BUFFER_DATA (buf))[1]), - uid3 = GUINT32_FROM_LE (((guint32 *) GST_BUFFER_DATA (buf))[2]), - uid4 = GUINT32_FROM_LE (((guint32 *) GST_BUFFER_DATA (buf))[3]); - - if (uid1 == 0x75B22630 && uid2 == 0x11CF668E && - uid3 == 0xAA00D9A6 && uid4 == 0x6CCE6200) { - new = GST_CAPS_NEW ("asf_type_find", - "video/x-ms-asf", - NULL); - } - } - - if (buf != NULL) { - gst_buffer_unref (buf); - } - - return new; -} - GST_PAD_TEMPLATE_FACTORY (sink_factory, "sink", GST_PAD_SINK, @@ -1554,7 +1516,6 @@ static gboolean plugin_init (GModule *module, GstPlugin *plugin) { GstElementFactory *factory; - GstTypeFactory *type; gint i = 0; GstCaps *audcaps = NULL, *vidcaps = NULL, *temp; guint32 vid_list[] = { @@ -1583,14 +1544,13 @@ plugin_init (GModule *module, GstPlugin *plugin) -1 /* end */ }; + if (!gst_library_load ("gstbytestream")) + return FALSE; + /* create an elementfactory for the asf_demux element */ factory = gst_element_factory_new ("asfdemux",GST_TYPE_ASF_DEMUX, &gst_asf_demux_details); - /* type finding */ - type = gst_type_factory_new (&asf_type_definition); - gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (type)); - g_return_val_if_fail (factory != NULL, FALSE); gst_element_factory_set_rank (factory, GST_ELEMENT_RANK_NONE); diff --git a/gst/asfdemux/gstasfdemux.h b/gst/asfdemux/gstasfdemux.h index 778b1995a7..9fff935105 100644 --- a/gst/asfdemux/gstasfdemux.h +++ b/gst/asfdemux/gstasfdemux.h @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include "asfheaders.h" G_BEGIN_DECLS diff --git a/gst/mpegaudioparse/Makefile.am b/gst/mpegaudioparse/Makefile.am index cb06727fd6..02f8a2ee77 100644 --- a/gst/mpegaudioparse/Makefile.am +++ b/gst/mpegaudioparse/Makefile.am @@ -6,4 +6,3 @@ libgstmpegaudioparse_la_LIBADD = libgstmpegaudioparse_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) noinst_HEADERS = gstmpegaudioparse.h -EXTRA_DIST = README diff --git a/gst/mpegaudioparse/README b/gst/mpegaudioparse/README deleted file mode 100644 index 8a803d3e9b..0000000000 --- a/gst/mpegaudioparse/README +++ /dev/null @@ -1,12 +0,0 @@ -MP3 Audio Parser -================ - -This element acts as a parser for mpeg audio data. It's called 'mp3' but -in reality will work for any MPEG-1, MPEG-2, or MPEG-2.5 elemental audio -stream of any of Layers I, II, and III. It will not (currently, ever?) -handle MPEG-2 BC or NBC streams, as those have rather specialized needs -best served be a different filter. - -It will take an mpeg audio stream in any form on its 'src' input, with any -buffer size, and split it into buffers containing a single frame each. -NOTE: ancillary data is not dealt with right now. diff --git a/gst/mpegaudioparse/gstmpegaudioparse.c b/gst/mpegaudioparse/gstmpegaudioparse.c index b0a308065f..a4d7a8492a 100644 --- a/gst/mpegaudioparse/gstmpegaudioparse.c +++ b/gst/mpegaudioparse/gstmpegaudioparse.c @@ -35,15 +35,6 @@ static GstElementDetails mp3parse_details = { "(C) 1999", }; -static GstCaps * mp3_type_find (GstByteStream *bs, gpointer data); - -static GstTypeDefinition mp3type_definition = { - "mp3_audio/mpeg", - "audio/mpeg", - ".mp3 .mp2 .mp1 .mpga", - mp3_type_find, -}; - static GstPadTemplate* mp3_src_factory (void) { @@ -267,78 +258,6 @@ mp3_caps_create (guint layer, guint channels, return new; } -static GstCaps * -mp3_type_find (GstByteStream *bs, gpointer private) -{ - GstBuffer *buf = NULL; - GstCaps *new = NULL; - guint8 *data; - guint size; - guint32 head; - guint layer = 0, bitrate = 0, samplerate = 0, channels = 0; - - /* note that even if we don't get the requested size, - * it might still be a (very small) mp3 */ - gst_bytestream_peek (bs, &buf, GST_MP3_TYPEFIND_MIN_DATA); - if (!buf) { - goto done; - } - - data = GST_BUFFER_DATA (buf); - size = GST_BUFFER_SIZE (buf); - - while (size >= 4) { - head = GUINT32_FROM_BE(*((guint32 *)data)); - if ((head & 0xffe00000) == 0xffe00000) { - guint length; - guint prev_layer = 0, prev_bitrate = 0, - prev_channels = 0, prev_samplerate = 0; - guint found = 0; /* number of valid headers found */ - guint pos = 0; - - do { - if (!(length = mp3_type_frame_length_from_header (head, &layer, - &channels, &bitrate, - &samplerate))) { - break; - } - if ((prev_layer && prev_layer != layer) || !layer || - (prev_bitrate && prev_bitrate != bitrate) || !bitrate || - (prev_samplerate && prev_samplerate != samplerate) || !samplerate || - (prev_channels && prev_channels != channels) || !channels) { - /* this means an invalid property, or a change, which likely - * indicates that this is not a mp3 but just a random bytestream */ - break; - } - prev_layer = layer; - prev_bitrate = bitrate; - prev_channels = channels; - prev_samplerate = samplerate; - pos += length; - if (++found >= GST_MP3_TYPEFIND_MIN_HEADERS) { - /* we're pretty sure that this is mp3 now */ - new = mp3_caps_create (layer, channels, bitrate, samplerate); - goto done; - } - - /* and now, find a new head */ - head = GUINT32_FROM_BE(*((guint32 *) &(data[pos]))); - if ((head & 0xffe00000) != 0xffe00000) - break; - } while (TRUE); - } - data++; - size--; - } - -done: - if (buf != NULL) { - gst_buffer_unref (buf); - } - - return new; -} - static void gst_mp3parse_class_init (GstMPEGAudioParseClass *klass) { @@ -658,7 +577,6 @@ static gboolean plugin_init (GModule *module, GstPlugin *plugin) { GstElementFactory *factory; - GstTypeFactory *type; /* create an elementfactory for the mp3parse element */ factory = gst_element_factory_new ("mp3parse", @@ -674,10 +592,6 @@ plugin_init (GModule *module, GstPlugin *plugin) gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory)); - /* type finding */ - type = gst_type_factory_new (&mp3type_definition); - gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (type)); - return TRUE; } diff --git a/gst/mpegstream/gstmpegpacketize.h b/gst/mpegstream/gstmpegpacketize.h index d4c1c3b668..3459316bf7 100644 --- a/gst/mpegstream/gstmpegpacketize.h +++ b/gst/mpegstream/gstmpegpacketize.h @@ -24,7 +24,7 @@ #include #include -#include +#include #ifdef __cplusplus diff --git a/gst/mpegstream/gstmpegparse.h b/gst/mpegstream/gstmpegparse.h index 27adb2a0c1..2f66594536 100644 --- a/gst/mpegstream/gstmpegparse.h +++ b/gst/mpegstream/gstmpegparse.h @@ -22,7 +22,7 @@ #define __MPEG_PARSE_H__ #include -#include +#include #include "gstmpegpacketize.h" #ifdef __cplusplus diff --git a/gst/mpegstream/gstmpegstream.c b/gst/mpegstream/gstmpegstream.c index 81339745d5..7bb43346f1 100644 --- a/gst/mpegstream/gstmpegstream.c +++ b/gst/mpegstream/gstmpegstream.c @@ -30,6 +30,9 @@ plugin_init (GModule *module, GstPlugin *plugin) * stack again and the first _init will be called more than once * and wtay wants to use dlclose at some point in the future */ + if (!gst_library_load ("gstbytestream")) + return FALSE; + if (!gst_mpeg_parse_plugin_init (module, plugin)) return FALSE; if (!gst_mpeg_demux_plugin_init (module, plugin)) return FALSE; if (!gst_rfc2250_enc_plugin_init (module, plugin)) return FALSE; diff --git a/gst/mpegstream/gstrfc2250enc.h b/gst/mpegstream/gstrfc2250enc.h index 5f405fa524..ae93bfd80e 100644 --- a/gst/mpegstream/gstrfc2250enc.h +++ b/gst/mpegstream/gstrfc2250enc.h @@ -24,7 +24,7 @@ #include #include -#include +#include #include "gstmpegpacketize.h" diff --git a/gst/realmedia/rmdemux.c b/gst/realmedia/rmdemux.c index 7fb97b4210..66f5c5e8e5 100644 --- a/gst/realmedia/rmdemux.c +++ b/gst/realmedia/rmdemux.c @@ -78,7 +78,7 @@ enum GstRMDemuxStreamType { static GstElementDetails gst_rmdemux_details = { - "QuickTime Demuxer", + "RealMedia Demuxer", "Codec/Demuxer", "LGPL", "Demultiplex a RealMedia file into audio and video streams", @@ -87,15 +87,6 @@ gst_rmdemux_details = "(C) 2003", }; -static GstCaps* realmedia_type_find (GstByteStream *bs, gpointer private); - -static GstTypeDefinition realmediadefinition = { - "rmdemux_video/realmedia", - "video/x-pn-realvideo", - ".ram .rm .ra", - realmedia_type_find, -}; - enum { LAST_SIGNAL }; @@ -194,34 +185,13 @@ gst_rmdemux_init (GstRMDemux *rmdemux) gst_element_add_pad (GST_ELEMENT (rmdemux), rmdemux->sinkpad); } -static GstCaps* -realmedia_type_find (GstByteStream *bs, gpointer private) -{ - GstBuffer *buf = NULL; - GstCaps *new = NULL; - - if (gst_bytestream_peek (bs, &buf, 4) == 4) { - gchar *data = GST_BUFFER_DATA (buf); - - if (!strncmp (data, ".RMF", 4)) { - new = GST_CAPS_NEW ("realmedia_type_find", - "application/vnd.rn-realmedia", - NULL); - } - } - - if (buf != NULL) { - gst_buffer_unref (buf); - } - - return new; -} - static gboolean plugin_init (GModule *module, GstPlugin *plugin) { GstElementFactory *factory; - GstTypeFactory *type; + + if (!gst_library_load ("gstbytestream")) + return FALSE; factory = gst_element_factory_new ("rmdemux", GST_TYPE_RMDEMUX, &gst_rmdemux_details); @@ -232,9 +202,6 @@ plugin_init (GModule *module, GstPlugin *plugin) gst_element_factory_add_pad_template (factory, GST_PAD_TEMPLATE_GET (src_video_templ)); gst_element_factory_add_pad_template (factory, GST_PAD_TEMPLATE_GET (src_audio_templ)); - type = gst_type_factory_new (&realmediadefinition); - gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (type)); - gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory)); return TRUE; diff --git a/gst/realmedia/rmdemux.h b/gst/realmedia/rmdemux.h index 231e1546af..d0a1531f82 100644 --- a/gst/realmedia/rmdemux.h +++ b/gst/realmedia/rmdemux.h @@ -22,7 +22,7 @@ #define __GST_RMDEMUX_H__ #include -#include +#include #ifdef __cplusplus extern "C" {