summaryrefslogtreecommitdiffstats
path: root/ext
diff options
context:
space:
mode:
authorDavid Schleef <ds@schleef.org>2003-10-29 05:09:40 +0000
committerDavid Schleef <ds@schleef.org>2003-10-29 05:09:40 +0000
commit377610829307e73ef6f63e8e21b6ac1ce86135f1 (patch)
tree6640e7254dc48c3690684acbb7c5c048a347cef4 /ext
parente58373a8b65fdcddd8a253f4b0ee2253e2af7042 (diff)
downloadgst-plugins-bad-377610829307e73ef6f63e8e21b6ac1ce86135f1.tar.gz
gst-plugins-bad-377610829307e73ef6f63e8e21b6ac1ce86135f1.tar.bz2
gst-plugins-bad-377610829307e73ef6f63e8e21b6ac1ce86135f1.zip
Move a few typefind functions to gst/typefind, remove all old typefinding code from bitrotten plugins
Original commit message from CVS: Move a few typefind functions to gst/typefind, remove all old typefinding code from bitrotten plugins
Diffstat (limited to 'ext')
-rw-r--r--ext/audiofile/Makefile.am2
-rw-r--r--ext/audiofile/gstaf.c3
-rw-r--r--ext/audiofile/gstaftypes.c73
-rw-r--r--ext/ivorbis/vorbis.c30
-rw-r--r--ext/tarkin/gsttarkin.c34
5 files changed, 34 insertions, 108 deletions
diff --git a/ext/audiofile/Makefile.am b/ext/audiofile/Makefile.am
index cdca46d1..821f0e0d 100644
--- a/ext/audiofile/Makefile.am
+++ b/ext/audiofile/Makefile.am
@@ -1,7 +1,7 @@
plugin_LTLIBRARIES = libgstaudiofile.la
-libgstaudiofile_la_SOURCES = gstaf.c gstafsink.c gstafsrc.c gstafparse.c
+libgstaudiofile_la_SOURCES = gstaf.c gstafsink.c gstafsrc.c gstafparse.c gstaftypes.c
libgstaudiofile_la_CFLAGS = $(GST_CFLAGS) $(AUDIOFILE_CFLAGS)
libgstaudiofile_la_LIBADD = $(AUDIOFILE_LIBS)
libgstaudiofile_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
diff --git a/ext/audiofile/gstaf.c b/ext/audiofile/gstaf.c
index cec38f1e..c3eb2bcf 100644
--- a/ext/audiofile/gstaf.c
+++ b/ext/audiofile/gstaf.c
@@ -22,6 +22,8 @@
#include "gstafsink.h"
#include "gstafparse.h"
+gboolean gst_aftypes_plugin_init (GModule *module, GstPlugin *plugin);
+
static gboolean
plugin_init (GModule *module, GstPlugin *plugin)
{
@@ -31,6 +33,7 @@ plugin_init (GModule *module, GstPlugin *plugin)
gst_afsink_plugin_init (module, plugin);
gst_afsrc_plugin_init (module, plugin);
gst_afparse_plugin_init (module, plugin);
+ gst_aftypes_plugin_init (module, plugin);
return TRUE;
}
diff --git a/ext/audiofile/gstaftypes.c b/ext/audiofile/gstaftypes.c
index 26832d76..befe141b 100644
--- a/ext/audiofile/gstaftypes.c
+++ b/ext/audiofile/gstaftypes.c
@@ -33,34 +33,33 @@ static void gst_aftypes_vf_destroy(AFvirtualfile *vfile);
static long gst_aftypes_vf_seek (AFvirtualfile *vfile, long offset, int is_relative);
static long gst_aftypes_vf_tell (AFvirtualfile *vfile);
-static GstCaps* gst_aftypes_type_find(GstBuffer *buf, gpointer private);
-
-static GstTypeDefinition aftype_definitions[] = {
- { "aftypes audio/x-aiff", "audio/x-aiff", ".aiff .aif .aifc", gst_aftypes_type_find },
- { "aftypes audio/x-wav", "audio/x-wav", ".wav", gst_aftypes_type_find },
- { "aftypes audio/basic", "audio/basic", ".au .snd", gst_aftypes_type_find },
- { NULL, NULL, NULL, NULL },
-};
+static void gst_aftypes_type_find(GstTypeFind *tf, gpointer private);
typedef struct _GstAFTypesBuffer GstAFTypesBuffer;
struct _GstAFTypesBuffer {
- GstBuffer *buffer;
+ guint8 *data;
+ int length;
long offset;
};
-static GstCaps*
-gst_aftypes_type_find(GstBuffer *buf, gpointer private)
+#define GST_AUDIOFILE_TYPE_FIND_SIZE 4096
+#define AF_CAPS(type) gst_caps_new ("audiofile_type_find", type, NULL)
+static void
+gst_aftypes_type_find(GstTypeFind *tf, gpointer private)
{
-
- GstAFTypesBuffer *buffer_wrap = g_new0(GstAFTypesBuffer, 1);
+ GstAFTypesBuffer *buffer_wrap;
+ guint8 *data;
AFvirtualfile *vfile;
AFfilehandle file;
int file_format, format_version;
gchar *type;
- GST_DEBUG("calling gst_aftypes_type_find");
+ data = gst_type_find_peek (tf, 0, GST_AUDIOFILE_TYPE_FIND_SIZE);
+ if (data == NULL) return;
- buffer_wrap->buffer = buf;
+ buffer_wrap = g_new0(GstAFTypesBuffer, 1);
+ buffer_wrap->data = data;
+ buffer_wrap->length = GST_AUDIOFILE_TYPE_FIND_SIZE;
buffer_wrap->offset = 0;
vfile = af_virtual_file_new();
@@ -76,12 +75,13 @@ gst_aftypes_type_find(GstBuffer *buf, gpointer private)
file_format = afGetFileFormat (file, &format_version);
afCloseFile (file);
- GST_DEBUG("file format: %d", file_format);
+ //GST_DEBUG("file format: %d", file_format);
/* reject raw data, just in case it is some other format */
if (file_format == AF_FILE_UNKNOWN ||
file_format == AF_FILE_RAWDATA){
- return NULL;
+ g_free (buffer_wrap);
+ return;
}
switch (file_format){
case AF_FILE_AIFF:
@@ -94,49 +94,36 @@ gst_aftypes_type_find(GstBuffer *buf, gpointer private)
case AF_FILE_NEXTSND:
type = "audio/basic";
break;
+ case AF_FILE_BICSF:
default:
type=NULL;
break;
}
if (type != NULL){
- return gst_caps_new ("audiofile_type_find", type, NULL);
+ gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, AF_CAPS(type));
}
-
- return NULL;
}
-static gboolean
-plugin_init (GModule *module, GstPlugin *plugin)
+gboolean
+gst_aftypes_plugin_init (GModule *module, GstPlugin *plugin)
{
- gint i=0;
+ static gchar * af_exts[] = { "aiff", "aif", "aifc", "wav", "au", "snd", NULL };
- while (aftype_definitions[i].name) {
- GstTypeFactory *type;
-
- type = gst_type_factory_new (&aftype_definitions[i]);
- gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (type));
- i++;
- }
-
+ gst_type_find_factory_register (plugin, "audio/x-mod",
+ GST_ELEMENT_RANK_MARGINAL, gst_aftypes_type_find, af_exts,
+ GST_CAPS_ANY, NULL);
+
return TRUE;
}
-GstPluginDesc plugin_desc = {
- GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "aftypes",
- plugin_init
-};
-
-
static ssize_t
gst_aftypes_vf_read (AFvirtualfile *vfile, void *data, size_t nbytes)
{
GstAFTypesBuffer *bwrap = (GstAFTypesBuffer*)vfile->closure;
- long bufsize = GST_BUFFER_SIZE(bwrap->buffer);
- guchar *bytes = GST_BUFFER_DATA(bwrap->buffer);
+ long bufsize = bwrap->length;
+ guint8 *bytes = bwrap->data;
if (bwrap->offset + nbytes > bufsize){
nbytes = bufsize;
@@ -155,7 +142,7 @@ static long
gst_aftypes_vf_seek (AFvirtualfile *vfile, long offset, int is_relative)
{
GstAFTypesBuffer *bwrap = (GstAFTypesBuffer*)vfile->closure;
- long bufsize = GST_BUFFER_SIZE(bwrap->buffer);
+ long bufsize = bwrap->length;
g_print("request seek to: %ld\n", offset);
if (!is_relative){
@@ -180,7 +167,7 @@ static long
gst_aftypes_vf_length (AFvirtualfile *vfile)
{
GstAFTypesBuffer *bwrap = (GstAFTypesBuffer*)vfile->closure;
- return GST_BUFFER_SIZE(bwrap->buffer);
+ return bwrap->length;
}
static ssize_t
diff --git a/ext/ivorbis/vorbis.c b/ext/ivorbis/vorbis.c
index 34536edc..b23bcbea 100644
--- a/ext/ivorbis/vorbis.c
+++ b/ext/ivorbis/vorbis.c
@@ -27,8 +27,6 @@ extern GType ivorbisfile_get_type(void);
extern GstElementDetails ivorbisfile_details;
-static GstCaps* vorbis_type_find (GstBuffer *buf, gpointer private);
-
GstPadTemplate *gst_vorbisdec_src_template, *gst_vorbisdec_sink_template;
static GstCaps*
@@ -73,35 +71,10 @@ raw_caps2_factory (void)
NULL));
}
-static GstTypeDefinition vorbisdefinition = {
- "tremor_audio/x-ogg",
- "application/ogg",
- ".ogg",
- vorbis_type_find,
-};
-
-static GstCaps*
-vorbis_type_find (GstBuffer *buf, gpointer private)
-{
- guint32 head;
-
- if (GST_BUFFER_SIZE (buf) < 4)
- return NULL;
-
- head = GUINT32_FROM_BE (*((guint32 *)GST_BUFFER_DATA (buf)));
-
- if (head != 0x4F676753)
- return NULL;
-
- return gst_caps_new ("vorbis_type_find", "application/ogg", NULL);
-}
-
-
static gboolean
plugin_init (GModule *module, GstPlugin *plugin)
{
GstElementFactory *file;
- GstTypeFactory *type;
GstCaps *raw_caps, *vorbis_caps, *raw_caps2;
if (!gst_library_load ("gstbytestream"))
@@ -135,9 +108,6 @@ plugin_init (GModule *module, GstPlugin *plugin)
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (file));
- type = gst_type_factory_new (&vorbisdefinition);
- gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (type));
-
return TRUE;
}
diff --git a/ext/tarkin/gsttarkin.c b/ext/tarkin/gsttarkin.c
index 6e9abbc1..04270231 100644
--- a/ext/tarkin/gsttarkin.c
+++ b/ext/tarkin/gsttarkin.c
@@ -24,8 +24,6 @@
extern GstElementDetails tarkinenc_details;
extern GstElementDetails tarkindec_details;
-static GstCaps* tarkin_type_find (GstBuffer *buf, gpointer private);
-
GstPadTemplate *enc_src_template, *enc_sink_template;
GstPadTemplate *dec_src_template, *dec_sink_template;
@@ -58,39 +56,10 @@ raw_caps_factory (void)
);
}
-static GstTypeDefinition tarkindefinition =
-{
- "tarkin_video/x-ogg",
- "application/ogg",
- ".ogg",
- tarkin_type_find,
-};
-
-static GstCaps*
-tarkin_type_find (GstBuffer *buf, gpointer private)
-{
- guint32 head;
-
- if (GST_BUFFER_SIZE (buf) < 4)
- return NULL;
-
- /* FIXME */
- return NULL;
-
- head = GUINT32_FROM_BE (*((guint32 *)GST_BUFFER_DATA (buf)));
-
- if (head != 0x4F676753)
- return NULL;
-
- return gst_caps_new ("tarkin_type_find", "application/ogg", NULL);
-}
-
-
static gboolean
plugin_init (GModule *module, GstPlugin *plugin)
{
GstElementFactory *enc, *dec;
- GstTypeFactory *type;
GstCaps *raw_caps, *tarkin_caps;
gst_plugin_set_longname (plugin, "The OGG Tarkin Codec");
@@ -147,9 +116,6 @@ plugin_init (GModule *module, GstPlugin *plugin)
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (dec));
- type = gst_type_factory_new (&tarkindefinition);
- gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (type));
-
return TRUE;
}