filter newlines out of GST_DEBUG statements to reflect new core behavior fixes to...
[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   "Parse a .avi file into audio and video",
33   VERSION,
34   "Erik Walthinsen <omega@cse.ogi.edu>\n"
35   "Wim Taymans <wim.taymans@tvd.be>",
36   "(C) 1999",
37 };
38
39 /* AviAudioDecoder signals and args */
40 enum {
41   /* FILL ME */
42   LAST_SIGNAL
43 };
44
45 enum {
46   ARG_0,
47   /* FILL ME */
48 };
49
50 GST_PADTEMPLATE_FACTORY (sink_templ,
51   "sink",
52   GST_PAD_SINK,
53   GST_PAD_ALWAYS,
54   GST_CAPS_NEW (
55     "avidecoder_sink",
56      "video/avi",
57       "format", GST_PROPS_STRING ("strf_auds")
58   )
59 )
60
61 GST_PADTEMPLATE_FACTORY (src_audio_templ,
62   "src",
63   GST_PAD_SRC,
64   GST_PAD_ALWAYS,
65   GST_CAPS_NEW (
66     "src_audio",
67     "audio/raw",
68       "format",           GST_PROPS_STRING ("int"),
69        "law",              GST_PROPS_INT (0),
70        "endianness",       GST_PROPS_INT (G_BYTE_ORDER),
71        "signed",           GST_PROPS_BOOLEAN (TRUE),
72        "width",            GST_PROPS_INT (16),
73        "depth",            GST_PROPS_INT (16),
74        "rate",             GST_PROPS_INT_RANGE (11025, 44100),
75        "channels",         GST_PROPS_INT_RANGE (1, 2)
76   )
77 )
78
79 static void     gst_avi_audio_decoder_class_init        (GstAviAudioDecoderClass *klass);
80 static void     gst_avi_audio_decoder_init              (GstAviAudioDecoder *avi_audio_decoder);
81
82 static void     gst_avi_audio_decoder_chain             (GstPad *pad, GstBuffer *buf);
83
84 static void     gst_avi_audio_decoder_get_property      (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
85
86
87
88 static GstElementClass *parent_class = NULL;
89 /*static guint gst_avi_audio_decoder_signals[LAST_SIGNAL] = { 0 }; */
90
91 GType
92 gst_avi_audio_decoder_get_type(void) 
93 {
94   static GType avi_audio_decoder_type = 0;
95
96   if (!avi_audio_decoder_type) {
97     static const GTypeInfo avi_audio_decoder_info = {
98       sizeof(GstAviAudioDecoderClass),      
99       NULL,
100       NULL,
101       (GClassInitFunc)gst_avi_audio_decoder_class_init,
102       NULL,
103       NULL,
104       sizeof(GstAviAudioDecoder),
105       0,
106       (GInstanceInitFunc)gst_avi_audio_decoder_init,
107     };
108     avi_audio_decoder_type = g_type_register_static(GST_TYPE_ELEMENT, "GstAviAudioDecoder", &avi_audio_decoder_info, 0);
109   }
110   return avi_audio_decoder_type;
111 }
112
113 static void
114 gst_avi_audio_decoder_class_init (GstAviAudioDecoderClass *klass) 
115 {
116   GObjectClass *gobject_class;
117   GstElementClass *gstelement_class;
118
119   gobject_class = (GObjectClass*)klass;
120   gstelement_class = (GstElementClass*)klass;
121
122   parent_class = g_type_class_ref (GST_TYPE_BIN);
123   
124   gobject_class->get_property = gst_avi_audio_decoder_get_property;
125 }
126
127 static void 
128 gst_avi_audio_decoder_init (GstAviAudioDecoder *avi_audio_decoder) 
129 {
130 }
131
132 static void
133 gst_avi_audio_decoder_chain (GstPad *pad,
134                        GstBuffer *buf)
135 {
136   GstAviAudioDecoder *avi_audio_decoder;
137   guchar *data;
138   gulong size;
139
140   g_return_if_fail (pad != NULL);
141   g_return_if_fail (GST_IS_PAD(pad));
142   g_return_if_fail (buf != NULL);
143   g_return_if_fail (GST_BUFFER_DATA(buf) != NULL);
144
145   avi_audio_decoder = GST_AVI_AUDIO_DECODER (gst_pad_get_parent (pad));
146   GST_DEBUG (0,"gst_avi_audio_decoder_chain: got buffer in %u", GST_BUFFER_OFFSET (buf));
147   g_print ("gst_avi_audio_decoder_chain: got buffer in %u\n", GST_BUFFER_OFFSET (buf));
148   data = (guchar *)GST_BUFFER_DATA (buf);
149   size = GST_BUFFER_SIZE (buf);
150
151   gst_buffer_unref (buf);
152 }
153
154 static void     
155 gst_avi_audio_decoder_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
156 {
157   GstAviAudioDecoder *src;
158
159   g_return_if_fail (GST_IS_AVI_AUDIO_DECODER (object));
160
161   src = GST_AVI_AUDIO_DECODER (object);
162
163   switch(prop_id) {
164     default:
165       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
166       break;
167   }
168 }
169
170
171 static gboolean
172 plugin_init (GModule *module, GstPlugin *plugin)
173 {
174   GstElementFactory *factory;
175
176   /* create an elementfactory for the avi_audio_decoder element */
177   factory = gst_elementfactory_new ("aviaudiodecoder",GST_TYPE_AVI_AUDIO_DECODER,
178                                     &gst_avi_audio_decoder_details);
179   g_return_val_if_fail (factory != NULL, FALSE);
180
181   gst_elementfactory_add_padtemplate (factory, GST_PADTEMPLATE_GET (sink_templ));
182   gst_elementfactory_add_padtemplate (factory, GST_PADTEMPLATE_GET (src_audio_templ));
183
184   gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
185
186   return TRUE;
187 }
188
189 GstPluginDesc plugin_desc = {
190   GST_VERSION_MAJOR,
191   GST_VERSION_MINOR,
192   "aviaudiodecoder",
193   plugin_init
194 };
195