Initialize Tizen 2.3
[framework/multimedia/gst-openmax.git] / wearable / omx / gstomx_ilbcenc.c
1 /*
2  * Copyright (C) 2007-2009 Nokia Corporation.
3  *
4  * Author: Felipe Contreras <felipe.contreras@nokia.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_ilbcenc.h"
23 #include "gstomx_base_filter.h"
24 #include "gstomx.h"
25
26 GSTOMX_BOILERPLATE (GstOmxIlbcEnc, gst_omx_ilbcenc, GstOmxBaseFilter,
27     GST_OMX_BASE_FILTER_TYPE);
28
29 static void
30 type_base_init (gpointer g_class)
31 {
32   GstElementClass *element_class;
33
34   element_class = GST_ELEMENT_CLASS (g_class);
35
36   gst_element_class_set_details_simple (element_class,
37       "OpenMAX IL iLBC audio encoder",
38       "Codec/Encoder/Audio",
39       "Encodes audio in iLBC format with OpenMAX IL", "Felipe Contreras");
40
41   gst_element_class_add_pad_template (element_class,
42       gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
43           gstomx_template_caps (G_TYPE_FROM_CLASS (g_class), "sink")));
44
45   gst_element_class_add_pad_template (element_class,
46       gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
47           gstomx_template_caps (G_TYPE_FROM_CLASS (g_class), "src")));
48 }
49
50 static void
51 type_class_init (gpointer g_class, gpointer class_data)
52 {
53 }
54
55 static gboolean
56 sink_setcaps (GstPad * pad, GstCaps * caps)
57 {
58   GstOmxBaseFilter *omx_base;
59
60   omx_base = GST_OMX_BASE_FILTER (GST_PAD_PARENT (pad));
61
62   GST_INFO_OBJECT (omx_base, "setcaps (sink): %" GST_PTR_FORMAT, caps);
63
64   /* set caps on the srcpad */
65   {
66     GstCaps *tmp_caps;
67
68     tmp_caps = gst_pad_get_allowed_caps (omx_base->srcpad);
69     tmp_caps = gst_caps_make_writable (tmp_caps);
70     gst_caps_truncate (tmp_caps);
71
72     gst_pad_fixate_caps (omx_base->srcpad, tmp_caps);
73
74     if (gst_caps_is_fixed (tmp_caps)) {
75       GST_INFO_OBJECT (omx_base, "fixated to: %" GST_PTR_FORMAT, tmp_caps);
76       gst_pad_set_caps (omx_base->srcpad, tmp_caps);
77     }
78
79     gst_caps_unref (tmp_caps);
80   }
81
82   return gst_pad_set_caps (pad, caps);
83 }
84
85 static void
86 type_instance_init (GTypeInstance * instance, gpointer g_class)
87 {
88   GstOmxBaseFilter *omx_base;
89
90   omx_base = GST_OMX_BASE_FILTER (instance);
91
92   gst_pad_set_setcaps_function (omx_base->sinkpad, sink_setcaps);
93 }