diff options
author | Ronald S. Bultje <rbultje@ronald.bitfreak.net> | 2003-10-01 13:14:52 +0000 |
---|---|---|
committer | Ronald S. Bultje <rbultje@ronald.bitfreak.net> | 2003-10-01 13:14:52 +0000 |
commit | 38946080fd20c3b73154685b10c29aa22fac69c3 (patch) | |
tree | e8a6e28a1fe368867ea663058fbd2dbc2b9d5e44 /gst | |
parent | 9905c2c25794875043af52aeff8cffad95faa5de (diff) |
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
Diffstat (limited to 'gst')
-rw-r--r-- | gst/auparse/gstauparse.c | 19 | ||||
-rw-r--r-- | gst/avi/gstavidemux.c | 36 | ||||
-rw-r--r-- | gst/avi/gstavidemux.h | 2 | ||||
-rw-r--r-- | gst/flx/gstflxdec.c | 38 | ||||
-rw-r--r-- | gst/flx/gstflxdec.h | 2 | ||||
-rw-r--r-- | gst/qtdemux/qtdemux.c | 40 | ||||
-rw-r--r-- | gst/qtdemux/qtdemux.h | 2 | ||||
-rw-r--r-- | gst/wavparse/gstwavparse.c | 27 |
8 files changed, 95 insertions, 71 deletions
diff --git a/gst/auparse/gstauparse.c b/gst/auparse/gstauparse.c index 422ee1ba..f2ce8c85 100644 --- a/gst/auparse/gstauparse.c +++ b/gst/auparse/gstauparse.c @@ -42,16 +42,23 @@ static GstElementDetails gst_auparse_details = { }; static GstCaps* -au_type_find (GstBuffer *buf, gpointer private) +au_type_find (GstByteStream *bs, gpointer private) { + GstBuffer *buf = NULL; GstCaps *new = NULL; - gulong *head = (gulong *) GST_BUFFER_DATA (buf); - if (GST_BUFFER_SIZE (buf) < 4) - return NULL; + if (gst_bytestream_peek (bs, &buf, 4) == 4) { + guint32 head = * (guint32 *) GST_BUFFER_DATA (buf); + if (head == 0x2e736e64 || head == 0x646e732e) { + new = gst_caps_new ("au_type_find", + "audio/x-au", + NULL); + } + } - if (*head == 0x2e736e64 || *head == 0x646e732e) - new = gst_caps_new ("au_type_find", "audio/x-au", NULL); + if (buf != NULL) { + gst_buffer_unref (buf); + } return new; } diff --git a/gst/avi/gstavidemux.c b/gst/avi/gstavidemux.c index ed605935..70170309 100644 --- a/gst/avi/gstavidemux.c +++ b/gst/avi/gstavidemux.c @@ -38,7 +38,7 @@ static GstElementDetails gst_avi_demux_details = { "(C) 1999", }; -static GstCaps* avi_type_find (GstBuffer *buf, gpointer private); +static GstCaps* avi_type_find (GstByteStream *bs, gpointer private); /* typefactory for 'avi' */ static GstTypeDefinition avidefinition = { @@ -173,25 +173,29 @@ gst_avi_demux_init (GstAviDemux *avi_demux) } static GstCaps* -avi_type_find (GstBuffer *buf, - gpointer private) +avi_type_find (GstByteStream *bs, + gpointer private) { - gchar *data = GST_BUFFER_DATA (buf); - GstCaps *new; + GstBuffer *buf = NULL; + GstCaps *new = NULL; GST_DEBUG ("avi_demux: typefind"); - if (GST_BUFFER_SIZE (buf) < 12) - return NULL; + if (gst_bytestream_peek (bs, &buf, 12) == 12) { + guint32 head1 = GUINT32_FROM_LE (((guint32 *) GST_BUFFER_DATA (buf))[0]), + head2 = GUINT32_FROM_LE (((guint32 *) GST_BUFFER_DATA (buf))[2]); - if (GUINT32_FROM_LE (((guint32 *)data)[0]) != GST_RIFF_TAG_RIFF) - return NULL; - if (GUINT32_FROM_LE (((guint32 *)data)[2]) != GST_RIFF_RIFF_AVI) - return NULL; + if (head1 == GST_RIFF_TAG_RIFF && head2 == GST_RIFF_RIFF_AVI) { + new = GST_CAPS_NEW ("avi_type_find", + "video/avi", + NULL); + } + } + + if (buf != NULL) { + gst_buffer_unref (buf); + } - new = GST_CAPS_NEW ("avi_type_find", - "video/avi", - NULL); return new; } @@ -1961,10 +1965,6 @@ plugin_init (GModule *module, GstPlugin *plugin) -1 /* end */ }; - /* this filter needs the riff parser */ - if (!gst_library_load ("gstbytestream")) - return FALSE; - if (!gst_library_load ("gstriff")) return FALSE; diff --git a/gst/avi/gstavidemux.h b/gst/avi/gstavidemux.h index d1c1d582..9a719a67 100644 --- a/gst/avi/gstavidemux.h +++ b/gst/avi/gstavidemux.h @@ -24,7 +24,7 @@ #include <config.h> #include <gst/gst.h> -#include <gst/bytestream/bytestream.h> +#include <gst/gstbytestream.h> #include <gst/riff/riff.h> #ifdef __cplusplus diff --git a/gst/flx/gstflxdec.c b/gst/flx/gstflxdec.c index c20327a7..1f55b7d9 100644 --- a/gst/flx/gstflxdec.c +++ b/gst/flx/gstflxdec.c @@ -28,7 +28,7 @@ #define JIFFIE (GST_SECOND/70) -static GstCaps* flxdec_type_find(GstBuffer *buf, gpointer private); +static GstCaps* flxdec_type_find (GstByteStream *bs, gpointer private); /* flx element information */ static GstElementDetails flxdec_details = { @@ -113,27 +113,33 @@ static void flx_decode_delta_flc (GstFlxDec *, guchar *, guchar *); static GstElementClass *parent_class = NULL; static GstCaps* -flxdec_type_find (GstBuffer *buf, gpointer private) +flxdec_type_find (GstByteStream *bs, gpointer private) { - guchar *data = GST_BUFFER_DATA(buf); - GstCaps *new; + GstBuffer *buf = NULL; + GstCaps *new = NULL; - if (GST_BUFFER_SIZE(buf) < 134){ - return NULL; - } + if (gst_bytestream_peek (bs, &buf, 134) == 134) { + guint8 *data = GST_BUFFER_DATA (buf); - /* check magic */ - if ((data[4] == 0x11 || data[4] == 0x12 - || data[4] == 0x30 || data[4] == 0x44) && data[5] == 0xaf) { + /* check magic */ + if ((data[4] == 0x11 || data[4] == 0x12 || + data[4] == 0x30 || data[4] == 0x44) && + data[5] == 0xaf) { /* check the frame type of the first frame */ if ((data[132] == 0x00 || data[132] == 0xfa) && data[133] == 0xf1) { GST_DEBUG ("GstFlxDec: found supported flx format"); - new = gst_caps_new("flxdec_type_find","video/x-fli", NULL); - return new; + new = gst_caps_new ("flxdec_type_find", + "video/x-fli", + NULL); } + } } - - return NULL; + + if (buf != NULL) { + gst_buffer_unref (buf); + } + + return new; } @@ -684,10 +690,6 @@ plugin_init (GModule *module, GstPlugin *plugin) GstElementFactory *factory; GstTypeFactory *type; - /* this filter needs the bytestream package */ - if (!gst_library_load ("gstbytestream")) - return FALSE; - factory = gst_element_factory_new("flxdec", GST_TYPE_FLXDEC, &flxdec_details); g_return_val_if_fail(factory != NULL, FALSE); gst_element_factory_set_rank (factory, GST_ELEMENT_RANK_PRIMARY); diff --git a/gst/flx/gstflxdec.h b/gst/flx/gstflxdec.h index c7d6f386..0ee4b1c5 100644 --- a/gst/flx/gstflxdec.h +++ b/gst/flx/gstflxdec.h @@ -23,7 +23,7 @@ #include <gst/gst.h> #include "flx_color.h" -#include <gst/bytestream/bytestream.h> +#include <gst/gstbytestream.h> #ifdef __cplusplus diff --git a/gst/qtdemux/qtdemux.c b/gst/qtdemux/qtdemux.c index 3358db33..f5a95c03 100644 --- a/gst/qtdemux/qtdemux.c +++ b/gst/qtdemux/qtdemux.c @@ -104,7 +104,7 @@ gst_qtdemux_details = "(C) 2003", }; -static GstCaps* quicktime_type_find (GstBuffer *buf, gpointer private); +static GstCaps* quicktime_type_find (GstByteStream *bs, gpointer private); static GstTypeDefinition quicktimedefinition = { "qtdemux_video/quicktime", @@ -187,24 +187,29 @@ gst_qtdemux_init (GstQTDemux *qtdemux) } static GstCaps* -quicktime_type_find (GstBuffer *buf, gpointer private) +quicktime_type_find (GstByteStream *bs, gpointer private) { - gchar *data = GST_BUFFER_DATA (buf); - - g_return_val_if_fail (data != NULL, NULL); - - if(GST_BUFFER_SIZE(buf) < 8){ - return NULL; + GstBuffer *buf = NULL; + GstCaps *new = NULL; + + if (gst_bytestream_peek (bs, &buf, 8) == 8) { + gchar *data = GST_BUFFER_DATA (buf); + + if (!strncmp (&data[4], "wide", 4) || + !strncmp (&data[4], "moov", 4) || + !strncmp (&data[4], "mdat", 4) || + !strncmp (&data[4], "free", 4)) { + new = GST_CAPS_NEW ("quicktime_type_find", + "video/quicktime", + NULL); + } } - if (strncmp (&data[4], "wide", 4)==0 || - strncmp (&data[4], "moov", 4)==0 || - strncmp (&data[4], "mdat", 4)==0 || - strncmp (&data[4], "free", 4)==0) { - return gst_caps_new ("quicktime_type_find", - "video/quicktime", - NULL); + + if (buf != NULL) { + gst_buffer_unref (buf); } - return NULL; + + return new; } static gboolean @@ -222,9 +227,6 @@ plugin_init (GModule *module, GstPlugin *plugin) }; gint i; - if (!gst_library_load ("gstbytestream")) - return FALSE; - factory = gst_element_factory_new ("qtdemux", GST_TYPE_QTDEMUX, &gst_qtdemux_details); g_return_val_if_fail(factory != NULL, FALSE); diff --git a/gst/qtdemux/qtdemux.h b/gst/qtdemux/qtdemux.h index 108faab1..46684be8 100644 --- a/gst/qtdemux/qtdemux.h +++ b/gst/qtdemux/qtdemux.h @@ -22,7 +22,7 @@ #define __GST_QTDEMUX_H__ #include <gst/gst.h> -#include <gst/bytestream/bytestream.h> +#include <gst/gstbytestream.h> #ifdef __cplusplus extern "C" { diff --git a/gst/wavparse/gstwavparse.c b/gst/wavparse/gstwavparse.c index c2e6063c..67d7fa19 100644 --- a/gst/wavparse/gstwavparse.c +++ b/gst/wavparse/gstwavparse.c @@ -31,7 +31,8 @@ static void gst_wavparse_init (GstWavParse *wavparse); static GstElementStateReturn gst_wavparse_change_state (GstElement *element); -static GstCaps* wav_type_find (GstBuffer *buf, gpointer private); +static GstCaps* wav_type_find (GstByteStream *bs, + gpointer private); static const GstFormat* gst_wavparse_get_formats (GstPad *pad); static const GstQueryType * @@ -213,15 +214,27 @@ gst_wavparse_init (GstWavParse *wavparse) } static GstCaps* -wav_type_find (GstBuffer *buf, gpointer private) +wav_type_find (GstByteStream *bs, gpointer private) { - gchar *data = GST_BUFFER_DATA (buf); + GstCaps *new = NULL; + GstBuffer *buf = NULL; - if (GST_BUFFER_SIZE (buf) < 12) return NULL; - if (strncmp (&data[0], "RIFF", 4)) return NULL; - if (strncmp (&data[8], "WAVE", 4)) return NULL; + if (gst_bytestream_peek (bs, &buf, 12) == 12) { + gchar *data = GST_BUFFER_DATA (buf); - return gst_caps_new ("wav_type_find", "audio/x-wav", NULL); + if (!strncmp (&data[0], "RIFF", 4) && + !strncmp (&data[8], "WAVE", 4)) { + new = GST_CAPS_NEW ("wav_type_find", + "audio/x-wav", + NULL); + } + } + + if (buf != NULL) { + gst_buffer_unref (buf); + } + + return new; } static void wav_new_chunk_callback(GstRiffChunk *chunk, gpointer data) |