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);
31 type_base_init (gpointer g_class)
33 GstElementClass *element_class;
35 element_class = GST_ELEMENT_CLASS (g_class);
37 gst_element_class_set_details_simple (element_class,
38 "OpenMAX IL Volume component",
39 "Filter/Effect/Audio",
40 "Changes the volume with OpenMAX IL", "Frederik Vernelen");
42 gst_element_class_add_pad_template (element_class,
43 gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
44 gstomx_template_caps (G_TYPE_FROM_CLASS (g_class), "sink")));
46 gst_element_class_add_pad_template (element_class,
47 gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
48 gstomx_template_caps (G_TYPE_FROM_CLASS (g_class), "src")));
52 type_class_init (gpointer g_class, gpointer class_data)
57 settings_changed_cb (GOmxCore * core)
59 GstOmxBaseFilter *omx_base;
63 omx_base = core->object;
65 GST_DEBUG_OBJECT (omx_base, "settings changed");
68 OMX_AUDIO_PARAM_PCMMODETYPE param;
70 G_OMX_INIT_PARAM (param);
72 param.nPortIndex = omx_base->out_port->port_index;
73 OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm,
76 rate = param.nSamplingRate;
77 channels = param.nChannels;
79 /** @todo: this shouldn't happen. */
80 GST_WARNING_OBJECT (omx_base, "Bad samplerate");
88 new_caps = gst_caps_new_simple ("audio/x-raw-int",
89 "width", G_TYPE_INT, 16,
90 "depth", G_TYPE_INT, 16,
91 "rate", G_TYPE_INT, rate,
92 "signed", G_TYPE_BOOLEAN, TRUE,
93 "endianness", G_TYPE_INT, G_BYTE_ORDER,
94 "channels", G_TYPE_INT, channels, NULL);
96 GST_INFO_OBJECT (omx_base, "caps are: %" GST_PTR_FORMAT, new_caps);
97 gst_pad_set_caps (omx_base->srcpad, new_caps);
102 type_instance_init (GTypeInstance * instance, gpointer g_class)
104 GstOmxBaseFilter *omx_base;
106 omx_base = GST_OMX_BASE_FILTER (instance);
108 GST_DEBUG_OBJECT (omx_base, "start");
110 omx_base->gomx->settings_changed_cb = settings_changed_cb;