aboutsummaryrefslogtreecommitdiffstats
path: root/common/recipes-multimedia/gstreamer/gstreamer1.0-omx/0012-gstomxvideoenc-implement-capture-configuration-suppo.patch
blob: 3df8f37f6c0373cf9c1e596e0c571109bf32ec6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
From eb7b8df4eb363f3799d2264f4761401aeb40fa26 Mon Sep 17 00:00:00 2001
From: Leo Liu <leo.liu@amd.com>
Date: Mon, 24 Feb 2014 15:03:50 -0500
Subject: [PATCH 12/14] gstomxvideoenc: implement capture configuration support

Signed-off-by: Leo Liu <leo.liu@amd.com>
---
 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