[Gstreamer-openmax] [PATCH] add some utility macros to get/set core and port configs/params

Rob Clark rob at ti.com
Tue Nov 3 18:25:27 PST 2009


Signed-off-by: Rob Clark <rob at ti.com>
---
 omx/gstomx_aacdec.c        |    8 +-----
 omx/gstomx_aacenc.c        |   38 +++++-------------------------
 omx/gstomx_adpcmdec.c      |   10 +------
 omx/gstomx_adpcmenc.c      |   18 ++------------
 omx/gstomx_amrnbdec.c      |    8 +-----
 omx/gstomx_amrnbenc.c      |   18 ++------------
 omx/gstomx_amrwbdec.c      |    8 +-----
 omx/gstomx_amrwbenc.c      |   18 ++------------
 omx/gstomx_audiosink.c     |   10 +------
 omx/gstomx_base_filter.c   |   14 +----------
 omx/gstomx_base_sink.c     |   11 +--------
 omx/gstomx_base_src.c      |   11 +--------
 omx/gstomx_base_videodec.c |   27 ++++------------------
 omx/gstomx_base_videoenc.c |   19 +++------------
 omx/gstomx_g711dec.c       |   10 +------
 omx/gstomx_g711enc.c       |   10 +------
 omx/gstomx_g729enc.c       |   10 +------
 omx/gstomx_h263enc.c       |    8 +-----
 omx/gstomx_h264enc.c       |    8 +-----
 omx/gstomx_jpegenc.c       |   36 +++++------------------------
 omx/gstomx_mp2dec.c        |    8 +-----
 omx/gstomx_mp3dec.c        |    8 +-----
 omx/gstomx_mpeg4enc.c      |    8 +-----
 omx/gstomx_util.h          |   53 ++++++++++++++++++++++++++++++++++++++++++++
 omx/gstomx_videosink.c     |   30 +++++--------------------
 omx/gstomx_volume.c        |    8 +-----
 omx/gstomx_vorbisdec.c     |    7 +-----
 27 files changed, 115 insertions(+), 307 deletions(-)

diff --git a/omx/gstomx_aacdec.c b/omx/gstomx_aacdec.c
index 2ec2b4d..dbe7846 100644
--- a/omx/gstomx_aacdec.c
+++ b/omx/gstomx_aacdec.c
@@ -144,13 +144,7 @@ settings_changed_cb (GOmxCore *core)
     {
         OMX_AUDIO_PARAM_PCMMODETYPE param;
 
-        memset (&param, 0, sizeof (param));
-        param.nSize = sizeof (OMX_AUDIO_PARAM_PCMMODETYPE);
-        param.nVersion.s.nVersionMajor = 1;
-        param.nVersion.s.nVersionMinor = 1;
-
-        param.nPortIndex = 1;
-        OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
+        G_OMX_PORT_GET_PARAM (omx_base->out_port, OMX_IndexParamAudioPcm, &param);
 
         rate = param.nSamplingRate;
         channels = param.nChannels;
diff --git a/omx/gstomx_aacenc.c b/omx/gstomx_aacenc.c
index eabc855..e1f8720 100644
--- a/omx/gstomx_aacenc.c
+++ b/omx/gstomx_aacenc.c
@@ -304,18 +304,12 @@ sink_setcaps (GstPad *pad,
     {
         OMX_AUDIO_PARAM_PCMMODETYPE param;
 
-        memset (&param, 0, sizeof (param));
-        param.nSize = sizeof (OMX_AUDIO_PARAM_PCMMODETYPE);
-        param.nVersion.s.nVersionMajor = 1;
-        param.nVersion.s.nVersionMinor = 1;
-
-        param.nPortIndex = 0;
-        OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
+        G_OMX_PORT_GET_PARAM (omx_base->in_port, OMX_IndexParamAudioPcm, &param);
 
         param.nSamplingRate = rate;
         param.nChannels = channels;
 
-        OMX_SetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
+        G_OMX_PORT_SET_PARAM (omx_base->in_port, OMX_IndexParamAudioPcm, &param);
     }
 
     {
@@ -350,15 +344,9 @@ omx_setup (GstOmxBaseFilter *omx_base)
     {
         OMX_AUDIO_PARAM_AACPROFILETYPE param;
 
-        memset (&param, 0, sizeof (param));
-        param.nSize = sizeof (OMX_AUDIO_PARAM_AACPROFILETYPE);
-        param.nVersion.s.nVersionMajor = 1;
-        param.nVersion.s.nVersionMinor = 1;
-
         /* Output port configuration. */
         {
-            param.nPortIndex = 1;
-            OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioAac, &param);
+            G_OMX_PORT_GET_PARAM (omx_base->out_port, OMX_IndexParamAudioAac, &param);
 
             GST_DEBUG_OBJECT (omx_base, "setting bitrate: %i", self->bitrate);
             param.nBitRate = self->bitrate;
@@ -370,7 +358,7 @@ omx_setup (GstOmxBaseFilter *omx_base)
                               self->output_format);
             param.eAACStreamFormat = self->output_format;
 
-            OMX_SetParameter (gomx->omx_handle, OMX_IndexParamAudioAac, &param);
+            G_OMX_PORT_SET_PARAM (omx_base->out_port, OMX_IndexParamAudioAac, &param);
         }
     }
 
@@ -379,13 +367,7 @@ omx_setup (GstOmxBaseFilter *omx_base)
     {
         OMX_AUDIO_PARAM_PCMMODETYPE param;
 
-        memset (&param, 0, sizeof (param));
-        param.nSize = sizeof (OMX_AUDIO_PARAM_PCMMODETYPE);
-        param.nVersion.s.nVersionMajor = 1;
-        param.nVersion.s.nVersionMinor = 1;
-
-        param.nPortIndex = 0;
-        OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
+        G_OMX_PORT_GET_PARAM (omx_base->in_port, OMX_IndexParamAudioPcm, &param);
 
         rate = param.nSamplingRate;
         channels = param.nChannels;
@@ -394,18 +376,12 @@ omx_setup (GstOmxBaseFilter *omx_base)
     {
         OMX_AUDIO_PARAM_AACPROFILETYPE param;
 
-        memset (&param, 0, sizeof (param));
-        param.nSize = sizeof (OMX_AUDIO_PARAM_AACPROFILETYPE);
-        param.nVersion.s.nVersionMajor = 1;
-        param.nVersion.s.nVersionMinor = 1;
-
-        param.nPortIndex = 1;
-        OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioAac, &param);
+        G_OMX_PORT_GET_PARAM (omx_base->out_port, OMX_IndexParamAudioAac, &param);
 
         param.nSampleRate = rate;
         param.nChannels = channels;
 
-        OMX_SetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioAac, &param);
+        G_OMX_PORT_SET_PARAM (omx_base->out_port, OMX_IndexParamAudioAac, &param);
     }
 #endif
 
