Plugins cleanup:
[platform/upstream/gstreamer.git] / gst / avi / gstaviaudiodecoder.c
1 /* GStreamer
2  * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20
21 /*#define GST_DEBUG_ENABLED */
22 #include <string.h>
23
24 #include "gstaviaudiodecoder.h"
25
26
27
28 /* elementfactory information */
29 static GstElementDetails gst_avi_audio_decoder_details = {
30   ".avi parser",
31   "Parser/Video",
32   "LGPL",
33   "Parse a .avi file into audio and video",
34   VERSION,
35   "Erik Walthinsen <omega@cse.ogi.edu>\n"
36   "Wim Taymans <wim.taymans@tvd.be>",
37   "(C) 1999",
38 };
39
40 /* AviAudioDecoder signals and args */
41 enum {
42   /* FILL ME */
43   LAST_SIGNAL
44 };
45
46 enum {
47   ARG_0,
48   /* FILL ME */
49 };
50
51 GST_PAD_TEMPLATE_FACTORY (sink_templ,
52   "sink",
53   GST_PAD_SINK,
54   GST_PAD_ALWAYS,
55   GST_CAPS_NEW (
56     "avidecoder_sink",
57      "video/avi",
58       "format", GST_PROPS_STRING ("strf_auds")
59   )
60 )
61
62 GST_PAD_TEMPLATE_FACTORY (src_audio_templ,
63   "src",
64   GST_PAD_SRC,
65   GST_PAD_ALWAYS,
66   GST_CAPS_NEW (
67     "src_audio",
68     "audio/raw",
69       "format",           GST_PROPS_STRING ("int"),
70        "law",              GST_PROPS_INT (0),
71        "endianness",       GST_PROPS_INT (G_BYTE_ORDER),
72        "signed",           GST_PROPS_BOOLEAN (TRUE),
73        "width",            GST_PROPS_INT (16),
74        "depth",            GST_PROPS_INT (16),
75        "rate",             GST_PROPS_INT_RANGE (11025, 44100),
76        "channels",         GST_PROPS_INT_RANGE (1, 2)
77   )
78 )
79
80 static void     gst_avi_audio_decoder_class_init        (GstAviAudioDecoderClass *klass);
81 static void     gst_avi_audio_decoder_init              (GstAviAudioDecoder *avi_audio_decoder);
82
83 static void     gst_avi_audio_decoder_chain             (GstPad *pad, GstBuffer *buf);
84
85 static void     gst_avi_audio_decoder_get_property      (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
86
87
88
89 static GstElementClass *parent_class = NULL;
90 /*static guint gst_avi_audio_decoder_signals[LAST_SIGNAL] = { 0 }; */
91
92 GType
93 gst_avi_audio_decoder_get_type(void) 
94 {
95   static GType avi_audio_decoder_type = 0;
96
97   if (!avi_audio_decoder_type) {
98     static const GTypeInfo avi_audio_decoder_info = {
99       sizeof(GstAviAudioDecoderClass),      
100       NULL,
101       NULL,
102       (GClassInitFunc)gst_avi_audio_decoder_class_init,
103       NULL,
104       NULL,
105       sizeof(GstAviAudioDecoder),
106       0,
107       (GInstanceInitFunc)gst_avi_audio_decoder_init,
108     };
109     avi_audio_decoder_type = g_type_register_static(GST_TYPE_ELEMENT, "GstAviAudioDecoder", &avi_audio_decoder_info, 0);
110   }
111   return avi_audio_decoder_type;
112 }
113
114 static void
115 gst_avi_audio_decoder_class_init (GstAviAudioDecoderClass *klass) 
116 {
117   GObjectClass *gobject_class;
118   GstElementClass *gstelement_class;
119
120   gobject_class = (GObjectClass*)klass;
121   gstelement_class = (GstElementClass*)klass;
122
123   parent_class = g_type_class_ref (GST_TYPE_BIN);
124   
125   gobject_class->get_property = gst_avi_audio_decoder_get_property;
126 }
127
128 static void 
129 gst_avi_audio_decoder_init (GstAviAudioDecoder *avi_audio_decoder) 
130 {
131 }
132
133 static void
134 gst_avi_audio_decoder_chain (GstPad *pad,
135                        GstBuffer *buf)
136 {
137   GstAviAudioDecoder *avi_audio_decoder;
138   guchar *data;
139   gulong size;
140
141   g_return_if_fail (pad != NULL);
142   g_return_if_fail (GST_IS_PAD(pad));
143   g_return_if_fail (buf != NULL);
144   g_return_if_fail (GST_BUFFER_DATA(buf) != NULL);
145
146   avi_audio_decoder = GST_AVI_AUDIO_DECODER (gst_pad_get_parent (pad));
147   GST_DEBUG (0,"gst_avi_audio_decoder_chain: got buffer in %u", GST_BUFFER_OFFSET (buf));
148   g_print ("gst_avi_audio_decoder_chain: got buffer in %u\n", GST_BUFFER_OFFSET (buf));
149   data = (guchar *)GST_BUFFER_DATA (buf);
150   size = GST_BUFFER_SIZE (buf);
151
152   gst_buffer_unref (buf);
153 }
154
155 static void     
156 gst_avi_audio_decoder_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
157 {
158   GstAviAudioDecoder *src;
159
160   g_return_if_fail (GST_IS_AVI_AUDIO_DECODER (object));
161
162   src = GST_AVI_AUDIO_DECODER (object);
163
164   switch(prop_id) {
165     default:
166       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
167       break;
168   }
169 }
170
171
172 static gboolean
173 plugin_init (GModule *module, GstPlugin *plugin)
174 {
175   GstElementFactory *factory;
176
177   /* create an elementfactory for the avi_audio_decoder element */
178   factory = gst_element_factory_new ("aviaudiodecoder",GST_TYPE_AVI_AUDIO_DECODER,
179                                     &gst_avi_audio_decoder_details);
180   g_return_val_if_fail (factory != NULL, FALSE);
181   gst_element_factory_set_rank (factory, GST_ELEMENT_RANK_PRIMARY);
182
183   gst_element_factory_add_pad_template (factory, GST_PAD_TEMPLATE_GET (sink_templ));
184   gst_element_factory_add_pad_template (factory, GST_PAD_TEMPLATE_GET (src_audio_templ));
185
186   gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
187
188   return TRUE;
189 }
190
191 GstPluginDesc plugin_desc = {
192   GST_VERSION_MAJOR,
193   GST_VERSION_MINOR,
194   "aviaudiodecoder",
195   plugin_init
196 };
197