mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-30 05:31:15 +00:00
omxvideoenc/dec: declare latency on zynqultrascaleplus
The OMX specification doesn't provide any API to expose the latency introduced by encoders and decoders. We implemented this as a custom extension as declaring the latency is needed for live pipelines like video conferencing. https://bugzilla.gnome.org/show_bug.cgi?id=785125
This commit is contained in:
parent
0ee8213ab2
commit
f2b0b66e39
2 changed files with 66 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue