Fix caps negotiation problems.

Original commit message from CVS:
Fix caps negotiation problems.
This commit is contained in:
David Schleef 2003-05-19 02:36:01 +00:00
parent 214c557a6d
commit 906329ab04
2 changed files with 50 additions and 14 deletions

View file

@ -125,13 +125,21 @@ gst_tee_sinklink (GstPad *pad, GstCaps *caps)
GstTee *tee; GstTee *tee;
const GList *pads; const GList *pads;
GstPadLinkReturn set_retval; 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)); tee = GST_TEE (gst_pad_get_parent (pad));
if (!GST_CAPS_IS_FIXED (caps)) { if (!GST_CAPS_IS_FIXED (caps)) {
return GST_PAD_LINK_DELAYED; 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 */ /* go through all the src pads */
pads = gst_element_get_pad_list (GST_ELEMENT (tee)); 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); GstPad *outpad = GST_PAD (pads->data);
pads = g_list_next (pads); 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; 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; return set_retval;
} }
} }
@ -154,35 +162,44 @@ gst_tee_srclink (GstPad *pad, GstCaps *caps)
{ {
GstTee *tee; GstTee *tee;
GST_DEBUG (0, "gst_tee_srclink caps=%s", gst_caps_to_string(caps));
tee = GST_TEE (gst_pad_get_parent (pad)); tee = GST_TEE (gst_pad_get_parent (pad));
return gst_pad_proxy_link (tee->sinkpad, caps); return gst_pad_proxy_link (tee->sinkpad, caps);
} }
static GstCaps* static GstCaps*
gst_tee_sinkgetcaps (GstPad *pad, GstCaps *filter) gst_tee_getcaps (GstPad *pad, GstCaps *filter)
{ {
GstCaps *caps = NULL; GstCaps *caps = NULL;
GstTee *tee; GstTee *tee;
const GList *pads; const GList *pads;
GST_DEBUG (0, "gst_tee_getcaps");
tee = GST_TEE (gst_pad_get_parent (pad)); tee = GST_TEE (gst_pad_get_parent (pad));
pads = gst_element_get_pad_list (GST_ELEMENT (tee)); pads = gst_element_get_pad_list (GST_ELEMENT (tee));
while (pads) { while (pads) {
GstPad *srcpad = GST_PAD_CAST (pads->data); GstPad *srcpad = GST_PAD_CAST (pads->data);
GstPad *peer;
GstCaps *peercaps; GstCaps *peercaps;
GstCaps *newcaps;
pads = g_list_next (pads); pads = g_list_next (pads);
if (!GST_PAD_IS_SRC (srcpad)) peer = gst_pad_get_peer(srcpad);
if(!peer){
continue; continue;
}
peercaps = gst_pad_get_caps (srcpad); peercaps = gst_pad_get_caps (peer);
caps = gst_caps_intersect (caps, peercaps); newcaps = gst_caps_intersect (caps, peercaps);
gst_caps_unref (caps); gst_caps_unref (caps);
gst_caps_unref (peercaps); gst_caps_unref (peercaps);
caps = newcaps;
} }
return caps; return caps;
@ -195,7 +212,7 @@ gst_tee_init (GstTee *tee)
gst_element_add_pad (GST_ELEMENT (tee), tee->sinkpad); 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_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_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->silent = FALSE;
tee->last_message = NULL; 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); srcpad = gst_pad_new_from_template (templ, name);
g_free (name); g_free (name);
gst_pad_set_link_function (srcpad, GST_DEBUG_FUNCPTR (gst_tee_srclink)); 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_element_add_pad (GST_ELEMENT (tee), srcpad);
GST_PAD_ELEMENT_PRIVATE (srcpad) = NULL; GST_PAD_ELEMENT_PRIVATE (srcpad) = NULL;

View file

@ -125,13 +125,21 @@ gst_tee_sinklink (GstPad *pad, GstCaps *caps)
GstTee *tee; GstTee *tee;
const GList *pads; const GList *pads;
GstPadLinkReturn set_retval; 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)); tee = GST_TEE (gst_pad_get_parent (pad));
if (!GST_CAPS_IS_FIXED (caps)) { if (!GST_CAPS_IS_FIXED (caps)) {
return GST_PAD_LINK_DELAYED; 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 */ /* go through all the src pads */
pads = gst_element_get_pad_list (GST_ELEMENT (tee)); 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); GstPad *outpad = GST_PAD (pads->data);
pads = g_list_next (pads); 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; 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; return set_retval;
} }
} }
@ -154,35 +162,44 @@ gst_tee_srclink (GstPad *pad, GstCaps *caps)
{ {
GstTee *tee; GstTee *tee;
GST_DEBUG (0, "gst_tee_srclink caps=%s", gst_caps_to_string(caps));
tee = GST_TEE (gst_pad_get_parent (pad)); tee = GST_TEE (gst_pad_get_parent (pad));
return gst_pad_proxy_link (tee->sinkpad, caps); return gst_pad_proxy_link (tee->sinkpad, caps);
} }
static GstCaps* static GstCaps*
gst_tee_sinkgetcaps (GstPad *pad, GstCaps *filter) gst_tee_getcaps (GstPad *pad, GstCaps *filter)
{ {
GstCaps *caps = NULL; GstCaps *caps = NULL;
GstTee *tee; GstTee *tee;
const GList *pads; const GList *pads;
GST_DEBUG (0, "gst_tee_getcaps");
tee = GST_TEE (gst_pad_get_parent (pad)); tee = GST_TEE (gst_pad_get_parent (pad));
pads = gst_element_get_pad_list (GST_ELEMENT (tee)); pads = gst_element_get_pad_list (GST_ELEMENT (tee));
while (pads) { while (pads) {
GstPad *srcpad = GST_PAD_CAST (pads->data); GstPad *srcpad = GST_PAD_CAST (pads->data);
GstPad *peer;
GstCaps *peercaps; GstCaps *peercaps;
GstCaps *newcaps;
pads = g_list_next (pads); pads = g_list_next (pads);
if (!GST_PAD_IS_SRC (srcpad)) peer = gst_pad_get_peer(srcpad);
if(!peer){
continue; continue;
}
peercaps = gst_pad_get_caps (srcpad); peercaps = gst_pad_get_caps (peer);
caps = gst_caps_intersect (caps, peercaps); newcaps = gst_caps_intersect (caps, peercaps);
gst_caps_unref (caps); gst_caps_unref (caps);
gst_caps_unref (peercaps); gst_caps_unref (peercaps);
caps = newcaps;
} }
return caps; return caps;
@ -195,7 +212,7 @@ gst_tee_init (GstTee *tee)
gst_element_add_pad (GST_ELEMENT (tee), tee->sinkpad); 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_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_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->silent = FALSE;
tee->last_message = NULL; 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); srcpad = gst_pad_new_from_template (templ, name);
g_free (name); g_free (name);
gst_pad_set_link_function (srcpad, GST_DEBUG_FUNCPTR (gst_tee_srclink)); 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_element_add_pad (GST_ELEMENT (tee), srcpad);
GST_PAD_ELEMENT_PRIVATE (srcpad) = NULL; GST_PAD_ELEMENT_PRIVATE (srcpad) = NULL;