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_g729enc.h"
23 #include "gstomx_base_filter.h"
26 #define DEFAULT_DTX TRUE
34 GSTOMX_BOILERPLATE (GstOmxG729Enc, gst_omx_g729enc, GstOmxBaseFilter,
35 GST_OMX_BASE_FILTER_TYPE);
38 type_base_init (gpointer g_class)
40 GstElementClass *element_class;
42 element_class = GST_ELEMENT_CLASS (g_class);
44 gst_element_class_set_details_simple (element_class,
45 "OpenMAX IL G.729 audio encoder",
46 "Codec/Encoder/Audio",
47 "Encodes audio in G.729 format with OpenMAX IL", "Felipe Contreras");
49 gst_element_class_add_pad_template (element_class,
50 gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
51 gstomx_template_caps (G_TYPE_FROM_CLASS (g_class), "sink")));
53 gst_element_class_add_pad_template (element_class,
54 gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
55 gstomx_template_caps (G_TYPE_FROM_CLASS (g_class), "src")));
59 set_property (GObject * obj,
60 guint prop_id, const GValue * value, GParamSpec * pspec)
64 self = GST_OMX_G729ENC (obj);
68 self->dtx = g_value_get_boolean (value);
71 G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
77 get_property (GObject * obj, guint prop_id, GValue * value, GParamSpec * pspec)
81 self = GST_OMX_G729ENC (obj);
85 /** @todo propagate this to OpenMAX when processing. */
86 g_value_set_boolean (value, self->dtx);
89 G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
95 type_class_init (gpointer g_class, gpointer class_data)
97 GObjectClass *gobject_class;
99 gobject_class = G_OBJECT_CLASS (g_class);
101 /* Properties stuff */
103 gobject_class->set_property = set_property;
104 gobject_class->get_property = get_property;
106 g_object_class_install_property (gobject_class, ARG_DTX,
107 g_param_spec_boolean ("dtx", "DTX",
109 DEFAULT_DTX, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
114 sink_setcaps (GstPad * pad, GstCaps * caps)
116 GstOmxBaseFilter *omx_base;
119 omx_base = GST_OMX_BASE_FILTER (GST_PAD_PARENT (pad));
121 GST_INFO_OBJECT (omx_base, "setcaps (sink): %" GST_PTR_FORMAT, caps);
123 if (!caps || gst_caps_get_size (caps) == 0)
126 /* some extreme checking */
127 if (!gst_pad_accept_caps (pad, caps))
130 /* set caps on the srcpad */
134 /* src template are fixed caps */
135 tmp_caps = gstomx_template_caps (G_TYPE_FROM_INSTANCE (omx_base), "src");
137 ret = gst_pad_set_caps (omx_base->srcpad, tmp_caps);
138 gst_caps_unref (tmp_caps);
146 GST_WARNING_OBJECT (omx_base, "refused caps %" GST_PTR_FORMAT, caps);
152 omx_setup (GstOmxBaseFilter * omx_base)
157 self = GST_OMX_G729ENC (omx_base);
158 gomx = omx_base->gomx;
160 GST_INFO_OBJECT (omx_base, "begin");
163 OMX_AUDIO_PARAM_G729TYPE param;
165 G_OMX_INIT_PARAM (param);
167 param.nPortIndex = omx_base->out_port->port_index;
168 OMX_GetParameter (gomx->omx_handle, OMX_IndexParamAudioG729, ¶m);
170 param.bDTX = self->dtx;
172 OMX_SetParameter (gomx->omx_handle, OMX_IndexParamAudioG729, ¶m);
175 GST_INFO_OBJECT (omx_base, "end");
179 type_instance_init (GTypeInstance * instance, gpointer g_class)
181 GstOmxBaseFilter *omx_base;
184 omx_base = GST_OMX_BASE_FILTER (instance);
185 self = GST_OMX_G729ENC (instance);
187 omx_base->omx_setup = omx_setup;
189 gst_pad_set_setcaps_function (omx_base->sinkpad, sink_setcaps);
191 self->dtx = DEFAULT_DTX;