summaryrefslogtreecommitdiffstats
path: root/gst/festival
diff options
context:
space:
mode:
authorRonald S. Bultje <rbultje@ronald.bitfreak.net>2003-10-01 13:14:50 +0000
committerRonald S. Bultje <rbultje@ronald.bitfreak.net>2003-10-01 13:14:50 +0000
commitd9e4457faa360b470a5ae418e3444fccd6c0a5de (patch)
tree2a981bbe80d369449ad5d79e65ae7e766f1635ba /gst/festival
parentb569848e286b7435997a67e17fa0b21db892131d (diff)
downloadgst-plugins-bad-d9e4457faa360b470a5ae418e3444fccd6c0a5de.tar.gz
gst-plugins-bad-d9e4457faa360b470a5ae418e3444fccd6c0a5de.tar.bz2
gst-plugins-bad-d9e4457faa360b470a5ae418e3444fccd6c0a5de.zip
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/festival')
-rw-r--r--gst/festival/gstfestival.c36
1 files changed, 25 insertions, 11 deletions
diff --git a/gst/festival/gstfestival.c b/gst/festival/gstfestival.c
index 87416184..4113410a 100644
--- a/gst/festival/gstfestival.c
+++ b/gst/festival/gstfestival.c
@@ -80,7 +80,7 @@
static void gst_festival_class_init (GstFestivalClass *klass);
static void gst_festival_init (GstFestival *festival);
-static GstCaps* text_type_find (GstBuffer *buf, gpointer private);
+static GstCaps* text_type_find (GstByteStream *bs, gpointer private);
static void gst_festival_chain (GstPad *pad, GstBuffer *buf);
static GstElementStateReturn
@@ -198,21 +198,35 @@ gst_festival_init (GstFestival *festival)
}
static GstCaps*
-text_type_find (GstBuffer *buf, gpointer private)
+text_type_find (GstByteStream *bs, gpointer private)
{
- gchar *data = GST_BUFFER_DATA (buf);
- gint i;
+ GstBuffer *buf = NULL;
+ GstCaps *new = NULL;
- /* 20 is arbitrary. 4 is definitely too small. */
- if (GST_BUFFER_SIZE (buf) < 20)
- return NULL;
+#define TEXT_SIZE 32
- for (i=0; i<GST_BUFFER_SIZE (buf); i++) {
- if (!isprint(data[i]) && data[i]!='\n')
- return NULL;
+ /* read arbitrary number and see if it's textual */
+ if (gst_bytestream_peek (bs, &buf, TEXT_SIZE) == TEXT_SIZE) {
+ gchar *data = GST_BUFFER_DATA (buf);
+ gint i;
+
+ for (i = 0; i < TEXT_SIZE; i++) {
+ if (!isprint (data[i]) && data[i] != '\n') {
+ break;
+ }
+ }
+
+ /* well, we found something that looks like text... */
+ new = gst_caps_new ("text_type_find",
+ "text/plain",
+ NULL);
+ }
+
+ if (buf != NULL) {
+ gst_buffer_unref (buf);
}
- return gst_caps_new ("text_type_find", "text/plain", NULL);
+ return new;
}