diff --git a/omx/gstomx_adpcmdec.c b/omx/gstomx_adpcmdec.c
index 86bb54c..a35a6cc 100644
--- a/omx/gstomx_adpcmdec.c
+++ b/omx/gstomx_adpcmdec.c
@@ -126,17 +126,11 @@ sink_setcaps (GstPad *pad,
     {
         OMX_AUDIO_PARAM_PCMMODETYPE param;
 
-        memset (&param, 0, sizeof (param));
-        param.nSize = sizeof (OMX_AUDIO_PARAM_PCMMODETYPE);
-        param.nVersion.s.nVersionMajor = 1;
-        param.nVersion.s.nVersionMinor = 1;
-
-        param.nPortIndex = 1;
-        OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
+        G_OMX_PORT_GET_PARAM (omx_base->out_port, OMX_IndexParamAudioPcm, &param);
 
         param.nSamplingRate = rate;
 
-        OMX_SetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
+        G_OMX_PORT_SET_PARAM (omx_base->out_port, OMX_IndexParamAudioPcm, &param);
     }
 
     /* set caps on the srcpad */
diff --git a/omx/gstomx_adpcmenc.c b/omx/gstomx_adpcmenc.c
index 967ebf9..c17a7b4 100644
--- a/omx/gstomx_adpcmenc.c
+++ b/omx/gstomx_adpcmenc.c
@@ -117,13 +117,7 @@ settings_changed_cb (GOmxCore *core)
     {
         OMX_AUDIO_PARAM_ADPCMTYPE param;
 
-        memset (&param, 0, sizeof (param));
-        param.nSize = sizeof (OMX_AUDIO_PARAM_ADPCMTYPE);
-        param.nVersion.s.nVersionMajor = 1;
-        param.nVersion.s.nVersionMinor = 1;
-
-        param.nPortIndex = 1;
-        OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioAdpcm, &param);
+        G_OMX_PORT_GET_PARAM (omx_base->out_port, OMX_IndexParamAudioAdpcm, &param);
 
         rate = param.nSampleRate;
     }
