mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-06 14:32:31 +00:00
videomixer: Don't return caps in get_caps() that will be rejected
This commit basically puts _get_caps() in sync with accept_caps(). If we don't have a master pad OR the master pad caps aren't negotiated then we just return the downstream allowed caps. If we have a master pad with negotiated caps, we return those caps with a free range of width/height/framerate
This commit is contained in:
parent
5072c47624
commit
d72a2fb6da
1 changed files with 26 additions and 32 deletions
|
@ -380,8 +380,7 @@ gst_videomixer_pad_sink_getcaps (GstPad * pad)
|
||||||
GstVideoMixer *mix;
|
GstVideoMixer *mix;
|
||||||
GstVideoMixerPad *mixpad;
|
GstVideoMixerPad *mixpad;
|
||||||
GstCaps *res = NULL;
|
GstCaps *res = NULL;
|
||||||
GstCaps *tmp;
|
GstCaps *mastercaps;
|
||||||
int ncaps, i;
|
|
||||||
GstStructure *st;
|
GstStructure *st;
|
||||||
|
|
||||||
mix = GST_VIDEO_MIXER (gst_pad_get_parent (pad));
|
mix = GST_VIDEO_MIXER (gst_pad_get_parent (pad));
|
||||||
|
@ -390,41 +389,36 @@ gst_videomixer_pad_sink_getcaps (GstPad * pad)
|
||||||
if (!mixpad)
|
if (!mixpad)
|
||||||
goto beach;
|
goto beach;
|
||||||
|
|
||||||
tmp = gst_pad_peer_get_caps (mix->srcpad);
|
/* Get downstream allowed caps */
|
||||||
if (G_UNLIKELY (tmp == NULL)) {
|
res = gst_pad_get_allowed_caps (mix->srcpad);
|
||||||
/* If no peer, then return template */
|
|
||||||
res = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
|
GST_VIDEO_MIXER_STATE_LOCK (mix);
|
||||||
|
|
||||||
|
/* Return as-is if not other sinkpad set as master */
|
||||||
|
if (mix->master == NULL) {
|
||||||
|
GST_VIDEO_MIXER_STATE_UNLOCK (mix);
|
||||||
goto beach;
|
goto beach;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Intersect with template caps, downstream might be returning formats
|
mastercaps = gst_pad_get_fixed_caps_func (GST_PAD (mix->master));
|
||||||
* or width/height/framerate/par combinations we don't handle */
|
|
||||||
res = gst_caps_intersect (tmp, gst_pad_get_pad_template_caps (pad));
|
|
||||||
gst_caps_unref (tmp);
|
|
||||||
|
|
||||||
ncaps = gst_caps_get_size (res);
|
/* If master pad caps aren't negotiated yet, return downstream
|
||||||
|
* allowed caps */
|
||||||
/* This Upstream can only produce:
|
if (!GST_CAPS_IS_SIMPLE (mastercaps)) {
|
||||||
* * The formats that downstream can do (intersected above)
|
GST_VIDEO_MIXER_STATE_UNLOCK (mix);
|
||||||
* * The PAR that downstream can do
|
gst_caps_unref (mastercaps);
|
||||||
* * Width within the maximum of what downstream can do
|
goto beach;
|
||||||
* * Height within the maximum of what downstream can do
|
|
||||||
* * a framerate at least greater than what downstream can do */
|
|
||||||
|
|
||||||
GST_VIDEO_MIXER_STATE_LOCK (mix);
|
|
||||||
if (mix->out_width) {
|
|
||||||
/* If we already have some configured with/height/framerate/par,
|
|
||||||
* then limit the returned caps */
|
|
||||||
for (i = 0; i < ncaps; i++) {
|
|
||||||
st = gst_caps_get_structure (res, i);
|
|
||||||
gst_structure_set (st,
|
|
||||||
"width", GST_TYPE_INT_RANGE, mix->in_width, G_MAXINT32,
|
|
||||||
"height", GST_TYPE_INT_RANGE, mix->in_height, G_MAXINT32,
|
|
||||||
"framerate", GST_TYPE_FRACTION_RANGE, mix->fps_n, mix->fps_d,
|
|
||||||
G_MAXINT32, 1, "pixel-aspect-ratio", GST_TYPE_FRACTION, mix->par_n,
|
|
||||||
mix->par_d, NULL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gst_caps_unref (res);
|
||||||
|
res = gst_caps_make_writable (mastercaps);
|
||||||
|
st = gst_caps_get_structure (res, 0);
|
||||||
|
gst_structure_set (st, "width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
|
||||||
|
"height", GST_TYPE_INT_RANGE, 1, G_MAXINT,
|
||||||
|
"framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
|
||||||
|
if (!gst_structure_has_field (st, "pixel-aspect-ratio"))
|
||||||
|
gst_structure_set (st, "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1, NULL);
|
||||||
|
|
||||||
GST_VIDEO_MIXER_STATE_UNLOCK (mix);
|
GST_VIDEO_MIXER_STATE_UNLOCK (mix);
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue