diff options
Diffstat (limited to 'omx/gstomx_base_audiodec.c')
-rw-r--r-- | omx/gstomx_base_audiodec.c | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/omx/gstomx_base_audiodec.c b/omx/gstomx_base_audiodec.c new file mode 100644 index 0000000..25f19cb --- /dev/null +++ b/omx/gstomx_base_audiodec.c @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2009 Texas Instruments, Inc. + * + * Author: Rob Clark <rob@ti.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include "gstomx_base_audiodec.h" +#include "gstomx.h" + +GSTOMX_BOILERPLATE (GstOmxBaseAudioDec, gst_omx_base_audiodec, GstOmxBaseFilter, GST_OMX_BASE_FILTER_TYPE); + +static void +type_base_init (gpointer g_class) +{ +} + +static void +type_class_init (gpointer g_class, + gpointer class_data) +{ +} + +static void +settings_changed_cb (GOmxCore *core) +{ + GstOmxBaseFilter *omx_base; + guint rate; + guint channels; + + omx_base = core->object; + + GST_DEBUG_OBJECT (omx_base, "settings changed"); + + { + OMX_AUDIO_PARAM_PCMMODETYPE param; + + G_OMX_INIT_PARAM (param); + + param.nPortIndex = omx_base->out_port->port_index; + OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m); + + rate = param.nSamplingRate; + channels = param.nChannels; + if (rate == 0) + { + /** @todo: this shouldn't happen. */ + GST_WARNING_OBJECT (omx_base, "Bad samplerate"); + rate = 44100; + } + } + + { + GstCaps *new_caps; + + new_caps = gst_caps_new_simple ("audio/x-raw-int", + "width", G_TYPE_INT, 16, + "depth", G_TYPE_INT, 16, + "rate", G_TYPE_INT, rate, + "signed", G_TYPE_BOOLEAN, TRUE, + "endianness", G_TYPE_INT, G_BYTE_ORDER, + "channels", G_TYPE_INT, channels, + NULL); + + GST_INFO_OBJECT (omx_base, "caps are: %" GST_PTR_FORMAT, new_caps); + gst_pad_set_caps (omx_base->srcpad, new_caps); + } +} + +static void +type_instance_init (GTypeInstance *instance, + gpointer g_class) +{ + GstOmxBaseFilter *omx_base; + + omx_base = GST_OMX_BASE_FILTER (instance); + + GST_DEBUG_OBJECT (omx_base, "start"); + + omx_base->gomx->settings_changed_cb = settings_changed_cb; +} |