2002-03-20 21:44:42 +00:00
|
|
|
/* GStreamer
|
2001-12-23 13:25:04 +00:00
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2002-11-06 23:53:46 +00:00
|
|
|
#include <assert.h>
|
2001-12-23 13:25:04 +00:00
|
|
|
#include <string.h>
|
2002-11-26 14:50:05 +00:00
|
|
|
#include "config.h"
|
|
|
|
#ifdef HAVE_FFMPEG_UNINSTALLED
|
|
|
|
#include <avcodec.h>
|
|
|
|
#else
|
|
|
|
#include <ffmpeg/avcodec.h>
|
|
|
|
#endif
|
2002-11-06 23:53:46 +00:00
|
|
|
|
|
|
|
#include <gst/gst.h>
|
|
|
|
|
2002-11-25 21:37:26 +00:00
|
|
|
extern GstCaps* gst_ffmpegcodec_codec_context_to_caps (AVCodecContext *ctx, int id);
|
|
|
|
|
|
|
|
|
2002-11-06 23:53:46 +00:00
|
|
|
typedef struct _GstFFMpegDec GstFFMpegDec;
|
|
|
|
|
|
|
|
struct _GstFFMpegDec {
|
|
|
|
GstElement element;
|
|
|
|
|
|
|
|
/* We need to keep track of our pads, so we do so here. */
|
|
|
|
GstPad *srcpad;
|
|
|
|
GstPad *sinkpad;
|
|
|
|
|
|
|
|
AVCodecContext *context;
|
|
|
|
AVPicture *picture;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _GstFFMpegDecClass GstFFMpegDecClass;
|
|
|
|
|
|
|
|
struct _GstFFMpegDecClass {
|
|
|
|
GstElementClass parent_class;
|
|
|
|
|
|
|
|
AVCodec *in_plugin;
|
2002-11-25 21:37:26 +00:00
|
|
|
GstPadTemplate *templ;
|
2002-11-06 23:53:46 +00:00
|
|
|
};
|
|
|
|
|
2002-11-25 21:37:26 +00:00
|
|
|
typedef struct {
|
|
|
|
AVCodec *in_plugin;
|
|
|
|
GstPadTemplate *templ;
|
|
|
|
} GstFFMpegClassParams;
|
|
|
|
|
2002-11-06 23:53:46 +00:00
|
|
|
#define GST_TYPE_FFMPEGDEC \
|
|
|
|
(gst_ffmpegdec_get_type())
|
|
|
|
#define GST_FFMPEGDEC(obj) \
|
|
|
|
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_FFMPEGDEC,GstFFMpegDec))
|
|
|
|
#define GST_FFMPEGDEC_CLASS(klass) \
|
|
|
|
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FFMPEGDEC,GstFFMpegDecClass))
|
|
|
|
#define GST_IS_FFMPEGDEC(obj) \
|
|
|
|
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FFMPEGDEC))
|
|
|
|
#define GST_IS_FFMPEGDEC_CLASS(obj) \
|
|
|
|
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FFMPEGDEC))
|
2001-12-23 13:25:04 +00:00
|
|
|
|
|
|
|
enum {
|
|
|
|
/* FILL ME */
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
ARG_0,
|
|
|
|
/* FILL ME */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* This factory is much simpler, and defines the source pad. */
|
2002-04-11 20:42:00 +00:00
|
|
|
GST_PAD_TEMPLATE_FACTORY (gst_ffmpegdec_audio_src_factory,
|
2001-12-23 13:25:04 +00:00
|
|
|
"src",
|
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_CAPS_NEW (
|
|
|
|
"ffmpegdec_src",
|
|
|
|
"audio/raw",
|
|
|
|
"format", GST_PROPS_STRING ("int"),
|
|
|
|
"law", GST_PROPS_INT (0),
|
|
|
|
"endianness", GST_PROPS_INT (G_BYTE_ORDER),
|
|
|
|
"signed", GST_PROPS_BOOLEAN (TRUE),
|
|
|
|
"width", GST_PROPS_INT (16),
|
|
|
|
"depth", GST_PROPS_INT (16),
|
|
|
|
"rate", GST_PROPS_INT_RANGE (8000, 96000),
|
|
|
|
"channels", GST_PROPS_INT_RANGE (1, 2)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
/* This factory is much simpler, and defines the source pad. */
|
2002-04-11 20:42:00 +00:00
|
|
|
GST_PAD_TEMPLATE_FACTORY (gst_ffmpegdec_video_src_factory,
|
2001-12-23 13:25:04 +00:00
|
|
|
"src",
|
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_CAPS_NEW (
|
|
|
|
"ffmpegdec_src",
|
|
|
|
"video/raw",
|
|
|
|
"format", GST_PROPS_LIST (
|
|
|
|
GST_PROPS_FOURCC (GST_STR_FOURCC ("I420"))
|
|
|
|
),
|
|
|
|
"width", GST_PROPS_INT_RANGE (16, 4096),
|
|
|
|
"height", GST_PROPS_INT_RANGE (16, 4096)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
static GHashTable *global_plugins;
|
|
|
|
|
|
|
|
/* A number of functon prototypes are given so we can refer to them later. */
|
|
|
|
static void gst_ffmpegdec_class_init (GstFFMpegDecClass *klass);
|
|
|
|
static void gst_ffmpegdec_init (GstFFMpegDec *ffmpegdec);
|
|
|
|
|
|
|
|
static void gst_ffmpegdec_chain_audio (GstPad *pad, GstBuffer *buffer);
|
|
|
|
static void gst_ffmpegdec_chain_video (GstPad *pad, GstBuffer *buffer);
|
|
|
|
|
|
|
|
static void gst_ffmpegdec_set_property (GObject *object, guint prop_id, const GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
static void gst_ffmpegdec_get_property (GObject *object, guint prop_id, GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
|
|
|
|
static GstElementClass *parent_class = NULL;
|
|
|
|
|
2002-03-19 04:09:41 +00:00
|
|
|
/*static guint gst_ffmpegdec_signals[LAST_SIGNAL] = { 0 }; */
|
2001-12-23 13:25:04 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gst_ffmpegdec_class_init (GstFFMpegDecClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GstElementClass *gstelement_class;
|
2002-11-25 21:37:26 +00:00
|
|
|
GstFFMpegClassParams *params;
|
2001-12-23 13:25:04 +00:00
|
|
|
|
|
|
|
gobject_class = (GObjectClass*)klass;
|
|
|
|
gstelement_class = (GstElementClass*)klass;
|
|
|
|
|
|
|
|
parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
|
|
|
|
|
2002-11-25 21:37:26 +00:00
|
|
|
params = g_hash_table_lookup (global_plugins,
|
2001-12-23 13:25:04 +00:00
|
|
|
GINT_TO_POINTER (G_OBJECT_CLASS_TYPE (gobject_class)));
|
|
|
|
|
2002-11-25 21:37:26 +00:00
|
|
|
klass->in_plugin = params->in_plugin;
|
|
|
|
klass->templ = params->templ;
|
|
|
|
|
2001-12-23 13:25:04 +00:00
|
|
|
gobject_class->set_property = gst_ffmpegdec_set_property;
|
|
|
|
gobject_class->get_property = gst_ffmpegdec_get_property;
|
|
|
|
}
|
|
|
|
|
2002-01-13 22:27:22 +00:00
|
|
|
static GstPadConnectReturn
|
|
|
|
gst_ffmpegdec_sinkconnect (GstPad *pad, GstCaps *caps)
|
2001-12-23 13:25:04 +00:00
|
|
|
{
|
|
|
|
GstFFMpegDec *ffmpegdec = (GstFFMpegDec *)(gst_pad_get_parent (pad));
|
|
|
|
GstFFMpegDecClass *oclass = (GstFFMpegDecClass*)(G_OBJECT_GET_CLASS (ffmpegdec));
|
|
|
|
|
2002-01-13 22:27:22 +00:00
|
|
|
if (!GST_CAPS_IS_FIXED (caps))
|
|
|
|
return GST_PAD_CONNECT_DELAYED;
|
|
|
|
|
2002-06-03 22:48:11 +00:00
|
|
|
if (gst_caps_has_property_typed (caps, "width", GST_PROPS_INT_TYPE))
|
|
|
|
gst_caps_get_int (caps, "width", &ffmpegdec->context->width);
|
|
|
|
if (gst_caps_has_property_typed (caps, "height", GST_PROPS_INT_TYPE))
|
|
|
|
gst_caps_get_int (caps, "height", &ffmpegdec->context->height);
|
|
|
|
|
2001-12-23 13:25:04 +00:00
|
|
|
ffmpegdec->context->pix_fmt = PIX_FMT_YUV420P;
|
|
|
|
ffmpegdec->context->bit_rate = 0;
|
|
|
|
|
|
|
|
/* FIXME bug in ffmpeg */
|
|
|
|
if (avcodec_open (ffmpegdec->context, avcodec_find_encoder(CODEC_ID_MPEG1VIDEO)) <0 ) {
|
|
|
|
g_warning ("ffmpegdec: could not open codec");
|
2002-01-13 22:27:22 +00:00
|
|
|
return GST_PAD_CONNECT_REFUSED;
|
2001-12-23 13:25:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (avcodec_open (ffmpegdec->context, oclass->in_plugin) < 0) {
|
|
|
|
g_warning ("ffmpegdec: could not open codec");
|
2002-01-13 22:27:22 +00:00
|
|
|
return GST_PAD_CONNECT_REFUSED;
|
2001-12-23 13:25:04 +00:00
|
|
|
}
|
2002-01-13 22:27:22 +00:00
|
|
|
return GST_PAD_CONNECT_OK;
|
2001-12-23 13:25:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_ffmpegdec_init(GstFFMpegDec *ffmpegdec)
|
|
|
|
{
|
|
|
|
GstFFMpegDecClass *oclass = (GstFFMpegDecClass*)(G_OBJECT_GET_CLASS (ffmpegdec));
|
|
|
|
|
|
|
|
ffmpegdec->context = g_malloc0 (sizeof (AVCodecContext));
|
|
|
|
|
2002-11-25 21:37:26 +00:00
|
|
|
ffmpegdec->sinkpad = gst_pad_new_from_template (oclass->templ, "sink");
|
2002-01-13 22:27:22 +00:00
|
|
|
gst_pad_set_connect_function (ffmpegdec->sinkpad, gst_ffmpegdec_sinkconnect);
|
2001-12-23 13:25:04 +00:00
|
|
|
|
|
|
|
if (oclass->in_plugin->type == CODEC_TYPE_VIDEO) {
|
|
|
|
ffmpegdec->srcpad = gst_pad_new_from_template (
|
2002-04-11 20:42:00 +00:00
|
|
|
GST_PAD_TEMPLATE_GET (gst_ffmpegdec_video_src_factory), "src");
|
2001-12-23 13:25:04 +00:00
|
|
|
gst_pad_set_chain_function (ffmpegdec->sinkpad, gst_ffmpegdec_chain_video);
|
|
|
|
}
|
|
|
|
else if (oclass->in_plugin->type == CODEC_TYPE_AUDIO) {
|
|
|
|
ffmpegdec->srcpad = gst_pad_new_from_template (
|
2002-04-11 20:42:00 +00:00
|
|
|
GST_PAD_TEMPLATE_GET (gst_ffmpegdec_audio_src_factory), "src");
|
2001-12-23 13:25:04 +00:00
|
|
|
gst_pad_set_chain_function (ffmpegdec->sinkpad, gst_ffmpegdec_chain_audio);
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_element_add_pad (GST_ELEMENT (ffmpegdec), ffmpegdec->sinkpad);
|
|
|
|
gst_element_add_pad (GST_ELEMENT (ffmpegdec), ffmpegdec->srcpad);
|
|
|
|
|
|
|
|
ffmpegdec->picture = g_malloc0 (sizeof (AVPicture));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_ffmpegdec_chain_audio (GstPad *pad, GstBuffer *inbuf)
|
|
|
|
{
|
2002-03-19 04:09:41 +00:00
|
|
|
/*GstFFMpegDec *ffmpegdec = (GstFFMpegDec *)(gst_pad_get_parent (pad)); */
|
2001-12-23 13:25:04 +00:00
|
|
|
gpointer data;
|
|
|
|
gint size;
|
|
|
|
|
|
|
|
data = GST_BUFFER_DATA (inbuf);
|
|
|
|
size = GST_BUFFER_SIZE (inbuf);
|
|
|
|
|
2002-03-24 22:06:46 +00:00
|
|
|
GST_DEBUG (0, "got buffer %p %d", data, size);
|
2001-12-23 13:25:04 +00:00
|
|
|
|
|
|
|
gst_buffer_unref (inbuf);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_ffmpegdec_chain_video (GstPad *pad, GstBuffer *inbuf)
|
|
|
|
{
|
|
|
|
GstBuffer *outbuf;
|
|
|
|
GstFFMpegDec *ffmpegdec = (GstFFMpegDec *)(gst_pad_get_parent (pad));
|
|
|
|
guchar *data;
|
|
|
|
gint size, frame_size, len;
|
|
|
|
gint have_picture;
|
|
|
|
|
|
|
|
data = GST_BUFFER_DATA (inbuf);
|
|
|
|
size = GST_BUFFER_SIZE (inbuf);
|
|
|
|
|
|
|
|
do {
|
|
|
|
ffmpegdec->context->frame_number++;
|
|
|
|
|
|
|
|
len = avcodec_decode_video (ffmpegdec->context, ffmpegdec->picture,
|
|
|
|
&have_picture, data, size);
|
|
|
|
|
|
|
|
if (len < 0) {
|
|
|
|
g_warning ("ffmpegdec: decoding error");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (have_picture) {
|
|
|
|
guchar *picdata, *picdata2, *outdata, *outdata2;
|
|
|
|
gint xsize, i, width, height;
|
|
|
|
|
|
|
|
width = ffmpegdec->context->width;
|
|
|
|
height = ffmpegdec->context->height;
|
|
|
|
|
|
|
|
if (!GST_PAD_CAPS (ffmpegdec->srcpad)) {
|
2002-01-13 22:27:22 +00:00
|
|
|
gst_pad_try_set_caps (ffmpegdec->srcpad,
|
2001-12-23 13:25:04 +00:00
|
|
|
GST_CAPS_NEW (
|
|
|
|
"ffmpegdec_src",
|
|
|
|
"video/raw",
|
|
|
|
"format", GST_PROPS_FOURCC (GST_STR_FOURCC ("I420")),
|
|
|
|
"width", GST_PROPS_INT (width),
|
|
|
|
"height", GST_PROPS_INT (height)
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
frame_size = width * height;
|
|
|
|
|
|
|
|
outbuf = gst_buffer_new ();
|
|
|
|
GST_BUFFER_SIZE (outbuf) = (frame_size*3)>>1;
|
|
|
|
outdata = GST_BUFFER_DATA (outbuf) = g_malloc (GST_BUFFER_SIZE (outbuf));
|
|
|
|
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (inbuf);
|
|
|
|
|
|
|
|
picdata = ffmpegdec->picture->data[0];
|
|
|
|
xsize = ffmpegdec->picture->linesize[0];
|
|
|
|
for (i=height; i; i--) {
|
|
|
|
memcpy (outdata, picdata, width);
|
|
|
|
outdata += width;
|
|
|
|
picdata += xsize;
|
|
|
|
}
|
|
|
|
|
|
|
|
frame_size >>= 2;
|
|
|
|
width >>= 1;
|
|
|
|
height >>= 1;
|
|
|
|
outdata2 = outdata + frame_size;
|
|
|
|
|
|
|
|
picdata = ffmpegdec->picture->data[1];
|
|
|
|
picdata2 = ffmpegdec->picture->data[2];
|
|
|
|
xsize = ffmpegdec->picture->linesize[1];
|
|
|
|
for (i=height; i; i--) {
|
|
|
|
memcpy (outdata, picdata, width);
|
|
|
|
memcpy (outdata2, picdata2, width);
|
|
|
|
outdata += width; outdata2 += width;
|
|
|
|
picdata += xsize; picdata2 += xsize;
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_pad_push (ffmpegdec->srcpad, outbuf);
|
|
|
|
}
|
|
|
|
|
|
|
|
size -= len;
|
|
|
|
data += len;
|
|
|
|
}
|
|
|
|
while (size > 0);
|
|
|
|
|
|
|
|
gst_buffer_unref (inbuf);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_ffmpegdec_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GstFFMpegDec *ffmpegdec;
|
|
|
|
|
|
|
|
/* Get a pointer of the right type. */
|
|
|
|
ffmpegdec = (GstFFMpegDec *)(object);
|
|
|
|
|
|
|
|
/* Check the argument id to see which argument we're setting. */
|
|
|
|
switch (prop_id) {
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The set function is simply the inverse of the get fuction. */
|
|
|
|
static void
|
|
|
|
gst_ffmpegdec_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GstFFMpegDec *ffmpegdec;
|
|
|
|
|
|
|
|
/* It's not null if we got it, but it might not be ours */
|
|
|
|
ffmpegdec = (GstFFMpegDec *)(object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gst_ffmpegdec_register (GstPlugin *plugin)
|
|
|
|
{
|
|
|
|
GstElementFactory *factory;
|
|
|
|
GTypeInfo typeinfo = {
|
|
|
|
sizeof(GstFFMpegDecClass),
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
(GClassInitFunc)gst_ffmpegdec_class_init,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
sizeof(GstFFMpegDec),
|
|
|
|
0,
|
|
|
|
(GInstanceInitFunc)gst_ffmpegdec_init,
|
|
|
|
};
|
|
|
|
GType type;
|
|
|
|
GstElementDetails *details;
|
|
|
|
AVCodec *in_plugin;
|
|
|
|
|
|
|
|
in_plugin = first_avcodec;
|
|
|
|
|
|
|
|
global_plugins = g_hash_table_new (NULL, NULL);
|
|
|
|
|
|
|
|
while (in_plugin) {
|
|
|
|
gchar *type_name;
|
|
|
|
gchar *codec_type;
|
2002-11-25 21:37:26 +00:00
|
|
|
GstPadTemplate *sinktempl;
|
|
|
|
GstCaps *sinkcaps;
|
|
|
|
GstFFMpegClassParams *params;
|
2001-12-23 13:25:04 +00:00
|
|
|
|
|
|
|
if (in_plugin->decode) {
|
|
|
|
codec_type = "dec";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
goto next;
|
|
|
|
}
|
2002-03-19 04:09:41 +00:00
|
|
|
/* construct the type */
|
2002-11-06 23:53:46 +00:00
|
|
|
type_name = g_strdup_printf("ff%s_%s", codec_type, in_plugin->name);
|
2001-12-23 13:25:04 +00:00
|
|
|
|
2002-03-19 04:09:41 +00:00
|
|
|
/* if it's already registered, drop it */
|
2001-12-23 13:25:04 +00:00
|
|
|
if (g_type_from_name(type_name)) {
|
|
|
|
g_free(type_name);
|
|
|
|
goto next;
|
|
|
|
}
|
|
|
|
|
2002-03-19 04:09:41 +00:00
|
|
|
/* create the gtk type now */
|
2001-12-23 13:25:04 +00:00
|
|
|
type = g_type_register_static(GST_TYPE_ELEMENT, type_name , &typeinfo, 0);
|
|
|
|
|
2002-03-19 04:09:41 +00:00
|
|
|
/* construct the element details struct */
|
2001-12-23 13:25:04 +00:00
|
|
|
details = g_new0 (GstElementDetails,1);
|
|
|
|
details->longname = g_strdup (in_plugin->name);
|
|
|
|
details->klass = "Codec/FFMpeg";
|
2002-09-18 19:02:18 +00:00
|
|
|
details->license = "LGPL";
|
2001-12-23 13:25:04 +00:00
|
|
|
details->description = g_strdup (in_plugin->name);
|
|
|
|
details->version = g_strdup("1.0.0");
|
|
|
|
details->author = g_strdup("The FFMPEG crew, GStreamer plugin by Wim Taymans <wim.taymans@chello.be>");
|
|
|
|
details->copyright = g_strdup("(c) 2001");
|
|
|
|
|
2002-03-19 04:09:41 +00:00
|
|
|
/* register the plugin with gstreamer */
|
2002-04-11 20:42:00 +00:00
|
|
|
factory = gst_element_factory_new(type_name,type,details);
|
2001-12-23 13:25:04 +00:00
|
|
|
g_return_val_if_fail(factory != NULL, FALSE);
|
|
|
|
|
2002-11-06 23:53:46 +00:00
|
|
|
gst_element_factory_set_rank (factory, GST_ELEMENT_RANK_NONE);
|
|
|
|
|
2002-11-25 21:37:26 +00:00
|
|
|
sinkcaps = gst_ffmpegcodec_codec_context_to_caps (NULL, in_plugin->id);
|
|
|
|
sinktempl = gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, sinkcaps, NULL);
|
|
|
|
gst_element_factory_add_pad_template (factory, sinktempl);
|
|
|
|
|
|
|
|
params = g_new0 (GstFFMpegClassParams, 1);
|
|
|
|
params->in_plugin = in_plugin;
|
|
|
|
params->templ = sinktempl;
|
|
|
|
|
|
|
|
g_hash_table_insert (global_plugins,
|
|
|
|
GINT_TO_POINTER (type),
|
|
|
|
(gpointer) params);
|
2001-12-23 13:25:04 +00:00
|
|
|
|
|
|
|
if (in_plugin->type == CODEC_TYPE_VIDEO) {
|
2002-04-11 20:42:00 +00:00
|
|
|
gst_element_factory_add_pad_template (factory,
|
|
|
|
GST_PAD_TEMPLATE_GET (gst_ffmpegdec_video_src_factory));
|
2001-12-23 13:25:04 +00:00
|
|
|
}
|
|
|
|
else if (in_plugin->type == CODEC_TYPE_AUDIO) {
|
2002-04-11 20:42:00 +00:00
|
|
|
gst_element_factory_add_pad_template (factory,
|
|
|
|
GST_PAD_TEMPLATE_GET (gst_ffmpegdec_audio_src_factory));
|
2001-12-23 13:25:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|