proxy: Forward queries/events sent directly to the element correctly

This commit is contained in:
Sebastian Dröge 2019-05-21 16:17:40 +03:00 committed by Sebastian Dröge
parent 70b08bdbfa
commit ab9d42cc7f
2 changed files with 71 additions and 0 deletions

View file

@ -67,6 +67,10 @@ static gboolean gst_proxy_sink_sink_event (GstPad * pad, GstObject * parent,
static GstStateChangeReturn gst_proxy_sink_change_state (GstElement * element,
GstStateChange transition);
static gboolean gst_proxy_sink_send_event (GstElement * element,
GstEvent * event);
static gboolean gst_proxy_sink_query (GstElement * element, GstQuery * query);
static void
gst_proxy_sink_class_init (GstProxySinkClass * klass)
{
@ -75,6 +79,8 @@ gst_proxy_sink_class_init (GstProxySinkClass * klass)
GST_DEBUG_CATEGORY_INIT (gst_proxy_sink_debug, "proxysink", 0, "proxy sink");
gstelement_class->change_state = gst_proxy_sink_change_state;
gstelement_class->send_event = gst_proxy_sink_send_event;
gstelement_class->query = gst_proxy_sink_query;
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&sink_template));
@ -122,6 +128,31 @@ gst_proxy_sink_change_state (GstElement * element, GstStateChange transition)
return ret;
}
static gboolean
gst_proxy_sink_send_event (GstElement * element, GstEvent * event)
{
GstProxySink *self = GST_PROXY_SINK (element);
if (GST_EVENT_IS_UPSTREAM (event)) {
return gst_pad_push_event (self->sinkpad, event);
} else {
gst_event_unref (event);
return FALSE;
}
}
static gboolean
gst_proxy_sink_query (GstElement * element, GstQuery * query)
{
GstProxySink *self = GST_PROXY_SINK (element);
if (GST_QUERY_IS_UPSTREAM (query)) {
return gst_pad_peer_query (self->sinkpad, query);
} else {
return FALSE;
}
}
static gboolean
gst_proxy_sink_sink_query (GstPad * pad, GstObject * parent, GstQuery * query)
{

View file

@ -108,6 +108,9 @@ static gboolean gst_proxy_src_internal_src_event (GstPad * pad,
static GstStateChangeReturn gst_proxy_src_change_state (GstElement * element,
GstStateChange transition);
static gboolean gst_proxy_src_send_event (GstElement * element,
GstEvent * event);
static gboolean gst_proxy_src_query (GstElement * element, GstQuery * query);
static void gst_proxy_src_dispose (GObject * object);
static void
@ -175,6 +178,8 @@ gst_proxy_src_class_init (GstProxySrcClass * klass)
GST_TYPE_PROXY_SINK, G_PARAM_READWRITE));
gstelement_class->change_state = gst_proxy_src_change_state;
gstelement_class->send_event = gst_proxy_src_send_event;
gstelement_class->query = gst_proxy_src_query;
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&src_template));
@ -275,6 +280,41 @@ gst_proxy_src_change_state (GstElement * element, GstStateChange transition)
return ret;
}
static gboolean
gst_proxy_src_send_event (GstElement * element, GstEvent * event)
{
GstProxySrc *self = GST_PROXY_SRC (element);
if (GST_EVENT_IS_DOWNSTREAM (event)) {
GstPad *sinkpad = gst_element_get_static_pad (self->queue, "sink");
gboolean ret;
ret = gst_pad_send_event (sinkpad, event);
gst_object_unref (sinkpad);
return ret;
} else {
gst_event_unref (event);
return FALSE;
}
}
static gboolean
gst_proxy_src_query (GstElement * element, GstQuery * query)
{
GstProxySrc *self = GST_PROXY_SRC (element);
if (GST_QUERY_IS_DOWNSTREAM (query)) {
GstPad *sinkpad = gst_element_get_static_pad (self->queue, "sink");
gboolean ret;
ret = gst_pad_query (sinkpad, query);
gst_object_unref (sinkpad);
return ret;
} else {
return FALSE;
}
}
static gboolean
gst_proxy_src_internal_src_query (GstPad * pad, GstObject * parent,
GstQuery * query)