Commit e5ed718c authored by Andy Wingo's avatar Andy Wingo
Browse files

changes to spider: add padtemplates so the connect functions can connect two...

changes to spider: add padtemplates so the connect functions can connect two request-pad elements add a hack in gstel...

Original commit message from CVS:
* changes to spider:
* add padtemplates so the connect functions can connect two request-pad
elements
* add a hack in gstelement.c. please look at this, Company, and see how
we can get around this
* add backwards caps-propagation support in identity, int2float, float2int,
adder, speed, volume
parent 0ba838f9
...@@ -138,18 +138,10 @@ gst_adder_get_type(void) { ...@@ -138,18 +138,10 @@ gst_adder_get_type(void) {
return adder_type; return adder_type;
} }
static GstPadConnectReturn static gboolean
gst_adder_sinkpad_connect (GstPad *pad, GstCaps *caps) gst_adder_parse_caps (GstAdder *adder, GstCaps *caps)
{ {
const gchar *format; const gchar *format = gst_caps_get_string (caps, "format");
GstAdder *adder;
g_return_val_if_fail (caps != NULL, GST_PAD_CONNECT_DELAYED);
g_return_val_if_fail (pad != NULL, GST_PAD_CONNECT_DELAYED);
adder = GST_ADDER (GST_PAD_PARENT (pad));
format = gst_caps_get_string (caps, "format");
if (adder->format == GST_ADDER_FORMAT_UNSET) { if (adder->format == GST_ADDER_FORMAT_UNSET) {
/* the caps haven't been set yet at all, so we need to go ahead and set all /* the caps haven't been set yet at all, so we need to go ahead and set all
...@@ -174,25 +166,57 @@ gst_adder_sinkpad_connect (GstPad *pad, GstCaps *caps) ...@@ -174,25 +166,57 @@ gst_adder_sinkpad_connect (GstPad *pad, GstCaps *caps)
if ((adder->format != GST_ADDER_FORMAT_INT) || if ((adder->format != GST_ADDER_FORMAT_INT) ||
(adder->width != gst_caps_get_int (caps, "width")) || (adder->width != gst_caps_get_int (caps, "width")) ||
(adder->is_signed != gst_caps_get_int (caps, "signed"))) { (adder->is_signed != gst_caps_get_int (caps, "signed"))) {
return GST_PAD_CONNECT_REFUSED; return FALSE;
} }
} else if (strcmp (format, "float") == 0) { } else if (strcmp (format, "float") == 0) {
if (adder->format != GST_ADDER_FORMAT_FLOAT) { if (adder->format != GST_ADDER_FORMAT_FLOAT) {
return GST_PAD_CONNECT_REFUSED; return FALSE;
} }
} else { } else {
/* whoa, we don't know what's trying to connect with us ! barf ! */ /* whoa, we don't know what's trying to connect with us ! barf ! */
return GST_PAD_CONNECT_REFUSED; return FALSE;
} }
} }
return TRUE;
}
static GstPadConnectReturn
gst_adder_connect (GstPad *pad, GstCaps *caps)
{
GstAdder *adder;
GList *sinkpads;
GstPad *p;
g_return_val_if_fail (caps != NULL, GST_PAD_CONNECT_REFUSED);
g_return_val_if_fail (pad != NULL, GST_PAD_CONNECT_REFUSED);
adder = GST_ADDER (GST_PAD_PARENT (pad));
if (GST_CAPS_IS_FIXED (caps)) if (GST_CAPS_IS_FIXED (caps)) {
if (gst_pad_try_set_caps (adder->srcpad, caps)) if (!gst_adder_parse_caps (adder, caps))
return GST_PAD_CONNECT_REFUSED;
if (pad == adder->srcpad || gst_pad_try_set_caps (adder->srcpad, caps)) {
sinkpads = gst_element_get_pad_list ((GstElement*) adder);
while (sinkpads) {
p = (GstPad*) sinkpads->data;
if (p != pad && p != adder->srcpad) {
if (!gst_pad_try_set_caps (p, caps)) {
GST_DEBUG (0, "caps mismatch; disconnecting and removing pad %s:%s (peer %s:%s)\n",
GST_DEBUG_PAD_NAME (p), GST_DEBUG_PAD_NAME (GST_PAD_PEER (p)));
gst_pad_disconnect (GST_PAD (GST_PAD_PEER (p)), p);
gst_element_remove_pad (GST_ELEMENT (adder), p);
}
}
sinkpads = g_list_next (sinkpads);
}
return GST_PAD_CONNECT_OK; return GST_PAD_CONNECT_OK;
else } else {
return GST_PAD_CONNECT_REFUSED; return GST_PAD_CONNECT_REFUSED;
else }
} else {
return GST_PAD_CONNECT_DELAYED; return GST_PAD_CONNECT_DELAYED;
}
} }
static void static void
...@@ -221,6 +245,7 @@ gst_adder_init (GstAdder *adder) ...@@ -221,6 +245,7 @@ gst_adder_init (GstAdder *adder)
adder->srcpad = gst_pad_new_from_template (gst_adder_src_template_factory (), "src"); adder->srcpad = gst_pad_new_from_template (gst_adder_src_template_factory (), "src");
gst_element_add_pad (GST_ELEMENT (adder), adder->srcpad); gst_element_add_pad (GST_ELEMENT (adder), adder->srcpad);
gst_element_set_loop_function (GST_ELEMENT (adder), gst_adder_loop); gst_element_set_loop_function (GST_ELEMENT (adder), gst_adder_loop);
gst_pad_set_connect_function (adder->srcpad, gst_adder_connect);
adder->format = GST_ADDER_FORMAT_UNSET; adder->format = GST_ADDER_FORMAT_UNSET;
...@@ -261,7 +286,7 @@ gst_adder_request_new_pad (GstElement *element, GstPadTemplate *templ, const gch ...@@ -261,7 +286,7 @@ gst_adder_request_new_pad (GstElement *element, GstPadTemplate *templ, const gch
input->bytestream = gst_bytestream_new (input->sinkpad); input->bytestream = gst_bytestream_new (input->sinkpad);
gst_element_add_pad (GST_ELEMENT (adder), input->sinkpad); gst_element_add_pad (GST_ELEMENT (adder), input->sinkpad);
gst_pad_set_connect_function(input->sinkpad, gst_adder_sinkpad_connect); gst_pad_set_connect_function(input->sinkpad, gst_adder_connect);
/* add the input_channel to the list of input channels */ /* add the input_channel to the list of input channels */
......
...@@ -109,16 +109,18 @@ volume_get_bufferpool (GstPad *pad) ...@@ -109,16 +109,18 @@ volume_get_bufferpool (GstPad *pad)
} }
static GstPadConnectReturn static GstPadConnectReturn
volume_connect_sink (GstPad *pad, GstCaps *caps) volume_connect (GstPad *pad, GstCaps *caps)
{ {
GstVolume *filter; GstVolume *filter;
GstPad *otherpad;
filter = GST_VOLUME (gst_pad_get_parent (pad)); filter = GST_VOLUME (gst_pad_get_parent (pad));
g_return_val_if_fail (filter != NULL, GST_PAD_CONNECT_REFUSED); g_return_val_if_fail (filter != NULL, GST_PAD_CONNECT_REFUSED);
g_return_val_if_fail (GST_IS_VOLUME (filter), GST_PAD_CONNECT_REFUSED); g_return_val_if_fail (GST_IS_VOLUME (filter), GST_PAD_CONNECT_REFUSED);
otherpad = (pad == filter->srcpad ? filter->sinkpad : filter->srcpad);
if (GST_CAPS_IS_FIXED (caps)) { if (GST_CAPS_IS_FIXED (caps)) {
if (!volume_parse_caps (filter, caps) || !gst_pad_try_set_caps (filter->srcpad, caps)) if (!volume_parse_caps (filter, caps) || !gst_pad_try_set_caps (otherpad, caps))
return GST_PAD_CONNECT_REFUSED; return GST_PAD_CONNECT_REFUSED;
return GST_PAD_CONNECT_OK; return GST_PAD_CONNECT_OK;
...@@ -222,9 +224,10 @@ static void ...@@ -222,9 +224,10 @@ static void
volume_init (GstVolume *filter) volume_init (GstVolume *filter)
{ {
filter->sinkpad = gst_pad_new_from_template(volume_sink_factory (),"sink"); filter->sinkpad = gst_pad_new_from_template(volume_sink_factory (),"sink");
gst_pad_set_connect_function(filter->sinkpad,volume_connect_sink); gst_pad_set_connect_function(filter->sinkpad,volume_connect);
gst_pad_set_bufferpool_function(filter->sinkpad,volume_get_bufferpool); gst_pad_set_bufferpool_function(filter->sinkpad,volume_get_bufferpool);
filter->srcpad = gst_pad_new_from_template(volume_src_factory (),"src"); filter->srcpad = gst_pad_new_from_template(volume_src_factory (),"src");
gst_pad_set_connect_function(filter->srcpad,volume_connect);
gst_element_add_pad(GST_ELEMENT(filter),filter->sinkpad); gst_element_add_pad(GST_ELEMENT(filter),filter->sinkpad);
gst_element_add_pad(GST_ELEMENT(filter),filter->srcpad); gst_element_add_pad(GST_ELEMENT(filter),filter->srcpad);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment