Imported Upstream version 0.10.36
[profile/ivi/gstreamer.git] / plugins / elements / gstoutputselector.c
1 /* GStreamer output selector
2  * Copyright (C) 2008 Nokia Corporation. (contact <stefan.kost@nokia.com>)
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 /**
21  * SECTION:element-output-selector
22  * @see_also: #GstOutputSelector, #GstInputSelector
23  *
24  * Direct input stream to one out of N output pads.
25  *
26  * Since: 0.10.32
27  */
28
29 #ifdef HAVE_CONFIG_H
30 #include "config.h"
31 #endif
32
33 #include <string.h>
34
35 #include "gstoutputselector.h"
36
37 GST_DEBUG_CATEGORY_STATIC (output_selector_debug);
38 #define GST_CAT_DEFAULT output_selector_debug
39
40 static GstStaticPadTemplate gst_output_selector_sink_factory =
41 GST_STATIC_PAD_TEMPLATE ("sink",
42     GST_PAD_SINK,
43     GST_PAD_ALWAYS,
44     GST_STATIC_CAPS_ANY);
45
46 static GstStaticPadTemplate gst_output_selector_src_factory =
47 GST_STATIC_PAD_TEMPLATE ("src%d",
48     GST_PAD_SRC,
49     GST_PAD_REQUEST,
50     GST_STATIC_CAPS_ANY);
51
52 enum GstOutputSelectorPadNegotiationMode
53 {
54   GST_OUTPUT_SELECTOR_PAD_NEGOTIATION_MODE_NONE,
55   GST_OUTPUT_SELECTOR_PAD_NEGOTIATION_MODE_ALL,
56   GST_OUTPUT_SELECTOR_PAD_NEGOTIATION_MODE_ACTIVE
57 };
58 #define GST_TYPE_OUTPUT_SELECTOR_PAD_NEGOTIATION_MODE (gst_output_selector_pad_negotiation_mode_get_type())
59 static GType
60 gst_output_selector_pad_negotiation_mode_get_type (void)
61 {
62   static GType pad_negotiation_mode_type = 0;
63   static GEnumValue pad_negotiation_modes[] = {
64     {GST_OUTPUT_SELECTOR_PAD_NEGOTIATION_MODE_NONE, "None", "none"},
65     {GST_OUTPUT_SELECTOR_PAD_NEGOTIATION_MODE_ALL, "All", "all"},
66     {GST_OUTPUT_SELECTOR_PAD_NEGOTIATION_MODE_ACTIVE, "Active", "active"},
67     {0, NULL, NULL}
68   };
69
70   if (!pad_negotiation_mode_type) {
71     pad_negotiation_mode_type =
72         g_enum_register_static ("GstOutputSelectorPadNegotiationMode",
73         pad_negotiation_modes);
74   }
75   return pad_negotiation_mode_type;
76 }
77
78
79 enum
80 {
81   PROP_0,
82   PROP_ACTIVE_PAD,
83   PROP_RESEND_LATEST,
84   PROP_PAD_NEGOTIATION_MODE
85 };
86
87 #define DEFAULT_PAD_NEGOTIATION_MODE GST_OUTPUT_SELECTOR_PAD_NEGOTIATION_MODE_ALL
88
89 #define _do_init(bla) \
90 GST_DEBUG_CATEGORY_INIT (output_selector_debug, \
91         "output-selector", 0, "Output stream selector");
92
93 GST_BOILERPLATE_FULL (GstOutputSelector, gst_output_selector, GstElement,
94     GST_TYPE_ELEMENT, _do_init);
95
96 static void gst_output_selector_dispose (GObject * object);
97 static void gst_output_selector_set_property (GObject * object,
98     guint prop_id, const GValue * value, GParamSpec * pspec);
99 static void gst_output_selector_get_property (GObject * object,
100     guint prop_id, GValue * value, GParamSpec * pspec);
101 static GstPad *gst_output_selector_request_new_pad (GstElement * element,
102     GstPadTemplate * templ, const gchar * unused);
103 static void gst_output_selector_release_pad (GstElement * element,
104     GstPad * pad);
105 static GstFlowReturn gst_output_selector_chain (GstPad * pad, GstBuffer * buf);
106 static GstFlowReturn gst_output_selector_buffer_alloc (GstPad * pad,
107     guint64 offset, guint size, GstCaps * caps, GstBuffer ** buf);
108 static GstStateChangeReturn gst_output_selector_change_state (GstElement *
109     element, GstStateChange transition);
110 static gboolean gst_output_selector_handle_sink_event (GstPad * pad,
111     GstEvent * event);
112 static void gst_output_selector_switch_pad_negotiation_mode (GstOutputSelector *
113     sel, gint mode);
114
115 static void
116 gst_output_selector_base_init (gpointer g_class)
117 {
118   GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
119
120   gst_element_class_set_details_simple (element_class, "Output selector",
121       "Generic", "1-to-N output stream selector",
122       "Stefan Kost <stefan.kost@nokia.com>");
123   gst_element_class_add_pad_template (element_class,
124       gst_static_pad_template_get (&gst_output_selector_sink_factory));
125   gst_element_class_add_pad_template (element_class,
126       gst_static_pad_template_get (&gst_output_selector_src_factory));
127 }
128
129 static void
130 gst_output_selector_class_init (GstOutputSelectorClass * klass)
131 {
132   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
133   GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
134
135   gobject_class->dispose = gst_output_selector_dispose;
136
137   gobject_class->set_property = gst_output_selector_set_property;
138   gobject_class->get_property = gst_output_selector_get_property;
139
140   g_object_class_install_property (gobject_class, PROP_ACTIVE_PAD,
141       g_param_spec_object ("active-pad", "Active pad",
142           "Currently active src pad", GST_TYPE_PAD,
143           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
144   g_object_class_install_property (gobject_class, PROP_RESEND_LATEST,
145       g_param_spec_boolean ("resend-latest", "Resend latest buffer",
146           "Resend latest buffer after a switch to a new pad", FALSE,
147           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
148   g_object_class_install_property (gobject_class, PROP_PAD_NEGOTIATION_MODE,
149       g_param_spec_enum ("pad-negotiation-mode", "Pad negotiation mode",
150           "The mode to be used for pad negotiation",
151           GST_TYPE_OUTPUT_SELECTOR_PAD_NEGOTIATION_MODE,
152           DEFAULT_PAD_NEGOTIATION_MODE,
153           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
154
155   gstelement_class->request_new_pad =
156       GST_DEBUG_FUNCPTR (gst_output_selector_request_new_pad);
157   gstelement_class->release_pad =
158       GST_DEBUG_FUNCPTR (gst_output_selector_release_pad);
159
160   gstelement_class->change_state = gst_output_selector_change_state;
161 }
162
163 static void
164 gst_output_selector_init (GstOutputSelector * sel,
165     GstOutputSelectorClass * g_class)
166 {
167   sel->sinkpad =
168       gst_pad_new_from_static_template (&gst_output_selector_sink_factory,
169       "sink");
170   gst_pad_set_chain_function (sel->sinkpad,
171       GST_DEBUG_FUNCPTR (gst_output_selector_chain));
172   gst_pad_set_event_function (sel->sinkpad,
173       GST_DEBUG_FUNCPTR (gst_output_selector_handle_sink_event));
174   gst_pad_set_bufferalloc_function (sel->sinkpad,
175       GST_DEBUG_FUNCPTR (gst_output_selector_buffer_alloc));
176
177   gst_element_add_pad (GST_ELEMENT (sel), sel->sinkpad);
178
179   /* srcpad management */
180   sel->active_srcpad = NULL;
181   sel->nb_srcpads = 0;
182   gst_segment_init (&sel->segment, GST_FORMAT_UNDEFINED);
183   sel->pending_srcpad = NULL;
184
185   sel->resend_latest = FALSE;
186   sel->latest_buffer = NULL;
187   gst_output_selector_switch_pad_negotiation_mode (sel,
188       DEFAULT_PAD_NEGOTIATION_MODE);
189 }
190
191 static void
192 gst_output_selector_reset (GstOutputSelector * osel)
193 {
194   if (osel->pending_srcpad != NULL) {
195     gst_object_unref (osel->pending_srcpad);
196     osel->pending_srcpad = NULL;
197   }
198   if (osel->latest_buffer != NULL) {
199     gst_buffer_unref (osel->latest_buffer);
200     osel->latest_buffer = NULL;
201   }
202   gst_segment_init (&osel->segment, GST_FORMAT_UNDEFINED);
203 }
204
205 static void
206 gst_output_selector_dispose (GObject * object)
207 {
208   GstOutputSelector *osel = GST_OUTPUT_SELECTOR (object);
209
210   gst_output_selector_reset (osel);
211
212   G_OBJECT_CLASS (parent_class)->dispose (object);
213 }
214
215 static void
216 gst_output_selector_set_property (GObject * object, guint prop_id,
217     const GValue * value, GParamSpec * pspec)
218 {
219   GstOutputSelector *sel = GST_OUTPUT_SELECTOR (object);
220
221   switch (prop_id) {
222     case PROP_ACTIVE_PAD:
223     {
224       GstPad *next_pad;
225
226       next_pad = g_value_get_object (value);
227
228       GST_INFO_OBJECT (sel, "Activating pad %s:%s",
229           GST_DEBUG_PAD_NAME (next_pad));
230
231       GST_OBJECT_LOCK (object);
232       if (next_pad != sel->active_srcpad) {
233         /* switch to new srcpad in next chain run */
234         if (sel->pending_srcpad != NULL) {
235           GST_INFO ("replacing pending switch");
236           gst_object_unref (sel->pending_srcpad);
237         }
238         if (next_pad)
239           gst_object_ref (next_pad);
240         sel->pending_srcpad = next_pad;
241       } else {
242         GST_INFO ("pad already active");
243         if (sel->pending_srcpad != NULL) {
244           gst_object_unref (sel->pending_srcpad);
245           sel->pending_srcpad = NULL;
246         }
247       }
248       GST_OBJECT_UNLOCK (object);
249       break;
250     }
251     case PROP_RESEND_LATEST:{
252       sel->resend_latest = g_value_get_boolean (value);
253       break;
254     }
255     case PROP_PAD_NEGOTIATION_MODE:{
256       gst_output_selector_switch_pad_negotiation_mode (sel,
257           g_value_get_enum (value));
258       break;
259     }
260     default:
261       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
262       break;
263   }
264 }
265
266 static void
267 gst_output_selector_get_property (GObject * object, guint prop_id,
268     GValue * value, GParamSpec * pspec)
269 {
270   GstOutputSelector *sel = GST_OUTPUT_SELECTOR (object);
271
272   switch (prop_id) {
273     case PROP_ACTIVE_PAD:
274       GST_OBJECT_LOCK (object);
275       g_value_set_object (value,
276           sel->pending_srcpad ? sel->pending_srcpad : sel->active_srcpad);
277       GST_OBJECT_UNLOCK (object);
278       break;
279     case PROP_RESEND_LATEST:{
280       GST_OBJECT_LOCK (object);
281       g_value_set_boolean (value, sel->resend_latest);
282       GST_OBJECT_UNLOCK (object);
283       break;
284     }
285     case PROP_PAD_NEGOTIATION_MODE:
286       g_value_set_enum (value, sel->pad_negotiation_mode);
287       break;
288     default:
289       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
290       break;
291   }
292 }
293
294 static GstCaps *
295 gst_output_selector_sink_getcaps (GstPad * pad)
296 {
297   GstOutputSelector *sel = GST_OUTPUT_SELECTOR (gst_pad_get_parent (pad));
298   GstPad *active = NULL;
299   GstCaps *caps = NULL;
300
301   if (G_UNLIKELY (sel == NULL))
302     return gst_caps_new_any ();
303
304   GST_OBJECT_LOCK (sel);
305   if (sel->pending_srcpad)
306     active = gst_object_ref (sel->pending_srcpad);
307   else if (sel->active_srcpad)
308     active = gst_object_ref (sel->active_srcpad);
309   GST_OBJECT_UNLOCK (sel);
310
311   if (active) {
312     caps = gst_pad_peer_get_caps_reffed (active);
313     gst_object_unref (active);
314   }
315   if (caps == NULL) {
316     caps = gst_caps_new_any ();
317   }
318
319   gst_object_unref (sel);
320   return caps;
321 }
322
323 static gboolean
324 gst_output_selector_sink_setcaps (GstPad * pad, GstCaps * caps)
325 {
326   GstOutputSelector *sel = GST_OUTPUT_SELECTOR (GST_PAD_PARENT (pad));
327   GstPad *active = NULL;
328   gboolean ret = TRUE;
329
330   GST_OBJECT_LOCK (sel);
331   if (sel->pending_srcpad)
332     active = gst_object_ref (sel->pending_srcpad);
333   else if (sel->active_srcpad)
334     active = gst_object_ref (sel->active_srcpad);
335   GST_OBJECT_UNLOCK (sel);
336
337   if (active) {
338     ret = gst_pad_set_caps (active, caps);
339     gst_object_unref (active);
340   }
341   return ret;
342 }
343
344 static void
345 gst_output_selector_switch_pad_negotiation_mode (GstOutputSelector * sel,
346     gint mode)
347 {
348   sel->pad_negotiation_mode = mode;
349   if (mode == GST_OUTPUT_SELECTOR_PAD_NEGOTIATION_MODE_ALL) {
350     gst_pad_set_getcaps_function (sel->sinkpad, gst_pad_proxy_getcaps);
351     gst_pad_set_setcaps_function (sel->sinkpad, gst_pad_proxy_setcaps);
352   } else if (mode == GST_OUTPUT_SELECTOR_PAD_NEGOTIATION_MODE_NONE) {
353     gst_pad_set_getcaps_function (sel->sinkpad, NULL);
354     gst_pad_set_setcaps_function (sel->sinkpad, NULL);
355   } else {                      /* active */
356     gst_pad_set_getcaps_function (sel->sinkpad,
357         gst_output_selector_sink_getcaps);
358     gst_pad_set_setcaps_function (sel->sinkpad,
359         gst_output_selector_sink_setcaps);
360   }
361 }
362
363 static GstFlowReturn
364 gst_output_selector_buffer_alloc (GstPad * pad, guint64 offset, guint size,
365     GstCaps * caps, GstBuffer ** buf)
366 {
367   GstOutputSelector *sel;
368   GstFlowReturn res;
369   GstPad *allocpad;
370
371   sel = GST_OUTPUT_SELECTOR (gst_pad_get_parent (pad));
372   if (G_UNLIKELY (sel == NULL))
373     return GST_FLOW_WRONG_STATE;
374
375   GST_OBJECT_LOCK (sel);
376   allocpad = sel->pending_srcpad ? sel->pending_srcpad : sel->active_srcpad;
377   if (allocpad) {
378     /* if we had a previous pad we used for allocating a buffer, continue using
379      * it. */
380     GST_DEBUG_OBJECT (sel, "using pad %s:%s for alloc",
381         GST_DEBUG_PAD_NAME (allocpad));
382     gst_object_ref (allocpad);
383     GST_OBJECT_UNLOCK (sel);
384
385     res = gst_pad_alloc_buffer (allocpad, offset, size, caps, buf);
386     gst_object_unref (allocpad);
387
388     GST_OBJECT_LOCK (sel);
389   } else {
390     /* fallback case, allocate a buffer of our own, add pad caps. */
391     GST_DEBUG_OBJECT (pad, "fallback buffer alloc");
392     *buf = NULL;
393     res = GST_FLOW_OK;
394   }
395   GST_OBJECT_UNLOCK (sel);
396
397   GST_DEBUG_OBJECT (sel, "buffer alloc finished: %s", gst_flow_get_name (res));
398
399   gst_object_unref (sel);
400   return res;
401 }
402
403 static GstPad *
404 gst_output_selector_request_new_pad (GstElement * element,
405     GstPadTemplate * templ, const gchar * name)
406 {
407   gchar *padname;
408   GstPad *srcpad;
409   GstOutputSelector *osel;
410
411   osel = GST_OUTPUT_SELECTOR (element);
412
413   GST_DEBUG_OBJECT (osel, "requesting pad");
414
415   GST_OBJECT_LOCK (osel);
416   padname = g_strdup_printf ("src%d", osel->nb_srcpads++);
417   srcpad = gst_pad_new_from_template (templ, padname);
418   GST_OBJECT_UNLOCK (osel);
419
420   gst_pad_set_active (srcpad, TRUE);
421   gst_element_add_pad (GST_ELEMENT (osel), srcpad);
422
423   /* Set the first requested src pad as active by default */
424   if (osel->active_srcpad == NULL) {
425     osel->active_srcpad = srcpad;
426   }
427   g_free (padname);
428
429   return srcpad;
430 }
431
432 static void
433 gst_output_selector_release_pad (GstElement * element, GstPad * pad)
434 {
435   GstOutputSelector *osel;
436
437   osel = GST_OUTPUT_SELECTOR (element);
438
439   GST_DEBUG_OBJECT (osel, "releasing pad");
440
441   gst_pad_set_active (pad, FALSE);
442
443   gst_element_remove_pad (GST_ELEMENT_CAST (osel), pad);
444 }
445
446 static gboolean
447 gst_output_selector_switch (GstOutputSelector * osel)
448 {
449   gboolean res = FALSE;
450   GstEvent *ev = NULL;
451   GstSegment *seg = NULL;
452   gint64 start = 0, position = 0;
453
454   /* Switch */
455   GST_OBJECT_LOCK (GST_OBJECT (osel));
456   GST_INFO ("switching to pad %" GST_PTR_FORMAT, osel->pending_srcpad);
457   if (gst_pad_is_linked (osel->pending_srcpad)) {
458     osel->active_srcpad = osel->pending_srcpad;
459     res = TRUE;
460   }
461   gst_object_unref (osel->pending_srcpad);
462   osel->pending_srcpad = NULL;
463   GST_OBJECT_UNLOCK (GST_OBJECT (osel));
464
465   /* Send NEWSEGMENT event and latest buffer if switching succeeded
466    * and we already have a valid segment configured */
467   if (res && osel->segment.format != GST_FORMAT_UNDEFINED) {
468     /* Send NEWSEGMENT to the pad we are going to switch to */
469     seg = &osel->segment;
470
471     /* If resending then mark newsegment start and position accordingly */
472     if (osel->resend_latest && osel->latest_buffer &&
473         GST_BUFFER_TIMESTAMP_IS_VALID (osel->latest_buffer)) {
474       start = position = GST_BUFFER_TIMESTAMP (osel->latest_buffer);
475     } else {
476       start = position = seg->last_stop;
477     }
478     ev = gst_event_new_new_segment (TRUE, seg->rate,
479         seg->format, start, seg->stop, position);
480     if (!gst_pad_push_event (osel->active_srcpad, ev)) {
481       GST_WARNING_OBJECT (osel,
482           "newsegment handling failed in %" GST_PTR_FORMAT,
483           osel->active_srcpad);
484     }
485
486     /* Resend latest buffer to newly switched pad */
487     if (osel->resend_latest && osel->latest_buffer) {
488       GST_INFO ("resending latest buffer");
489       gst_pad_push (osel->active_srcpad, gst_buffer_ref (osel->latest_buffer));
490     }
491   } else {
492     GST_WARNING_OBJECT (osel, "switch failed, pad not linked");
493   }
494
495   return res;
496 }
497
498 static GstFlowReturn
499 gst_output_selector_chain (GstPad * pad, GstBuffer * buf)
500 {
501   GstFlowReturn res;
502   GstOutputSelector *osel;
503   GstClockTime last_stop, duration;
504
505   osel = GST_OUTPUT_SELECTOR (gst_pad_get_parent (pad));
506
507   /*
508    * The _switch function might push a buffer if 'resend-latest' is true.
509    *
510    * Elements/Applications (e.g. camerabin) might use pad probes to
511    * switch output-selector's active pad. If we simply switch and don't
512    * recheck any pending pad switch the following codepath could end
513    * up pushing a buffer on a non-active pad. This is bad.
514    *
515    * So we always should check the pending_srcpad before going further down
516    * the chain and pushing the new buffer
517    */
518   while (osel->pending_srcpad) {
519     /* Do the switch */
520     gst_output_selector_switch (osel);
521   }
522
523   if (osel->latest_buffer) {
524     gst_buffer_unref (osel->latest_buffer);
525     osel->latest_buffer = NULL;
526   }
527
528   if (osel->resend_latest) {
529     /* Keep reference to latest buffer to resend it after switch */
530     osel->latest_buffer = gst_buffer_ref (buf);
531   }
532
533   /* Keep track of last stop and use it in NEWSEGMENT start after 
534      switching to a new src pad */
535   last_stop = GST_BUFFER_TIMESTAMP (buf);
536   if (GST_CLOCK_TIME_IS_VALID (last_stop)) {
537     duration = GST_BUFFER_DURATION (buf);
538     if (GST_CLOCK_TIME_IS_VALID (duration)) {
539       last_stop += duration;
540     }
541     GST_LOG_OBJECT (osel, "setting last stop %" GST_TIME_FORMAT,
542         GST_TIME_ARGS (last_stop));
543     gst_segment_set_last_stop (&osel->segment, osel->segment.format, last_stop);
544   }
545
546   GST_LOG_OBJECT (osel, "pushing buffer to %" GST_PTR_FORMAT,
547       osel->active_srcpad);
548   res = gst_pad_push (osel->active_srcpad, buf);
549   gst_object_unref (osel);
550
551   return res;
552 }
553
554 static GstStateChangeReturn
555 gst_output_selector_change_state (GstElement * element,
556     GstStateChange transition)
557 {
558   GstOutputSelector *sel;
559   GstStateChangeReturn result;
560
561   sel = GST_OUTPUT_SELECTOR (element);
562
563   switch (transition) {
564     case GST_STATE_CHANGE_READY_TO_PAUSED:
565       break;
566     default:
567       break;
568   }
569
570   result = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
571
572   switch (transition) {
573     case GST_STATE_CHANGE_PAUSED_TO_READY:
574       gst_output_selector_reset (sel);
575       break;
576     default:
577       break;
578   }
579
580   return result;
581 }
582
583 static gboolean
584 gst_output_selector_handle_sink_event (GstPad * pad, GstEvent * event)
585 {
586   gboolean res = TRUE;
587   GstOutputSelector *sel;
588   GstPad *output_pad = NULL;
589
590   sel = GST_OUTPUT_SELECTOR (gst_pad_get_parent (pad));
591   if (G_UNLIKELY (sel == NULL)) {
592     gst_event_unref (event);
593     return FALSE;
594   }
595
596   switch (GST_EVENT_TYPE (event)) {
597     case GST_EVENT_NEWSEGMENT:
598     {
599       gboolean update;
600       GstFormat format;
601       gdouble rate, arate;
602       gint64 start, stop, time;
603
604       gst_event_parse_new_segment_full (event, &update, &rate, &arate, &format,
605           &start, &stop, &time);
606
607       GST_DEBUG_OBJECT (sel,
608           "configured NEWSEGMENT update %d, rate %lf, applied rate %lf, "
609           "format %d, " "%" G_GINT64_FORMAT " -- %" G_GINT64_FORMAT ", time %"
610           G_GINT64_FORMAT, update, rate, arate, format, start, stop, time);
611
612       gst_segment_set_newsegment_full (&sel->segment, update,
613           rate, arate, format, start, stop, time);
614
615       /* Send newsegment to all src pads */
616       gst_pad_event_default (pad, event);
617       break;
618     }
619     case GST_EVENT_EOS:
620       /* Send eos to all src pads */
621       gst_pad_event_default (pad, event);
622       break;
623     default:
624       /* Send other events to pending or active src pad */
625       output_pad =
626           sel->pending_srcpad ? sel->pending_srcpad : sel->active_srcpad;
627       res = gst_pad_push_event (output_pad, event);
628       break;
629   }
630
631   gst_object_unref (sel);
632
633   return res;
634 }