From: Iain <nod...@us...> - 2002-12-13 15:25:34
|
CVS Root: /cvsroot/gstreamer Module: gst-plugins Changes by: nodatadj Date: Fri Dec 13 2002 07:25:33 PST Log message: Make float2int reset its caps on PAUSED_TO_READY so that on READY_TO_PAUSED it can nego again. Make int2float handle having pads being removed from it. Modified files: gst/intfloat : gstfloat2int.c gstfloat2int.h Links: http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins/gst/intfloat/gstfloat2int.c.diff?r1=1.24&r2=1.25 http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins/gst/intfloat/gstfloat2int.h.diff?r1=1.8&r2=1.9 ====Begin Diffs==== Index: gstfloat2int.c =================================================================== RCS file: /cvsroot/gstreamer/gst-plugins/gst/intfloat/gstfloat2int.c,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- gstfloat2int.c 22 Sep 2002 13:59:13 -0000 1.24 +++ gstfloat2int.c 13 Dec 2002 15:25:16 -0000 1.25 @@ -87,6 +87,7 @@ static GstPad* gst_float2int_request_new_pad (GstElement *element, GstPadTemplate *temp, const gchar *unused); +static void gst_float2int_pad_removed (GstElement *element, GstPad *pad); static void gst_float2int_loop (GstElement *element); @@ -126,6 +127,7 @@ parent_class = g_type_class_ref(GST_TYPE_ELEMENT); gstelement_class->request_new_pad = gst_float2int_request_new_pad; + gstelement_class->pad_removed = gst_float2int_pad_removed; gstelement_class->change_state = gst_float2int_change_state; } @@ -139,6 +141,7 @@ gst_pad_set_connect_function (plugin->srcpad, gst_float2int_connect); plugin->numchannels = 0; + plugin->channelcount = 0; plugin->channels = NULL; } @@ -191,7 +194,7 @@ gint rate, channels; filter = GST_FLOAT2INT (GST_PAD_PARENT (pad)); - + /* we have two variables to play with: "rate" and "channels" on the int side. */ if (GST_CAPS_IS_FIXED (caps)) { if (pad == filter->srcpad) { @@ -240,8 +243,10 @@ intcaps->fixed = TRUE; gst_caps_debug (intcaps, "int source pad caps going into try_set_caps()"); - if (gst_pad_try_set_caps (filter->srcpad, intcaps) <= 0) + if (gst_pad_try_set_caps (filter->srcpad, intcaps) <= 0) { return GST_PAD_CONNECT_REFUSED; + } + for (l=filter->channels; l; l=l->next) if (! (GST_FLOAT2INT_CHANNEL (l)->sinkpad == pad || gst_pad_try_set_caps (GST_FLOAT2INT_CHANNEL (l)->sinkpad, caps) > 0)) @@ -282,7 +287,7 @@ } channel = g_new0 (GstFloat2IntInputChannel, 1); - name = g_strdup_printf ("sink%d", plugin->numchannels); + name = g_strdup_printf ("sink%d", plugin->channelcount); channel->sinkpad = gst_pad_new_from_template (templ, name); gst_element_add_pad (GST_ELEMENT (plugin), channel->sinkpad); gst_pad_set_connect_function (channel->sinkpad, gst_float2int_connect); @@ -291,12 +296,47 @@ plugin->channels = g_slist_append (plugin->channels, channel); plugin->numchannels++; + plugin->channelcount++; GST_DEBUG (0, "float2int added pad %s\n", name); + g_free (name); return channel->sinkpad; } +static void +gst_float2int_pad_removed (GstElement *element, + GstPad *pad) +{ + GstFloat2Int *plugin; + GSList *p; + + GST_DEBUG(0, "float2int removed pad %s\n", GST_OBJECT_NAME (pad)); + + plugin = GST_FLOAT2INT (element); + + /* Find our channel for this pad */ + for (p = plugin->channels; p;) { + GstFloat2IntInputChannel *channel = p->data; + GSList *p_copy; + + if (channel->sinkpad == pad) { + p_copy = p; + + p = p->next; + plugin->channels = g_slist_remove_link (plugin->channels, p_copy); + plugin->numchannels--; + + g_slist_free (p_copy); + + gst_bytestream_destroy (channel->bytestream); + g_free (channel); + } else { + p = p->next; + } + } +} + static gboolean all_channels_eos (GSList *inputs) { @@ -428,6 +468,11 @@ c->eos = FALSE; } + break; + + case GST_STATE_PAUSED_TO_READY: + plugin->intcaps = NULL; + plugin->floatcaps = NULL; break; default: Index: gstfloat2int.h =================================================================== RCS file: /cvsroot/gstreamer/gst-plugins/gst/intfloat/gstfloat2int.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- gstfloat2int.h 22 Sep 2002 13:59:13 -0000 1.8 +++ gstfloat2int.h 13 Dec 2002 15:25:17 -0000 1.9 @@ -59,8 +59,9 @@ GSList *channels; GstBufferPool *pool; - gint numchannels; - + gint numchannels; /* Number of pads on the element */ + gint channelcount; /* counter to get safest pad name */ + GstCaps *intcaps; GstCaps *floatcaps; gint rate; |