+ the last of the float caps changes ... these are a bit more pervasive
[platform/upstream/gst-plugins-good.git] / gst / law / alaw.c
1 #ifdef HAVE_CONFIG_H
2 #include "config.h"
3 #endif
4 #include "alaw-encode.h"
5 #include "alaw-decode.h"
6
7 /* elementfactory information */
8 static GstElementDetails alawenc_details = {
9   "PCM to A Law conversion",
10   "Codec/Audio/Encoder",
11   "LGPL",
12   "Convert 16bit PCM to 8bit A law",
13   VERSION,
14   "Zaheer Merali <zaheer@bellworldwide.net>",
15   "(C) 2001"
16 };
17
18 /* elementfactory information */
19 static GstElementDetails alawdec_details = {
20   "A Law to PCM conversion",
21   "Codec/Audio/Decoder",
22   "LGPL",
23   "Convert 8bit A law to 16bit PCM",
24   VERSION,
25   "Zaheer Merali <zaheer@bellworldwide.net>",
26   "(C) 2001"
27 };
28
29 static GstCaps*
30 alaw_factory (void)
31 {
32   return
33    gst_caps_new (
34         "test_src",
35         "audio/x-alaw",
36         gst_props_new (
37           "rate",     GST_PROPS_INT_RANGE (8000, 192000),
38           "channels", GST_PROPS_INT_RANGE (1, 2),
39           NULL));
40 }
41
42 static GstCaps*
43 linear_factory (void)
44 {
45   return
46    gst_caps_new (
47         "test_sink",
48         "audio/x-raw-int",
49         gst_props_new (
50             "width",      GST_PROPS_INT(16),
51             "depth",      GST_PROPS_INT(16),
52             "endianness", GST_PROPS_INT(G_BYTE_ORDER),
53             "signed",     GST_PROPS_BOOLEAN(TRUE),
54             "rate",       GST_PROPS_INT_RANGE (8000, 192000),
55             "channels",   GST_PROPS_INT_RANGE (1, 2),
56             NULL));
57 }
58
59 GstPadTemplate *alawenc_src_template, *alawenc_sink_template; 
60 GstPadTemplate *alawdec_src_template, *alawdec_sink_template;
61
62 static gboolean
63 plugin_init (GModule *module, GstPlugin *plugin)
64 {
65   GstElementFactory *alawenc_factory, *alawdec_factory;
66   GstCaps* alaw_caps, *linear_caps;
67
68   alawenc_factory = gst_element_factory_new("alawenc",GST_TYPE_ALAWENC,
69                                             &alawenc_details);
70   g_return_val_if_fail(alawenc_factory != NULL, FALSE);
71   alawdec_factory = gst_element_factory_new("alawdec",GST_TYPE_ALAWDEC,
72                                             &alawdec_details);
73   g_return_val_if_fail(alawdec_factory != NULL, FALSE);
74   gst_element_factory_set_rank (alawdec_factory, GST_ELEMENT_RANK_PRIMARY);
75
76   alaw_caps = alaw_factory ();
77   linear_caps = linear_factory ();
78  
79   alawenc_src_template = gst_pad_template_new ("src",GST_PAD_SRC,GST_PAD_ALWAYS,alaw_caps, NULL);
80   alawenc_sink_template = gst_pad_template_new ("sink",GST_PAD_SINK,GST_PAD_ALWAYS,linear_caps, NULL);
81   gst_element_factory_add_pad_template (alawenc_factory, alawenc_src_template);
82   gst_element_factory_add_pad_template (alawenc_factory, alawenc_sink_template);
83
84   alawdec_src_template = gst_pad_template_new ("src",GST_PAD_SRC,GST_PAD_ALWAYS,linear_caps, NULL);
85   alawdec_sink_template = gst_pad_template_new ("sink",GST_PAD_SINK,GST_PAD_ALWAYS,alaw_caps, NULL);
86   
87   gst_element_factory_add_pad_template (alawdec_factory, alawdec_src_template);
88   gst_element_factory_add_pad_template (alawdec_factory, alawdec_sink_template);
89   gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (alawenc_factory));
90   gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (alawdec_factory));
91
92   return TRUE;
93 }
94
95 GstPluginDesc plugin_desc = {
96   GST_VERSION_MAJOR,
97   GST_VERSION_MINOR,
98   "alaw",
99   plugin_init
100 };
101