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