interleave: port to GstCollectPads2

This commit is contained in:
Vincent Penquerc'h 2011-12-14 18:55:36 +00:00
parent 44d001346a
commit 3135cab5a3
2 changed files with 20 additions and 20 deletions

View file

@ -227,7 +227,7 @@ static gboolean gst_interleave_sink_setcaps (GstPad * pad, GstCaps * caps);
static GstCaps *gst_interleave_sink_getcaps (GstPad * pad); static GstCaps *gst_interleave_sink_getcaps (GstPad * pad);
static GstFlowReturn gst_interleave_collected (GstCollectPads * pads, static GstFlowReturn gst_interleave_collected (GstCollectPads2 * pads,
GstInterleave * self); GstInterleave * self);
static void static void
@ -405,9 +405,9 @@ gst_interleave_init (GstInterleave * self, GstInterleaveClass * klass)
gst_element_add_pad (GST_ELEMENT (self), self->src); gst_element_add_pad (GST_ELEMENT (self), self->src);
self->collect = gst_collect_pads_new (); self->collect = gst_collect_pads2_new ();
gst_collect_pads_set_function (self->collect, gst_collect_pads2_set_function (self->collect,
(GstCollectPadsFunction) gst_interleave_collected, self); (GstCollectPads2Function) gst_interleave_collected, self);
self->input_channel_positions = g_value_array_new (0); self->input_channel_positions = g_value_array_new (0);
self->channel_positions_from_input = TRUE; self->channel_positions_from_input = TRUE;
@ -498,10 +498,10 @@ gst_interleave_request_new_pad (GstElement * element, GstPadTemplate * templ,
gst_pad_set_getcaps_function (new_pad, gst_pad_set_getcaps_function (new_pad,
GST_DEBUG_FUNCPTR (gst_interleave_sink_getcaps)); GST_DEBUG_FUNCPTR (gst_interleave_sink_getcaps));
gst_collect_pads_add_pad (self->collect, new_pad, sizeof (GstCollectData)); gst_collect_pads2_add_pad (self->collect, new_pad, sizeof (GstCollectData2));
/* FIXME: hacked way to override/extend the event function of /* FIXME: hacked way to override/extend the event function of
* GstCollectPads; because it sets its own event function giving the * GstCollectPads2; because it sets its own event function giving the
* element no access to events */ * element no access to events */
self->collect_event = (GstPadEventFunction) GST_PAD_EVENTFUNC (new_pad); self->collect_event = (GstPadEventFunction) GST_PAD_EVENTFUNC (new_pad);
gst_pad_set_event_function (new_pad, gst_pad_set_event_function (new_pad,
@ -547,7 +547,7 @@ not_sink_pad:
could_not_add: could_not_add:
{ {
GST_DEBUG_OBJECT (self, "could not add pad %s", GST_PAD_NAME (new_pad)); GST_DEBUG_OBJECT (self, "could not add pad %s", GST_PAD_NAME (new_pad));
gst_collect_pads_remove_pad (self->collect, new_pad); gst_collect_pads2_remove_pad (self->collect, new_pad);
gst_object_unref (new_pad); gst_object_unref (new_pad);
return NULL; return NULL;
} }
@ -601,7 +601,7 @@ gst_interleave_release_pad (GstElement * element, GstPad * pad)
GST_OBJECT_UNLOCK (self->collect); GST_OBJECT_UNLOCK (self->collect);
gst_collect_pads_remove_pad (self->collect, pad); gst_collect_pads2_remove_pad (self->collect, pad);
gst_element_remove_pad (element, pad); gst_element_remove_pad (element, pad);
} }
@ -623,7 +623,7 @@ gst_interleave_change_state (GstElement * element, GstStateChange transition)
self->segment_position = 0; self->segment_position = 0;
self->segment_rate = 1.0; self->segment_rate = 1.0;
gst_segment_init (&self->segment, GST_FORMAT_UNDEFINED); gst_segment_init (&self->segment, GST_FORMAT_UNDEFINED);
gst_collect_pads_start (self->collect); gst_collect_pads2_start (self->collect);
break; break;
case GST_STATE_CHANGE_PAUSED_TO_PLAYING: case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
break; break;
@ -632,11 +632,11 @@ gst_interleave_change_state (GstElement * element, GstStateChange transition)
} }
/* Stop before calling the parent's state change function as /* Stop before calling the parent's state change function as
* GstCollectPads might take locks and we would deadlock in that * GstCollectPads2 might take locks and we would deadlock in that
* case * case
*/ */
if (transition == GST_STATE_CHANGE_PAUSED_TO_READY) if (transition == GST_STATE_CHANGE_PAUSED_TO_READY)
gst_collect_pads_stop (self->collect); gst_collect_pads2_stop (self->collect);
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition); ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
@ -876,7 +876,7 @@ gst_interleave_sink_event (GstPad * pad, GstEvent * event)
break; break;
} }
/* now GstCollectPads can take care of the rest, e.g. EOS */ /* now GstCollectPads2 can take care of the rest, e.g. EOS */
ret = self->collect_event (pad, event); ret = self->collect_event (pad, event);
gst_object_unref (self); gst_object_unref (self);
@ -1157,7 +1157,7 @@ gst_interleave_src_event (GstPad * pad, GstEvent * event)
/* check if we are flushing */ /* check if we are flushing */
if (flags & GST_SEEK_FLAG_FLUSH) { if (flags & GST_SEEK_FLAG_FLUSH) {
/* make sure we accept nothing anymore and return WRONG_STATE */ /* make sure we accept nothing anymore and return WRONG_STATE */
gst_collect_pads_set_flushing (self->collect, TRUE); gst_collect_pads2_set_flushing (self->collect, TRUE);
/* flushing seek, start flush downstream, the flush will be done /* flushing seek, start flush downstream, the flush will be done
* when all pads received a FLUSH_STOP. */ * when all pads received a FLUSH_STOP. */
@ -1192,7 +1192,7 @@ gst_interleave_src_event (GstPad * pad, GstEvent * event)
} }
static GstFlowReturn static GstFlowReturn
gst_interleave_collected (GstCollectPads * pads, GstInterleave * self) gst_interleave_collected (GstCollectPads2 * pads, GstInterleave * self)
{ {
guint size; guint size;
GstBuffer *outbuf; GstBuffer *outbuf;
@ -1208,7 +1208,7 @@ gst_interleave_collected (GstCollectPads * pads, GstInterleave * self)
g_return_val_if_fail (self->channels > 0, GST_FLOW_NOT_NEGOTIATED); g_return_val_if_fail (self->channels > 0, GST_FLOW_NOT_NEGOTIATED);
g_return_val_if_fail (self->rate > 0, GST_FLOW_NOT_NEGOTIATED); g_return_val_if_fail (self->rate > 0, GST_FLOW_NOT_NEGOTIATED);
size = gst_collect_pads_available (pads); size = gst_collect_pads2_available (pads);
g_return_val_if_fail (size % width == 0, GST_FLOW_ERROR); g_return_val_if_fail (size % width == 0, GST_FLOW_ERROR);
@ -1235,13 +1235,13 @@ gst_interleave_collected (GstCollectPads * pads, GstInterleave * self)
memset (GST_BUFFER_DATA (outbuf), 0, size * self->channels); memset (GST_BUFFER_DATA (outbuf), 0, size * self->channels);
for (collected = pads->data; collected != NULL; collected = collected->next) { for (collected = pads->data; collected != NULL; collected = collected->next) {
GstCollectData *cdata; GstCollectData2 *cdata;
GstBuffer *inbuf; GstBuffer *inbuf;
guint8 *outdata; guint8 *outdata;
cdata = (GstCollectData *) collected->data; cdata = (GstCollectData2 *) collected->data;
inbuf = gst_collect_pads_take_buffer (pads, cdata, size); inbuf = gst_collect_pads2_take_buffer (pads, cdata, size);
if (inbuf == NULL) { if (inbuf == NULL) {
GST_DEBUG_OBJECT (cdata->pad, "No buffer available"); GST_DEBUG_OBJECT (cdata->pad, "No buffer available");
goto next; goto next;

View file

@ -27,7 +27,7 @@
#define __INTERLEAVE_H__ #define __INTERLEAVE_H__
#include <gst/gst.h> #include <gst/gst.h>
#include <gst/base/gstcollectpads.h> #include <gst/base/gstcollectpads2.h>
G_BEGIN_DECLS G_BEGIN_DECLS
@ -49,7 +49,7 @@ struct _GstInterleave
GstElement element; GstElement element;
/*< private >*/ /*< private >*/
GstCollectPads *collect; GstCollectPads2 *collect;
gint channels; gint channels;
gint padcounter; gint padcounter;