mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
gst/gstpad.c: Added simple version of improved caps checking. It was previously assumed that a setcaps function would...
Original commit message from CVS: * gst/gstpad.c: (gst_pad_get_caps_unlocked), (gst_pad_acceptcaps_default), (gst_pad_configure_sink), (gst_pad_configure_src): Added simple version of improved caps checking. It was previously assumed that a setcaps function would check the validity of the caps but people prefer us to check caps against the template automatically. Fixes #421543.
This commit is contained in:
parent
caa1b7d068
commit
fc32cd9c98
2 changed files with 25 additions and 22 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2007-05-21 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
|
* gst/gstpad.c: (gst_pad_get_caps_unlocked),
|
||||||
|
(gst_pad_acceptcaps_default), (gst_pad_configure_sink),
|
||||||
|
(gst_pad_configure_src):
|
||||||
|
Added simple version of improved caps checking. It was previously
|
||||||
|
assumed that a setcaps function would check the validity of the caps but
|
||||||
|
people prefer us to check caps against the template automatically.
|
||||||
|
Fixes #421543.
|
||||||
|
|
||||||
2007-05-21 Wim Taymans <wim@fluendo.com>
|
2007-05-21 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
* libs/gst/base/gstbasetransform.h:
|
* libs/gst/base/gstbasetransform.h:
|
||||||
|
|
37
gst/gstpad.c
37
gst/gstpad.c
|
@ -1954,6 +1954,7 @@ static GstCaps *
|
||||||
gst_pad_get_caps_unlocked (GstPad * pad)
|
gst_pad_get_caps_unlocked (GstPad * pad)
|
||||||
{
|
{
|
||||||
GstCaps *result = NULL;
|
GstCaps *result = NULL;
|
||||||
|
GstPadTemplate *templ;
|
||||||
|
|
||||||
GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, pad, "get pad caps");
|
GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, pad, "get pad caps");
|
||||||
|
|
||||||
|
@ -1997,9 +1998,7 @@ gst_pad_get_caps_unlocked (GstPad * pad)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (GST_PAD_PAD_TEMPLATE (pad)) {
|
if ((templ = GST_PAD_PAD_TEMPLATE (pad))) {
|
||||||
GstPadTemplate *templ = GST_PAD_PAD_TEMPLATE (pad);
|
|
||||||
|
|
||||||
result = GST_PAD_TEMPLATE_CAPS (templ);
|
result = GST_PAD_TEMPLATE_CAPS (templ);
|
||||||
GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, pad,
|
GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, pad,
|
||||||
"using pad template %p with caps %p %" GST_PTR_FORMAT, templ, result,
|
"using pad template %p with caps %p %" GST_PTR_FORMAT, templ, result,
|
||||||
|
@ -2008,9 +2007,7 @@ gst_pad_get_caps_unlocked (GstPad * pad)
|
||||||
result = gst_caps_ref (result);
|
result = gst_caps_ref (result);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (GST_PAD_CAPS (pad)) {
|
if ((result = GST_PAD_CAPS (pad))) {
|
||||||
result = GST_PAD_CAPS (pad);
|
|
||||||
|
|
||||||
GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, pad,
|
GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, pad,
|
||||||
"using pad caps %p %" GST_PTR_FORMAT, result, result);
|
"using pad caps %p %" GST_PTR_FORMAT, result, result);
|
||||||
|
|
||||||
|
@ -2203,12 +2200,18 @@ gst_pad_acceptcaps_default (GstPad * pad, GstCaps * caps)
|
||||||
GstCaps *allowed;
|
GstCaps *allowed;
|
||||||
gboolean result = FALSE;
|
gboolean result = FALSE;
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (pad, "caps %" GST_PTR_FORMAT, caps);
|
||||||
|
|
||||||
allowed = gst_pad_get_caps (pad);
|
allowed = gst_pad_get_caps (pad);
|
||||||
if (!allowed)
|
if (!allowed)
|
||||||
goto nothing_allowed;
|
goto nothing_allowed;
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (pad, "allowed caps %" GST_PTR_FORMAT, allowed);
|
||||||
|
|
||||||
intersect = gst_caps_intersect (allowed, caps);
|
intersect = gst_caps_intersect (allowed, caps);
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (pad, "intersection %" GST_PTR_FORMAT, intersect);
|
||||||
|
|
||||||
result = !gst_caps_is_empty (intersect);
|
result = !gst_caps_is_empty (intersect);
|
||||||
if (!result)
|
if (!result)
|
||||||
GST_DEBUG_OBJECT (pad, "intersection gave empty caps");
|
GST_DEBUG_OBJECT (pad, "intersection gave empty caps");
|
||||||
|
@ -2404,16 +2407,11 @@ could_not_set:
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_pad_configure_sink (GstPad * pad, GstCaps * caps)
|
gst_pad_configure_sink (GstPad * pad, GstCaps * caps)
|
||||||
{
|
{
|
||||||
GstPadSetCapsFunction setcaps;
|
|
||||||
gboolean res;
|
gboolean res;
|
||||||
|
|
||||||
setcaps = GST_PAD_SETCAPSFUNC (pad);
|
/* See if pad accepts the caps */
|
||||||
|
if (!gst_pad_accept_caps (pad, caps))
|
||||||
/* See if pad accepts the caps - only needed if
|
goto not_accepted;
|
||||||
* no setcaps function */
|
|
||||||
if (setcaps == NULL)
|
|
||||||
if (!gst_pad_accept_caps (pad, caps))
|
|
||||||
goto not_accepted;
|
|
||||||
|
|
||||||
/* set caps on pad if call succeeds */
|
/* set caps on pad if call succeeds */
|
||||||
res = gst_pad_set_caps (pad, caps);
|
res = gst_pad_set_caps (pad, caps);
|
||||||
|
@ -2434,16 +2432,11 @@ not_accepted:
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_pad_configure_src (GstPad * pad, GstCaps * caps, gboolean dosetcaps)
|
gst_pad_configure_src (GstPad * pad, GstCaps * caps, gboolean dosetcaps)
|
||||||
{
|
{
|
||||||
GstPadSetCapsFunction setcaps;
|
|
||||||
gboolean res;
|
gboolean res;
|
||||||
|
|
||||||
setcaps = GST_PAD_SETCAPSFUNC (pad);
|
/* See if pad accepts the caps */
|
||||||
|
if (!gst_pad_accept_caps (pad, caps))
|
||||||
/* See if pad accepts the caps - only needed if
|
goto not_accepted;
|
||||||
* no setcaps function */
|
|
||||||
if (setcaps == NULL)
|
|
||||||
if (!gst_pad_accept_caps (pad, caps))
|
|
||||||
goto not_accepted;
|
|
||||||
|
|
||||||
if (dosetcaps)
|
if (dosetcaps)
|
||||||
res = gst_pad_set_caps (pad, caps);
|
res = gst_pad_set_caps (pad, caps);
|
||||||
|
|
Loading…
Reference in a new issue