2 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3 * 2000 Wim Taymans <wtay@chello.be>
4 * 2005 Wim Taymans <wim@fluendo.com>
5 * 2007 Andy Wingo <wingo at pobox.com>
6 * 2008 Sebastian Dröge <slomo@circular-chaos.org>
8 * deinterleave.c: deinterleave samples
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Library General Public
12 * License as published by the Free Software Foundation; either
13 * version 2 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Library General Public License for more details.
20 * You should have received a copy of the GNU Library General Public
21 * License along with this library; if not, write to the
22 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23 * Boston, MA 02110-1301, USA.
27 * - handle changes in number of channels
28 * - handle changes in channel positions
29 * - better capsnego by using a buffer alloc function
30 * and passing downstream caps changes upstream there
34 * SECTION:element-deinterleave
35 * @see_also: interleave
37 * Splits one interleaved multichannel audio stream into many mono audio streams.
39 * This element handles all raw audio formats and supports changing the input caps as long as
40 * all downstream elements can handle the new caps and the number of channels and the channel
41 * positions stay the same. This restriction will be removed in later versions by adding or
42 * removing some source pads as required.
44 * In most cases a queue and an audioconvert element should be added after each source pad
45 * before further processing of the audio data.
48 * <title>Example launch line</title>
50 * gst-launch-1.0 filesrc location=/path/to/file.mp3 ! decodebin ! audioconvert ! "audio/x-raw,channels=2 ! deinterleave name=d d.src_0 ! queue ! audioconvert ! vorbisenc ! oggmux ! filesink location=channel1.ogg d.src_1 ! queue ! audioconvert ! vorbisenc ! oggmux ! filesink location=channel2.ogg
51 * ]| Decodes an MP3 file and encodes the left and right channel into separate
54 * gst-launch-1.0 filesrc location=file.mp3 ! decodebin ! audioconvert ! "audio/x-raw,channels=2" ! deinterleave name=d interleave name=i ! audioconvert ! wavenc ! filesink location=test.wav d.src_0 ! queue ! audioconvert ! i.sink_1 d.src_1 ! queue ! audioconvert ! i.sink_0
55 * ]| Decodes and deinterleaves a Stereo MP3 file into separate channels and
56 * then interleaves the channels again to a WAV file with the channel with the
67 #include "deinterleave.h"
69 GST_DEBUG_CATEGORY_STATIC (gst_deinterleave_debug);
70 #define GST_CAT_DEFAULT gst_deinterleave_debug
72 static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src_%u",
75 GST_STATIC_CAPS ("audio/x-raw, "
76 "format = (string) " GST_AUDIO_FORMATS_ALL ", "
77 "rate = (int) [ 1, MAX ], "
78 "channels = (int) 1, layout = (string) {non-interleaved, interleaved}"));
80 static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
83 GST_STATIC_CAPS ("audio/x-raw, "
84 "format = (string) " GST_AUDIO_FORMATS_ALL ", "
85 "rate = (int) [ 1, MAX ], "
86 "channels = (int) [ 1, MAX ], layout = (string) interleaved"));
88 #define MAKE_FUNC(type) \
89 static void deinterleave_##type (guint##type *out, guint##type *in, \
90 guint stride, guint nframes) \
94 for (i = 0; i < nframes; i++) { \
106 deinterleave_24 (guint8 * out, guint8 * in, guint stride, guint nframes)
110 for (i = 0; i < nframes; i++) {
117 #define gst_deinterleave_parent_class parent_class
118 G_DEFINE_TYPE (GstDeinterleave, gst_deinterleave, GST_TYPE_ELEMENT);
126 static GstFlowReturn gst_deinterleave_chain (GstPad * pad, GstObject * parent,
129 static gboolean gst_deinterleave_sink_setcaps (GstDeinterleave * self,
132 static GstStateChangeReturn
133 gst_deinterleave_change_state (GstElement * element, GstStateChange transition);
135 static gboolean gst_deinterleave_sink_event (GstPad * pad, GstObject * parent,
138 static gboolean gst_deinterleave_src_query (GstPad * pad, GstObject * parent,
141 static void gst_deinterleave_set_property (GObject * object,
142 guint prop_id, const GValue * value, GParamSpec * pspec);
143 static void gst_deinterleave_get_property (GObject * object,
144 guint prop_id, GValue * value, GParamSpec * pspec);
148 gst_deinterleave_finalize (GObject * obj)
150 GstDeinterleave *self = GST_DEINTERLEAVE (obj);
152 if (self->pending_events) {
153 g_list_foreach (self->pending_events, (GFunc) gst_mini_object_unref, NULL);
154 g_list_free (self->pending_events);
155 self->pending_events = NULL;
158 G_OBJECT_CLASS (parent_class)->finalize (obj);
162 gst_deinterleave_class_init (GstDeinterleaveClass * klass)
164 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
165 GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
167 GST_DEBUG_CATEGORY_INIT (gst_deinterleave_debug, "deinterleave", 0,
168 "deinterleave element");
170 gst_element_class_set_static_metadata (gstelement_class,
171 "Audio deinterleaver", "Filter/Converter/Audio",
172 "Splits one interleaved multichannel audio stream into many mono audio streams",
173 "Andy Wingo <wingo at pobox.com>, " "Iain <iain@prettypeople.org>, "
174 "Sebastian Dröge <slomo@circular-chaos.org>");
176 gst_element_class_add_pad_template (gstelement_class,
177 gst_static_pad_template_get (&sink_template));
178 gst_element_class_add_pad_template (gstelement_class,
179 gst_static_pad_template_get (&src_template));
181 gstelement_class->change_state = gst_deinterleave_change_state;
183 gobject_class->finalize = gst_deinterleave_finalize;
184 gobject_class->set_property = gst_deinterleave_set_property;
185 gobject_class->get_property = gst_deinterleave_get_property;
188 * GstDeinterleave:keep-positions
190 * Keep positions: When enable the caps on the output buffers will
191 * contain the original channel positions. This can be used to correctly
192 * interleave the output again later but can also lead to unwanted effects
193 * if the output should be handled as Mono.
196 g_object_class_install_property (gobject_class, PROP_KEEP_POSITIONS,
197 g_param_spec_boolean ("keep-positions", "Keep positions",
198 "Keep the original channel positions on the output buffers",
199 FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
203 gst_deinterleave_init (GstDeinterleave * self)
205 self->keep_positions = FALSE;
207 gst_audio_info_init (&self->audio_info);
210 self->sink = gst_pad_new_from_static_template (&sink_template, "sink");
211 gst_pad_set_chain_function (self->sink,
212 GST_DEBUG_FUNCPTR (gst_deinterleave_chain));
213 gst_pad_set_event_function (self->sink,
214 GST_DEBUG_FUNCPTR (gst_deinterleave_sink_event));
215 gst_element_add_pad (GST_ELEMENT (self), self->sink);
219 gst_deinterleave_add_new_pads (GstDeinterleave * self, GstCaps * caps)
225 for (i = 0; i < GST_AUDIO_INFO_CHANNELS (&self->audio_info); i++) {
226 gchar *name = g_strdup_printf ("src_%u", i);
230 GstAudioFormat format = GST_AUDIO_INFO_FORMAT (&self->audio_info);
231 gint rate = GST_AUDIO_INFO_RATE (&self->audio_info);
232 GstAudioChannelPosition position = GST_AUDIO_CHANNEL_POSITION_MONO;
234 /* Set channel position if we know it */
235 if (self->keep_positions)
236 position = GST_AUDIO_INFO_POSITION (&self->audio_info, i);
238 gst_audio_info_init (&info);
239 gst_audio_info_set_format (&info, format, rate, 1, &position);
241 srccaps = gst_audio_info_to_caps (&info);
243 pad = gst_pad_new_from_static_template (&src_template, name);
246 gst_pad_use_fixed_caps (pad);
247 gst_pad_set_query_function (pad,
248 GST_DEBUG_FUNCPTR (gst_deinterleave_src_query));
249 gst_pad_set_active (pad, TRUE);
250 gst_pad_set_caps (pad, srccaps);
251 gst_element_add_pad (GST_ELEMENT (self), pad);
252 self->srcpads = g_list_prepend (self->srcpads, gst_object_ref (pad));
254 gst_caps_unref (srccaps);
257 gst_element_no_more_pads (GST_ELEMENT (self));
258 self->srcpads = g_list_reverse (self->srcpads);
262 gst_deinterleave_set_pads_caps (GstDeinterleave * self, GstCaps * caps)
267 for (l = self->srcpads, i = 0; l; l = l->next, i++) {
268 GstPad *pad = GST_PAD (l->data);
272 gst_audio_info_from_caps (&info, caps);
273 if (self->keep_positions)
274 GST_AUDIO_INFO_POSITION (&info, i) =
275 GST_AUDIO_INFO_POSITION (&self->audio_info, i);
277 srccaps = gst_audio_info_to_caps (&info);
279 gst_pad_set_caps (pad, srccaps);
280 gst_caps_unref (srccaps);
285 gst_deinterleave_remove_pads (GstDeinterleave * self)
289 GST_INFO_OBJECT (self, "removing pads");
291 for (l = self->srcpads; l; l = l->next) {
292 GstPad *pad = GST_PAD (l->data);
294 gst_element_remove_pad (GST_ELEMENT_CAST (self), pad);
295 gst_object_unref (pad);
297 g_list_free (self->srcpads);
298 self->srcpads = NULL;
300 gst_caps_replace (&self->sinkcaps, NULL);
304 gst_deinterleave_set_process_function (GstDeinterleave * self)
306 switch (GST_AUDIO_INFO_WIDTH (&self->audio_info)) {
308 self->func = (GstDeinterleaveFunc) deinterleave_8;
311 self->func = (GstDeinterleaveFunc) deinterleave_16;
314 self->func = (GstDeinterleaveFunc) deinterleave_24;
317 self->func = (GstDeinterleaveFunc) deinterleave_32;
320 self->func = (GstDeinterleaveFunc) deinterleave_64;
329 gst_deinterleave_sink_setcaps (GstDeinterleave * self, GstCaps * caps)
334 GST_DEBUG_OBJECT (self, "got caps: %" GST_PTR_FORMAT, caps);
336 if (!gst_audio_info_from_caps (&self->audio_info, caps))
339 if (!gst_deinterleave_set_process_function (self))
340 goto unsupported_caps;
342 if (self->sinkcaps && !gst_caps_is_equal (caps, self->sinkcaps)) {
344 gboolean same_layout = TRUE;
345 gboolean was_unpositioned;
346 gboolean is_unpositioned =
347 GST_AUDIO_INFO_IS_UNPOSITIONED (&self->audio_info);
348 gint new_channels = GST_AUDIO_INFO_CHANNELS (&self->audio_info);
350 GstAudioInfo old_info;
352 gst_audio_info_init (&old_info);
353 gst_audio_info_from_caps (&old_info, self->sinkcaps);
354 was_unpositioned = GST_AUDIO_INFO_IS_UNPOSITIONED (&old_info);
355 old_channels = GST_AUDIO_INFO_CHANNELS (&old_info);
357 /* We allow caps changes as long as the number of channels doesn't change
358 * and the channel positions stay the same. _getcaps() should've cared
359 * for this already but better be safe.
361 if (new_channels != old_channels ||
362 !gst_deinterleave_set_process_function (self))
363 goto cannot_change_caps;
365 /* Now check the channel positions. If we had no channel positions
366 * and get them or the other way around things have changed.
367 * If we had channel positions and get different ones things have
368 * changed too of course
370 if ((!was_unpositioned && is_unpositioned) || (was_unpositioned
371 && !is_unpositioned))
372 goto cannot_change_caps;
374 if (!is_unpositioned) {
375 if (GST_AUDIO_INFO_CHANNELS (&old_info) !=
376 GST_AUDIO_INFO_CHANNELS (&self->audio_info))
377 goto cannot_change_caps;
378 for (i = 0; i < GST_AUDIO_INFO_CHANNELS (&old_info); i++) {
379 if (self->audio_info.position[i] != old_info.position[i]) {
385 goto cannot_change_caps;
390 gst_caps_replace (&self->sinkcaps, caps);
392 /* Get srcpad caps */
393 srccaps = gst_caps_copy (caps);
394 s = gst_caps_get_structure (srccaps, 0);
395 gst_structure_set (s, "channels", G_TYPE_INT, 1, NULL);
396 gst_structure_remove_field (s, "channel-mask");
398 /* If we already have pads, update the caps otherwise
401 gst_deinterleave_set_pads_caps (self, srccaps);
403 gst_deinterleave_add_new_pads (self, srccaps);
406 gst_caps_unref (srccaps);
412 GST_WARNING_OBJECT (self, "caps change from %" GST_PTR_FORMAT
413 " to %" GST_PTR_FORMAT " not supported: channel number or channel "
414 "positions change", self->sinkcaps, caps);
419 GST_ERROR_OBJECT (self, "caps not supported: %" GST_PTR_FORMAT, caps);
424 GST_ERROR_OBJECT (self, "invalid caps");
430 __remove_channels (GstCaps * caps)
436 size = gst_caps_get_size (caps);
437 for (i = 0; i < size; i++) {
438 s = gst_caps_get_structure (caps, i);
439 gst_structure_remove_field (s, "channel-mask");
440 gst_structure_remove_field (s, "channels");
445 __set_channels (GstCaps * caps, gint channels)
451 size = gst_caps_get_size (caps);
452 for (i = 0; i < size; i++) {
453 s = gst_caps_get_structure (caps, i);
455 gst_structure_set (s, "channels", G_TYPE_INT, channels, NULL);
457 gst_structure_set (s, "channels", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL);
462 gst_deinterleave_sink_getcaps (GstPad * pad, GstObject * parent,
465 GstDeinterleave *self = GST_DEINTERLEAVE (parent);
471 GST_OBJECT_LOCK (self);
472 /* Intersect all of our pad template caps with the peer caps of the pad
473 * to get all formats that are possible up- and downstream.
475 * For the pad for which the caps are requested we don't remove the channel
476 * informations as they must be in the returned caps and incompatibilities
477 * will be detected here already
479 ret = gst_caps_new_any ();
480 for (l = GST_ELEMENT (self)->pads; l != NULL; l = l->next) {
481 GstPad *ourpad = GST_PAD (l->data);
483 GstCaps *peercaps = NULL, *ourcaps;
485 ourcaps = gst_caps_copy (gst_pad_get_pad_template_caps (ourpad));
488 if (GST_PAD_DIRECTION (pad) == GST_PAD_SINK)
489 __set_channels (ourcaps, GST_AUDIO_INFO_CHANNELS (&self->audio_info));
491 __set_channels (ourcaps, 1);
493 __remove_channels (ourcaps);
494 /* Only ask for peer caps for other pads than pad
495 * as otherwise gst_pad_peer_get_caps() might call
496 * back into this function and deadlock
498 peercaps = gst_pad_peer_query_caps (ourpad, NULL);
499 peercaps = gst_caps_make_writable (peercaps);
502 /* If the peer exists and has caps add them to the intersection,
503 * otherwise assume that the peer accepts everything */
505 GstCaps *intersection;
507 GstCaps *oldret = ret;
509 __remove_channels (peercaps);
511 intersection = gst_caps_intersect (peercaps, ourcaps);
513 ret = gst_caps_intersect (ret, intersection);
514 gst_caps_unref (intersection);
515 gst_caps_unref (peercaps);
516 gst_caps_unref (oldret);
518 GstCaps *oldret = ret;
520 ret = gst_caps_intersect (ret, ourcaps);
521 gst_caps_unref (oldret);
523 gst_caps_unref (ourcaps);
525 GST_OBJECT_UNLOCK (self);
527 GST_DEBUG_OBJECT (pad, "Intersected caps to %" GST_PTR_FORMAT, ret);
533 gst_deinterleave_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
535 GstDeinterleave *self = GST_DEINTERLEAVE (parent);
539 GST_DEBUG ("Got %s event on pad %s:%s", GST_EVENT_TYPE_NAME (event),
540 GST_DEBUG_PAD_NAME (pad));
542 /* Send FLUSH_STOP, FLUSH_START and EOS immediately, no matter if
543 * we have src pads already or not. Queue all other events and
544 * push them after we have src pads
546 switch (GST_EVENT_TYPE (event)) {
547 case GST_EVENT_FLUSH_STOP:
548 case GST_EVENT_FLUSH_START:
550 ret = gst_pad_event_default (pad, parent, event);
556 gst_event_parse_caps (event, &caps);
557 ret = gst_deinterleave_sink_setcaps (self, caps);
558 gst_event_unref (event);
564 ret = gst_pad_event_default (pad, parent, event);
566 GST_OBJECT_LOCK (self);
567 self->pending_events = g_list_append (self->pending_events, event);
568 GST_OBJECT_UNLOCK (self);
578 gst_deinterleave_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
580 GstDeinterleave *self = GST_DEINTERLEAVE (parent);
584 res = gst_pad_query_default (pad, parent, query);
586 if (res && GST_QUERY_TYPE (query) == GST_QUERY_DURATION) {
591 gst_query_parse_duration (query, &format, &dur);
593 /* Need to divide by the number of channels in byte format
594 * to get the correct value. All other formats should be fine
596 if (format == GST_FORMAT_BYTES && dur != -1)
597 gst_query_set_duration (query, format,
598 dur / GST_AUDIO_INFO_CHANNELS (&self->audio_info));
599 } else if (res && GST_QUERY_TYPE (query) == GST_QUERY_POSITION) {
604 gst_query_parse_position (query, &format, &pos);
606 /* Need to divide by the number of channels in byte format
607 * to get the correct value. All other formats should be fine
609 if (format == GST_FORMAT_BYTES && pos != -1)
610 gst_query_set_position (query, format,
611 pos / GST_AUDIO_INFO_CHANNELS (&self->audio_info));
612 } else if (res && GST_QUERY_TYPE (query) == GST_QUERY_CAPS) {
613 GstCaps *filter, *caps;
615 gst_query_parse_caps (query, &filter);
616 caps = gst_deinterleave_sink_getcaps (pad, parent, filter);
617 gst_query_set_caps_result (query, caps);
618 gst_caps_unref (caps);
625 gst_deinterleave_set_property (GObject * object, guint prop_id,
626 const GValue * value, GParamSpec * pspec)
628 GstDeinterleave *self = GST_DEINTERLEAVE (object);
631 case PROP_KEEP_POSITIONS:
632 self->keep_positions = g_value_get_boolean (value);
635 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
641 gst_deinterleave_get_property (GObject * object, guint prop_id,
642 GValue * value, GParamSpec * pspec)
644 GstDeinterleave *self = GST_DEINTERLEAVE (object);
647 case PROP_KEEP_POSITIONS:
648 g_value_set_boolean (value, self->keep_positions);
651 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
657 gst_deinterleave_process (GstDeinterleave * self, GstBuffer * buf)
659 GstFlowReturn ret = GST_FLOW_OK;
661 guint channels = GST_AUDIO_INFO_CHANNELS (&self->audio_info);
663 guint pads_pushed = 0, buffers_allocated = 0;
666 gst_buffer_get_size (buf) / channels /
667 (GST_AUDIO_INFO_WIDTH (&self->audio_info) / 8);
669 guint bufsize = nframes * (GST_AUDIO_INFO_WIDTH (&self->audio_info) / 8);
675 GstBuffer **buffers_out = g_new0 (GstBuffer *, channels);
679 GstMapInfo read_info;
680 gst_buffer_map (buf, &read_info, GST_MAP_READ);
682 /* Send any pending events to all src pads */
683 GST_OBJECT_LOCK (self);
684 if (self->pending_events) {
689 GST_DEBUG_OBJECT (self, "Sending pending events to all src pads");
691 for (events = self->pending_events; events != NULL; events = events->next) {
692 event = GST_EVENT (events->data);
694 for (srcs = self->srcpads; srcs != NULL; srcs = srcs->next)
695 gst_pad_push_event (GST_PAD (srcs->data), gst_event_ref (event));
696 gst_event_unref (event);
699 g_list_free (self->pending_events);
700 self->pending_events = NULL;
702 GST_OBJECT_UNLOCK (self);
704 /* Allocate buffers */
705 for (srcs = self->srcpads, i = 0; srcs; srcs = srcs->next, i++) {
706 buffers_out[i] = gst_buffer_new_allocate (NULL, bufsize, NULL);
708 /* Make sure we got a correct buffer. The only other case we allow
709 * here is an unliked pad */
711 goto alloc_buffer_failed;
712 else if (buffers_out[i] && gst_buffer_get_size (buffers_out[i]) != bufsize)
713 goto alloc_buffer_bad_size;
715 if (buffers_out[i]) {
716 gst_buffer_copy_into (buffers_out[i], buf, GST_BUFFER_COPY_METADATA, 0,
722 /* Return NOT_LINKED if no pad was linked */
723 if (!buffers_allocated) {
724 GST_WARNING_OBJECT (self,
725 "Couldn't allocate any buffers because no pad was linked");
726 ret = GST_FLOW_NOT_LINKED;
731 for (srcs = self->srcpads, i = 0; srcs; srcs = srcs->next, i++) {
732 GstPad *pad = (GstPad *) srcs->data;
733 GstMapInfo write_info;
736 in = (guint8 *) read_info.data;
737 in += i * (GST_AUDIO_INFO_WIDTH (&self->audio_info) / 8);
738 if (buffers_out[i]) {
739 gst_buffer_map (buffers_out[i], &write_info, GST_MAP_WRITE);
741 out = (guint8 *) write_info.data;
743 self->func (out, in, channels, nframes);
745 gst_buffer_unmap (buffers_out[i], &write_info);
747 ret = gst_pad_push (pad, buffers_out[i]);
748 buffers_out[i] = NULL;
749 if (ret == GST_FLOW_OK)
751 else if (ret == GST_FLOW_NOT_LINKED)
758 /* Return NOT_LINKED if no pad was linked */
760 ret = GST_FLOW_NOT_LINKED;
762 GST_DEBUG_OBJECT (self, "Pushed on %d pads", pads_pushed);
765 gst_buffer_unmap (buf, &read_info);
766 gst_buffer_unref (buf);
767 g_free (buffers_out);
772 GST_WARNING ("gst_pad_alloc_buffer() returned %s", gst_flow_get_name (ret));
776 alloc_buffer_bad_size:
778 GST_WARNING ("called alloc_buffer(), but didn't get requested bytes");
779 ret = GST_FLOW_NOT_NEGOTIATED;
784 GST_DEBUG ("push() failed, flow = %s", gst_flow_get_name (ret));
789 gst_buffer_unmap (buf, &read_info);
790 for (i = 0; i < channels; i++) {
792 gst_buffer_unref (buffers_out[i]);
794 gst_buffer_unref (buf);
795 g_free (buffers_out);
801 gst_deinterleave_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
803 GstDeinterleave *self = GST_DEINTERLEAVE (parent);
807 g_return_val_if_fail (self->func != NULL, GST_FLOW_NOT_NEGOTIATED);
808 g_return_val_if_fail (GST_AUDIO_INFO_WIDTH (&self->audio_info) > 0,
809 GST_FLOW_NOT_NEGOTIATED);
810 g_return_val_if_fail (GST_AUDIO_INFO_CHANNELS (&self->audio_info) > 0,
811 GST_FLOW_NOT_NEGOTIATED);
813 ret = gst_deinterleave_process (self, buffer);
815 if (ret != GST_FLOW_OK)
816 GST_DEBUG_OBJECT (self, "flow return: %s", gst_flow_get_name (ret));
821 static GstStateChangeReturn
822 gst_deinterleave_change_state (GstElement * element, GstStateChange transition)
824 GstStateChangeReturn ret;
825 GstDeinterleave *self = GST_DEINTERLEAVE (element);
827 switch (transition) {
828 case GST_STATE_CHANGE_NULL_TO_READY:
830 case GST_STATE_CHANGE_READY_TO_PAUSED:
831 gst_deinterleave_remove_pads (self);
835 if (self->pending_events) {
836 g_list_foreach (self->pending_events, (GFunc) gst_mini_object_unref,
838 g_list_free (self->pending_events);
839 self->pending_events = NULL;
842 case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
848 ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
850 switch (transition) {
851 case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
853 case GST_STATE_CHANGE_PAUSED_TO_READY:
854 gst_deinterleave_remove_pads (self);
858 if (self->pending_events) {
859 g_list_foreach (self->pending_events, (GFunc) gst_mini_object_unref,
861 g_list_free (self->pending_events);
862 self->pending_events = NULL;
865 case GST_STATE_CHANGE_READY_TO_NULL: