2 * Siren Depayloader Gst Element
4 * @author: Youness Alaoui <kakaroto@kakaroto.homelinux.net>
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.
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.
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.
28 #include <gst/rtp/gstrtpbuffer.h>
29 #include <gst/audio/audio.h>
30 #include "gstrtpsirendepay.h"
31 #include "gstrtputils.h"
33 static GstStaticPadTemplate gst_rtp_siren_depay_sink_template =
34 GST_STATIC_PAD_TEMPLATE ("sink",
37 GST_STATIC_CAPS ("application/x-rtp, "
38 "media = (string) \"audio\", "
39 "clock-rate = (int) 16000, " "encoding-name = (string) \"SIREN\"")
40 /* This is the default, so the peer doesn't have to specify it */
41 /* " "dct-length = (int) 320") */
44 static GstStaticPadTemplate gst_rtp_siren_depay_src_template =
45 GST_STATIC_PAD_TEMPLATE ("src",
48 GST_STATIC_CAPS ("audio/x-siren, " "dct-length = (int) 320")
51 static GstBuffer *gst_rtp_siren_depay_process (GstRTPBaseDepayload *
52 depayload, GstRTPBuffer * rtp);
53 static gboolean gst_rtp_siren_depay_setcaps (GstRTPBaseDepayload *
54 depayload, GstCaps * caps);
56 G_DEFINE_TYPE (GstRTPSirenDepay, gst_rtp_siren_depay,
57 GST_TYPE_RTP_BASE_DEPAYLOAD);
59 static void gst_rtp_siren_depay_class_init (GstRTPSirenDepayClass * klass)
61 GstElementClass *gstelement_class;
62 GstRTPBaseDepayloadClass *gstrtpbasedepayload_class;
64 gstelement_class = (GstElementClass *) klass;
65 gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) klass;
67 gstrtpbasedepayload_class->process_rtp_packet = gst_rtp_siren_depay_process;
68 gstrtpbasedepayload_class->set_caps = gst_rtp_siren_depay_setcaps;
70 gst_element_class_add_static_pad_template (gstelement_class,
71 &gst_rtp_siren_depay_src_template);
72 gst_element_class_add_static_pad_template (gstelement_class,
73 &gst_rtp_siren_depay_sink_template);
74 gst_element_class_set_static_metadata (gstelement_class,
75 "RTP Siren packet depayloader", "Codec/Depayloader/Network/RTP",
76 "Extracts Siren audio from RTP packets",
77 "Philippe Kalaf <philippe.kalaf@collabora.co.uk>");
81 gst_rtp_siren_depay_init (GstRTPSirenDepay * rtpsirendepay)
87 gst_rtp_siren_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
92 srccaps = gst_caps_new_simple ("audio/x-siren",
93 "dct-length", G_TYPE_INT, 320, NULL);
94 ret = gst_pad_set_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depayload), srccaps);
96 GST_DEBUG ("set caps on source: %" GST_PTR_FORMAT " (ret=%d)", srccaps, ret);
97 gst_caps_unref (srccaps);
99 /* always fixed clock rate of 16000 */
100 depayload->clock_rate = 16000;
106 gst_rtp_siren_depay_process (GstRTPBaseDepayload * depayload,
111 outbuf = gst_rtp_buffer_get_payload_buffer (rtp);
114 gst_rtp_drop_meta (GST_ELEMENT_CAST (depayload), outbuf,
115 g_quark_from_static_string (GST_META_TAG_AUDIO_STR));
122 gst_rtp_siren_depay_plugin_init (GstPlugin * plugin)
124 return gst_element_register (plugin, "rtpsirendepay",
125 GST_RANK_SECONDARY, GST_TYPE_RTP_SIREN_DEPAY);