611dec0ac59898752d8b650f2f0642a691fdc772
[platform/upstream/gst-plugins-good.git] / gst / law / mulaw.c
1 #ifdef HAVE_CONFIG_H
2 #include "config.h"
3 #endif
4 #include "mulaw-encode.h"
5 #include "mulaw-decode.h"
6
7 static GstCaps*
8 mulaw_factory (void)
9 {
10   return
11     gst_caps_new (
12         "test_src",
13         "audio/x-mulaw",
14         gst_props_new (
15             "width",    GST_PROPS_INT(8),
16             "depth",    GST_PROPS_INT(8),
17             "signed",   GST_PROPS_BOOLEAN(FALSE),
18             "rate",     GST_PROPS_INT_RANGE (8000, 192000),
19             "channels", GST_PROPS_INT_RANGE (1, 2),
20             NULL));
21 }
22
23 static GstCaps*
24 linear_factory (void)
25 {
26   return
27     gst_caps_new (
28         "test_sink",
29         "audio/x-raw-int",
30         gst_props_new (
31             "width",      GST_PROPS_INT(16),
32             "depth",      GST_PROPS_INT(16),
33             "signed",     GST_PROPS_BOOLEAN(TRUE),
34             "endianness", GST_PROPS_INT(G_BYTE_ORDER),
35             "rate",       GST_PROPS_INT_RANGE (8000, 192000),
36             "channels",   GST_PROPS_INT_RANGE (1, 2),
37             NULL));
38 }
39
40 GstPadTemplate *mulawenc_src_template, *mulawenc_sink_template;
41 GstPadTemplate *mulawdec_src_template, *mulawdec_sink_template;
42
43 static gboolean
44 plugin_init (GstPlugin *plugin)
45 {
46   GstCaps* mulaw_caps, *linear_caps;
47
48   mulaw_caps = mulaw_factory ();
49   linear_caps = linear_factory ();
50
51   mulawenc_src_template = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
52                                                mulaw_caps, NULL);
53   mulawenc_sink_template = gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
54                                                 linear_caps, NULL);
55
56   mulawdec_src_template = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
57                                                 linear_caps, NULL);
58   mulawdec_sink_template = gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
59                                                 mulaw_caps, NULL);
60
61   if (!gst_element_register (plugin, "mulawenc",
62                              GST_RANK_NONE, GST_TYPE_MULAWENC) ||
63       !gst_element_register (plugin, "mulawdec",
64                              GST_RANK_PRIMARY, GST_TYPE_MULAWENC))
65     return FALSE;
66
67   return TRUE;
68 }
69
70 GST_PLUGIN_DEFINE (
71   GST_VERSION_MAJOR,
72   GST_VERSION_MINOR,
73   "mulaw",
74   "MuLaw audio conversion routines",
75   plugin_init,
76   VERSION,
77   GST_LICENSE,
78   GST_COPYRIGHT,
79   GST_PACKAGE,
80   GST_ORIGIN
81 )