@@ -181,17 +175,11 @@ sink_setcaps (GstPad *pad,
     {
         OMX_AUDIO_PARAM_PCMMODETYPE param;
 
-        memset (&param, 0, sizeof (param));
-        param.nSize = sizeof (OMX_AUDIO_PARAM_PCMMODETYPE);
-        param.nVersion.s.nVersionMajor = 1;
-        param.nVersion.s.nVersionMinor = 1;
-
-        param.nPortIndex = 0;
-        OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
+        G_OMX_PORT_GET_PARAM (omx_base->in_port, OMX_IndexParamAudioPcm, &param);
 
         param.nSamplingRate = rate;
 
-        OMX_SetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
+        G_OMX_PORT_SET_PARAM (omx_base->in_port, OMX_IndexParamAudioPcm, &param);
     }
 
     /* set caps on the srcpad */
diff --git a/omx/gstomx_amrnbdec.c b/omx/gstomx_amrnbdec.c
index bdacb06..9250420 100644
--- a/omx/gstomx_amrnbdec.c
+++ b/omx/gstomx_amrnbdec.c
@@ -117,13 +117,7 @@ settings_changed_cb (GOmxCore *core)
     {
         OMX_AUDIO_PARAM_PCMMODETYPE param;
 
-        memset (&param, 0, sizeof (param));
-        param.nSize = sizeof (OMX_AUDIO_PARAM_PCMMODETYPE);
-        param.nVersion.s.nVersionMajor = 1;
-        param.nVersion.s.nVersionMinor = 1;
-
-        param.nPortIndex = 1;
-        OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
+        G_OMX_PORT_GET_PARAM (omx_base->out_port, OMX_IndexParamAudioPcm, &param);
 
         rate = param.nSamplingRate;
         channels = param.nChannels;
diff --git a/omx/gstomx_amrnbenc.c b/omx/gstomx_amrnbenc.c
index d8b921b..92df603 100644
--- a/omx/gstomx_amrnbenc.c
+++ b/omx/gstomx_amrnbenc.c
@@ -182,13 +182,7 @@ settings_changed_cb (GOmxCore *core)
     {
         OMX_AUDIO_PARAM_AMRTYPE param;
 
-        memset (&param, 0, sizeof (param));
-        param.nSize = sizeof (OMX_AUDIO_PARAM_AMRTYPE);
-        param.nVersion.s.nVersionMajor = 1;
-        param.nVersion.s.nVersionMinor = 1;
-
-        param.nPortIndex = 1;
-        OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioAmr, &param);
+        G_OMX_PORT_GET_PARAM (omx_base->out_port, OMX_IndexParamAudioAmr, &param);
 
         channels = param.nChannels;
     }
@@ -232,18 +226,12 @@ sink_setcaps (GstPad *pad,
     {
         OMX_AUDIO_PARAM_PCMMODETYPE param;
 
-        memset (&param, 0, sizeof (param));
-        param.nSize = sizeof (OMX_AUDIO_PARAM_PCMMODETYPE);
-        param.nVersion.s.nVersionMajor = 1;
-        param.nVersion.s.nVersionMinor = 1;
-
-        param.nPortIndex = 0;
-        OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
+        G_OMX_PORT_GET_PARAM (omx_base->in_port, OMX_IndexParamAudioPcm, &param);
 
         param.nSamplingRate = rate;
         param.nChannels = channels;
 
-        OMX_SetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
+        G_OMX_PORT_SET_PARAM (omx_base->in_port, OMX_IndexParamAudioPcm, &param);
     }
 
     return gst_pad_set_caps (pad, caps);
diff --git a/omx/gstomx_amrwbdec.c b/omx/gstomx_amrwbdec.c
index 0914f84..bc406c0 100644
--- a/omx/gstomx_amrwbdec.c
+++ b/omx/gstomx_amrwbdec.c
@@ -117,13 +117,7 @@ settings_changed_cb (GOmxCore *core)
     {
         OMX_AUDIO_PARAM_PCMMODETYPE param;
 
-        memset (&param, 0, sizeof (param));
-        param.nSize = sizeof (OMX_AUDIO_PARAM_PCMMODETYPE);
-        param.nVersion.s.nVersionMajor = 1;
-        param.nVersion.s.nVersionMinor = 1;
-
-        param.nPortIndex = 1;
-        OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
+        G_OMX_PORT_GET_PARAM (omx_base->out_port, OMX_IndexParamAudioPcm, &param);
 
         rate = param.nSamplingRate;
         channels = param.nChannels;
diff --git a/omx/gstomx_amrwbenc.c b/omx/gstomx_amrwbenc.c
index 176ccb3..40d0cf5 100644
--- a/omx/gstomx_amrwbenc.c
+++ b/omx/gstomx_amrwbenc.c
@@ -182,13 +182,7 @@ settings_changed_cb (GOmxCore *core)
     {
         OMX_AUDIO_PARAM_AMRTYPE param;
 
-        memset (&param, 0, sizeof (param));
-        param.nSize = sizeof (OMX_AUDIO_PARAM_AMRTYPE);
-        param.nVersion.s.nVersionMajor = 1;
-        param.nVersion.s.nVersionMinor = 1;
-
-        param.nPortIndex = 1;
-        OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioAmr, &param);
+        G_OMX_PORT_GET_PARAM (omx_base->out_port, OMX_IndexParamAudioAmr, &param);
 
         channels = param.nChannels;
     }
@@ -232,18 +226,12 @@ sink_setcaps (GstPad *pad,
     {
         OMX_AUDIO_PARAM_PCMMODETYPE param;
 
-        memset (&param, 0, sizeof (param));
-        param.nSize = sizeof (OMX_AUDIO_PARAM_PCMMODETYPE);
-        param.nVersion.s.nVersionMajor = 1;
-        param.nVersion.s.nVersionMinor = 1;
-
-        param.nPortIndex = 0;
-        OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
+        G_OMX_PORT_GET_PARAM (omx_base->in_port, OMX_IndexParamAudioPcm, &param);
 
         param.nSamplingRate = rate;
         param.nChannels = channels;
 
-        OMX_SetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
+        G_OMX_PORT_SET_PARAM (omx_base->in_port, OMX_IndexParamAudioPcm, &param);
     }
 
     return gst_pad_set_caps (pad, caps);
diff --git a/omx/gstomx_audiosink.c b/omx/gstomx_audiosink.c
index 8fa1748..44dc92a 100644
--- a/omx/gstomx_audiosink.c
+++ b/omx/gstomx_audiosink.c
@@ -109,13 +109,7 @@ setcaps (GstBaseSink *gst_sink,
         {
             OMX_AUDIO_PARAM_PCMMODETYPE param;
 
-            memset (&param, 0, sizeof (param));
-            param.nSize = sizeof (OMX_AUDIO_PARAM_PCMMODETYPE);
-            param.nVersion.s.nVersionMajor = 1;
-            param.nVersion.s.nVersionMinor = 1;
-
-            param.nPortIndex = 0;
-            OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
+            G_OMX_PORT_GET_PARAM (self->in_port, OMX_IndexParamAudioPcm, &param);
 
             param.nChannels = channels;
             param.eNumData = is_signed ? OMX_NumericalDataSigned : OMX_NumericalDataUnsigned;
@@ -123,7 +117,7 @@ setcaps (GstBaseSink *gst_sink,
             param.nBitPerSample = width;
             param.nSamplingRate = rate;
 
-            OMX_SetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
+            G_OMX_PORT_SET_PARAM (self->in_port, OMX_IndexParamAudioPcm, &param);
         }
     }
 
diff --git a/omx/gstomx_base_filter.c b/omx/gstomx_base_filter.c
index 6b90673..5a68d02 100644
--- a/omx/gstomx_base_filter.c
+++ b/omx/gstomx_base_filter.c
@@ -52,27 +52,17 @@ log_buffer (GstOmxBaseFilter *self,
 static void
 setup_ports (GstOmxBaseFilter *self)
 {
-    GOmxCore *core;
     OMX_PARAM_PORTDEFINITIONTYPE param;
 
-    core = self->gomx;
-
-    memset (&param, 0, sizeof (param));
-    param.nSize = sizeof (OMX_PARAM_PORTDEFINITIONTYPE);
-    param.nVersion.s.nVersionMajor = 1;
-    param.nVersion.s.nVersionMinor = 1;
-
     /* Input port configuration. */
 
-    param.nPortIndex = 0;
-    OMX_GetParameter (core->omx_handle, OMX_IndexParamPortDefinition, &param);
+    G_OMX_PORT_GET_PARAM (self->in_port, OMX_IndexParamPortDefinition, &param);
     g_omx_port_setup (self->in_port, &param);
     gst_pad_set_element_private (self->sinkpad, self->in_port);
 
     /* Output port configuration. */
 
-    param.nPortIndex = 1;
-    OMX_GetParameter (core->omx_handle, OMX_IndexParamPortDefinition, &param);
+    G_OMX_PORT_GET_PARAM (self->out_port, OMX_IndexParamPortDefinition, &param);
     g_omx_port_setup (self->out_port, &param);
     gst_pad_set_element_private (self->srcpad, self->out_port);
 
diff --git a/omx/gstomx_base_sink.c b/omx/gstomx_base_sink.c
index 1f2e271..c25c0ad 100644
--- a/omx/gstomx_base_sink.c
+++ b/omx/gstomx_base_sink.c
@@ -44,20 +44,11 @@ static GstElementClass *parent_class;
 static void
 setup_ports (GstOmxBaseSink *self)
 {
-    GOmxCore *core;
     OMX_PARAM_PORTDEFINITIONTYPE param;
 
-    core = self->gomx;
-
-    memset (&param, 0, sizeof (param));
-    param.nSize = sizeof (OMX_PARAM_PORTDEFINITIONTYPE);
-    param.nVersion.s.nVersionMajor = 1;
-    param.nVersion.s.nVersionMinor = 1;
-
     /* Input port configuration. */
 
-    param.nPortIndex = 0;
-    OMX_GetParameter (core->omx_handle, OMX_IndexParamPortDefinition, &param);
+    G_OMX_PORT_GET_PARAM (self->in_port, OMX_IndexParamPortDefinition, &param);
     g_omx_port_setup (self->in_port, &param);
     gst_pad_set_element_private (self->sinkpad, self->in_port);
 }
diff --git a/omx/gstomx_base_src.c b/omx/gstomx_base_src.c
index e8a1c95..94bf5e9 100644
--- a/omx/gstomx_base_src.c
+++ b/omx/gstomx_base_src.c
@@ -36,20 +36,11 @@ static GstElementClass *parent_class;
 static void
 setup_ports (GstOmxBaseSrc *self)
 {
-    GOmxCore *core;
     OMX_PARAM_PORTDEFINITIONTYPE param;
 
-    core = self->gomx;
-
-    memset (&param, 0, sizeof (param));
-    param.nSize = sizeof (OMX_PARAM_PORTDEFINITIONTYPE);
-    param.nVersion.s.nVersionMajor = 1;
-    param.nVersion.s.nVersionMinor = 1;
-
     /* Input port configuration. */
 
-    param.nPortIndex = 0;
-    OMX_GetParameter (core->omx_handle, OMX_IndexParamPortDefinition, &param);
+    G_OMX_PORT_GET_PARAM (self->out_port, OMX_IndexParamPortDefinition, &param);
     g_omx_port_setup (self->out_port, &param);
 
     if (self->setup_ports)
diff --git a/omx/gstomx_base_videodec.c b/omx/gstomx_base_videodec.c
index 5cebc4b..ce7dfc8 100644
--- a/omx/gstomx_base_videodec.c
+++ b/omx/gstomx_base_videodec.c
@@ -113,12 +113,7 @@ settings_changed_cb (GOmxCore *core)
 
         memset (&param, 0, sizeof (param));
 
-        param.nSize = sizeof (OMX_PARAM_PORTDEFINITIONTYPE);
-        param.nVersion.s.nVersionMajor = 1;
-        param.nVersion.s.nVersionMinor = 1;
-
-        param.nPortIndex = 1;
-        OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
+        G_OMX_PORT_GET_PARAM (omx_base->out_port, OMX_IndexParamPortDefinition, &param);
 
         width = param.format.video.nFrameWidth;
         height = param.format.video.nFrameHeight;
@@ -194,11 +189,6 @@ sink_setcaps (GstPad *pad,
         }
     }
 
-    memset (&param, 0, sizeof (param));
-    param.nSize = sizeof (OMX_PARAM_PORTDEFINITIONTYPE);
-    param.nVersion.s.nVersionMajor = 1;
-    param.nVersion.s.nVersionMinor = 1;
-
     {
         const GValue *codec_data;
         GstBuffer *buffer;
@@ -214,13 +204,12 @@ sink_setcaps (GstPad *pad,
 
     /* Input port configuration. */
     {
-        param.nPortIndex = 0;
-        OMX_GetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
+        G_OMX_PORT_GET_PARAM (omx_base->in_port, OMX_IndexParamPortDefinition, &param);
 
         param.format.video.nFrameWidth = width;
         param.format.video.nFrameHeight = height;
 
-        OMX_SetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
+        G_OMX_PORT_SET_PARAM (omx_base->in_port, OMX_IndexParamPortDefinition, &param);
     }
 
     return gst_pad_set_caps (pad, caps);
@@ -240,19 +229,13 @@ omx_setup (GstOmxBaseFilter *omx_base)
     {
         OMX_PARAM_PORTDEFINITIONTYPE param;
 
-        memset (&param, 0, sizeof (param));
-        param.nSize = sizeof (OMX_PARAM_PORTDEFINITIONTYPE);
-        param.nVersion.s.nVersionMajor = 1;
-        param.nVersion.s.nVersionMinor = 1;
-
         /* Input port configuration. */
         {
-            param.nPortIndex = 0;
-            OMX_GetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
+            G_OMX_PORT_GET_PARAM (omx_base->in_port, OMX_IndexParamPortDefinition, &param);
 
             param.format.video.eCompressionFormat = self->compression_format;
 
-            OMX_SetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
+            G_OMX_PORT_SET_PARAM (omx_base->in_port, OMX_IndexParamPortDefinition, &param);
         }
     }
 
diff --git a/omx/gstomx_base_videoenc.c b/omx/gstomx_base_videoenc.c
index f788817..a3e0625 100644
--- a/omx/gstomx_base_videoenc.c
+++ b/omx/gstomx_base_videoenc.c
@@ -216,15 +216,10 @@ sink_setcaps (GstPad *pad,
 
     {
         OMX_PARAM_PORTDEFINITIONTYPE param;
-        memset (&param, 0, sizeof (param));
-        param.nSize = sizeof (OMX_PARAM_PORTDEFINITIONTYPE);
-        param.nVersion.s.nVersionMajor = 1;
-        param.nVersion.s.nVersionMinor = 1;
 
         /* Input port configuration. */
         {
-            param.nPortIndex = 0;
-            OMX_GetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
+            G_OMX_PORT_GET_PARAM (omx_base->in_port, OMX_IndexParamPortDefinition, &param);
 
             param.format.video.nFrameWidth = width;
             param.format.video.nFrameHeight = height;
@@ -237,7 +232,7 @@ sink_setcaps (GstPad *pad,
                     gst_value_get_fraction_denominator (framerate);
             }
 
-            OMX_SetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
+            G_OMX_PORT_SET_PARAM (omx_base->in_port, OMX_IndexParamPortDefinition, &param);
         }
     }
 
@@ -258,22 +253,16 @@ omx_setup (GstOmxBaseFilter *omx_base)
     {
         OMX_PARAM_PORTDEFINITIONTYPE param;
 
-        memset (&param, 0, sizeof (param));
-        param.nSize = sizeof (OMX_PARAM_PORTDEFINITIONTYPE);
-        param.nVersion.s.nVersionMajor = 1;
-        param.nVersion.s.nVersionMinor = 1;
-
         /* Output port configuration. */
         {
-            param.nPortIndex = 1;
-            OMX_GetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
+            G_OMX_PORT_GET_PARAM (omx_base->out_port, OMX_IndexParamPortDefinition, &param);
 
             param.format.video.eCompressionFormat = self->compression_format;
 
             if (self->bitrate != 0)
                 param.format.video.nBitrate = self->bitrate;
 
-            OMX_SetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
+            G_OMX_PORT_SET_PARAM (omx_base->out_port, OMX_IndexParamPortDefinition, &param);
         }
     }
 
diff --git a/omx/gstomx_g711dec.c b/omx/gstomx_g711dec.c
index f2b5e73..f62796b 100644
--- a/omx/gstomx_g711dec.c
+++ b/omx/gstomx_g711dec.c
@@ -138,20 +138,14 @@ sink_setcaps (GstPad *pad,
     {
         OMX_AUDIO_PARAM_PCMMODETYPE param;
 
-        memset (&param, 0, sizeof (param));
-        param.nSize = sizeof (OMX_AUDIO_PARAM_PCMMODETYPE);
-        param.nVersion.s.nVersionMajor = 1;
-        param.nVersion.s.nVersionMinor = 1;
-
-        param.nPortIndex = 0;
-        OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
+        G_OMX_PORT_GET_PARAM (omx_base->in_port, OMX_IndexParamAudioPcm, &param);
 
         if (strcmp (mode, "audio/x-alaw") == 0)
             param.ePCMMode = OMX_AUDIO_PCMModeALaw;
         else if (strcmp (mode, "audio/x-mulaw") == 0)
             param.ePCMMode = OMX_AUDIO_PCMModeMULaw;
 
-        OMX_SetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
+        G_OMX_PORT_SET_PARAM (omx_base->in_port, OMX_IndexParamAudioPcm, &param);
     }
 
     /* set caps on the srcpad */
diff --git a/omx/gstomx_g711enc.c b/omx/gstomx_g711enc.c
index 440f3f4..bcfb72b 100644
--- a/omx/gstomx_g711enc.c
+++ b/omx/gstomx_g711enc.c
@@ -148,20 +148,14 @@ sink_setcaps (GstPad *pad,
     {
         OMX_AUDIO_PARAM_PCMMODETYPE param;
 
-        memset (&param, 0, sizeof (param));
-        param.nSize = sizeof (OMX_AUDIO_PARAM_PCMMODETYPE);
-        param.nVersion.s.nVersionMajor = 1;
-        param.nVersion.s.nVersionMinor = 1;
-
-        param.nPortIndex = 1;
-        OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
+        G_OMX_PORT_GET_PARAM (omx_base->out_port, OMX_IndexParamAudioPcm, &param);
 
         if (strcmp (mode, "audio/x-alaw") == 0)
             param.ePCMMode = OMX_AUDIO_PCMModeALaw;
         else if (strcmp (mode, "audio/x-mulaw") == 0)
             param.ePCMMode = OMX_AUDIO_PCMModeMULaw;
 
-        OMX_SetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
+        G_OMX_PORT_SET_PARAM (omx_base->out_port, OMX_IndexParamAudioPcm, &param);
     }
 
 leave:
diff --git a/omx/gstomx_g729enc.c b/omx/gstomx_g729enc.c
index 1a2c853..aa44c35 100644
--- a/omx/gstomx_g729enc.c
+++ b/omx/gstomx_g729enc.c
@@ -227,17 +227,11 @@ omx_setup (GstOmxBaseFilter *omx_base)
     {
         OMX_AUDIO_PARAM_G729TYPE param;
 
-        memset (&param, 0, sizeof (param));
-        param.nSize = sizeof (OMX_AUDIO_PARAM_G729TYPE);
-        param.nVersion.s.nVersionMajor = 1;
-        param.nVersion.s.nVersionMinor = 1;
-
-        param.nPortIndex = 1;
-        OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioG729, &param);
+        G_OMX_PORT_GET_PARAM (omx_base->out_port, OMX_IndexParamAudioG729, &param);
 
         param.bDTX = self->dtx;
 
-        OMX_SetParameter (gomx->omx_handle, OMX_IndexParamAudioG729, &param);
+        G_OMX_PORT_SET_PARAM (omx_base->out_port, OMX_IndexParamAudioG729, &param);
     }
 
     GST_INFO_OBJECT (omx_base, "end");
diff --git a/omx/gstomx_h263enc.c b/omx/gstomx_h263enc.c
index 90237e4..19d313a 100644
--- a/omx/gstomx_h263enc.c
+++ b/omx/gstomx_h263enc.c
@@ -93,13 +93,7 @@ settings_changed_cb (GOmxCore *core)
     {
         OMX_PARAM_PORTDEFINITIONTYPE param;
 
-        memset (&param, 0, sizeof (param));
-        param.nSize = sizeof (OMX_PARAM_PORTDEFINITIONTYPE);
-        param.nVersion.s.nVersionMajor = 1;
-        param.nVersion.s.nVersionMinor = 1;
-
-        param.nPortIndex = 1;
-        OMX_GetParameter (core->omx_handle, OMX_IndexParamPortDefinition, &param);
+        G_OMX_PORT_GET_PARAM (omx_base_filter->out_port, OMX_IndexParamPortDefinition, &param);
 
         width = param.format.video.nFrameWidth;
         height = param.format.video.nFrameHeight;
diff --git a/omx/gstomx_h264enc.c b/omx/gstomx_h264enc.c
index 3dbf245..1a4510e 100644
--- a/omx/gstomx_h264enc.c
+++ b/omx/gstomx_h264enc.c
@@ -92,13 +92,7 @@ settings_changed_cb (GOmxCore *core)
     {
         OMX_PARAM_PORTDEFINITIONTYPE param;
 
-        memset (&param, 0, sizeof (param));
-        param.nSize = sizeof (OMX_PARAM_PORTDEFINITIONTYPE);
-        param.nVersion.s.nVersionMajor = 1;
-        param.nVersion.s.nVersionMinor = 1;
-
-        param.nPortIndex = 1;
-        OMX_GetParameter (core->omx_handle, OMX_IndexParamPortDefinition, &param);
+        G_OMX_PORT_GET_PARAM (omx_base_filter->out_port, OMX_IndexParamPortDefinition, &param);
 
         width = param.format.video.nFrameWidth;
         height = param.format.video.nFrameHeight;
diff --git a/omx/gstomx_jpegenc.c b/omx/gstomx_jpegenc.c
index e78b5b1..d826149 100644
--- a/omx/gstomx_jpegenc.c
+++ b/omx/gstomx_jpegenc.c
@@ -207,13 +207,7 @@ settings_changed_cb (GOmxCore *core)
     {
         OMX_PARAM_PORTDEFINITIONTYPE param;
 
-        memset (&param, 0, sizeof (param));
-        param.nSize = sizeof (OMX_PARAM_PORTDEFINITIONTYPE);
-        param.nVersion.s.nVersionMajor = 1;
-        param.nVersion.s.nVersionMinor = 1;
-
-        param.nPortIndex = 1;
-        OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
+        G_OMX_PORT_GET_PARAM (omx_base->out_port, OMX_IndexParamPortDefinition, &param);
 
         width = param.format.image.nFrameWidth;
         height = param.format.image.nFrameHeight;
@@ -288,21 +282,15 @@ sink_setcaps (GstPad *pad,
     {
         OMX_PARAM_PORTDEFINITIONTYPE param;
 
-        memset (&param, 0, sizeof (param));
-        param.nSize = sizeof (OMX_PARAM_PORTDEFINITIONTYPE);
-        param.nVersion.s.nVersionMajor = 1;
-        param.nVersion.s.nVersionMinor = 1;
-
         /* Input port configuration. */
         {
-            param.nPortIndex = 0;
-            OMX_GetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
+            G_OMX_PORT_GET_PARAM (omx_base->in_port, OMX_IndexParamPortDefinition, &param);
 
             param.format.image.nFrameWidth = width;
             param.format.image.nFrameHeight = height;
             param.format.image.eColorFormat = color_format;
 
-            OMX_SetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
+            G_OMX_PORT_SET_PARAM (omx_base->in_port, OMX_IndexParamPortDefinition, &param);
         }
     }
 
@@ -323,34 +311,24 @@ omx_setup (GstOmxBaseFilter *omx_base)
     {
         OMX_PARAM_PORTDEFINITIONTYPE param;
 
-        memset (&param, 0, sizeof (param));
-        param.nSize = sizeof (OMX_PARAM_PORTDEFINITIONTYPE);
-        param.nVersion.s.nVersionMajor = 1;
-        param.nVersion.s.nVersionMinor = 1;
-
         /* Output port configuration. */
         {
-            param.nPortIndex = 1;
-            OMX_GetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
+            G_OMX_PORT_GET_PARAM (omx_base->out_port, OMX_IndexParamPortDefinition, &param);
 
             param.format.image.eCompressionFormat = OMX_IMAGE_CodingJPEG;
 
-            OMX_SetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
+            G_OMX_PORT_SET_PARAM (omx_base->out_port, OMX_IndexParamPortDefinition, &param);
         }
     }
 
     {
         OMX_IMAGE_PARAM_QFACTORTYPE param;
 
-        memset (&param, 0, sizeof (param));
-        param.nSize = sizeof (OMX_IMAGE_PARAM_QFACTORTYPE);
-        param.nVersion.s.nVersionMajor = 1;
-        param.nVersion.s.nVersionMinor = 1;
+        G_OMX_PORT_GET_PARAM (omx_base->out_port, OMX_IndexParamQFactor, &param);
 
         param.nQFactor = self->quality;
-        param.nPortIndex = 1;
 
-        OMX_SetParameter (gomx->omx_handle, OMX_IndexParamQFactor, &param);
+        G_OMX_PORT_SET_PARAM (omx_base->out_port, OMX_IndexParamQFactor, &param);
     }
 
     GST_INFO_OBJECT (omx_base, "end");
diff --git a/omx/gstomx_mp2dec.c b/omx/gstomx_mp2dec.c
index 90dcb7f..b6bef4f 100644
--- a/omx/gstomx_mp2dec.c
+++ b/omx/gstomx_mp2dec.c
@@ -120,13 +120,7 @@ settings_changed_cb (GOmxCore *core)
     {
         OMX_AUDIO_PARAM_PCMMODETYPE param;
 
-        memset (&param, 0, sizeof (param));
-        param.nSize = sizeof (OMX_AUDIO_PARAM_PCMMODETYPE);
-        param.nVersion.s.nVersionMajor = 1;
-        param.nVersion.s.nVersionMinor = 1;
-
-        param.nPortIndex = 1;
-        OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
+        G_OMX_PORT_GET_PARAM (omx_base->out_port, OMX_IndexParamAudioPcm, &param);
 
         rate = param.nSamplingRate;
         channels = param.nChannels;
diff --git a/omx/gstomx_mp3dec.c b/omx/gstomx_mp3dec.c
index ad53d29..0036fac 100644
--- a/omx/gstomx_mp3dec.c
+++ b/omx/gstomx_mp3dec.c
@@ -120,13 +120,7 @@ settings_changed_cb (GOmxCore *core)
     {
         OMX_AUDIO_PARAM_PCMMODETYPE param;
 
-        memset (&param, 0, sizeof (param));
-        param.nSize = sizeof (OMX_AUDIO_PARAM_PCMMODETYPE);
-        param.nVersion.s.nVersionMajor = 1;
-        param.nVersion.s.nVersionMinor = 1;
-
-        param.nPortIndex = 1;
-        OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
+        G_OMX_PORT_GET_PARAM (omx_base->out_port, OMX_IndexParamAudioPcm, &param);
 
         rate = param.nSamplingRate;
         channels = param.nChannels;
diff --git a/omx/gstomx_mpeg4enc.c b/omx/gstomx_mpeg4enc.c
index 8f40da1..62f9f23 100644
--- a/omx/gstomx_mpeg4enc.c
+++ b/omx/gstomx_mpeg4enc.c
@@ -94,13 +94,7 @@ settings_changed_cb (GOmxCore *core)
     {
         OMX_PARAM_PORTDEFINITIONTYPE param;
 
-        memset (&param, 0, sizeof (param));
-        param.nSize = sizeof (OMX_PARAM_PORTDEFINITIONTYPE);
-        param.nVersion.s.nVersionMajor = 1;
-        param.nVersion.s.nVersionMinor = 1;
-
-        param.nPortIndex = 1;
-        OMX_GetParameter (core->omx_handle, OMX_IndexParamPortDefinition, &param);
+        G_OMX_PORT_GET_PARAM (omx_base_filter->out_port, OMX_IndexParamPortDefinition, &param);
 
         width = param.format.video.nFrameWidth;
         height = param.format.video.nFrameHeight;
diff --git a/omx/gstomx_util.h b/omx/gstomx_util.h
index 4857265..be9290f 100644
--- a/omx/gstomx_util.h
+++ b/omx/gstomx_util.h
@@ -145,5 +145,58 @@ void g_omx_port_disable (GOmxPort *port);
 void g_omx_port_finish (GOmxPort *port);
 
 
+/* Utility Macros */
+
+#define _G_OMX_INIT_PARAM(param) G_STMT_START {  /* util for other macros */  \
+        memset ((param), 0, sizeof (*(param)));                               \
+        (param)->nSize = sizeof (*(param));                                   \
+        (param)->nVersion.s.nVersionMajor = 1;                                \
+        (param)->nVersion.s.nVersionMinor = 1;                                \
+    } G_STMT_END
+
+/* "CORE" macros for GetParameter/SetParameter and GetConfig/SetConfig */
+
+#define G_OMX_CORE_GET_PARAM(core, idx, param) G_STMT_START {                 \
+        _G_OMX_INIT_PARAM (param);                                            \
+        OMX_GetParameter (g_omx_core_get_handle (core), (idx), (param));      \
+    } G_STMT_END
+
+#define G_OMX_CORE_SET_PARAM(core, idx, param)                                \
+        OMX_SetParameter (                                                    \
+            g_omx_core_get_handle (core), (idx), (param))
+
+#define G_OMX_CORE_GET_CONFIG(core, idx, param) G_STMT_START {                \
+        _G_OMX_INIT_PARAM (param);                                            \
+        OMX_GetConfig (g_omx_core_get_handle (core), (idx), (param));         \
+    } G_STMT_END
+
+#define G_OMX_CORE_SET_CONFIG(core, idx, param)                               \
+        OMX_SetConfig (                                                       \
+            g_omx_core_get_handle (core), (idx), (param))
+
+/* "PORT" macros for GetParameter/SetParameter and GetConfig/SetConfig
+ * of port specific params/configs
+ */
+
+#define G_OMX_PORT_GET_PARAM(port, idx, param) G_STMT_START {                 \
+        _G_OMX_INIT_PARAM (param);                                            \
+        (param)->nPortIndex = (port)->port_index;                             \
+        OMX_GetParameter (g_omx_core_get_handle ((port)->core), idx, (param));\
+    } G_STMT_END
+
+#define G_OMX_PORT_SET_PARAM(port, idx, param)                                \
+        OMX_SetParameter (                                                    \
+            g_omx_core_get_handle ((port)->core), idx, (param))
+
+#define G_OMX_PORT_GET_CONFIG(port, idx, param) G_STMT_START {                \
+        _G_OMX_INIT_PARAM (param);                                            \
+        (param)->nPortIndex = (port)->port_index;                             \
+        OMX_GetConfig (g_omx_core_get_handle ((port)->core), idx, (param));   \
+    } G_STMT_END
+
+#define G_OMX_PORT_SET_CONFIG(port, idx, param)                               \
+        OMX_SetConfig (                                                       \
+            g_omx_core_get_handle ((port)->core), idx, (param))
+
 
 #endif /* GSTOMX_UTIL_H */
diff --git a/omx/gstomx_videosink.c b/omx/gstomx_videosink.c
index 923b5ed..dbced76 100644
--- a/omx/gstomx_videosink.c
+++ b/omx/gstomx_videosink.c
@@ -161,13 +161,7 @@ setcaps (GstBaseSink *gst_sink,
         {
             OMX_PARAM_PORTDEFINITIONTYPE param;
 
-            memset (&param, 0, sizeof (param));
-            param.nSize = sizeof (OMX_PARAM_PORTDEFINITIONTYPE);
-            param.nVersion.s.nVersionMajor = 1;
-            param.nVersion.s.nVersionMinor = 1;
-
-            param.nPortIndex = 0;
-            OMX_GetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
+            G_OMX_PORT_GET_PARAM (omx_base->in_port, OMX_IndexParamPortDefinition, &param);
 
             switch (color_format)
             {
@@ -194,40 +188,28 @@ setcaps (GstBaseSink *gst_sink,
                     gst_value_get_fraction_denominator (framerate);
             }
 
-            OMX_SetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, &param);
+            G_OMX_PORT_SET_PARAM (omx_base->in_port, OMX_IndexParamPortDefinition, &param);
         }
 
         {
             OMX_CONFIG_ROTATIONTYPE config;
 
-            memset (&config, 0, sizeof (config));
-            config.nSize = sizeof (OMX_CONFIG_ROTATIONTYPE);
-            config.nVersion.s.nVersionMajor = 1;
-            config.nVersion.s.nVersionMinor = 1;
-
-            config.nPortIndex = 0;
-            OMX_GetConfig (gomx->omx_handle, OMX_IndexConfigCommonScale, &config);
+            G_OMX_PORT_GET_CONFIG (omx_base->in_port, OMX_IndexConfigCommonScale, &config);
 
             config.nRotation = self->rotation;
 
-            OMX_SetConfig (gomx->omx_handle, OMX_IndexConfigCommonRotate, &config);
+            G_OMX_PORT_SET_CONFIG (omx_base->in_port, OMX_IndexConfigCommonRotate, &config);
         }
 
         {
             OMX_CONFIG_SCALEFACTORTYPE config;
 
-            memset (&config, 0, sizeof (config));
-            config.nSize = sizeof (OMX_CONFIG_SCALEFACTORTYPE);
-            config.nVersion.s.nVersionMajor = 1;
-            config.nVersion.s.nVersionMinor = 1;
-
-            config.nPortIndex = 0;
-            OMX_GetConfig (gomx->omx_handle, OMX_IndexConfigCommonScale, &config);
+            G_OMX_PORT_GET_CONFIG (omx_base->in_port, OMX_IndexConfigCommonScale, &config);
 
             config.xWidth = self->x_scale;
             config.xHeight = self->y_scale;
 
-            OMX_SetConfig (gomx->omx_handle, OMX_IndexConfigCommonScale, &config);
+            G_OMX_PORT_SET_CONFIG (omx_base->in_port, OMX_IndexConfigCommonScale, &config);
         }
     }
 
diff --git a/omx/gstomx_volume.c b/omx/gstomx_volume.c
index 3fbc4e9..9e79176 100644
--- a/omx/gstomx_volume.c
+++ b/omx/gstomx_volume.c
@@ -122,13 +122,7 @@ settings_changed_cb (GOmxCore *core)
     {
         OMX_AUDIO_PARAM_PCMMODETYPE param;
 
-        memset (&param, 0, sizeof (param));
-        param.nSize = sizeof (OMX_AUDIO_PARAM_PCMMODETYPE);
-        param.nVersion.s.nVersionMajor = 1;
-        param.nVersion.s.nVersionMinor = 1;
-
-        param.nPortIndex = 1;
-        OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
+        G_OMX_PORT_GET_PARAM (omx_base->out_port, OMX_IndexParamAudioPcm, &param);
 
         rate = param.nSamplingRate;
         channels = param.nChannels;
diff --git a/omx/gstomx_vorbisdec.c b/omx/gstomx_vorbisdec.c
index 437dc90..aba6b45 100644
--- a/omx/gstomx_vorbisdec.c
+++ b/omx/gstomx_vorbisdec.c
@@ -115,13 +115,8 @@ settings_changed_cb (GOmxCore *core)
     {
         OMX_AUDIO_PARAM_PCMMODETYPE param;
 
-        memset (&param, 0, sizeof (param));
-        param.nSize = sizeof (OMX_AUDIO_PARAM_PCMMODETYPE);
-        param.nVersion.s.nVersionMajor = 1;
-        param.nVersion.s.nVersionMinor = 1;
+        G_OMX_PORT_GET_PARAM (omx_base->out_port, OMX_IndexParamAudioPcm, &param);
 
-        param.nPortIndex = 1;
-        OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm, &param);
 
         rate = param.nSamplingRate;
         channels = param.nChannels;
-- 
1.6.3.2





More information about the Gstreamer-openmax mailing list