Original commit message from CVS:
Bla
This commit is contained in:
Ronald S. Bultje 2003-11-02 13:12:14 +00:00
parent 815423e05e
commit 28ba793266
6 changed files with 241 additions and 234 deletions

View file

@ -40,7 +40,7 @@ extern gboolean gst_ffmpegcsp_register (GstPlugin *plugin);
extern URLProtocol gstreamer_protocol;
static gboolean
plugin_init (GModule *module, GstPlugin *plugin)
plugin_init (GstPlugin *plugin)
{
if (!gst_library_load ("gstbytestream"))
return FALSE;
@ -61,9 +61,15 @@ plugin_init (GModule *module, GstPlugin *plugin)
return TRUE;
}
GstPluginDesc plugin_desc = {
GST_PLUGIN_DEFINE (
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"ffmpeg",
plugin_init
};
"All FFMPEG codecs",
plugin_init,
FFMPEG_VERSION,
"LGPL",
"(c) 2003 The FFMPEG team",
"FFMpeg",
"http://ffmpeg.sourceforge.net/"
)

View file

@ -71,12 +71,8 @@ struct _GstFFMpegCspClass {
static GstElementDetails ffmpegcsp_details = {
"FFMPEG Colorspace converter",
"Filter/Effect",
"LGPL",
"Converts video from one colorspace to another",
VERSION,
"The FFMPEG crew, "
"Ronald Bultje <rbultje@ronald.bitfreak.net>",
"(C) 2003",
};
@ -92,6 +88,7 @@ enum {
static GType gst_ffmpegcsp_get_type (void);
static void gst_ffmpegcsp_base_init (GstFFMpegCspClass *klass);
static void gst_ffmpegcsp_class_init (GstFFMpegCspClass *klass);
static void gst_ffmpegcsp_init (GstFFMpegCsp *space);
@ -312,7 +309,7 @@ gst_ffmpegcsp_get_type (void)
if (!ffmpegcsp_type) {
static const GTypeInfo ffmpegcsp_info = {
sizeof (GstFFMpegCspClass),
NULL,
(GBaseInitFunc) gst_ffmpegcsp_base_init,
NULL,
(GClassInitFunc) gst_ffmpegcsp_class_init,
NULL,
@ -330,6 +327,16 @@ gst_ffmpegcsp_get_type (void)
return ffmpegcsp_type;
}
static void
gst_ffmpegcsp_base_init (GstFFMpegCspClass *klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class, srctempl);
gst_element_class_add_pad_template (element_class, sinktempl);
gst_element_class_set_details (element_class, &ffmpegcsp_details);
}
static void
gst_ffmpegcsp_class_init (GstFFMpegCspClass *klass)
{
@ -490,12 +497,8 @@ gst_ffmpegcsp_get_property (GObject *object,
gboolean
gst_ffmpegcsp_register (GstPlugin *plugin)
{
GstElementFactory *factory;
GstCaps *caps;
factory = gst_element_factory_new ("ffcolorspace", GST_TYPE_FFMPEGCSP,
&ffmpegcsp_details);
g_return_val_if_fail (factory != NULL, FALSE);
GstPadTemplate *srctempl, *sinktempl;
/* template caps */
caps = gst_ffmpeg_codectype_to_caps (CODEC_TYPE_VIDEO, NULL);
@ -511,10 +514,6 @@ gst_ffmpegcsp_register (GstPlugin *plugin)
GST_PAD_ALWAYS,
caps, NULL);
gst_element_factory_add_pad_template (factory, srctempl);
gst_element_factory_add_pad_template (factory, sinktempl);
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
return TRUE;
return gst_element_register (plugin, "ffcolorspace",
GST_RANK_NONE, GST_TYPE_FFMPEGCSP);
}

View file

@ -55,10 +55,12 @@ struct _GstFFMpegDecClass {
GstPadTemplate *srctempl, *sinktempl;
};
typedef struct {
typedef struct _GstFFMpegDecClassParams GstFFMpegDecClassParams;
struct _GstFFMpegDecClassParams {
AVCodec *in_plugin;
GstPadTemplate *srctempl, *sinktempl;
} GstFFMpegDecClassParams;
GstCaps *srccaps, *sinkcaps;
};
#define GST_TYPE_FFMPEGDEC \
(gst_ffmpegdec_get_type())
@ -84,6 +86,7 @@ enum {
static GHashTable *global_plugins;
/* A number of functon prototypes are given so we can refer to them later. */
static void gst_ffmpegdec_base_init (GstFFMpegDecClass *klass);
static void gst_ffmpegdec_class_init (GstFFMpegDecClass *klass);
static void gst_ffmpegdec_init (GstFFMpegDec *ffmpegdec);
static void gst_ffmpegdec_dispose (GObject *object);
@ -108,25 +111,56 @@ static GstElementClass *parent_class = NULL;
/*static guint gst_ffmpegdec_signals[LAST_SIGNAL] = { 0 }; */
static void
gst_ffmpegdec_base_init (GstFFMpegDecClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
GstFFMpegDecClassParams *params;
GstElementDetails *details;
GstPadTemplate *sinktempl, *srctempl;
params = g_hash_table_lookup (global_plugins,
GINT_TO_POINTER (G_OBJECT_CLASS_TYPE (gobject_class)));
/* construct the element details struct */
details = g_new0 (GstElementDetails, 1);
details->longname = g_strdup_printf("FFMPEG %s decoder",
params->in_plugin->name);
details->klass = g_strdup_printf("Codec/%s/Decoder",
(params->in_plugin->type == CODEC_TYPE_VIDEO) ?
"Video" : "Audio");
details->description = g_strdup_printf("FFMPEG %s decoder",
params->in_plugin->name);
details->author = g_strdup("Wim Taymans <wim.taymans@chello.be>\n"
"Ronald Bultje <rbultje@ronald.bitfreak.net>");
/* pad templates */
sinktempl = gst_pad_template_new ("sink", GST_PAD_SINK,
GST_PAD_ALWAYS, params->sinkcaps, NULL);
srctempl = gst_pad_template_new ("src", GST_PAD_SRC,
GST_PAD_ALWAYS, params->srccaps, NULL);
gst_element_class_add_pad_template (element_class, srctempl);
gst_element_class_add_pad_template (element_class, sinktempl);
gst_element_class_set_details (element_class, details);
klass->in_plugin = params->in_plugin;
klass->srctempl = srctempl;
klass->sinktempl = sinktempl;
}
static void
gst_ffmpegdec_class_init (GstFFMpegDecClass *klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
GstFFMpegDecClassParams *params;
gobject_class = (GObjectClass*)klass;
gstelement_class = (GstElementClass*)klass;
parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
params = g_hash_table_lookup (global_plugins,
GINT_TO_POINTER (G_OBJECT_CLASS_TYPE (gobject_class)));
klass->in_plugin = params->in_plugin;
klass->srctempl = params->srctempl;
klass->sinktempl = params->sinktempl;
gobject_class->dispose = gst_ffmpegdec_dispose;
gstelement_class->change_state = gst_ffmpegdec_change_state;
}
@ -411,10 +445,9 @@ gst_ffmpegdec_change_state (GstElement *element)
gboolean
gst_ffmpegdec_register (GstPlugin *plugin)
{
GstElementFactory *factory;
GTypeInfo typeinfo = {
sizeof(GstFFMpegDecClass),
NULL,
(GBaseInitFunc)gst_ffmpegdec_base_init,
NULL,
(GClassInitFunc)gst_ffmpegdec_class_init,
NULL,
@ -424,7 +457,6 @@ gst_ffmpegdec_register (GstPlugin *plugin)
(GInstanceInitFunc)gst_ffmpegdec_init,
};
GType type;
GstElementDetails *details;
AVCodec *in_plugin;
in_plugin = first_avcodec;
@ -432,10 +464,9 @@ gst_ffmpegdec_register (GstPlugin *plugin)
global_plugins = g_hash_table_new (NULL, NULL);
while (in_plugin) {
gchar *type_name;
GstPadTemplate *sinktempl, *srctempl;
GstCaps *sinkcaps, *srccaps;
GstFFMpegDecClassParams *params;
GstCaps *srccaps, *sinkcaps;
gchar *type_name;
/* no quasi-codecs, please */
if (in_plugin->id == CODEC_ID_RAWVIDEO ||
@ -464,50 +495,19 @@ gst_ffmpegdec_register (GstPlugin *plugin)
goto next;
}
/* create the gtk type now */
/* create the gtype now */
type = g_type_register_static(GST_TYPE_ELEMENT, type_name , &typeinfo, 0);
/* construct the element details struct */
details = g_new0 (GstElementDetails, 1);
details->longname = g_strdup_printf("FFMPEG %s decoder", in_plugin->name);
details->klass = g_strdup_printf("Codec/%s/Decoder",
(in_plugin->type == CODEC_TYPE_VIDEO) ?
"Video" : "Audio");
details->license = g_strdup("LGPL");
details->description = g_strdup_printf("FFMPEG %s decoder",
in_plugin->name);
details->version = g_strdup(VERSION);
details->author = g_strdup("The FFMPEG crew, "
"Wim Taymans <wim.taymans@chello.be>, "
"Ronald Bultje <rbultje@ronald.bitfreak.net>");
details->copyright = g_strdup("(c) 2001-2003");
/* register the plugin with gstreamer */
factory = gst_element_factory_new(type_name,type,details);
g_return_val_if_fail(factory != NULL, FALSE);
gst_element_factory_set_rank (factory, GST_ELEMENT_RANK_MARGINAL);
sinktempl = gst_pad_template_new ("sink", GST_PAD_SINK,
GST_PAD_ALWAYS, sinkcaps, NULL);
gst_element_factory_add_pad_template (factory, sinktempl);
srctempl = gst_pad_template_new ("src", GST_PAD_SRC,
GST_PAD_ALWAYS, srccaps, NULL);
gst_element_factory_add_pad_template (factory, srctempl);
if (!gst_element_register (plugin, type_name, GST_RANK_MARGINAL, type))
return FALSE;
params = g_new0 (GstFFMpegDecClassParams, 1);
params->in_plugin = in_plugin;
params->sinktempl = sinktempl;
params->srctempl = srctempl;
params->srccaps = srccaps;
params->sinkcaps = sinkcaps;
g_hash_table_insert (global_plugins,
GINT_TO_POINTER (type),
(gpointer) params);
/* The very last thing is to register the elementfactory with the plugin. */
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
next:
in_plugin = in_plugin->next;
}

View file

@ -51,9 +51,7 @@ struct _GstFFMpegDemux {
typedef struct _GstFFMpegDemuxClassParams {
AVInputFormat *in_plugin;
GstPadTemplate *sinktempl;
GstPadTemplate *videosrctempl;
GstPadTemplate *audiosrctempl;
GstCaps *sinkcaps, *videosrccaps, *audiosrccaps;
} GstFFMpegDemuxClassParams;
typedef struct _GstFFMpegDemuxClass GstFFMpegDemuxClass;
@ -92,6 +90,7 @@ static GHashTable *global_plugins;
/* A number of functon prototypes are given so we can refer to them later. */
static void gst_ffmpegdemux_class_init (GstFFMpegDemuxClass *klass);
static void gst_ffmpegdemux_base_init (GstFFMpegDemuxClass *klass);
static void gst_ffmpegdemux_init (GstFFMpegDemux *ffmpegdemux);
static void gst_ffmpegdemux_dispose (GObject *object);
@ -104,26 +103,64 @@ static GstElementClass *parent_class = NULL;
/*static guint gst_ffmpegdemux_signals[LAST_SIGNAL] = { 0 }; */
static void
gst_ffmpegdemux_base_init (GstFFMpegDemuxClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
GstFFMpegDemuxClassParams *params;
GstElementDetails *details;
GstPadTemplate *sinktempl, *audiosrctempl, *videosrctempl;
params = g_hash_table_lookup (global_plugins,
GINT_TO_POINTER (G_OBJECT_CLASS_TYPE (gobject_class)));
/* construct the element details struct */
details = g_new0 (GstElementDetails, 1);
details->longname = g_strdup_printf("FFMPEG %s demuxer",
params->in_plugin->name);
details->klass = g_strdup("Codec/Demuxer");
details->description = g_strdup_printf("FFMPEG %s decoder",
params->in_plugin->name);
details->author = g_strdup("Wim Taymans <wim.taymans@chello.be>\n"
"Ronald Bultje <rbultje@ronald.bitfreak.net>");
/* pad templates */
sinktempl = gst_pad_template_new ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
params->sinkcaps, NULL);
videosrctempl = gst_pad_template_new ("video_%02d",
GST_PAD_SRC,
GST_PAD_SOMETIMES,
params->videosrccaps, NULL);
audiosrctempl = gst_pad_template_new ("audio_%02d",
GST_PAD_SRC,
GST_PAD_SOMETIMES,
params->audiosrccaps, NULL);
gst_element_class_add_pad_template (element_class, videosrctempl);
gst_element_class_add_pad_template (element_class, audiosrctempl);
gst_element_class_add_pad_template (element_class, sinktempl);
gst_element_class_set_details (element_class, details);
klass->in_plugin = params->in_plugin;
klass->videosrctempl = videosrctempl;
klass->audiosrctempl = audiosrctempl;
klass->sinktempl = sinktempl;
}
static void
gst_ffmpegdemux_class_init (GstFFMpegDemuxClass *klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
GstFFMpegDemuxClassParams *params;
gobject_class = (GObjectClass*)klass;
gstelement_class = (GstElementClass*)klass;
parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
params = g_hash_table_lookup (global_plugins,
GINT_TO_POINTER (G_OBJECT_CLASS_TYPE (gobject_class)));
klass->in_plugin = params->in_plugin;
klass->videosrctempl = params->videosrctempl;
klass->audiosrctempl = params->audiosrctempl;
klass->sinktempl = params->sinktempl;
gstelement_class->change_state = gst_ffmpegdemux_change_state;
gobject_class->dispose = gst_ffmpegdemux_dispose;
}
@ -177,7 +214,7 @@ gst_ffmpegdemux_type_find (GstTypeFind *tf, gpointer priv)
res = in_plugin->read_probe (&probe_data);
res = res * GST_TYPE_FIND_MAXIMUM / AVPROBE_SCORE_MAX;
if (res > 0) {
GstCaps *caps = GST_PAD_TEMPLATE_CAPS (params->sinktempl);
GstCaps *caps = params->sinkcaps;
/* make sure we still hold a refcount to this caps */
gst_caps_ref (caps);
gst_type_find_suggest (tf, res, caps);
@ -345,10 +382,9 @@ gst_ffmpegdemux_change_state (GstElement *element)
gboolean
gst_ffmpegdemux_register (GstPlugin *plugin)
{
GstElementFactory *factory;
GTypeInfo typeinfo = {
sizeof(GstFFMpegDemuxClass),
NULL,
(GBaseInitFunc)gst_ffmpegdemux_base_init,
NULL,
(GClassInitFunc)gst_ffmpegdemux_class_init,
NULL,
@ -358,7 +394,6 @@ gst_ffmpegdemux_register (GstPlugin *plugin)
(GInstanceInitFunc)gst_ffmpegdemux_init,
};
GType type;
GstElementDetails *details;
AVInputFormat *in_plugin;
GstFFMpegDemuxClassParams *params;
AVCodec *in_codec;
@ -369,7 +404,7 @@ gst_ffmpegdemux_register (GstPlugin *plugin)
global_plugins = g_hash_table_new (NULL, NULL);
while (in_plugin) {
gchar *type_name;
gchar *type_name, *typefind_name;
gchar *p;
GstCaps *sinkcaps, *audiosrccaps, *videosrccaps;
@ -404,6 +439,7 @@ gst_ffmpegdemux_register (GstPlugin *plugin)
/* construct the type */
type_name = g_strdup_printf("ffdemux_%s", in_plugin->name);
typefind_name = g_strdup_printf("fftype_%s", in_plugin->name);
p = type_name;
@ -421,59 +457,24 @@ gst_ffmpegdemux_register (GstPlugin *plugin)
/* create the type now */
type = g_type_register_static(GST_TYPE_ELEMENT, type_name , &typeinfo, 0);
/* construct the element details struct */
details = g_new0 (GstElementDetails, 1);
details->longname = g_strdup (in_plugin->long_name);
details->klass = g_strdup ("Codec/Demuxer");
details->license = g_strdup ("LGPL");
details->description = g_strdup_printf ("FFMPEG %s demuxer",
in_plugin->name);
details->version = g_strdup (VERSION);
details->author = g_strdup ("The FFMPEG crew, "
"Wim Taymans <wim.taymans@chello.be>, "
"Ronald Bultje <rbultje@ronald.bitfreak.net>");
details->copyright = g_strdup ("(c) 2002-2003");
/* register the plugin with gstreamer */
factory = gst_element_factory_new(type_name,type,details);
g_return_val_if_fail(factory != NULL, FALSE);
/* create a cache for these properties */
params = g_new0 (GstFFMpegDemuxClassParams, 1);
params->in_plugin = in_plugin;
params->sinktempl = gst_pad_template_new ("sink", GST_PAD_SINK,
GST_PAD_ALWAYS,
sinkcaps, NULL);
gst_element_factory_add_pad_template (factory,
params->sinktempl);
params->audiosrctempl = gst_pad_template_new ("audio_%02d",
GST_PAD_SRC,
GST_PAD_SOMETIMES,
audiosrccaps, NULL);
gst_element_factory_add_pad_template (factory,
params->audiosrctempl);
params->videosrctempl = gst_pad_template_new ("video_%02d",
GST_PAD_SRC,
GST_PAD_SOMETIMES,
videosrccaps, NULL);
gst_element_factory_add_pad_template (factory,
params->videosrctempl);
/* typefind registering */
extensions = g_strsplit (in_plugin->extensions, " ", 0);
gst_type_find_factory_register (plugin, g_strdup_printf ("fftype_%s", in_plugin->name),
GST_ELEMENT_RANK_MARGINAL, gst_ffmpegdemux_type_find,
extensions, GST_CAPS_ANY, params);
g_strfreev (extensions);
params->sinkcaps = sinkcaps;
params->videosrccaps = videosrccaps;
params->audiosrccaps = audiosrccaps;
g_hash_table_insert (global_plugins,
GINT_TO_POINTER (type),
(gpointer) params);
gst_element_factory_set_rank (factory, GST_ELEMENT_RANK_MARGINAL);
/* The very last thing is to register the elementfactory with the plugin. */
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
extensions = g_strsplit (in_plugin->extensions, " ", 0);
if (!gst_element_register (plugin, type_name, GST_RANK_MARGINAL, type) ||
!gst_type_find_register (plugin, typefind_name, GST_RANK_MARGINAL,
gst_ffmpegdemux_type_find,
extensions, GST_CAPS_ANY, params))
return FALSE;
g_strfreev (extensions);
next:
in_plugin = in_plugin->next;

View file

@ -63,7 +63,7 @@ struct _GstFFMpegEncClass {
typedef struct {
AVCodec *in_plugin;
GstPadTemplate *srctempl, *sinktempl;
GstCaps *srccaps, *sinkcaps;
} GstFFMpegEncClassParams;
#define GST_TYPE_FFMPEGENC \
@ -117,6 +117,7 @@ static GHashTable *enc_global_plugins;
/* A number of functon prototypes are given so we can refer to them later. */
static void gst_ffmpegenc_class_init (GstFFMpegEncClass *klass);
static void gst_ffmpegenc_base_init (GstFFMpegEncClass *klass);
static void gst_ffmpegenc_init (GstFFMpegEnc *ffmpegenc);
static void gst_ffmpegenc_dispose (GObject *object);
@ -140,25 +141,56 @@ static GstElementClass *parent_class = NULL;
/*static guint gst_ffmpegenc_signals[LAST_SIGNAL] = { 0 }; */
static void
gst_ffmpegenc_base_init (GstFFMpegEncClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
GstFFMpegEncClassParams *params;
GstElementDetails *details;
GstPadTemplate *srctempl, *sinktempl;
params = g_hash_table_lookup (enc_global_plugins,
GINT_TO_POINTER (G_OBJECT_CLASS_TYPE (gobject_class)));
/* construct the element details struct */
details = g_new0 (GstElementDetails, 1);
details->longname = g_strdup_printf("FFMPEG %s encoder",
params->in_plugin->name);
details->klass = g_strdup_printf("Codec/%s/Encoder",
(params->in_plugin->type == CODEC_TYPE_VIDEO) ?
"Video" : "Audio");
details->description = g_strdup_printf("FFMPEG %s encoder",
params->in_plugin->name);
details->author = g_strdup("Wim Taymans <wim.taymans@chello.be>\n"
"Ronald Bultje <rbultje@ronald.bitfreak.net>");
/* pad templates */
sinktempl = gst_pad_template_new ("sink", GST_PAD_SINK,
GST_PAD_ALWAYS, params->sinkcaps, NULL);
srctempl = gst_pad_template_new ("src", GST_PAD_SRC,
GST_PAD_ALWAYS, params->srccaps, NULL);
gst_element_class_add_pad_template (element_class, srctempl);
gst_element_class_add_pad_template (element_class, sinktempl);
gst_element_class_set_details (element_class, details);
klass->in_plugin = params->in_plugin;
klass->srctempl = srctempl;
klass->sinktempl = sinktempl;
}
static void
gst_ffmpegenc_class_init (GstFFMpegEncClass *klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
GstFFMpegEncClassParams *params;
gobject_class = (GObjectClass*)klass;
gstelement_class = (GstElementClass*)klass;
parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
params = g_hash_table_lookup (enc_global_plugins,
GINT_TO_POINTER (G_OBJECT_CLASS_TYPE (gobject_class)));
klass->in_plugin = params->in_plugin;
klass->srctempl = params->srctempl;
klass->sinktempl = params->sinktempl;
if (klass->in_plugin->type == CODEC_TYPE_VIDEO) {
g_object_class_install_property(G_OBJECT_CLASS (klass), ARG_BIT_RATE,
g_param_spec_ulong ("bitrate","Bit Rate",
@ -469,10 +501,9 @@ gst_ffmpegenc_change_state (GstElement *element)
gboolean
gst_ffmpegenc_register (GstPlugin *plugin)
{
GstElementFactory *factory;
GTypeInfo typeinfo = {
sizeof(GstFFMpegEncClass),
NULL,
(GBaseInitFunc)gst_ffmpegenc_base_init,
NULL,
(GClassInitFunc)gst_ffmpegenc_class_init,
NULL,
@ -482,7 +513,6 @@ gst_ffmpegenc_register (GstPlugin *plugin)
(GInstanceInitFunc)gst_ffmpegenc_init,
};
GType type;
GstElementDetails *details;
AVCodec *in_plugin;
in_plugin = first_avcodec;
@ -492,7 +522,6 @@ gst_ffmpegenc_register (GstPlugin *plugin)
while (in_plugin) {
gchar *type_name;
GstCaps *srccaps, *sinkcaps;
GstPadTemplate *srctempl, *sinktempl;
GstFFMpegEncClassParams *params;
/* no quasi codecs, please */
@ -524,48 +553,18 @@ gst_ffmpegenc_register (GstPlugin *plugin)
/* create the glib type now */
type = g_type_register_static(GST_TYPE_ELEMENT, type_name , &typeinfo, 0);
g_return_val_if_fail(type != 0, FALSE);
/* construct the element details struct */
details = g_new0 (GstElementDetails,1);
details->longname = g_strdup_printf("FFMPEG %s encoder",
in_plugin->name);
details->klass = g_strdup_printf("Codec/%s/Encoder",
(in_plugin->type == CODEC_TYPE_VIDEO) ?
"Video" : "Audio");
details->license = g_strdup("LGPL");
details->description = g_strdup_printf("FFMPEG %s encoder",
in_plugin->name);
details->version = g_strdup(VERSION);
details->author = g_strdup("The FFMPEG crew, "
"Wim Taymans <wim.taymans@chello.be>, "
"Ronald Bultje <rbultje@ronald.bitfreak.net>");
details->copyright = g_strdup("(c) 2001-2003");
/* register the plugin with gstreamer */
factory = gst_element_factory_new(type_name,type,details);
g_return_val_if_fail(factory != NULL, FALSE);
sinktempl = gst_pad_template_new ("sink", GST_PAD_SINK,
GST_PAD_ALWAYS, sinkcaps, NULL);
gst_element_factory_add_pad_template (factory, sinktempl);
srctempl = gst_pad_template_new ("src", GST_PAD_SRC,
GST_PAD_ALWAYS, srccaps, NULL);
gst_element_factory_add_pad_template (factory, srctempl);
if (!gst_element_register (plugin, type_name, GST_RANK_NONE, type))
return FALSE;
params = g_new0 (GstFFMpegEncClassParams, 1);
params->in_plugin = in_plugin;
params->sinktempl = sinktempl;
params->srctempl = srctempl;
params->srccaps = srccaps;
params->sinkcaps = sinkcaps;
g_hash_table_insert (enc_global_plugins,
GINT_TO_POINTER (type),
(gpointer) params);
/* The very last thing is to register the elementfactory with the plugin. */
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
next:
in_plugin = in_plugin->next;
}

View file

@ -51,9 +51,7 @@ struct _GstFFMpegMux {
typedef struct _GstFFMpegMuxClassParams {
AVOutputFormat *in_plugin;
GstPadTemplate *srctempl;
GstPadTemplate *videosinktempl;
GstPadTemplate *audiosinktempl;
GstCaps *srccaps, *videosinkcaps, *audiosinkcaps;
} GstFFMpegMuxClassParams;
typedef struct _GstFFMpegMuxClass GstFFMpegMuxClass;
@ -92,6 +90,7 @@ static GHashTable *global_plugins;
/* A number of functon prototypes are given so we can refer to them later. */
static void gst_ffmpegmux_class_init (GstFFMpegMuxClass *klass);
static void gst_ffmpegmux_base_init (GstFFMpegMuxClass *klass);
static void gst_ffmpegmux_init (GstFFMpegMux *ffmpegmux);
static void gst_ffmpegmux_dispose (GObject *object);
@ -110,26 +109,63 @@ static GstElementClass *parent_class = NULL;
/*static guint gst_ffmpegmux_signals[LAST_SIGNAL] = { 0 }; */
static void
gst_ffmpegmux_base_init (GstFFMpegMuxClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
GstFFMpegMuxClassParams *params;
GstElementDetails *details;
GstPadTemplate *videosinktempl, *audiosinktempl, *srctempl;
params = g_hash_table_lookup (global_plugins,
GINT_TO_POINTER (G_OBJECT_CLASS_TYPE (gobject_class)));
/* construct the element details struct */
details = g_new0 (GstElementDetails, 1);
details->longname = g_strdup_printf ("FFMPEG %s Muxer",
params->in_plugin->name);
details->klass = g_strdup ("Codec/Muxer");
details->description = g_strdup_printf ("FFMPEG %s Muxer",
params->in_plugin->name);
details->author = g_strdup ("Wim Taymans <wim.taymans@chello.be>\n"
"Ronald Bultje <rbultje@ronald.bitfreak.net>");
/* pad templates */
srctempl = gst_pad_template_new ("sink", GST_PAD_SRC,
GST_PAD_ALWAYS,
params->srccaps, NULL);
audiosinktempl = gst_pad_template_new ("audio_%d",
GST_PAD_SINK,
GST_PAD_REQUEST,
params->audiosinkcaps, NULL);
videosinktempl = gst_pad_template_new ("video_%d",
GST_PAD_SINK,
GST_PAD_REQUEST,
params->videosinkcaps, NULL);
gst_element_class_add_pad_template (element_class, srctempl);
gst_element_class_add_pad_template (element_class, videosinktempl);
gst_element_class_add_pad_template (element_class, audiosinktempl);
gst_element_class_set_details (element_class, details);
klass->in_plugin = params->in_plugin;
klass->srctempl = srctempl;
klass->videosinktempl = videosinktempl;
klass->audiosinktempl = audiosinktempl;
}
static void
gst_ffmpegmux_class_init (GstFFMpegMuxClass *klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
GstFFMpegMuxClassParams *params;
gobject_class = (GObjectClass*)klass;
gstelement_class = (GstElementClass*)klass;
parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
params = g_hash_table_lookup (global_plugins,
GINT_TO_POINTER (G_OBJECT_CLASS_TYPE (gobject_class)));
klass->in_plugin = params->in_plugin;
klass->videosinktempl = params->videosinktempl;
klass->audiosinktempl = params->audiosinktempl;
klass->srctempl = params->srctempl;
gstelement_class->request_new_pad = gst_ffmpegmux_request_new_pad;
gstelement_class->change_state = gst_ffmpegmux_change_state;
gobject_class->dispose = gst_ffmpegmux_dispose;
@ -400,10 +436,9 @@ gst_ffmpegmux_change_state (GstElement *element)
gboolean
gst_ffmpegmux_register (GstPlugin *plugin)
{
GstElementFactory *factory;
GTypeInfo typeinfo = {
sizeof(GstFFMpegMuxClass),
NULL,
(GBaseInitFunc)gst_ffmpegmux_base_init,
NULL,
(GClassInitFunc)gst_ffmpegmux_class_init,
NULL,
@ -413,7 +448,6 @@ gst_ffmpegmux_register (GstPlugin *plugin)
(GInstanceInitFunc)gst_ffmpegmux_init,
};
GType type;
GstElementDetails *details;
AVOutputFormat *in_plugin;
GstFFMpegMuxClassParams *params;
AVCodec *in_codec;
@ -474,52 +508,20 @@ gst_ffmpegmux_register (GstPlugin *plugin)
/* create the type now */
type = g_type_register_static(GST_TYPE_ELEMENT, type_name , &typeinfo, 0);
/* construct the element details struct */
details = g_new0 (GstElementDetails, 1);
details->longname = g_strdup (in_plugin->long_name);
details->klass = g_strdup ("Codec/Muxer");
details->license = g_strdup ("LGPL");
details->description = g_strdup_printf ("FFMPEG %s Muxer",
in_plugin->name);
details->version = g_strdup (VERSION);
details->author = g_strdup ("The FFMPEG crew, "
"Wim Taymans <wim.taymans@chello.be>, "
"Ronald Bultje <rbultje@ronald.bitfreak.net>");
details->copyright = g_strdup ("(c) 2002-2003");
/* register the plugin with gstreamer */
factory = gst_element_factory_new(type_name,type,details);
g_return_val_if_fail(factory != NULL, FALSE);
if (!gst_element_register (plugin, type_name, GST_RANK_NONE, type))
return FALSE;
/* create a cache for these properties */
params = g_new0 (GstFFMpegMuxClassParams, 1);
params->in_plugin = in_plugin;
params->srctempl = gst_pad_template_new ("sink", GST_PAD_SRC,
GST_PAD_ALWAYS,
srccaps, NULL);
gst_element_factory_add_pad_template (factory,
params->srctempl);
params->audiosinktempl = gst_pad_template_new ("audio_%d",
GST_PAD_SINK,
GST_PAD_REQUEST,
audiosinkcaps, NULL);
gst_element_factory_add_pad_template (factory,
params->audiosinktempl);
params->videosinktempl = gst_pad_template_new ("video_%d",
GST_PAD_SINK,
GST_PAD_REQUEST,
videosinkcaps, NULL);
gst_element_factory_add_pad_template (factory,
params->videosinktempl);
params->srccaps = srccaps;
params->videosinkcaps = videosinkcaps;
params->audiosinkcaps = audiosinkcaps;
g_hash_table_insert (global_plugins,
GINT_TO_POINTER (type),
(gpointer) params);
/* The very last thing is to register the elementfactory with the plugin. */
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
next:
in_plugin = in_plugin->next;
}