2 * Copyright (C) 2007-2009 Nokia Corporation.
4 * Author: Felipe Contreras <felipe.contreras@nokia.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation
9 * version 2.1 of the License.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 #include "gstomx_audiosink.h"
25 GSTOMX_BOILERPLATE (GstOmxAudioSink, gst_omx_audiosink, GstOmxBaseSink,
26 GST_OMX_BASE_SINK_TYPE);
29 type_base_init (gpointer g_class)
31 GstElementClass *element_class;
33 element_class = GST_ELEMENT_CLASS (g_class);
35 gst_element_class_set_details_simple (element_class,
36 "OpenMAX IL audiosink element",
37 "Sink/Audio", "Renders audio", "Felipe Contreras");
39 gst_element_class_add_pad_template (element_class,
40 gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
41 gstomx_template_caps (G_TYPE_FROM_CLASS (g_class), "sink")));
45 setcaps (GstBaseSink * gst_sink, GstCaps * caps)
50 self = GST_OMX_BASE_SINK (gst_sink);
51 gomx = (GOmxCore *) self->gomx;
53 GST_INFO_OBJECT (self, "setcaps (sink): %" GST_PTR_FORMAT, caps);
55 g_return_val_if_fail (gst_caps_get_size (caps) == 1, FALSE);
58 GstStructure *structure;
63 gboolean is_bigendian;
65 structure = gst_caps_get_structure (caps, 0);
67 gst_structure_get_int (structure, "channels", &channels);
68 gst_structure_get_int (structure, "width", &width);
69 gst_structure_get_int (structure, "rate", &rate);
70 gst_structure_get_boolean (structure, "signed", &is_signed);
73 gst_structure_get_int (structure, "endianness", &endianness);
74 is_bigendian = (endianness == 1234) ? FALSE : TRUE;
78 OMX_AUDIO_PARAM_PCMMODETYPE param;
80 G_OMX_INIT_PARAM (param);
82 param.nPortIndex = self->in_port->port_index;
83 OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m);
85 param.nChannels = channels;
87 is_signed ? OMX_NumericalDataSigned : OMX_NumericalDataUnsigned;
88 param.eEndian = is_bigendian ? OMX_EndianBig : OMX_EndianLittle;
89 param.nBitPerSample = width;
90 param.nSamplingRate = rate;
92 OMX_SetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m);
100 type_class_init (gpointer g_class, gpointer class_data)
102 GstBaseSinkClass *gst_base_sink_class;
104 gst_base_sink_class = GST_BASE_SINK_CLASS (g_class);
106 gst_base_sink_class->set_caps = setcaps;
110 type_instance_init (GTypeInstance * instance, gpointer g_class)
112 GstOmxBaseSink *omx_base;
114 omx_base = GST_OMX_BASE_SINK (instance);
116 GST_DEBUG_OBJECT (omx_base, "start");