2 * Copyright (C) 2007-2009 Nokia Corporation.
3 * Copyright (C) 2008 NXP.
5 * Author: Frederik Vernelen <frederik.vernelen@nxp.com>
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation
10 * version 2.1 of the License.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "gstomx_volume.h"
24 #include "gstomx_base_filter.h"
27 GSTOMX_BOILERPLATE (GstOmxVolume, gst_omx_volume, GstOmxBaseFilter,
28 GST_OMX_BASE_FILTER_TYPE);
30 static void instance_init (GstElement * element);
33 type_base_init (gpointer g_class)
35 GstElementClass *element_class;
37 element_class = GST_ELEMENT_CLASS (g_class);
39 gst_element_class_set_details_simple (element_class,
40 "OpenMAX IL Volume component",
41 "Filter/Effect/Audio",
42 "Changes the volume with OpenMAX IL", "Frederik Vernelen");
44 gst_element_class_add_pad_template (element_class,
45 gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
46 gstomx_template_caps (G_TYPE_FROM_CLASS (g_class), "sink")));
48 gst_element_class_add_pad_template (element_class,
49 gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
50 gstomx_template_caps (G_TYPE_FROM_CLASS (g_class), "src")));
54 type_class_init (gpointer g_class, gpointer class_data)
56 GstOmxBaseFilterClass *basefilter_class;
58 basefilter_class = GST_OMX_BASE_FILTER_CLASS (g_class);
59 basefilter_class->instance_init = instance_init;
63 settings_changed_cb (GOmxCore * core)
65 GstOmxBaseFilter *omx_base;
69 omx_base = core->object;
71 GST_DEBUG_OBJECT (omx_base, "settings changed");
74 OMX_AUDIO_PARAM_PCMMODETYPE param;
76 G_OMX_INIT_PARAM (param);
78 param.nPortIndex = omx_base->out_port->port_index;
79 OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm,
82 rate = param.nSamplingRate;
83 channels = param.nChannels;
85 /** @todo: this shouldn't happen. */
86 GST_WARNING_OBJECT (omx_base, "Bad samplerate");
94 new_caps = gst_caps_new_simple ("audio/x-raw-int",
95 "width", G_TYPE_INT, 16,
96 "depth", G_TYPE_INT, 16,
97 "rate", G_TYPE_INT, rate,
98 "signed", G_TYPE_BOOLEAN, TRUE,
99 "endianness", G_TYPE_INT, G_BYTE_ORDER,
100 "channels", G_TYPE_INT, channels, NULL);
102 GST_INFO_OBJECT (omx_base, "caps are: %" GST_PTR_FORMAT, new_caps);
103 gst_pad_set_caps (omx_base->srcpad, new_caps);
108 instance_private_value_init(GstElement * element)
110 GstOmxBaseFilter *omx_base;
112 omx_base = GST_OMX_BASE_FILTER (element);
114 omx_base->gomx->settings_changed_cb = settings_changed_cb;
118 instance_init (GstElement * element)
120 GST_OMX_BASE_FILTER_CLASS (parent_class)->instance_init(element);
122 instance_private_value_init(element);
126 type_instance_init (GTypeInstance * instance, gpointer g_class)
128 instance_private_value_init(GST_ELEMENT(instance));