Commit 5bb80c9f authored by Benjamin Otte's avatar Benjamin Otte

merge TYPEFIND branch. Major changes:

Original commit message from CVS:
merge TYPEFIND branch. Major changes:
- totally reworked type(find) system
- all typefind functions are in gst/typefind now
- more typefind functions then before
- some plugins might fail to compile now because I don't have them installed and they
a) require bytestream or
b) haven't had their typefind fixed.
Please fix those plugins and put the typefind functions into gst/typefind if they don't have dependencies
parent 680f08e3
......@@ -264,10 +264,10 @@ GST_PLUGINS_ALL="\
cutter debug deinterlace effectv festival \
filter flx goom id3 intfloat law level median mixmatrix \
mpeg1sys mpeg1videoparse mpeg2enc mpeg2sub \
mpegaudio mpegaudioparse mpegstream mpegtypes \
mpegaudio mpegaudioparse mpegstream \
monoscope oneton overlay passthrough playondemand qtdemux \
realmedia rtp rtjpeg silence sine smooth smpte \
spectrum speed stereo synaesthesia tcp udp vbidec \
spectrum speed stereo synaesthesia tcp typefind udp vbidec \
videocrop videodrop videofilter videoflip videoscale \
videotestsrc volenv volume wavenc wavparse y4m"
......@@ -1193,7 +1193,6 @@ gst/mpeg2sub/Makefile
gst/mpegaudio/Makefile
gst/mpegaudioparse/Makefile
gst/mpegstream/Makefile
gst/mpegtypes/Makefile
gst/modplug/Makefile
gst/modplug/libmodplug/Makefile
gst/monoscope/Makefile
......@@ -1214,6 +1213,7 @@ gst/speed/Makefile
gst/stereo/Makefile
gst/synaesthesia/Makefile
gst/tcp/Makefile
gst/typefind/Makefile
gst/udp/Makefile
gst/vbidec/Makefile
gst/videocrop/Makefile
......
......@@ -25,6 +25,9 @@
static gboolean
plugin_init (GModule *module, GstPlugin *plugin)
{
if (!gst_library_load ("gstbytestream"))
return FALSE;
gst_afsink_plugin_init (module, plugin);
gst_afsrc_plugin_init (module, plugin);
gst_afparse_plugin_init (module, plugin);
......
......@@ -27,7 +27,7 @@
#include <config.h>
#include <gst/gst.h>
#include <gst/gstbytestream.h>
#include <gst/bytestream.h>
#include <audiofile.h> /* what else are we to do */
#include <af_vfs.h>
......
......@@ -21,7 +21,7 @@
#include <gst/gst.h>
#include <tremor/ivorbiscodec.h>
#include <tremor/ivorbisfile.h>
#include <gst/gstbytestream.h>
#include <gst/bytestream.h>
extern GType ivorbisfile_get_type(void);
......@@ -104,6 +104,9 @@ plugin_init (GModule *module, GstPlugin *plugin)
GstTypeFactory *type;
GstCaps *raw_caps, *vorbis_caps, *raw_caps2;
if (!gst_library_load ("gstbytestream"))
return FALSE;
gst_plugin_set_longname (plugin, "The OGG Vorbis Codec");
raw_caps = raw_caps_factory ();
......
......@@ -24,7 +24,7 @@
#include <gst/gst.h>
#include <tremor/ivorbiscodec.h>
#include <tremor/ivorbisfile.h>
#include <gst/gstbytestream.h>
#include <gst/bytestream.h>
#define GST_TYPE_IVORBISFILE \
(ivorbisfile_get_type())
......
......@@ -22,7 +22,7 @@
#include <jack/jack.h>
#include <gst/gst.h>
#include <gst/gstbytestream.h>
#include <gst/bytestream.h>
//#define JACK_DEBUG(str, a...) g_message (str, ##a)
#define JACK_DEBUG(str, a...)
......
......@@ -26,7 +26,7 @@
#include <config.h>
#include <gst/gst.h>
#include <gst/gstbytestream.h>
#include <gst/bytestream.h>
#include "ladspa.h"
......
......@@ -578,8 +578,8 @@ plugin_init (GModule *module, GstPlugin *plugin)
GstElementFactory *factory;
/* this filter needs the bytestream package */
/* if (!gst_library_load ("gstbytestream"))
return FALSE;*/
if (!gst_library_load ("gstbytestream"))
return FALSE;
/* create an elementfactory for the avi_demux element */
factory = gst_element_factory_new ("mplex",GST_TYPE_MPLEX,
......
......@@ -26,7 +26,7 @@
#include <stdlib.h>
#include <gst/gst.h>
#include <gst/gstbytestream.h>
#include <gst/bytestream.h>
#include "outputstream.hh"
#include "bits.hh"
......
......@@ -626,34 +626,10 @@ gst_swfdec_get_property (GObject *object, guint prop_id, GValue *value, GParamSp
}
}
static GstCaps *
swf_type_find(GstByteStream *bs, gpointer private)
{
GstBuffer *buf;
gchar *data;
gst_bytestream_peek (bs, &buf, 4);
data = GST_BUFFER_DATA(buf);
if (GST_BUFFER_SIZE (buf) < 4)
return NULL;
if((data[0] != 'F' && data[0] != 'C') ||
data[1] != 'W' || data[2] != 'S')return NULL;
return gst_caps_new("swf_type_find","application/x-shockwave-flash",
NULL);
}
static GstTypeDefinition swftype_definition =
{ "swfdecode/x-shockwave-flash", "application/x-shockwave-flash",
".swf .swfl", swf_type_find };
static gboolean
plugin_init (GModule *module, GstPlugin *plugin)
{
GstElementFactory *factory;
GstTypeFactory *type;
/* create an elementfactory for the swfdec element */
factory = gst_element_factory_new("swfdec",GST_TYPE_SWFDEC,
......@@ -670,9 +646,6 @@ plugin_init (GModule *module, GstPlugin *plugin)
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
type = gst_type_factory_new(&swftype_definition);
gst_plugin_add_feature(plugin, GST_PLUGIN_FEATURE(type));
return TRUE;
}
......
D2003.10.26.10.00.00
2003-10-26 10:00 GMT
......@@ -50,16 +50,6 @@ static GstElementDetails gst_cdxa_parse_details = {
"(C) 2002",
};
static GstCaps* cdxa_type_find (GstByteStream *bs, gpointer private);
/* typefactory for 'cdxa' */
static GstTypeDefinition cdxadefinition = {
"cdxaparse_video",
"video/x-cdxa",
".dat",
cdxa_type_find,
};
/* CDXAParse signals and args */
enum {
/* FILL ME */
......@@ -158,33 +148,6 @@ gst_cdxa_parse_init (GstCDXAParse *cdxa_parse)
}
static GstCaps*
cdxa_type_find (GstByteStream *bs,
gpointer private)
{
GstBuffer *buf = NULL;
GstCaps *new = NULL;
GST_DEBUG ("cdxa_parse: typefind");
if (gst_bytestream_peek (bs, &buf, 12) == 12) {
guint32 head1 = GUINT32_FROM_LE (((guint32 *) GST_BUFFER_DATA (buf))[0]),
head2 = GUINT32_FROM_LE (((guint32 *) GST_BUFFER_DATA (buf))[2]);
if (head1 == GST_RIFF_TAG_RIFF && head2 == GST_RIFF_RIFF_CDXA) {
new = GST_CAPS_NEW ("cdxa_type_find",
"video/x-cdxa",
NULL);
}
}
if (buf != NULL) {
gst_buffer_unref (buf);
}
return new;
}
static gboolean
gst_cdxa_parse_handle_event (GstCDXAParse *cdxa_parse)
{
......@@ -343,7 +306,9 @@ static gboolean
plugin_init (GModule *module, GstPlugin *plugin)
{
GstElementFactory *factory;
GstTypeFactory *type;
if (!gst_library_load ("gstbytestream"))
return FALSE;
/* create an elementfactory for the cdxa_parse element */
factory = gst_element_factory_new ("cdxaparse", GST_TYPE_CDXA_PARSE,
......@@ -353,9 +318,6 @@ plugin_init (GModule *module, GstPlugin *plugin)
gst_element_factory_add_pad_template (factory, GST_PAD_TEMPLATE_GET (src_templ));
gst_element_factory_add_pad_template (factory, GST_PAD_TEMPLATE_GET (sink_templ));
type = gst_type_factory_new (&cdxadefinition);
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (type));
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
return TRUE;
......
......@@ -24,7 +24,7 @@
#include <config.h>
#include <gst/gst.h>
#include <gst/gstbytestream.h>
#include <gst/bytestream.h>
#ifdef __cplusplus
extern "C" {
......
......@@ -80,8 +80,6 @@
static void gst_festival_class_init (GstFestivalClass *klass);
static void gst_festival_init (GstFestival *festival);
static GstCaps* text_type_find (GstByteStream *bs, gpointer private);
static void gst_festival_chain (GstPad *pad, GstData *_data);
static GstElementStateReturn
gst_festival_change_state (GstElement *element);
......@@ -123,17 +121,6 @@ GST_PAD_TEMPLATE_FACTORY (src_template_factory,
)
)
/* typefactory for 'wav' */
static GstTypeDefinition
textdefinition =
{
"festival_text/plain",
"text/plain",
".txt",
text_type_find,
};
/* Festival signals and args */
enum {
/* FILL ME */
......@@ -197,40 +184,6 @@ gst_festival_init (GstFestival *festival)
festival->info = festival_default_info();
}
static GstCaps*
text_type_find (GstByteStream *bs, gpointer private)
{
GstBuffer *buf = NULL;
GstCaps *new = NULL;
#define TEXT_SIZE 32
/* 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') {
goto out;
}
}
/* well, we found something that looks like text... */
new = gst_caps_new ("text_type_find",
"text/plain",
NULL);
}
out:
if (buf != NULL) {
gst_buffer_unref (buf);
}
return new;
}
static void
gst_festival_chain (GstPad *pad, GstData *_data)
{
......@@ -484,7 +437,6 @@ static gboolean
plugin_init (GModule *module, GstPlugin *plugin)
{
GstElementFactory *factory;
GstTypeFactory *type;
/* create an elementfactory for the festival element */
factory = gst_element_factory_new ("festival", GST_TYPE_FESTIVAL,
......@@ -495,9 +447,7 @@ plugin_init (GModule *module, GstPlugin *plugin)
gst_element_factory_add_pad_template (factory, GST_PAD_TEMPLATE_GET (sink_template_factory));
gst_element_factory_add_pad_template (factory, GST_PAD_TEMPLATE_GET (src_template_factory));
type = gst_type_factory_new (&textdefinition);
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (type));
return TRUE;
}
......
......@@ -28,8 +28,6 @@
#define JIFFIE (GST_SECOND/70)
static GstCaps* flxdec_type_find (GstByteStream *bs, gpointer private);
/* flx element information */
static GstElementDetails flxdec_details = {
"FLX Decoder",
......@@ -41,13 +39,6 @@ static GstElementDetails flxdec_details = {
"(C) 2001",
};
static GstTypeDefinition flxdec_definition = {
"flxdec_video/fli",
"video/fli",
".flc .fli",
flxdec_type_find,
};
/* Flx signals and args */
enum {
/* FILL ME */
......@@ -112,37 +103,6 @@ static void flx_decode_delta_flc (GstFlxDec *, guchar *, guchar *);
static GstElementClass *parent_class = NULL;
static GstCaps*
flxdec_type_find (GstByteStream *bs, gpointer private)
{
GstBuffer *buf = NULL;
GstCaps *new = NULL;
if (gst_bytestream_peek (bs, &buf, 134) == 134) {
guint8 *data = GST_BUFFER_DATA (buf);
/* check magic */
if ((data[4] == 0x11 || data[4] == 0x12 ||
data[4] == 0x30 || data[4] == 0x44) &&
data[5] == 0xaf) {
/* check the frame type of the first frame */
if ((data[132] == 0x00 || data[132] == 0xfa) && data[133] == 0xf1) {
GST_DEBUG ("GstFlxDec: found supported flx format");
new = gst_caps_new ("flxdec_type_find",
"video/x-fli",
NULL);
}
}
}
if (buf != NULL) {
gst_buffer_unref (buf);
}
return new;
}
GType
gst_flxdec_get_type(void)
{
......@@ -688,7 +648,9 @@ static gboolean
plugin_init (GModule *module, GstPlugin *plugin)
{
GstElementFactory *factory;
GstTypeFactory *type;
if (!gst_library_load ("gstbytestream"))
return FALSE;
factory = gst_element_factory_new("flxdec", GST_TYPE_FLXDEC, &flxdec_details);
g_return_val_if_fail(factory != NULL, FALSE);
......@@ -699,9 +661,6 @@ plugin_init (GModule *module, GstPlugin *plugin)
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
type = gst_type_factory_new (&flxdec_definition);
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (type));
return TRUE;
}
......
......@@ -23,7 +23,7 @@
#include <gst/gst.h>
#include "flx_color.h"
#include <gst/gstbytestream.h>
#include <gst/bytestream.h>
#ifdef __cplusplus
......
......@@ -22,7 +22,7 @@
#endif
#include <config.h>
#include <gst/gst.h>
#include <gst/gstbytestream.h>
#include <gst/bytestream.h>
#include <gst/audio/audio.h>
#include <string.h>
......@@ -500,6 +500,9 @@ plugin_init (GModule *module, GstPlugin *plugin)
{
GstElementFactory *factory;
if (!gst_library_load ("gstbytestream"))
return FALSE;
factory = gst_element_factory_new ("mixmatrix", GST_TYPE_MIXMATRIX,
&mixmatrix_details);
g_return_val_if_fail (factory != NULL, FALSE);
......
......@@ -2,9 +2,9 @@ SUBDIRS=libmodplug .
plugin_LTLIBRARIES = libgstmodplug.la
libgstmodplug_la_SOURCES = modplug_types.cc gstmodplug.cc
libgstmodplug_la_SOURCES = gstmodplug.cc
libgstmodplug_la_CXXFLAGS = $(GST_CFLAGS)
libgstmodplug_la_LIBADD = $(top_builddir)/gst/modplug/libmodplug/libmodplug.la
libgstmodplug_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
noinst_HEADERS = gstmodplug.h modplug_types.h
noinst_HEADERS = gstmodplug.h
......@@ -129,50 +129,6 @@ static GstElementStateReturn
static GstElementClass *parent_class = NULL;
static GstCaps*
modplug_type_find (GstByteStream *bs, gpointer priv)
{
GstBuffer *buf = NULL;
GstCaps *newc = NULL;
if (gst_bytestream_peek (bs, &buf, 75) == 75) {
if (MOD_CheckType (buf) ||
Mod_669_CheckType (buf) ||
Amf_CheckType (buf) ||
Dsm_CheckType (buf) ||
Fam_CheckType (buf) ||
Gdm_CheckType (buf) ||
Imf_CheckType (buf) ||
It_CheckType (buf) ||
M15_CheckType (buf) ||
#if 0
Med_CheckType (buf) || /* FIXME */
#endif
Mtm_CheckType (buf) ||
Okt_CheckType (buf) ||
S3m_CheckType (buf) ||
Xm_CheckType (buf)) {
newc = GST_CAPS_NEW ("modplug_type_find",
"audio/x-mod",
NULL);
}
}
if (buf != NULL) {
gst_buffer_unref (buf);
}
return newc;
}
static GstTypeDefinition modplug_definitions[] = {
{ "modplug_audio/mod", "audio/x-mod",
".mod .sam .med .stm .mtm .669 .ult .far .amf "
".dsm .imf .gdm .stx .okt .xm .it .s3m",
modplug_type_find },
{ NULL, NULL, NULL, NULL }
};
GType
gst_modplug_get_type(void) {
static GType modplug_type = 0;
......@@ -858,12 +814,12 @@ gst_modplug_get_property (GObject *object, guint id, GValue *value, GParamSpec *
static gboolean
plugin_init (GModule *module, GstPlugin *plugin)
{
GstElementFactory *factory;
guint i;
GstElementFactory *factory;
guint i;
/* this filter needs the bytestream package */
/* if (!gst_library_load ("gstbytestream"))
return FALSE;*/
if (!gst_library_load ("gstbytestream"))
return FALSE;
factory = gst_element_factory_new ("modplug", GST_TYPE_MODPLUG, &modplug_details);
g_return_val_if_fail (factory != NULL, FALSE);
......@@ -874,13 +830,6 @@ plugin_init (GModule *module, GstPlugin *plugin)
gst_element_factory_add_pad_template (factory, GST_PAD_TEMPLATE_GET (modplug_src_template_factory));
i = 0;
while (modplug_definitions[i].name) {
GstTypeFactory *type;
type = gst_type_factory_new (&modplug_definitions[i]);
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (type));
i++;
}
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
......
......@@ -28,10 +28,8 @@ extern "C" {
#endif /* __cplusplus */
#include <gst/gst.h>
#include <gst/gstbytestream.h>
#include <gst/bytestream.h>
#include "modplug_types.h"
#define GST_TYPE_MODPLUG \
(gst_modplug_get_type())
......
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <gst/gst.h>
#include <string.h> /* memcmp */
#include <ctype.h> /* isdigit */
#include "modplug_types.h"
#define MODULEHEADERSIZE 0x438
gboolean MOD_CheckType( GstBuffer *buf )
{
guint8 *data;
data = GST_BUFFER_DATA( buf ) + MODULEHEADERSIZE;
/* Protracker and variants */
if (( ! memcmp( data, "M.K.", 4 )) || ( ! memcmp( data, "M!K!", 4 )))
return TRUE;
/* Star Tracker */
if ((( ! memcmp( data, "FLT", 3 )) || ( ! memcmp( data, "EXO", 3 ))) && ( isdigit( data[3] )))
return TRUE;
/* Oktalyzer (Amiga) */
if (! memcmp( data, "OKTA", 4 ))
return TRUE;
/* Oktalyser (Atari) */
if ( ! memcmp( data, "CD81", 4 ))
return TRUE;
/* Fasttracker */
if (( ! memcmp( data + 1, "CHN", 3 )) && ( isdigit( data[0] )))
return TRUE;
/* Fasttracker or Taketracker */
if ((( ! memcmp( data + 2, "CH", 2 )) || ( ! memcmp( data + 2, "CN", 2 ))) && ( isdigit( data[0] )) && ( isdigit( data[1] )))
return TRUE;
return FALSE;
}
gboolean Mod_669_CheckType( GstBuffer *buf )
{
guint8 *data;
data = GST_BUFFER_DATA( buf );
if( ! memcmp( data, "if", 2 ) || ! memcmp( data, "JN", 2 ))
return TRUE;
return FALSE;
}
gboolean Amf_CheckType( GstBuffer *buf )
{
guint8 *data;
data = GST_BUFFER_DATA( buf );
if( memcmp( data, "AMF", 3) )
return FALSE;
data = GST_BUFFER_DATA( buf ) + 3;
if (( (gint)*data >= 10 ) && ( (gint)*data <= 14 ))
return TRUE;
return FALSE;
}
gboolean Dsm_CheckType( GstBuffer *buf )
{
guint8 *data;
data = GST_BUFFER_DATA( buf );
if( ! memcmp( data, "RIFF", 4 ) && ! memcmp( data + 8, "DSMF", 4 ))
return TRUE;
return FALSE;
}
gboolean Fam_CheckType( GstBuffer *buf )
{
guint8 *data;