summaryrefslogtreecommitdiffstats
path: root/gst/videodrop
diff options
context:
space:
mode:
authorDavid Schleef <ds@schleef.org>2004-01-08 21:53:32 +0000
committerDavid Schleef <ds@schleef.org>2004-01-08 21:53:32 +0000
commit8c1615554b5941a3cebecf100b333fb51536b920 (patch)
tree673ed9a995b98e928aa9b550e2820eb9edb382c8 /gst/videodrop
parent3cf8cd02b137c74cf96e1b238004423507dcd403 (diff)
downloadgst-plugins-bad-8c1615554b5941a3cebecf100b333fb51536b920.tar.gz
gst-plugins-bad-8c1615554b5941a3cebecf100b333fb51536b920.tar.bz2
gst-plugins-bad-8c1615554b5941a3cebecf100b333fb51536b920.zip
Fix negotiation
Original commit message from CVS: Fix negotiation
Diffstat (limited to 'gst/videodrop')
-rw-r--r--gst/videodrop/gstvideodrop.c50
1 files changed, 49 insertions, 1 deletions
diff --git a/gst/videodrop/gstvideodrop.c b/gst/videodrop/gstvideodrop.c
index 05c23220..e3dd45a7 100644
--- a/gst/videodrop/gstvideodrop.c
+++ b/gst/videodrop/gstvideodrop.c
@@ -146,21 +146,67 @@ gst_videodrop_class_init (GstVideodropClass *klass)
name), \
min, max)
+static GstCaps *
+gst_videodrop_getcaps (GstPad *pad)
+{
+ GstVideodrop *videodrop;
+ GstPad *otherpad;
+ GstCaps *caps;
+ int i;
+ GstStructure *structure;
+
+ videodrop = GST_VIDEODROP (gst_pad_get_parent (pad));
+
+ otherpad = (pad == videodrop->srcpad) ? videodrop->sinkpad :
+ videodrop->srcpad;
+
+ caps = gst_pad_get_allowed_caps (otherpad);
+ for (i=0;i<gst_caps_get_size(caps);i++) {
+ structure = gst_caps_get_structure (caps, i);
+
+ gst_structure_set (structure,
+ "framerate", GST_TYPE_DOUBLE_RANGE, 0.0, G_MAXDOUBLE, NULL);
+ }
+
+ return caps;
+}
+
static GstPadLinkReturn
gst_videodrop_link (GstPad *pad, const GstCaps *caps)
{
GstVideodrop *videodrop;
GstStructure *structure;
+ GstPadLinkReturn link_ret;
gboolean ret;
double fps;
+ double otherfps;
+ GstPad *otherpad;
+ GstCaps *othercaps;
videodrop = GST_VIDEODROP (gst_pad_get_parent (pad));
+ otherpad = (pad == videodrop->srcpad) ? videodrop->sinkpad :
+ videodrop->srcpad;
+
structure = gst_caps_get_structure (caps, 0);
ret = gst_structure_get_double (structure, "framerate", &fps);
-
if (!ret) return GST_PAD_LINK_REFUSED;
+ if (gst_pad_is_negotiated (otherpad)) {
+ othercaps = gst_caps_copy (caps);
+ if (pad == videodrop->srcpad) {
+ otherfps = videodrop->from_fps;
+ } else {
+ otherfps = videodrop->to_fps;
+ }
+ gst_caps_set_simple (othercaps,
+ "framerate", G_TYPE_DOUBLE, otherfps, NULL);
+ link_ret = gst_pad_try_set_caps (otherpad, othercaps);
+ if (GST_PAD_LINK_FAILED (link_ret)) {
+ return link_ret;
+ }
+ }
+
if (pad == videodrop->srcpad) {
videodrop->to_fps = fps;
} else {
@@ -178,11 +224,13 @@ gst_videodrop_init (GstVideodrop *videodrop)
gst_static_pad_template_get (&gst_videodrop_sink_template), "sink");
gst_element_add_pad (GST_ELEMENT (videodrop), videodrop->sinkpad);
gst_pad_set_chain_function (videodrop->sinkpad, gst_videodrop_chain);
+ gst_pad_set_getcaps_function (videodrop->sinkpad, gst_videodrop_getcaps);
gst_pad_set_link_function (videodrop->sinkpad, gst_videodrop_link);
videodrop->srcpad = gst_pad_new_from_template (
gst_static_pad_template_get (&gst_videodrop_src_template), "src");
gst_element_add_pad (GST_ELEMENT(videodrop), videodrop->srcpad);
+ gst_pad_set_getcaps_function (videodrop->srcpad, gst_videodrop_getcaps);
gst_pad_set_link_function (videodrop->srcpad, gst_videodrop_link);
videodrop->inited = FALSE;