tizen beta release
[profile/ivi/gst-openmax0.10.git] / omx / gstomx_aacdec.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_aacdec.h"
23 #include "gstomx.h"
24
25 GSTOMX_BOILERPLATE (GstOmxAacDec, gst_omx_aacdec, GstOmxBaseAudioDec,
26     GST_OMX_BASE_AUDIODEC_TYPE);
27
28 static void
29 type_base_init (gpointer g_class)
30 {
31   GstElementClass *element_class;
32
33   element_class = GST_ELEMENT_CLASS (g_class);
34
35   gst_element_class_set_details_simple (element_class,
36       "OpenMAX IL AAC audio decoder",
37       "Codec/Decoder/Audio",
38       "Decodes audio in AAC format with OpenMAX IL", "Felipe Contreras");
39
40   gst_element_class_add_pad_template (element_class,
41       gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
42           gstomx_template_caps (G_TYPE_FROM_CLASS (g_class), "sink")));
43
44   gst_element_class_add_pad_template (element_class,
45       gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
46           gstomx_template_caps (G_TYPE_FROM_CLASS (g_class), "src")));
47 }
48
49 static void
50 type_class_init (gpointer g_class, gpointer class_data)
51 {
52 }
53
54 static gboolean
55 sink_setcaps (GstPad * pad, GstCaps * caps)
56 {
57   GstStructure *structure;
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   structure = gst_caps_get_structure (caps, 0);
65
66   {
67     const GValue *codec_data;
68     GstBuffer *buffer;
69
70     codec_data = gst_structure_get_value (structure, "codec_data");
71     if (codec_data) {
72       buffer = gst_value_get_buffer (codec_data);
73       omx_base->codec_data = buffer;
74       gst_buffer_ref (buffer);
75     }
76   }
77
78   return gst_pad_set_caps (pad, caps);
79 }
80
81 static void
82 type_instance_init (GTypeInstance * instance, gpointer g_class)
83 {
84   GstOmxBaseFilter *omx_base;
85
86   omx_base = GST_OMX_BASE_FILTER (instance);
87
88   gst_pad_set_setcaps_function (omx_base->sinkpad, sink_setcaps);
89 }