uridecodebin3: Forward upstream events to decodebin3 directly
authorSeungha Yang <seungha@centricular.com>
Tue, 13 Oct 2020 08:57:53 +0000 (17:57 +0900)
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Wed, 14 Oct 2020 18:24:11 +0000 (18:24 +0000)
Otherwise default handler will try to forward it to sink element
or srcpad which might not be available at that moment.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/867>

gst/playback/gsturidecodebin3.c

index 0286d95..fcfdbf4 100644 (file)
@@ -345,6 +345,8 @@ static GstSourceHandler *new_source_handler (GstURIDecodeBin3 * uridecodebin,
 
 static GstStateChangeReturn gst_uri_decode_bin3_change_state (GstElement *
     element, GstStateChange transition);
+static gboolean gst_uri_decodebin3_send_event (GstElement * element,
+    GstEvent * event);
 
 static gboolean
 _gst_int_accumulator (GSignalInvocationHint * ihint,
@@ -515,6 +517,8 @@ gst_uri_decode_bin3_class_init (GstURIDecodeBin3Class * klass)
       "Edward Hervey <edward@centricular.com>, Jan Schmidt <jan@centricular.com>");
 
   gstelement_class->change_state = gst_uri_decode_bin3_change_state;
+  gstelement_class->send_event =
+      GST_DEBUG_FUNCPTR (gst_uri_decodebin3_send_event);
 
   klass->select_stream = gst_uridecodebin3_select_stream;
 }
@@ -1118,6 +1122,16 @@ failure:
   }
 }
 
+static gboolean
+gst_uri_decodebin3_send_event (GstElement * element, GstEvent * event)
+{
+  GstURIDecodeBin3 *self = GST_URI_DECODE_BIN3 (element);
+
+  if (GST_EVENT_IS_UPSTREAM (event) && self->decodebin)
+    return gst_element_send_event (self->decodebin, event);
+
+  return GST_ELEMENT_CLASS (parent_class)->send_event (element, event);
+}
 
 gboolean
 gst_uri_decode_bin3_plugin_init (GstPlugin * plugin)