diff --git a/omx/gstomxvideodec.c b/omx/gstomxvideodec.c index 31be4df473..70307ec928 100644 --- a/omx/gstomxvideodec.c +++ b/omx/gstomxvideodec.c @@ -1987,6 +1987,35 @@ gst_omx_video_dec_negotiate (GstOMXVideoDec * self) return (err == OMX_ErrorNone); } +#ifdef USE_OMX_TARGET_ZYNQ_USCALE_PLUS +static void +gst_omx_video_dec_set_latency (GstOMXVideoDec * self) +{ + GstClockTime latency; + OMX_ALG_PARAM_REPORTED_LATENCY param; + OMX_ERRORTYPE err; + + GST_OMX_INIT_STRUCT (¶m); + err = + gst_omx_component_get_parameter (self->dec, + (OMX_INDEXTYPE) OMX_ALG_IndexParamReportedLatency, ¶m); + + if (err != OMX_ErrorNone) { + GST_WARNING_OBJECT (self, "Couldn't retrieve latency: %s (0x%08x)", + gst_omx_error_to_string (err), err); + return; + } + + GST_DEBUG_OBJECT (self, "retrieved latency of %d ms", + (guint32) param.nLatency); + + /* Convert to ns */ + latency = param.nLatency * GST_MSECOND; + + gst_video_encoder_set_latency (GST_VIDEO_ENCODER (self), latency, latency); +} +#endif + static gboolean gst_omx_video_dec_disable (GstOMXVideoDec * self) { @@ -2282,6 +2311,10 @@ gst_omx_video_dec_set_format (GstVideoDecoder * decoder, gst_buffer_replace (&self->codec_data, state->codec_data); self->input_state = gst_video_codec_state_ref (state); +#ifdef USE_OMX_TARGET_ZYNQ_USCALE_PLUS + gst_omx_video_dec_set_latency (self); +#endif + self->downstream_flow_ret = GST_FLOW_OK; return TRUE; } diff --git a/omx/gstomxvideoenc.c b/omx/gstomxvideoenc.c index fb53c82901..3172903da1 100644 --- a/omx/gstomxvideoenc.c +++ b/omx/gstomxvideoenc.c @@ -944,6 +944,35 @@ gst_omx_video_enc_stop (GstVideoEncoder * encoder) return TRUE; } +#ifdef USE_OMX_TARGET_ZYNQ_USCALE_PLUS +static void +gst_omx_video_enc_set_latency (GstOMXVideoEnc * self) +{ + GstClockTime latency; + OMX_ALG_PARAM_REPORTED_LATENCY param; + OMX_ERRORTYPE err; + + GST_OMX_INIT_STRUCT (¶m); + err = + gst_omx_component_get_parameter (self->enc, + (OMX_INDEXTYPE) OMX_ALG_IndexParamReportedLatency, ¶m); + + if (err != OMX_ErrorNone) { + GST_WARNING_OBJECT (self, "Couldn't retrieve latency: %s (0x%08x)", + gst_omx_error_to_string (err), err); + return; + } + + GST_DEBUG_OBJECT (self, "retrieved latency of %d ms", + (guint32) param.nLatency); + + /* Convert to ns */ + latency = param.nLatency * GST_MSECOND; + + gst_video_encoder_set_latency (GST_VIDEO_ENCODER (self), latency, latency); +} +#endif + static gboolean gst_omx_video_enc_disable (GstOMXVideoEnc * self) { @@ -1329,6 +1358,10 @@ gst_omx_video_enc_set_format (GstVideoEncoder * encoder, gst_video_codec_state_unref (self->input_state); self->input_state = gst_video_codec_state_ref (state); +#ifdef USE_OMX_TARGET_ZYNQ_USCALE_PLUS + gst_omx_video_enc_set_latency (self); +#endif + self->downstream_flow_ret = GST_FLOW_OK; return TRUE; }