From 38946080fd20c3b73154685b10c29aa22fac69c3 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Wed, 1 Oct 2003 13:14:52 +0000 Subject: 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 --- gst/wavparse/gstwavparse.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'gst/wavparse') 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) -- cgit