Skip to content

Commit

Permalink
Merge branch 'feature/fix-pads-caps-handling' into dev-0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
maumonteroj committed Jun 26, 2019
2 parents 8179d4c + c0c2f9f commit 9ba0245
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions gst-libs/gst/r2inference/gstvideoinference.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -1044,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)) {
Expand Down

0 comments on commit 9ba0245

Please sign in to comment.