+forward_sticky_events (GstPad * sinkpad, GstEvent ** event, gpointer user_data)
+{
+ GstInputSelector *sel = GST_INPUT_SELECTOR (user_data);
+
+ GST_DEBUG_OBJECT (sinkpad, "forward sticky event %" GST_PTR_FORMAT, *event);
+
+ if (GST_EVENT_TYPE (*event) == GST_EVENT_SEGMENT) {
+ GstSegment *seg = &GST_SELECTOR_PAD (sinkpad)->segment;
+ GstEvent *e;
+
+ e = gst_event_new_segment (seg);
+ gst_event_set_seqnum (e, GST_SELECTOR_PAD_CAST (sinkpad)->segment_seqnum);
+
+ gst_pad_push_event (sel->srcpad, e);
+ } else if (GST_EVENT_TYPE (*event) == GST_EVENT_STREAM_START
+ && !sel->have_group_id) {
+ GstEvent *tmp =
+ gst_pad_get_sticky_event (sel->srcpad, GST_EVENT_STREAM_START, 0);
+
+ /* Only push stream-start once if not all our streams have a stream-id */
+ if (!tmp) {
+ gst_pad_push_event (sel->srcpad, gst_event_ref (*event));
+ } else {
+ gst_event_unref (tmp);
+ }
+ } else {
+ gst_pad_push_event (sel->srcpad, gst_event_ref (*event));
+ }
+
+ return TRUE;
+}
+
+static gboolean
+gst_input_selector_eos_wait (GstInputSelector * self, GstSelectorPad * pad,
+ GstEvent * eos_event)
+{
+ while (!self->eos && !self->flushing && !pad->flushing) {
+ GstPad *active_sinkpad;
+ active_sinkpad = gst_input_selector_get_active_sinkpad (self);
+ if (pad == GST_SELECTOR_PAD_CAST (active_sinkpad) && pad->eos
+ && !pad->eos_sent) {
+ GST_DEBUG_OBJECT (pad, "send EOS event");
+ GST_INPUT_SELECTOR_UNLOCK (self);
+ /* if we have a pending events, push them now */
+ if (pad->events_pending) {
+ gst_pad_sticky_events_foreach (GST_PAD_CAST (pad),
+ forward_sticky_events, self);
+ pad->events_pending = FALSE;
+ }
+
+ gst_pad_push_event (self->srcpad, gst_event_ref (eos_event));
+ GST_INPUT_SELECTOR_LOCK (self);
+ /* Wake up other pads so they can continue when syncing to
+ * running time, as this pad just switched to EOS and
+ * may enable others to progress */
+ GST_INPUT_SELECTOR_BROADCAST (self);
+ pad->eos_sent = TRUE;
+ } else {
+ /* we can be unlocked here when we are shutting down (flushing) or when we
+ * get unblocked */
+ GST_INPUT_SELECTOR_WAIT (self);
+ }
+ }
+
+ return self->flushing;
+}
+
+static gboolean
+gst_input_selector_all_eos (GstInputSelector * sel)
+{
+ GList *walk;
+
+ for (walk = GST_ELEMENT_CAST (sel)->sinkpads; walk; walk = walk->next) {
+ GstSelectorPad *selpad;
+
+ selpad = GST_SELECTOR_PAD_CAST (walk->data);
+ if (!selpad->eos) {
+ return FALSE;
+ }
+
+ }
+
+ return TRUE;
+}
+
+static gboolean