summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@gmail.com>2002-01-13 22:27:22 +0000
committerWim Taymans <wim.taymans@gmail.com>2002-01-13 22:27:22 +0000
commit7e54c58ea624fa5ac373225f39c0d8789aeb04fd (patch)
tree4943b81949f30f4d731a8a9f5e2652e720fc6d86
parent428baadc62fae1ae5077af1244584b3166fb4244 (diff)
Original commit message from CVS: Bring the plugins in sync with the new core capsnego system. Added some features, enhancements...
-rw-r--r--ext/ffmpeg/gstffmpegdec.c14
-rw-r--r--ext/ffmpeg/gstffmpegenc.c12
2 files changed, 19 insertions, 7 deletions
diff --git a/ext/ffmpeg/gstffmpegdec.c b/ext/ffmpeg/gstffmpegdec.c
index 14033cd..f851719 100644
--- a/ext/ffmpeg/gstffmpegdec.c
+++ b/ext/ffmpeg/gstffmpegdec.c
@@ -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",
diff --git a/ext/ffmpeg/gstffmpegenc.c b/ext/ffmpeg/gstffmpegenc.c
index deab9cb..8e752c3 100644
--- a/ext/ffmpeg/gstffmpegenc.c
+++ b/ext/ffmpeg/gstffmpegenc.c
@@ -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 (