tizen beta release
[profile/ivi/gst-openmax0.10.git] / omx / gstomx_base_audiodec.c
1 /*
2  * Copyright (C) 2009 Texas Instruments, Inc.
3  *
4  * Author: Rob Clark <rob@ti.com>
5  *
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.
10  *
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.
15  *
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
19  *
20  */
21
22 #include "gstomx_base_audiodec.h"
23 #include "gstomx.h"
24
25 GSTOMX_BOILERPLATE (GstOmxBaseAudioDec, gst_omx_base_audiodec, GstOmxBaseFilter,
26     GST_OMX_BASE_FILTER_TYPE);
27
28 static void
29 type_base_init (gpointer g_class)
30 {
31 }
32
33 static void
34 type_class_init (gpointer g_class, gpointer class_data)
35 {
36 }
37
38 static void
39 settings_changed_cb (GOmxCore * core)
40 {
41   GstOmxBaseFilter *omx_base;
42   guint rate;
43   guint channels;
44
45   omx_base = core->object;
46
47   GST_DEBUG_OBJECT (omx_base, "settings changed");
48
49   {
50     OMX_AUDIO_PARAM_PCMMODETYPE param;
51
52     G_OMX_INIT_PARAM (param);
53
54     param.nPortIndex = omx_base->out_port->port_index;
55     OMX_GetParameter (omx_base->gomx->omx_handle, OMX_IndexParamAudioPcm,
56         &param);
57
58     rate = param.nSamplingRate;
59     channels = param.nChannels;
60     if (rate == 0) {
61             /** @todo: this shouldn't happen. */
62       GST_WARNING_OBJECT (omx_base, "Bad samplerate");
63       rate = 44100;
64     }
65   }
66
67   {
68     GstCaps *new_caps;
69
70     new_caps = gst_caps_new_simple ("audio/x-raw-int",
71         "width", G_TYPE_INT, 16,
72         "depth", G_TYPE_INT, 16,
73         "rate", G_TYPE_INT, rate,
74         "signed", G_TYPE_BOOLEAN, TRUE,
75         "endianness", G_TYPE_INT, G_BYTE_ORDER,
76         "channels", G_TYPE_INT, channels, NULL);
77
78     GST_INFO_OBJECT (omx_base, "caps are: %" GST_PTR_FORMAT, new_caps);
79     gst_pad_set_caps (omx_base->srcpad, new_caps);
80   }
81 }
82
83 static void
84 type_instance_init (GTypeInstance * instance, gpointer g_class)
85 {
86   GstOmxBaseFilter *omx_base;
87
88   omx_base = GST_OMX_BASE_FILTER (instance);
89
90   GST_DEBUG_OBJECT (omx_base, "start");
91
92   omx_base->gomx->settings_changed_cb = settings_changed_cb;
93 }