04c149acd82387177a022228f72b9da39f771a71
[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 static GstCaps*
8 alaw_factory (void)
9 {
10   return
11    gst_caps_new (
12         "test_src",
13         "audio/x-alaw",
14         gst_props_new (
15           "rate",     GST_PROPS_INT_RANGE (8000, 192000),
16           "channels", GST_PROPS_INT_RANGE (1, 2),
17           NULL));
18 }
19
20 static GstCaps*
21 linear_factory (void)
22 {
23   return
24    gst_caps_new (
25         "test_sink",
26         "audio/x-raw-int",
27         gst_props_new (
28             "width",      GST_PROPS_INT(16),
29             "depth",      GST_PROPS_INT(16),
30             "endianness", GST_PROPS_INT(G_BYTE_ORDER),
31             "signed",     GST_PROPS_BOOLEAN(TRUE),
32             "rate",       GST_PROPS_INT_RANGE (8000, 192000),
33             "channels",   GST_PROPS_INT_RANGE (1, 2),
34             NULL));
35 }
36
37 GstPadTemplate *alawenc_src_template, *alawenc_sink_template;
38 GstPadTemplate *alawdec_src_template, *alawdec_sink_template;
39
40 static gboolean
41 plugin_init (GstPlugin *plugin)
42 {
43   GstCaps* alaw_caps, *linear_caps;
44
45   alaw_caps = alaw_factory ();
46   linear_caps = linear_factory ();
47
48   alawenc_src_template = gst_pad_template_new ("src",GST_PAD_SRC,GST_PAD_ALWAYS,alaw_caps, NULL);
49   alawenc_sink_template = gst_pad_template_new ("sink",GST_PAD_SINK,GST_PAD_ALWAYS,linear_caps, NULL);
50
51   alawdec_src_template = gst_pad_template_new ("src",GST_PAD_SRC,GST_PAD_ALWAYS,linear_caps, NULL);
52   alawdec_sink_template = gst_pad_template_new ("sink",GST_PAD_SINK,GST_PAD_ALWAYS,alaw_caps, NULL);
53
54   if (!gst_element_register (plugin, "alawenc",
55                              GST_RANK_NONE, GST_TYPE_ALAWENC) ||
56       !gst_element_register (plugin, "alawdec",
57                              GST_RANK_PRIMARY, GST_TYPE_ALAWENC))
58     return FALSE;
59
60   return TRUE;
61 }
62
63 GST_PLUGIN_DEFINE (
64   GST_VERSION_MAJOR,
65   GST_VERSION_MINOR,
66   "alaw",
67   "ALaw audio conversion routines",
68   plugin_init,
69   VERSION,
70   GST_LICENSE,
71   GST_COPYRIGHT,
72   GST_PACKAGE,
73   GST_ORIGIN
74 )