Bring the plugins in sync with the new core capsnego system.

Original commit message from CVS:
Bring the plugins in sync with the new core capsnego system.
Added some features, enhancements...
This commit is contained in:
Wim Taymans 2002-01-13 22:27:22 +00:00
parent 428baadc62
commit 7e54c58ea6
2 changed files with 19 additions and 7 deletions

View file

@ -114,12 +114,15 @@ gst_ffmpegdec_class_init (GstFFMpegDecClass *klass)
gobject_class->get_property = gst_ffmpegdec_get_property;
}
static void
gst_ffmpegdec_newcaps (GstPad *pad, GstCaps *caps)
static GstPadConnectReturn
gst_ffmpegdec_sinkconnect (GstPad *pad, GstCaps *caps)
{
GstFFMpegDec *ffmpegdec = (GstFFMpegDec *)(gst_pad_get_parent (pad));
GstFFMpegDecClass *oclass = (GstFFMpegDecClass*)(G_OBJECT_GET_CLASS (ffmpegdec));
if (!GST_CAPS_IS_FIXED (caps))
return GST_PAD_CONNECT_DELAYED;
ffmpegdec->context->width = gst_caps_get_int (caps, "width");
ffmpegdec->context->height = gst_caps_get_int (caps, "height");
ffmpegdec->context->pix_fmt = PIX_FMT_YUV420P;
@ -129,11 +132,14 @@ gst_ffmpegdec_newcaps (GstPad *pad, GstCaps *caps)
/* FIXME bug in ffmpeg */
if (avcodec_open (ffmpegdec->context, avcodec_find_encoder(CODEC_ID_MPEG1VIDEO)) <0 ) {
g_warning ("ffmpegdec: could not open codec");
return GST_PAD_CONNECT_REFUSED;
}
if (avcodec_open (ffmpegdec->context, oclass->in_plugin) < 0) {
g_warning ("ffmpegdec: could not open codec");
return GST_PAD_CONNECT_REFUSED;
}
return GST_PAD_CONNECT_OK;
}
static void
@ -145,7 +151,7 @@ gst_ffmpegdec_init(GstFFMpegDec *ffmpegdec)
ffmpegdec->sinkpad = gst_pad_new_from_template (
GST_PADTEMPLATE_GET (gst_ffmpegdec_sink_factory), "sink");
gst_pad_set_newcaps_function (ffmpegdec->sinkpad, gst_ffmpegdec_newcaps);
gst_pad_set_connect_function (ffmpegdec->sinkpad, gst_ffmpegdec_sinkconnect);
if (oclass->in_plugin->type == CODEC_TYPE_VIDEO) {
ffmpegdec->srcpad = gst_pad_new_from_template (
@ -210,7 +216,7 @@ gst_ffmpegdec_chain_video (GstPad *pad, GstBuffer *inbuf)
height = ffmpegdec->context->height;
if (!GST_PAD_CAPS (ffmpegdec->srcpad)) {
gst_pad_set_caps (ffmpegdec->srcpad,
gst_pad_try_set_caps (ffmpegdec->srcpad,
GST_CAPS_NEW (
"ffmpegdec_src",
"video/raw",

View file

@ -174,12 +174,15 @@ gst_ffmpegenc_class_init (GstFFMpegEncClass *klass)
gobject_class->get_property = gst_ffmpegenc_get_property;
}
static void
gst_ffmpegenc_newcaps (GstPad *pad, GstCaps *caps)
static GstPadConnectReturn
gst_ffmpegenc_sinkconnect (GstPad *pad, GstCaps *caps)
{
GstFFMpegEnc *ffmpegenc = (GstFFMpegEnc *) gst_pad_get_parent (pad);
GstFFMpegEncClass *oclass = (GstFFMpegEncClass*)(G_OBJECT_GET_CLASS(ffmpegenc));
if (!GST_CAPS_IS_FIXED (caps))
return GST_PAD_CONNECT_DELAYED;
if (strstr (gst_caps_get_mime (caps), "audio/raw")) {
ffmpegenc->context->sample_rate = gst_caps_get_int (caps, "rate");
ffmpegenc->context->channels = gst_caps_get_int (caps, "channels");
@ -207,10 +210,12 @@ gst_ffmpegenc_newcaps (GstPad *pad, GstCaps *caps)
}
else {
g_warning ("ffmpegenc: invalid caps %s\n", gst_caps_get_mime (caps));
return GST_PAD_CONNECT_REFUSED;
}
if (avcodec_open (ffmpegenc->context, oclass->in_plugin) < 0) {
g_warning ("ffmpegenc: could not open codec\n");
return GST_PAD_CONNECT_REFUSED;
}
if (oclass->in_plugin->type == CODEC_TYPE_AUDIO) {
@ -218,6 +223,7 @@ gst_ffmpegenc_newcaps (GstPad *pad, GstCaps *caps)
ffmpegenc->context->channels);
ffmpegenc->buffer_pos = 0;
}
return GST_PAD_CONNECT_OK;
}
static void
@ -245,7 +251,7 @@ gst_ffmpegenc_init(GstFFMpegEnc *ffmpegenc)
ffmpegenc->context->sample_rate = -1;
}
gst_pad_set_newcaps_function (ffmpegenc->sinkpad, gst_ffmpegenc_newcaps);
gst_pad_set_connect_function (ffmpegenc->sinkpad, gst_ffmpegenc_sinkconnect);
gst_element_add_pad (GST_ELEMENT (ffmpegenc), ffmpegenc->sinkpad);
ffmpegenc->srcpad = gst_pad_new_from_template (