mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
Fix caps negotiation problems.
Original commit message from CVS: Fix caps negotiation problems.
This commit is contained in:
parent
214c557a6d
commit
906329ab04
2 changed files with 50 additions and 14 deletions
|
@ -125,6 +125,9 @@ gst_tee_sinklink (GstPad *pad, GstCaps *caps)
|
|||
GstTee *tee;
|
||||
const GList *pads;
|
||||
GstPadLinkReturn set_retval;
|
||||
GstCaps *caps1;
|
||||
|
||||
GST_DEBUG (0, "gst_tee_sinklink caps=%s", gst_caps_to_string(caps));
|
||||
|
||||
tee = GST_TEE (gst_pad_get_parent (pad));
|
||||
|
||||
|
@ -132,6 +135,11 @@ gst_tee_sinklink (GstPad *pad, GstCaps *caps)
|
|||
return GST_PAD_LINK_DELAYED;
|
||||
}
|
||||
|
||||
if (GST_CAPS_IS_CHAINED (caps)) {
|
||||
caps1 = gst_caps_copy_1(caps);
|
||||
caps = caps1;
|
||||
}
|
||||
|
||||
/* go through all the src pads */
|
||||
pads = gst_element_get_pad_list (GST_ELEMENT (tee));
|
||||
|
||||
|
@ -139,10 +147,10 @@ gst_tee_sinklink (GstPad *pad, GstCaps *caps)
|
|||
GstPad *outpad = GST_PAD (pads->data);
|
||||
pads = g_list_next (pads);
|
||||
|
||||
if (GST_PAD_DIRECTION (outpad) != GST_PAD_SRC || !GST_PAD_IS_USABLE (outpad))
|
||||
if (GST_PAD_DIRECTION (outpad) != GST_PAD_SRC || !GST_PAD_IS_LINKED (outpad))
|
||||
continue;
|
||||
|
||||
if ((set_retval = gst_pad_proxy_link (outpad, caps)) <= 0) {
|
||||
if ((set_retval = gst_pad_try_set_caps (outpad, caps)) <= 0) {
|
||||
return set_retval;
|
||||
}
|
||||
}
|
||||
|
@ -154,35 +162,44 @@ gst_tee_srclink (GstPad *pad, GstCaps *caps)
|
|||
{
|
||||
GstTee *tee;
|
||||
|
||||
GST_DEBUG (0, "gst_tee_srclink caps=%s", gst_caps_to_string(caps));
|
||||
|
||||
tee = GST_TEE (gst_pad_get_parent (pad));
|
||||
|
||||
return gst_pad_proxy_link (tee->sinkpad, caps);
|
||||
}
|
||||
|
||||
static GstCaps*
|
||||
gst_tee_sinkgetcaps (GstPad *pad, GstCaps *filter)
|
||||
gst_tee_getcaps (GstPad *pad, GstCaps *filter)
|
||||
{
|
||||
GstCaps *caps = NULL;
|
||||
GstTee *tee;
|
||||
const GList *pads;
|
||||
|
||||
GST_DEBUG (0, "gst_tee_getcaps");
|
||||
|
||||
tee = GST_TEE (gst_pad_get_parent (pad));
|
||||
|
||||
pads = gst_element_get_pad_list (GST_ELEMENT (tee));
|
||||
|
||||
while (pads) {
|
||||
GstPad *srcpad = GST_PAD_CAST (pads->data);
|
||||
GstPad *peer;
|
||||
GstCaps *peercaps;
|
||||
GstCaps *newcaps;
|
||||
|
||||
pads = g_list_next (pads);
|
||||
|
||||
if (!GST_PAD_IS_SRC (srcpad))
|
||||
peer = gst_pad_get_peer(srcpad);
|
||||
if(!peer){
|
||||
continue;
|
||||
}
|
||||
|
||||
peercaps = gst_pad_get_caps (srcpad);
|
||||
caps = gst_caps_intersect (caps, peercaps);
|
||||
peercaps = gst_pad_get_caps (peer);
|
||||
newcaps = gst_caps_intersect (caps, peercaps);
|
||||
gst_caps_unref (caps);
|
||||
gst_caps_unref (peercaps);
|
||||
caps = newcaps;
|
||||
}
|
||||
|
||||
return caps;
|
||||
|
@ -195,7 +212,7 @@ gst_tee_init (GstTee *tee)
|
|||
gst_element_add_pad (GST_ELEMENT (tee), tee->sinkpad);
|
||||
gst_pad_set_chain_function (tee->sinkpad, GST_DEBUG_FUNCPTR (gst_tee_chain));
|
||||
gst_pad_set_link_function (tee->sinkpad, GST_DEBUG_FUNCPTR (gst_tee_sinklink));
|
||||
gst_pad_set_getcaps_function (tee->sinkpad, GST_DEBUG_FUNCPTR (gst_tee_sinkgetcaps));
|
||||
gst_pad_set_getcaps_function (tee->sinkpad, GST_DEBUG_FUNCPTR (gst_tee_getcaps));
|
||||
|
||||
tee->silent = FALSE;
|
||||
tee->last_message = NULL;
|
||||
|
@ -254,6 +271,7 @@ gst_tee_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar
|
|||
srcpad = gst_pad_new_from_template (templ, name);
|
||||
g_free (name);
|
||||
gst_pad_set_link_function (srcpad, GST_DEBUG_FUNCPTR (gst_tee_srclink));
|
||||
gst_pad_set_getcaps_function (srcpad, GST_DEBUG_FUNCPTR (gst_tee_getcaps));
|
||||
gst_element_add_pad (GST_ELEMENT (tee), srcpad);
|
||||
GST_PAD_ELEMENT_PRIVATE (srcpad) = NULL;
|
||||
|
||||
|
|
|
@ -125,6 +125,9 @@ gst_tee_sinklink (GstPad *pad, GstCaps *caps)
|
|||
GstTee *tee;
|
||||
const GList *pads;
|
||||
GstPadLinkReturn set_retval;
|
||||
GstCaps *caps1;
|
||||
|
||||
GST_DEBUG (0, "gst_tee_sinklink caps=%s", gst_caps_to_string(caps));
|
||||
|
||||
tee = GST_TEE (gst_pad_get_parent (pad));
|
||||
|
||||
|
@ -132,6 +135,11 @@ gst_tee_sinklink (GstPad *pad, GstCaps *caps)
|
|||
return GST_PAD_LINK_DELAYED;
|
||||
}
|
||||
|
||||
if (GST_CAPS_IS_CHAINED (caps)) {
|
||||
caps1 = gst_caps_copy_1(caps);
|
||||
caps = caps1;
|
||||
}
|
||||
|
||||
/* go through all the src pads */
|
||||
pads = gst_element_get_pad_list (GST_ELEMENT (tee));
|
||||
|
||||
|
@ -139,10 +147,10 @@ gst_tee_sinklink (GstPad *pad, GstCaps *caps)
|
|||
GstPad *outpad = GST_PAD (pads->data);
|
||||
pads = g_list_next (pads);
|
||||
|
||||
if (GST_PAD_DIRECTION (outpad) != GST_PAD_SRC || !GST_PAD_IS_USABLE (outpad))
|
||||
if (GST_PAD_DIRECTION (outpad) != GST_PAD_SRC || !GST_PAD_IS_LINKED (outpad))
|
||||
continue;
|
||||
|
||||
if ((set_retval = gst_pad_proxy_link (outpad, caps)) <= 0) {
|
||||
if ((set_retval = gst_pad_try_set_caps (outpad, caps)) <= 0) {
|
||||
return set_retval;
|
||||
}
|
||||
}
|
||||
|
@ -154,35 +162,44 @@ gst_tee_srclink (GstPad *pad, GstCaps *caps)
|
|||
{
|
||||
GstTee *tee;
|
||||
|
||||
GST_DEBUG (0, "gst_tee_srclink caps=%s", gst_caps_to_string(caps));
|
||||
|
||||
tee = GST_TEE (gst_pad_get_parent (pad));
|
||||
|
||||
return gst_pad_proxy_link (tee->sinkpad, caps);
|
||||
}
|
||||
|
||||
static GstCaps*
|
||||
gst_tee_sinkgetcaps (GstPad *pad, GstCaps *filter)
|
||||
gst_tee_getcaps (GstPad *pad, GstCaps *filter)
|
||||
{
|
||||
GstCaps *caps = NULL;
|
||||
GstTee *tee;
|
||||
const GList *pads;
|
||||
|
||||
GST_DEBUG (0, "gst_tee_getcaps");
|
||||
|
||||
tee = GST_TEE (gst_pad_get_parent (pad));
|
||||
|
||||
pads = gst_element_get_pad_list (GST_ELEMENT (tee));
|
||||
|
||||
while (pads) {
|
||||
GstPad *srcpad = GST_PAD_CAST (pads->data);
|
||||
GstPad *peer;
|
||||
GstCaps *peercaps;
|
||||
GstCaps *newcaps;
|
||||
|
||||
pads = g_list_next (pads);
|
||||
|
||||
if (!GST_PAD_IS_SRC (srcpad))
|
||||
peer = gst_pad_get_peer(srcpad);
|
||||
if(!peer){
|
||||
continue;
|
||||
}
|
||||
|
||||
peercaps = gst_pad_get_caps (srcpad);
|
||||
caps = gst_caps_intersect (caps, peercaps);
|
||||
peercaps = gst_pad_get_caps (peer);
|
||||
newcaps = gst_caps_intersect (caps, peercaps);
|
||||
gst_caps_unref (caps);
|
||||
gst_caps_unref (peercaps);
|
||||
caps = newcaps;
|
||||
}
|
||||
|
||||
return caps;
|
||||
|
@ -195,7 +212,7 @@ gst_tee_init (GstTee *tee)
|
|||
gst_element_add_pad (GST_ELEMENT (tee), tee->sinkpad);
|
||||
gst_pad_set_chain_function (tee->sinkpad, GST_DEBUG_FUNCPTR (gst_tee_chain));
|
||||
gst_pad_set_link_function (tee->sinkpad, GST_DEBUG_FUNCPTR (gst_tee_sinklink));
|
||||
gst_pad_set_getcaps_function (tee->sinkpad, GST_DEBUG_FUNCPTR (gst_tee_sinkgetcaps));
|
||||
gst_pad_set_getcaps_function (tee->sinkpad, GST_DEBUG_FUNCPTR (gst_tee_getcaps));
|
||||
|
||||
tee->silent = FALSE;
|
||||
tee->last_message = NULL;
|
||||
|
@ -254,6 +271,7 @@ gst_tee_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar
|
|||
srcpad = gst_pad_new_from_template (templ, name);
|
||||
g_free (name);
|
||||
gst_pad_set_link_function (srcpad, GST_DEBUG_FUNCPTR (gst_tee_srclink));
|
||||
gst_pad_set_getcaps_function (srcpad, GST_DEBUG_FUNCPTR (gst_tee_getcaps));
|
||||
gst_element_add_pad (GST_ELEMENT (tee), srcpad);
|
||||
GST_PAD_ELEMENT_PRIVATE (srcpad) = NULL;
|
||||
|
||||
|
|
Loading…
Reference in a new issue