omxvideoenc: factor out gst_omx_video_enc_set_to_idle()
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Tue, 15 May 2018 09:01:13 +0000 (11:01 +0200)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Thu, 30 Aug 2018 08:59:30 +0000 (10:59 +0200)
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

omx/gstomxvideoenc.c

index 174bc93..c92468e 100644 (file)
@@ -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,