rtpvrawpay: Add missing break
[platform/upstream/gst-plugins-good.git] / gst / rtp / gstrtpsirendepay.c
1 /*
2  * Siren Depayloader Gst Element
3  *
4  *   @author: Youness Alaoui <kakaroto@kakaroto.homelinux.net>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  */
21
22 #ifdef HAVE_CONFIG_H
23 #  include "config.h"
24 #endif
25
26 #include <string.h>
27 #include <stdlib.h>
28 #include <gst/rtp/gstrtpbuffer.h>
29 #include "gstrtpsirendepay.h"
30
31 static GstStaticPadTemplate gst_rtp_siren_depay_sink_template =
32 GST_STATIC_PAD_TEMPLATE ("sink",
33     GST_PAD_SINK,
34     GST_PAD_ALWAYS,
35     GST_STATIC_CAPS ("application/x-rtp, "
36         "media = (string) \"audio\", "
37         "clock-rate = (int) 16000, "
38         "encoding-name = (string) \"SIREN\", " "dct-length = (int) 320")
39     );
40
41 static GstStaticPadTemplate gst_rtp_siren_depay_src_template =
42 GST_STATIC_PAD_TEMPLATE ("src",
43     GST_PAD_SRC,
44     GST_PAD_ALWAYS,
45     GST_STATIC_CAPS ("audio/x-siren, " "dct-length = (int) 320")
46     );
47
48 static GstBuffer *gst_rtp_siren_depay_process (GstRTPBaseDepayload * depayload,
49     GstBuffer * buf);
50 static gboolean gst_rtp_siren_depay_setcaps (GstRTPBaseDepayload * depayload,
51     GstCaps * caps);
52
53 G_DEFINE_TYPE (GstRTPSirenDepay, gst_rtp_siren_depay,
54     GST_TYPE_RTP_BASE_DEPAYLOAD);
55
56 static void
57 gst_rtp_siren_depay_class_init (GstRTPSirenDepayClass * klass)
58 {
59   GstElementClass *gstelement_class;
60   GstRTPBaseDepayloadClass *gstrtpbasedepayload_class;
61
62   gstelement_class = (GstElementClass *) klass;
63   gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) klass;
64
65   gstrtpbasedepayload_class->process = gst_rtp_siren_depay_process;
66   gstrtpbasedepayload_class->set_caps = gst_rtp_siren_depay_setcaps;
67
68   gst_element_class_add_pad_template (gstelement_class,
69       gst_static_pad_template_get (&gst_rtp_siren_depay_src_template));
70   gst_element_class_add_pad_template (gstelement_class,
71       gst_static_pad_template_get (&gst_rtp_siren_depay_sink_template));
72   gst_element_class_set_static_metadata (gstelement_class,
73       "RTP Siren packet depayloader", "Codec/Depayloader/Network/RTP",
74       "Extracts Siren audio from RTP packets",
75       "Philippe Kalaf <philippe.kalaf@collabora.co.uk>");
76 }
77
78 static void
79 gst_rtp_siren_depay_init (GstRTPSirenDepay * rtpsirendepay)
80 {
81
82 }
83
84 static gboolean
85 gst_rtp_siren_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
86 {
87   GstCaps *srccaps;
88   gboolean ret;
89
90   srccaps = gst_caps_new_simple ("audio/x-siren",
91       "dct-length", G_TYPE_INT, 320, NULL);
92   ret = gst_pad_set_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depayload), srccaps);
93
94   GST_DEBUG ("set caps on source: %" GST_PTR_FORMAT " (ret=%d)", srccaps, ret);
95   gst_caps_unref (srccaps);
96
97   /* always fixed clock rate of 16000 */
98   depayload->clock_rate = 16000;
99
100   return ret;
101 }
102
103 static GstBuffer *
104 gst_rtp_siren_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
105 {
106   GstBuffer *outbuf;
107   GstRTPBuffer rtp = { NULL };
108
109   gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
110   outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
111   gst_rtp_buffer_unmap (&rtp);
112
113   return outbuf;
114 }
115
116 gboolean
117 gst_rtp_siren_depay_plugin_init (GstPlugin * plugin)
118 {
119   return gst_element_register (plugin, "rtpsirendepay",
120       GST_RANK_SECONDARY, GST_TYPE_RTP_SIREN_DEPAY);
121 }