From 8781d7b4d7bdab0bfea4c9e1260d387df246f4d9 Mon Sep 17 00:00:00 2001 From: maumonteroj Date: Wed, 26 Jun 2019 11:32:24 -0600 Subject: [PATCH 1/2] Associate internal pads for correct caps handling Queries were not being forwarded from sink to src pads (and viceversa. Hence, caps were not being properly negotiated. In order to fix each pad was associated internally with the respective proxy, so that GStreamer is able to handle forwards appropriately. --- gst-libs/gst/r2inference/gstvideoinference.c | 64 ++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/gst-libs/gst/r2inference/gstvideoinference.c b/gst-libs/gst/r2inference/gstvideoinference.c index 94e6730a..d87cbb3e 100644 --- a/gst-libs/gst/r2inference/gstvideoinference.c +++ b/gst-libs/gst/r2inference/gstvideoinference.c @@ -136,12 +136,16 @@ static gboolean gst_video_inference_postprocess (GstVideoInference * self, GstVideoInferencePad * pad_model, GstBuffer * buffer_bypass, GstVideoInferencePad * pad_bypass); +static GstIterator *gst_video_inference_iterate_internal_links (GstPad * pad, + GstObject * parent); static gboolean gst_video_inference_sink_event (GstCollectPads * pads, GstCollectData * pad, GstEvent * event, gpointer user_data); static gboolean gst_video_inference_src_event (GstPad * pad, GstObject * parent, GstEvent * event); static GstPad *gst_video_inference_get_src_pad (GstVideoInference * self, GstVideoInferencePrivate * priv, GstPad * pad); +static GstPad *gst_video_inference_get_sink_pad (GstVideoInference * self, + GstVideoInferencePrivate * priv, GstPad * pad); static void gst_video_inference_set_backend (GstVideoInference * self, gint backend); static guint gst_video_inference_get_backend_type (GstVideoInference * self); @@ -487,6 +491,13 @@ gst_video_inference_create_pad (GstVideoInference * self, goto remove_pad; } + gst_pad_set_iterate_internal_links_function (pad, + gst_video_inference_iterate_internal_links); + + GST_PAD_SET_PROXY_CAPS (pad); + GST_PAD_SET_PROXY_ALLOCATION (pad); + GST_PAD_SET_PROXY_SCHEDULING (pad); + return GST_PAD_CAST (gst_object_ref (pad)); remove_pad: @@ -1008,6 +1019,23 @@ gst_video_inference_get_src_pad (GstVideoInference * self, return pad; } +static GstPad * +gst_video_inference_get_sink_pad (GstVideoInference * self, + GstVideoInferencePrivate * priv, GstPad * srcpad) +{ + GstPad *pad; + + if (srcpad == priv->src_model) { + pad = priv->sink_model; + } else if (srcpad == priv->src_bypass) { + pad = priv->sink_bypass; + } else { + g_return_val_if_reached (NULL); + } + + return pad; +} + static void gst_video_inference_set_caps (GstVideoInference * self, GstVideoInferencePrivate * priv, GstCollectData * data, GstEvent * event) @@ -1035,6 +1063,42 @@ gst_video_inference_set_caps (GstVideoInference * self, } } +static GstIterator * +gst_video_inference_iterate_internal_links (GstPad * pad, GstObject * parent) +{ + GstIterator *it = NULL; + GstPad *opad; + GValue val = { 0, }; + GstVideoInference *self = GST_VIDEO_INFERENCE (parent); + GstVideoInferencePrivate *priv = GST_VIDEO_INFERENCE_PRIVATE (self); + + GST_LOG_OBJECT (self, "Internal links"); + + GST_OBJECT_LOCK (parent); + + if (GST_PAD_IS_SINK (pad)) { + opad = gst_video_inference_get_src_pad (self, priv, pad); + if (opad == NULL) { + goto out; + } + } else { + opad = gst_video_inference_get_sink_pad (self, priv, pad); + if (opad == NULL) { + goto out; + } + } + + g_value_init (&val, GST_TYPE_PAD); + g_value_set_object (&val, opad); + it = gst_iterator_new_single (GST_TYPE_PAD, &val); + g_value_unset (&val); + +out: + GST_OBJECT_UNLOCK (parent); + + return it; +} + static gboolean gst_video_inference_sink_event (GstCollectPads * pads, GstCollectData * pad, GstEvent * event, gpointer user_data) From c0c2f9fc87967ebd9c8cf2bb3523dc96f690c04e Mon Sep 17 00:00:00 2001 From: maumonteroj Date: Wed, 26 Jun 2019 12:19:11 -0600 Subject: [PATCH 2/2] Add recieved event log --- gst-libs/gst/r2inference/gstvideoinference.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gst-libs/gst/r2inference/gstvideoinference.c b/gst-libs/gst/r2inference/gstvideoinference.c index d87cbb3e..01ea6863 100644 --- a/gst-libs/gst/r2inference/gstvideoinference.c +++ b/gst-libs/gst/r2inference/gstvideoinference.c @@ -1108,6 +1108,9 @@ gst_video_inference_sink_event (GstCollectPads * pads, GstCollectData * pad, gboolean ret = FALSE; GstPad *srcpad; + GST_LOG_OBJECT (self, "Received event %s from %" GST_PTR_FORMAT, + GST_EVENT_TYPE_NAME (event), pad->pad); + srcpad = gst_video_inference_get_src_pad (self, priv, pad->pad); switch (GST_EVENT_TYPE (event)) {