gst/law/: Compulsive clean-ups: use boilerplate macros, add debug categories, fix...
[platform/upstream/gst-plugins-good.git] / gst / law / alaw.c
1 /* GStreamer PCM/A-Law conversions
2  *
3  * This library is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU Library General Public
5  * License as published by the Free Software Foundation; either
6  * version 2.1 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  * Library General Public License for more details.
12  *
13  * You should have received a copy of the GNU Library General Public
14  * License along with this library; if not, write to the
15  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16  * Boston, MA 02111-1307, USA.
17  */
18
19 #ifdef HAVE_CONFIG_H
20 #include "config.h"
21 #endif
22
23 #include "alaw-encode.h"
24 #include "alaw-decode.h"
25
26 static GstCaps *
27 alaw_factory (void)
28 {
29   return gst_caps_new_simple ("audio/x-alaw",
30       "rate", GST_TYPE_INT_RANGE, 8000, 192000,
31       "channels", GST_TYPE_INT_RANGE, 1, 2, NULL);
32 }
33
34 static GstCaps *
35 linear_factory (void)
36 {
37   return gst_caps_new_simple ("audio/x-raw-int",
38       "width", G_TYPE_INT, 16,
39       "depth", G_TYPE_INT, 16,
40       "endianness", G_TYPE_INT, G_BYTE_ORDER,
41       "signed", G_TYPE_BOOLEAN, TRUE,
42       "rate", GST_TYPE_INT_RANGE, 8000, 192000,
43       "channels", GST_TYPE_INT_RANGE, 1, 2, NULL);
44 }
45
46 GstPadTemplate *alawenc_src_template, *alawenc_sink_template;
47 GstPadTemplate *alawdec_src_template, *alawdec_sink_template;
48
49 static gboolean
50 plugin_init (GstPlugin * plugin)
51 {
52   GstCaps *alaw_caps, *linear_caps;
53
54   alaw_caps = alaw_factory ();
55   linear_caps = linear_factory ();
56
57   alawenc_src_template =
58       gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, alaw_caps);
59   alawenc_sink_template =
60       gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, linear_caps);
61
62   alawdec_src_template =
63       gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, linear_caps);
64   alawdec_sink_template =
65       gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, alaw_caps);
66
67   if (!gst_element_register (plugin, "alawenc",
68           GST_RANK_NONE, GST_TYPE_ALAW_ENC) ||
69       !gst_element_register (plugin, "alawdec",
70           GST_RANK_PRIMARY, GST_TYPE_ALAW_DEC))
71     return FALSE;
72
73   return TRUE;
74 }
75
76 /* FIXME 0.11: merge alaw and mulaw into one plugin? */
77 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
78     GST_VERSION_MINOR,
79     "alaw",
80     "ALaw audio conversion routines",
81     plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)