diff options
author | David Schleef <ds@schleef.org> | 2004-01-08 21:53:32 +0000 |
---|---|---|
committer | David Schleef <ds@schleef.org> | 2004-01-08 21:53:32 +0000 |
commit | 8c1615554b5941a3cebecf100b333fb51536b920 (patch) | |
tree | 673ed9a995b98e928aa9b550e2820eb9edb382c8 /gst | |
parent | 3cf8cd02b137c74cf96e1b238004423507dcd403 (diff) |
Fix negotiation
Original commit message from CVS:
Fix negotiation
Diffstat (limited to 'gst')
-rw-r--r-- | gst/videodrop/gstvideodrop.c | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/gst/videodrop/gstvideodrop.c b/gst/videodrop/gstvideodrop.c index 05c232209..e3dd45a75 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; |