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_g711dec.h"
23 #include "gstomx_base_filter.h"
26 #include <string.h> /* for strcmp */
28 /* should this class extend GstOmxBaseAudioDec? */
29 GSTOMX_BOILERPLATE (GstOmxG711Dec, gst_omx_g711dec, GstOmxBaseFilter,
30 GST_OMX_BASE_FILTER_TYPE);
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 G.711 audio decoder",
41 "Codec/Decoder/Audio",
42 "Decodes audio in G.711 format with OpenMAX IL", "Felipe Contreras");
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)
59 sink_setcaps (GstPad * pad, GstCaps * caps)
61 GstStructure *structure;
62 GstOmxBaseFilter *omx_base;
67 omx_base = GST_OMX_BASE_FILTER (GST_PAD_PARENT (pad));
68 gomx = (GOmxCore *) omx_base->gomx;
70 GST_INFO_OBJECT (omx_base, "setcaps (sink): %" GST_PTR_FORMAT, caps);
72 structure = gst_caps_get_structure (caps, 0);
74 mode = gst_structure_get_name (structure);
76 /* Output port configuration. */
78 OMX_AUDIO_PARAM_PCMMODETYPE param;
80 G_OMX_INIT_PARAM (param);
82 param.nPortIndex = omx_base->in_port->port_index;
83 OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m);
85 if (strcmp (mode, "audio/x-alaw") == 0)
86 param.ePCMMode = OMX_AUDIO_PCMModeALaw;
87 else if (strcmp (mode, "audio/x-mulaw") == 0)
88 param.ePCMMode = OMX_AUDIO_PCMModeMULaw;
90 OMX_SetParameter (gomx->omx_handle, OMX_IndexParamAudioPcm, ¶m);
93 /* set caps on the srcpad */
97 tmp_caps = gst_pad_get_allowed_caps (omx_base->srcpad);
98 tmp_caps = gst_caps_make_writable (tmp_caps);
99 gst_caps_truncate (tmp_caps);
101 gst_pad_fixate_caps (omx_base->srcpad, tmp_caps);
103 if (gst_caps_is_fixed (tmp_caps)) {
104 GST_INFO_OBJECT (omx_base, "fixated to: %" GST_PTR_FORMAT, tmp_caps);
105 gst_pad_set_caps (omx_base->srcpad, tmp_caps);
108 gst_caps_unref (tmp_caps);
111 ret = gst_pad_set_caps (pad, caps);
117 type_instance_init (GTypeInstance * instance, gpointer g_class)
119 GstOmxBaseFilter *omx_base;
121 omx_base = GST_OMX_BASE_FILTER (instance);
123 gst_pad_set_setcaps_function (omx_base->sinkpad, sink_setcaps);