[Gstreamer-openmax] [PATCH 3/3] Don't hard-code port indexes
Rob Clark
rob at ti.com
Wed Mar 17 15:50:31 PDT 2010
This improves readability by keeping knowledge of numeric port-index value
in only one place (in the element constructor), and makes it easier to
later add derived classes with different port indexes (for example
GstOmxCamera subclassing GstOmxBaseSrc, but having GstOmxBaseSrc handling a
port whose index != 0 while derived class handles port index 0 and others).
---
omx/gstomx_aacdec.c | 2 +-
omx/gstomx_aacenc.c | 8 ++++----
omx/gstomx_adpcmdec.c | 2 +-
omx/gstomx_adpcmenc.c | 4 ++--
omx/gstomx_amrnbdec.c | 2 +-
omx/gstomx_amrnbenc.c | 4 ++--
omx/gstomx_amrwbdec.c | 2 +-
omx/gstomx_amrwbenc.c | 4 ++--
omx/gstomx_audiosink.c | 2 +-
omx/gstomx_base_videodec.c | 6 +++---
omx/gstomx_base_videoenc.c | 4 ++--
omx/gstomx_g711dec.c | 2 +-
omx/gstomx_g711enc.c | 2 +-
omx/gstomx_g729enc.c | 2 +-
omx/gstomx_h263enc.c | 2 +-
omx/gstomx_h264enc.c | 2 +-
omx/gstomx_jpegenc.c | 8 ++++----
omx/gstomx_mp2dec.c | 2 +-
omx/gstomx_mp3dec.c | 2 +-
omx/gstomx_mpeg4enc.c | 2 +-
omx/gstomx_videosink.c | 6 +++---
omx/gstomx_volume.c | 2 +-
omx/gstomx_vorbisdec.c | 2 +-
23 files changed, 37 insertions(+), 37 deletions(-)
diff --git a/omx/gstomx_aacdec.c b/omx/gstomx_aacdec.c
index f72178d..1f22dd8 100644
--- a/omx/gstomx_aacdec.c
+++ b/omx/gstomx_aacdec.c
@@ -148,7 +148,7 @@ settings_changed_cb (GOmxCore *core)
param.nVersion.s.nVersionMajor = 1;
param.nVersion.s.nVersionMinor = 1;
- param.nPortIndex = 1;
+ param.nPortIndex = omx_base->out_port->port_index;
OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m);
rate = param.nSamplingRate;
diff --git a/omx/gstomx_aacenc.c b/omx/gstomx_aacenc.c
index 5882a31..565bc82 100644
--- a/omx/gstomx_aacenc.c
+++ b/omx/gstomx_aacenc.c
@@ -308,7 +308,7 @@ sink_setcaps (GstPad *pad,
param.nVersion.s.nVersionMajor = 1;
param.nVersion.s.nVersionMinor = 1;
- param.nPortIndex = 0;
+ param.nPortIndex = omx_base->in_port->port_index;
OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m);
param.nSamplingRate = rate;
@@ -356,7 +356,7 @@ omx_setup (GstOmxBaseFilter *omx_base)
/* Output port configuration. */
{
- param.nPortIndex = 1;
+ param.nPortIndex = omx_base->out_port->port_index;
OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioAac, ¶m);
GST_DEBUG_OBJECT (omx_base, "setting bitrate: %i", self->bitrate);
@@ -383,7 +383,7 @@ omx_setup (GstOmxBaseFilter *omx_base)
param.nVersion.s.nVersionMajor = 1;
param.nVersion.s.nVersionMinor = 1;
- param.nPortIndex = 0;
+ param.nPortIndex = omx_base->in_port->port_index;
OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m);
rate = param.nSamplingRate;
@@ -398,7 +398,7 @@ omx_setup (GstOmxBaseFilter *omx_base)
param.nVersion.s.nVersionMajor = 1;
param.nVersion.s.nVersionMinor = 1;
- param.nPortIndex = 1;
+ param.nPortIndex = omx_base->out_port->port_index;
OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioAac, ¶m);
param.nSampleRate = rate;
diff --git a/omx/gstomx_adpcmdec.c b/omx/gstomx_adpcmdec.c
index ed77085..12ee81f 100644
--- a/omx/gstomx_adpcmdec.c
+++ b/omx/gstomx_adpcmdec.c
@@ -130,7 +130,7 @@ sink_setcaps (GstPad *pad,
param.nVersion.s.nVersionMajor = 1;
param.nVersion.s.nVersionMinor = 1;
- param.nPortIndex = 1;
+ param.nPortIndex = omx_base->out_port->port_index;
OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m);
param.nSamplingRate = rate;
diff --git a/omx/gstomx_adpcmenc.c b/omx/gstomx_adpcmenc.c
index ab5ce61..fea6bf4 100644
--- a/omx/gstomx_adpcmenc.c
+++ b/omx/gstomx_adpcmenc.c
@@ -121,7 +121,7 @@ settings_changed_cb (GOmxCore *core)
param.nVersion.s.nVersionMajor = 1;
param.nVersion.s.nVersionMinor = 1;
- param.nPortIndex = 1;
+ param.nPortIndex = omx_base->out_port->port_index;
OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioAdpcm, ¶m);
rate = param.nSampleRate;
@@ -185,7 +185,7 @@ sink_setcaps (GstPad *pad,
param.nVersion.s.nVersionMajor = 1;
param.nVersion.s.nVersionMinor = 1;
- param.nPortIndex = 0;
+ param.nPortIndex = omx_base->in_port->port_index;
OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m);
param.nSamplingRate = rate;
diff --git a/omx/gstomx_amrnbdec.c b/omx/gstomx_amrnbdec.c
index a32f162..f32b15f 100644
--- a/omx/gstomx_amrnbdec.c
+++ b/omx/gstomx_amrnbdec.c
@@ -121,7 +121,7 @@ settings_changed_cb (GOmxCore *core)
param.nVersion.s.nVersionMajor = 1;
param.nVersion.s.nVersionMinor = 1;
- param.nPortIndex = 1;
+ param.nPortIndex = omx_base->out_port->port_index;
OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m);
rate = param.nSamplingRate;
diff --git a/omx/gstomx_amrnbenc.c b/omx/gstomx_amrnbenc.c
index e1c9b19..cc3486f 100644
--- a/omx/gstomx_amrnbenc.c
+++ b/omx/gstomx_amrnbenc.c
@@ -186,7 +186,7 @@ settings_changed_cb (GOmxCore *core)
param.nVersion.s.nVersionMajor = 1;
param.nVersion.s.nVersionMinor = 1;
- param.nPortIndex = 1;
+ param.nPortIndex = omx_base->out_port->port_index;
OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioAmr, ¶m);
channels = param.nChannels;
@@ -236,7 +236,7 @@ sink_setcaps (GstPad *pad,
param.nVersion.s.nVersionMajor = 1;
param.nVersion.s.nVersionMinor = 1;
- param.nPortIndex = 0;
+ param.nPortIndex = omx_base->in_port->port_index;
OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m);
param.nSamplingRate = rate;
diff --git a/omx/gstomx_amrwbdec.c b/omx/gstomx_amrwbdec.c
index 26e1692..20dddcb 100644
--- a/omx/gstomx_amrwbdec.c
+++ b/omx/gstomx_amrwbdec.c
@@ -121,7 +121,7 @@ settings_changed_cb (GOmxCore *core)
param.nVersion.s.nVersionMajor = 1;
param.nVersion.s.nVersionMinor = 1;
- param.nPortIndex = 1;
+ param.nPortIndex = omx_base->out_port->port_index;
OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m);
rate = param.nSamplingRate;
diff --git a/omx/gstomx_amrwbenc.c b/omx/gstomx_amrwbenc.c
index a19e670..3d95272 100644
--- a/omx/gstomx_amrwbenc.c
+++ b/omx/gstomx_amrwbenc.c
@@ -186,7 +186,7 @@ settings_changed_cb (GOmxCore *core)
param.nVersion.s.nVersionMajor = 1;
param.nVersion.s.nVersionMinor = 1;
- param.nPortIndex = 1;
+ param.nPortIndex = omx_base->out_port->port_index;
OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioAmr, ¶m);
channels = param.nChannels;
@@ -236,7 +236,7 @@ sink_setcaps (GstPad *pad,
param.nVersion.s.nVersionMajor = 1;
param.nVersion.s.nVersionMinor = 1;
- param.nPortIndex = 0;
+ param.nPortIndex = omx_base->in_port->port_index;
OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m);
param.nSamplingRate = rate;
diff --git a/omx/gstomx_audiosink.c b/omx/gstomx_audiosink.c
index a05a7cd..6c912f0 100644
--- a/omx/gstomx_audiosink.c
+++ b/omx/gstomx_audiosink.c
@@ -114,7 +114,7 @@ setcaps (GstBaseSink *gst_sink,
param.nVersion.s.nVersionMajor = 1;
param.nVersion.s.nVersionMinor = 1;
- param.nPortIndex = 0;
+ param.nPortIndex = self->in_port->port_index;
OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m);
param.nChannels = channels;
diff --git a/omx/gstomx_base_videodec.c b/omx/gstomx_base_videodec.c
index 3ff2f44..5c6d1e1 100644
--- a/omx/gstomx_base_videodec.c
+++ b/omx/gstomx_base_videodec.c
@@ -116,7 +116,7 @@ settings_changed_cb (GOmxCore *core)
param.nVersion.s.nVersionMajor = 1;
param.nVersion.s.nVersionMinor = 1;
- param.nPortIndex = 1;
+ param.nPortIndex = omx_base->out_port->port_index;
OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamPortDefinition, ¶m);
width = param.format.video.nFrameWidth;
@@ -217,7 +217,7 @@ sink_setcaps (GstPad *pad,
/* Input port configuration. */
{
- param.nPortIndex = 0;
+ param.nPortIndex = omx_base->in_port->port_index;
OMX_GetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, ¶m);
param.format.video.nFrameWidth = width;
@@ -250,7 +250,7 @@ omx_setup (GstOmxBaseFilter *omx_base)
/* Input port configuration. */
{
- param.nPortIndex = 0;
+ param.nPortIndex = omx_base->in_port->port_index;
OMX_GetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, ¶m);
param.format.video.eCompressionFormat = self->compression_format;
diff --git a/omx/gstomx_base_videoenc.c b/omx/gstomx_base_videoenc.c
index 7c99a53..d243fbd 100644
--- a/omx/gstomx_base_videoenc.c
+++ b/omx/gstomx_base_videoenc.c
@@ -222,7 +222,7 @@ sink_setcaps (GstPad *pad,
/* Input port configuration. */
{
- param.nPortIndex = 0;
+ param.nPortIndex = omx_base->in_port->port_index;
OMX_GetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, ¶m);
param.format.video.nFrameWidth = width;
@@ -264,7 +264,7 @@ omx_setup (GstOmxBaseFilter *omx_base)
/* Output port configuration. */
{
- param.nPortIndex = 1;
+ param.nPortIndex = omx_base->out_port->port_index;
OMX_GetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, ¶m);
param.format.video.eCompressionFormat = self->compression_format;
diff --git a/omx/gstomx_g711dec.c b/omx/gstomx_g711dec.c
index 40cd64b..bc2fb18 100644
--- a/omx/gstomx_g711dec.c
+++ b/omx/gstomx_g711dec.c
@@ -142,7 +142,7 @@ sink_setcaps (GstPad *pad,
param.nVersion.s.nVersionMajor = 1;
param.nVersion.s.nVersionMinor = 1;
- param.nPortIndex = 0;
+ param.nPortIndex = omx_base->in_port->port_index;
OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m);
if (strcmp (mode, "audio/x-alaw") == 0)
diff --git a/omx/gstomx_g711enc.c b/omx/gstomx_g711enc.c
index 16d58aa..ba8d297 100644
--- a/omx/gstomx_g711enc.c
+++ b/omx/gstomx_g711enc.c
@@ -152,7 +152,7 @@ sink_setcaps (GstPad *pad,
param.nVersion.s.nVersionMajor = 1;
param.nVersion.s.nVersionMinor = 1;
- param.nPortIndex = 1;
+ param.nPortIndex = omx_base->out_port->port_index;
OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m);
if (strcmp (mode, "audio/x-alaw") == 0)
diff --git a/omx/gstomx_g729enc.c b/omx/gstomx_g729enc.c
index b6c41f0..67f9b38 100644
--- a/omx/gstomx_g729enc.c
+++ b/omx/gstomx_g729enc.c
@@ -230,7 +230,7 @@ omx_setup (GstOmxBaseFilter *omx_base)
param.nVersion.s.nVersionMajor = 1;
param.nVersion.s.nVersionMinor = 1;
- param.nPortIndex = 1;
+ param.nPortIndex = omx_base->out_port->port_index;
OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioG729, ¶m);
param.bDTX = self->dtx;
diff --git a/omx/gstomx_h263enc.c b/omx/gstomx_h263enc.c
index 5f39029..2d2a1a0 100644
--- a/omx/gstomx_h263enc.c
+++ b/omx/gstomx_h263enc.c
@@ -97,7 +97,7 @@ settings_changed_cb (GOmxCore *core)
param.nVersion.s.nVersionMajor = 1;
param.nVersion.s.nVersionMinor = 1;
- param.nPortIndex = 1;
+ param.nPortIndex = omx_base_filter->out_port->port_index;
OMX_GetParameter (core->omx_handle, OMX_IndexParamPortDefinition, ¶m);
width = param.format.video.nFrameWidth;
diff --git a/omx/gstomx_h264enc.c b/omx/gstomx_h264enc.c
index 336ea9a..7d2c2b6 100644
--- a/omx/gstomx_h264enc.c
+++ b/omx/gstomx_h264enc.c
@@ -96,7 +96,7 @@ settings_changed_cb (GOmxCore *core)
param.nVersion.s.nVersionMajor = 1;
param.nVersion.s.nVersionMinor = 1;
- param.nPortIndex = 1;
+ param.nPortIndex = omx_base_filter->out_port->port_index;
OMX_GetParameter (core->omx_handle, OMX_IndexParamPortDefinition, ¶m);
width = param.format.video.nFrameWidth;
diff --git a/omx/gstomx_jpegenc.c b/omx/gstomx_jpegenc.c
index 2799521..63ff8fe 100644
--- a/omx/gstomx_jpegenc.c
+++ b/omx/gstomx_jpegenc.c
@@ -211,7 +211,7 @@ settings_changed_cb (GOmxCore *core)
param.nVersion.s.nVersionMajor = 1;
param.nVersion.s.nVersionMinor = 1;
- param.nPortIndex = 1;
+ param.nPortIndex = omx_base->out_port->port_index;
OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamPortDefinition, ¶m);
width = param.format.image.nFrameWidth;
@@ -294,7 +294,7 @@ sink_setcaps (GstPad *pad,
/* Input port configuration. */
{
- param.nPortIndex = 0;
+ param.nPortIndex = omx_base->in_port->port_index;
OMX_GetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, ¶m);
param.format.image.nFrameWidth = width;
@@ -329,7 +329,7 @@ omx_setup (GstOmxBaseFilter *omx_base)
/* Output port configuration. */
{
- param.nPortIndex = 1;
+ param.nPortIndex = omx_base->out_port->port_index;
OMX_GetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, ¶m);
param.format.image.eCompressionFormat = OMX_IMAGE_CodingJPEG;
@@ -347,7 +347,7 @@ omx_setup (GstOmxBaseFilter *omx_base)
param.nVersion.s.nVersionMinor = 1;
param.nQFactor = self->quality;
- param.nPortIndex = 1;
+ param.nPortIndex = omx_base->out_port->port_index;
OMX_SetParameter (gomx->omx_handle, OMX_IndexParamQFactor, ¶m);
}
diff --git a/omx/gstomx_mp2dec.c b/omx/gstomx_mp2dec.c
index f6c2568..6e78e5f 100644
--- a/omx/gstomx_mp2dec.c
+++ b/omx/gstomx_mp2dec.c
@@ -124,7 +124,7 @@ settings_changed_cb (GOmxCore *core)
param.nVersion.s.nVersionMajor = 1;
param.nVersion.s.nVersionMinor = 1;
- param.nPortIndex = 1;
+ param.nPortIndex = omx_base->out_port->port_index;
OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m);
rate = param.nSamplingRate;
diff --git a/omx/gstomx_mp3dec.c b/omx/gstomx_mp3dec.c
index 08f1896..3824a9d 100644
--- a/omx/gstomx_mp3dec.c
+++ b/omx/gstomx_mp3dec.c
@@ -124,7 +124,7 @@ settings_changed_cb (GOmxCore *core)
param.nVersion.s.nVersionMajor = 1;
param.nVersion.s.nVersionMinor = 1;
- param.nPortIndex = 1;
+ param.nPortIndex = omx_base->out_port->port_index;
OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m);
rate = param.nSamplingRate;
diff --git a/omx/gstomx_mpeg4enc.c b/omx/gstomx_mpeg4enc.c
index 7a91c1c..f365639 100644
--- a/omx/gstomx_mpeg4enc.c
+++ b/omx/gstomx_mpeg4enc.c
@@ -98,7 +98,7 @@ settings_changed_cb (GOmxCore *core)
param.nVersion.s.nVersionMajor = 1;
param.nVersion.s.nVersionMinor = 1;
- param.nPortIndex = 1;
+ param.nPortIndex = omx_base_filter->out_port->port_index;
OMX_GetParameter (core->omx_handle, OMX_IndexParamPortDefinition, ¶m);
width = param.format.video.nFrameWidth;
diff --git a/omx/gstomx_videosink.c b/omx/gstomx_videosink.c
index 683ee4c..7c5849b 100644
--- a/omx/gstomx_videosink.c
+++ b/omx/gstomx_videosink.c
@@ -166,7 +166,7 @@ setcaps (GstBaseSink *gst_sink,
param.nVersion.s.nVersionMajor = 1;
param.nVersion.s.nVersionMinor = 1;
- param.nPortIndex = 0;
+ param.nPortIndex = omx_base->in_port->port_index;
OMX_GetParameter (gomx->omx_handle, OMX_IndexParamPortDefinition, ¶m);
switch (color_format)
@@ -205,7 +205,7 @@ setcaps (GstBaseSink *gst_sink,
config.nVersion.s.nVersionMajor = 1;
config.nVersion.s.nVersionMinor = 1;
- config.nPortIndex = 0;
+ config.nPortIndex = omx_base->in_port->port_index;
OMX_GetConfig (gomx->omx_handle, OMX_IndexConfigCommonScale, &config);
config.nRotation = self->rotation;
@@ -221,7 +221,7 @@ setcaps (GstBaseSink *gst_sink,
config.nVersion.s.nVersionMajor = 1;
config.nVersion.s.nVersionMinor = 1;
- config.nPortIndex = 0;
+ config.nPortIndex = omx_base->in_port->port_index;
OMX_GetConfig (gomx->omx_handle, OMX_IndexConfigCommonScale, &config);
config.xWidth = self->x_scale;
diff --git a/omx/gstomx_volume.c b/omx/gstomx_volume.c
index cd23103..91e116e 100644
--- a/omx/gstomx_volume.c
+++ b/omx/gstomx_volume.c
@@ -126,7 +126,7 @@ settings_changed_cb (GOmxCore *core)
param.nVersion.s.nVersionMajor = 1;
param.nVersion.s.nVersionMinor = 1;
- param.nPortIndex = 1;
+ param.nPortIndex = omx_base->out_port->port_index;
OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m);
rate = param.nSamplingRate;
diff --git a/omx/gstomx_vorbisdec.c b/omx/gstomx_vorbisdec.c
index 2adad9b..aad896a 100644
--- a/omx/gstomx_vorbisdec.c
+++ b/omx/gstomx_vorbisdec.c
@@ -119,7 +119,7 @@ settings_changed_cb (GOmxCore *core)
param.nVersion.s.nVersionMajor = 1;
param.nVersion.s.nVersionMinor = 1;
- param.nPortIndex = 1;
+ param.nPortIndex = omx_base->out_port->port_index;
OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m);
rate = param.nSamplingRate;
--
1.6.3.2
More information about the Gstreamer-openmax
mailing list