diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2018-05-15 11:01:13 +0200 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2018-08-30 10:59:30 +0200 |
commit | 092788a96810e3897bd143746eb17a25f9f3a5de (patch) | |
tree | 1f2b369d65c39caf2b3b8470015c7d04e31c7007 | |
parent | 7d3b0cd1e87a18ed65f7f58a988ae693c7bc94af (diff) | |
download | gst-omx-092788a96810e3897bd143746eb17a25f9f3a5de.tar.gz |
omxvideoenc: factor out gst_omx_video_enc_set_to_idle()
No semantic change. We'll have to use this when the input pool is
activated so we can allocate buffers.
https://bugzilla.gnome.org/show_bug.cgi?id=796918
-rw-r--r-- | omx/gstomxvideoenc.c | 68 |
1 files changed, 38 insertions, 30 deletions
diff --git a/omx/gstomxvideoenc.c b/omx/gstomxvideoenc.c index 174bc93..c92468e 100644 --- a/omx/gstomxvideoenc.c +++ b/omx/gstomxvideoenc.c @@ -2002,6 +2002,43 @@ gst_omx_video_enc_pick_input_allocation_mode (GstOMXVideoEnc * self, } static gboolean +gst_omx_video_enc_set_to_idle (GstOMXVideoEnc * self) +{ + GstOMXVideoEncClass *klass = GST_OMX_VIDEO_ENC_GET_CLASS (self); + gboolean no_disable_outport; + + no_disable_outport = klass->cdata.hacks & GST_OMX_HACK_NO_DISABLE_OUTPORT; + + if (!no_disable_outport) { + /* Disable output port */ + if (gst_omx_port_set_enabled (self->enc_out_port, FALSE) != OMX_ErrorNone) + return FALSE; + + if (gst_omx_port_wait_enabled (self->enc_out_port, + 1 * GST_SECOND) != OMX_ErrorNone) + return FALSE; + } + + if (gst_omx_component_set_state (self->enc, OMX_StateIdle) != OMX_ErrorNone) + return FALSE; + + /* Need to allocate buffers to reach Idle state */ + if (!gst_omx_video_enc_allocate_in_buffers (self)) + return FALSE; + + if (no_disable_outport) { + if (gst_omx_port_allocate_buffers (self->enc_out_port) != OMX_ErrorNone) + return FALSE; + } + + if (gst_omx_component_get_state (self->enc, + GST_CLOCK_TIME_NONE) != OMX_StateIdle) + return FALSE; + + return TRUE; +} + +static gboolean gst_omx_video_enc_enable (GstOMXVideoEnc * self, GstBuffer * input) { GstOMXVideoEncClass *klass; @@ -2060,36 +2097,7 @@ gst_omx_video_enc_enable (GstOMXVideoEnc * self, GstBuffer * input) if (gst_omx_port_mark_reconfigured (self->enc_in_port) != OMX_ErrorNone) return FALSE; } else { - if (!(klass->cdata.hacks & GST_OMX_HACK_NO_DISABLE_OUTPORT)) { - /* Disable output port */ - if (gst_omx_port_set_enabled (self->enc_out_port, FALSE) != OMX_ErrorNone) - return FALSE; - - if (gst_omx_port_wait_enabled (self->enc_out_port, - 1 * GST_SECOND) != OMX_ErrorNone) - return FALSE; - - if (gst_omx_component_set_state (self->enc, - OMX_StateIdle) != OMX_ErrorNone) - return FALSE; - - /* Need to allocate buffers to reach Idle state */ - if (!gst_omx_video_enc_allocate_in_buffers (self)) - return FALSE; - } else { - if (gst_omx_component_set_state (self->enc, - OMX_StateIdle) != OMX_ErrorNone) - return FALSE; - - /* Need to allocate buffers to reach Idle state */ - if (!gst_omx_video_enc_allocate_in_buffers (self)) - return FALSE; - if (gst_omx_port_allocate_buffers (self->enc_out_port) != OMX_ErrorNone) - return FALSE; - } - - if (gst_omx_component_get_state (self->enc, - GST_CLOCK_TIME_NONE) != OMX_StateIdle) + if (!gst_omx_video_enc_set_to_idle (self)) return FALSE; if (gst_omx_component_set_state (self->enc, |