summaryrefslogtreecommitdiff
path: root/ext/audiofile
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/audiofile
parente58373a8b65fdcddd8a253f4b0ee2253e2af7042 (diff)
downloadgstreamer-plugins-bad-377610829307e73ef6f63e8e21b6ac1ce86135f1.tar.gz
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/audiofile')
-rw-r--r--ext/audiofile/Makefile.am2
-rw-r--r--ext/audiofile/gstaf.c3
-rw-r--r--ext/audiofile/gstaftypes.c73
3 files changed, 34 insertions, 44 deletions
diff --git a/ext/audiofile/Makefile.am b/ext/audiofile/Makefile.am
index cdca46d17..821f0e0d3 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 cec38f1eb..c3eb2bcff 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 26832d760..befe141b8 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