mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-28 11:10:37 +00:00
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
This commit is contained in:
parent
e58373a8b6
commit
3776108293
6 changed files with 35 additions and 116 deletions
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -47,14 +47,7 @@ static GstElementDetails mpeg2subt_details = {
|
|||
"Wim Taymans <wim.taymans@chello.be>",
|
||||
"(C) 2000",
|
||||
};
|
||||
/* defined but not used
|
||||
static GstTypeDefinition mpeg2subtitledefinition = {
|
||||
"mpeg2subt_video/mpeg2ubtitle",
|
||||
"video/mpeg2subtitle",
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
*/
|
||||
|
||||
/* GstMpeg2Subt signals and args */
|
||||
enum {
|
||||
/* FILL ME */
|
||||
|
|
Loading…
Reference in a new issue