From eb7b8df4eb363f3799d2264f4761401aeb40fa26 Mon Sep 17 00:00:00 2001 From: Leo Liu Date: Mon, 24 Feb 2014 15:03:50 -0500 Subject: [PATCH 12/14] gstomxvideoenc: implement capture configuration support Signed-off-by: Leo Liu --- omx/gstomxvideoenc.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++- omx/gstomxvideoenc.h | 2 ++ 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/omx/gstomxvideoenc.c b/omx/gstomxvideoenc.c index e65a9e0..cbb8cb9 100644 --- a/omx/gstomxvideoenc.c +++ b/omx/gstomxvideoenc.c @@ -98,7 +98,8 @@ enum PROP_QUANT_P_FRAMES, PROP_QUANT_B_FRAMES, PROP_SCALING_WIDTH, - PROP_SCALING_HEIGHT + PROP_SCALING_HEIGHT, + PROP_CAPTURE }; /* FIXME: Better defaults */ @@ -109,6 +110,7 @@ enum #define GST_OMX_VIDEO_ENC_QUANT_B_FRAMES_DEFAULT (0xffffffff) #define GST_OMX_VIDEO_ENC_SCALING_WIDTH_DEFAULT (0xffffffff) #define GST_OMX_VIDEO_ENC_SCALING_HEIGHT_DEFAULT (0xffffffff) +#define GST_OMX_VIDEO_ENC_CAPTURE_DEFAULT (FALSE) /* class initialization */ @@ -181,6 +183,12 @@ gst_omx_video_enc_class_init (GstOMXVideoEncClass * klass) G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_MUTABLE_READY)); + g_object_class_install_property (gobject_class, PROP_CAPTURE, + g_param_spec_boolean ("capture", "Capture", + "Capture parameter (FALSE=component default)", + FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | + GST_PARAM_MUTABLE_READY)); + element_class->change_state = GST_DEBUG_FUNCPTR (gst_omx_video_enc_change_state); @@ -217,6 +225,7 @@ gst_omx_video_enc_init (GstOMXVideoEnc * self) self->quant_b_frames = GST_OMX_VIDEO_ENC_QUANT_B_FRAMES_DEFAULT; self->scaling_width = GST_OMX_VIDEO_ENC_SCALING_WIDTH_DEFAULT; self->scaling_height = GST_OMX_VIDEO_ENC_SCALING_HEIGHT_DEFAULT; + self->capture = GST_OMX_VIDEO_ENC_CAPTURE_DEFAULT; g_mutex_init (&self->drain_lock); g_cond_init (&self->drain_cond); @@ -404,6 +413,40 @@ gst_omx_video_enc_open (GstVideoEncoder * encoder) gst_omx_error_to_string (err), err); } } + + if (self->capture) { + OMX_CONFIG_BOOLEANTYPE capture_factor; + GST_OMX_INIT_STRUCT (&capture_factor); + + err = gst_omx_component_get_config (self->enc, + OMX_IndexConfigCapturing, &capture_factor); + + if (err == OMX_ErrorNone) { + + if (self->capture) + capture_factor.bEnabled = TRUE; + + err = + gst_omx_component_set_config (self->enc, + OMX_IndexConfigCapturing, &capture_factor); + if (err == OMX_ErrorUnsupportedIndex) { + GST_WARNING_OBJECT (self, + "Setting capture configuration not supported by the component"); + } else if (err == OMX_ErrorUnsupportedSetting) { + GST_WARNING_OBJECT (self, + "Setting capture configuration not supported by the component"); + } else if (err != OMX_ErrorNone) { + GST_ERROR_OBJECT (self, + "Failed to set capture configuration: %s (0x%08x)", + gst_omx_error_to_string (err), err); + return FALSE; + } + } else { + GST_ERROR_OBJECT (self, + "Failed to set capture configuration: %s (0x%08x)", + gst_omx_error_to_string (err), err); + } + } } return TRUE; @@ -508,6 +551,9 @@ gst_omx_video_enc_set_property (GObject * object, guint prop_id, case PROP_SCALING_HEIGHT: self->scaling_height = g_value_get_uint (value); break; + case PROP_CAPTURE: + self->capture = g_value_get_boolean (value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -542,6 +588,9 @@ gst_omx_video_enc_get_property (GObject * object, guint prop_id, GValue * value, case PROP_SCALING_HEIGHT: g_value_set_uint (value, self->scaling_height); break; + case PROP_CAPTURE: + g_value_set_boolean (value, self->capture); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; diff --git a/omx/gstomxvideoenc.h b/omx/gstomxvideoenc.h index 86e9c8f..e9844b8 100644 --- a/omx/gstomxvideoenc.h +++ b/omx/gstomxvideoenc.h @@ -80,6 +80,8 @@ struct _GstOMXVideoEnc guint32 scaling_width; guint32 scaling_height; + gboolean capture; + GstFlowReturn downstream_flow_ret; }; -- 1.9.1