mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 03:35:21 +00:00
videorate: Update for negotiation related API changes
This commit is contained in:
parent
7330318e2f
commit
e21ec369f0
1 changed files with 38 additions and 20 deletions
|
@ -200,7 +200,7 @@ gst_video_rate_class_init (GstVideoRateClass * klass)
|
||||||
/* return the caps that can be used on out_pad given in_caps on in_pad */
|
/* return the caps that can be used on out_pad given in_caps on in_pad */
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_video_rate_transformcaps (GstPad * in_pad, GstCaps * in_caps,
|
gst_video_rate_transformcaps (GstPad * in_pad, GstCaps * in_caps,
|
||||||
GstPad * out_pad, GstCaps ** out_caps)
|
GstPad * out_pad, GstCaps ** out_caps, GstCaps * filter)
|
||||||
{
|
{
|
||||||
GstCaps *intersect;
|
GstCaps *intersect;
|
||||||
const GstCaps *in_templ;
|
const GstCaps *in_templ;
|
||||||
|
@ -209,7 +209,8 @@ gst_video_rate_transformcaps (GstPad * in_pad, GstCaps * in_caps,
|
||||||
GSList *iter;
|
GSList *iter;
|
||||||
|
|
||||||
in_templ = gst_pad_get_pad_template_caps (in_pad);
|
in_templ = gst_pad_get_pad_template_caps (in_pad);
|
||||||
intersect = gst_caps_intersect (in_caps, in_templ);
|
intersect =
|
||||||
|
gst_caps_intersect_full (in_caps, in_templ, GST_CAPS_INTERSECT_FIRST);
|
||||||
|
|
||||||
/* all possible framerates are allowed */
|
/* all possible framerates are allowed */
|
||||||
for (i = 0; i < gst_caps_get_size (intersect); i++) {
|
for (i = 0; i < gst_caps_get_size (intersect); i++) {
|
||||||
|
@ -233,13 +234,21 @@ gst_video_rate_transformcaps (GstPad * in_pad, GstCaps * in_caps,
|
||||||
}
|
}
|
||||||
g_slist_free (extra_structures);
|
g_slist_free (extra_structures);
|
||||||
|
|
||||||
|
if (filter) {
|
||||||
|
GstCaps *tmp;
|
||||||
|
|
||||||
|
tmp = gst_caps_intersect_full (filter, intersect, GST_CAPS_INTERSECT_FIRST);
|
||||||
|
gst_caps_unref (intersect);
|
||||||
|
intersect = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
*out_caps = intersect;
|
*out_caps = intersect;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstCaps *
|
static GstCaps *
|
||||||
gst_video_rate_getcaps (GstPad * pad)
|
gst_video_rate_getcaps (GstPad * pad, GstCaps * filter)
|
||||||
{
|
{
|
||||||
GstVideoRate *videorate;
|
GstVideoRate *videorate;
|
||||||
GstPad *otherpad;
|
GstPad *otherpad;
|
||||||
|
@ -251,16 +260,31 @@ gst_video_rate_getcaps (GstPad * pad)
|
||||||
videorate->srcpad;
|
videorate->srcpad;
|
||||||
|
|
||||||
/* we can do what the peer can */
|
/* we can do what the peer can */
|
||||||
caps = gst_pad_peer_get_caps (otherpad);
|
caps = gst_pad_peer_get_caps (otherpad, filter);
|
||||||
if (caps) {
|
if (caps) {
|
||||||
GstCaps *transform;
|
GstCaps *transform, *intersect;
|
||||||
|
|
||||||
gst_video_rate_transformcaps (otherpad, caps, pad, &transform);
|
gst_video_rate_transformcaps (otherpad, caps, pad, &transform, filter);
|
||||||
gst_caps_unref (caps);
|
|
||||||
caps = transform;
|
/* Now prefer the downstream caps if possible */
|
||||||
|
intersect =
|
||||||
|
gst_caps_intersect_full (caps, transform, GST_CAPS_INTERSECT_FIRST);
|
||||||
|
if (!gst_caps_is_empty (intersect)) {
|
||||||
|
gst_caps_append (intersect, transform);
|
||||||
|
gst_caps_unref (caps);
|
||||||
|
caps = intersect;
|
||||||
|
} else {
|
||||||
|
gst_caps_unref (intersect);
|
||||||
|
caps = transform;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
/* no peer, our padtemplate is enough then */
|
/* no peer, our padtemplate is enough then */
|
||||||
caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
|
if (filter)
|
||||||
|
caps =
|
||||||
|
gst_caps_intersect_full (filter, gst_pad_get_pad_template_caps (pad),
|
||||||
|
GST_CAPS_INTERSECT_FIRST);
|
||||||
|
else
|
||||||
|
caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
|
||||||
}
|
}
|
||||||
|
|
||||||
return caps;
|
return caps;
|
||||||
|
@ -313,27 +337,20 @@ gst_video_rate_setcaps (GstPad * pad, GstCaps * caps)
|
||||||
|
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
} else {
|
} else {
|
||||||
GstCaps *peercaps;
|
|
||||||
GstCaps *transform = NULL;
|
GstCaps *transform = NULL;
|
||||||
|
|
||||||
ret = FALSE;
|
ret = FALSE;
|
||||||
|
|
||||||
/* see how we can transform the input caps */
|
/* see how we can transform the input caps */
|
||||||
if (!gst_video_rate_transformcaps (pad, caps, otherpad, &transform))
|
if (!gst_video_rate_transformcaps (pad, caps, otherpad, &transform, NULL))
|
||||||
goto no_transform;
|
goto no_transform;
|
||||||
|
|
||||||
/* see what the peer can do */
|
|
||||||
peercaps = gst_pad_get_caps (opeer);
|
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (opeer, "icaps %" GST_PTR_FORMAT, peercaps);
|
|
||||||
GST_DEBUG_OBJECT (videorate, "transform %" GST_PTR_FORMAT, transform);
|
GST_DEBUG_OBJECT (videorate, "transform %" GST_PTR_FORMAT, transform);
|
||||||
|
|
||||||
/* filter against our possibilities */
|
/* see what the peer can do */
|
||||||
caps = gst_caps_intersect (peercaps, transform);
|
caps = gst_pad_get_caps (opeer, transform);
|
||||||
gst_caps_unref (peercaps);
|
|
||||||
gst_caps_unref (transform);
|
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (videorate, "intersect %" GST_PTR_FORMAT, caps);
|
GST_DEBUG_OBJECT (opeer, "icaps %" GST_PTR_FORMAT, caps);
|
||||||
|
|
||||||
/* could turn up empty, due to e.g. colorspace etc */
|
/* could turn up empty, due to e.g. colorspace etc */
|
||||||
if (gst_caps_get_size (caps) == 0) {
|
if (gst_caps_get_size (caps) == 0) {
|
||||||
|
@ -342,6 +359,7 @@ gst_video_rate_setcaps (GstPad * pad, GstCaps * caps)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* take first possibility */
|
/* take first possibility */
|
||||||
|
caps = gst_caps_make_writable (caps);
|
||||||
gst_caps_truncate (caps);
|
gst_caps_truncate (caps);
|
||||||
structure = gst_caps_get_structure (caps, 0);
|
structure = gst_caps_get_structure (caps, 0);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue