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., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
28 #include <gst/rtp/gstrtpbuffer.h>
29 #include "gstrtpsirendepay.h"
31 static GstStaticPadTemplate gst_rtp_siren_depay_sink_template =
32 GST_STATIC_PAD_TEMPLATE ("sink",
35 GST_STATIC_CAPS ("application/x-rtp, "
36 "media = (string) \"audio\", "
37 "payload = (int) " GST_RTP_PAYLOAD_DYNAMIC_STRING ", "
38 "clock-rate = (int) 16000, "
39 "encoding-name = (string) \"SIREN\", " "dct-length = (int) 320")
42 static GstStaticPadTemplate gst_rtp_siren_depay_src_template =
43 GST_STATIC_PAD_TEMPLATE ("src",
46 GST_STATIC_CAPS ("audio/x-siren, " "dct-length = (int) 320")
49 static GstBuffer *gst_rtp_siren_depay_process (GstRTPBaseDepayload * depayload,
51 static gboolean gst_rtp_siren_depay_setcaps (GstRTPBaseDepayload * depayload,
54 G_DEFINE_TYPE (GstRTPSirenDepay, gst_rtp_siren_depay,
55 GST_TYPE_RTP_BASE_DEPAYLOAD);
58 gst_rtp_siren_depay_class_init (GstRTPSirenDepayClass * klass)
60 GstElementClass *gstelement_class;
61 GstRTPBaseDepayloadClass *gstrtpbasedepayload_class;
63 gstelement_class = (GstElementClass *) klass;
64 gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) klass;
66 gstrtpbasedepayload_class->process = gst_rtp_siren_depay_process;
67 gstrtpbasedepayload_class->set_caps = gst_rtp_siren_depay_setcaps;
69 gst_element_class_add_pad_template (gstelement_class,
70 gst_static_pad_template_get (&gst_rtp_siren_depay_src_template));
71 gst_element_class_add_pad_template (gstelement_class,
72 gst_static_pad_template_get (&gst_rtp_siren_depay_sink_template));
73 gst_element_class_set_static_metadata (gstelement_class,
74 "RTP Siren packet depayloader", "Codec/Depayloader/Network/RTP",
75 "Extracts Siren audio from RTP packets",
76 "Philippe Kalaf <philippe.kalaf@collabora.co.uk>");
80 gst_rtp_siren_depay_init (GstRTPSirenDepay * rtpsirendepay)
86 gst_rtp_siren_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
91 srccaps = gst_caps_new_simple ("audio/x-siren",
92 "dct-length", G_TYPE_INT, 320, NULL);
93 ret = gst_pad_set_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depayload), srccaps);
95 GST_DEBUG ("set caps on source: %" GST_PTR_FORMAT " (ret=%d)", srccaps, ret);
96 gst_caps_unref (srccaps);
98 /* always fixed clock rate of 16000 */
99 depayload->clock_rate = 16000;
105 gst_rtp_siren_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
108 GstRTPBuffer rtp = { NULL };
110 gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
111 outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
112 gst_rtp_buffer_unmap (&rtp);
118 gst_rtp_siren_depay_plugin_init (GstPlugin * plugin)
120 return gst_element_register (plugin, "rtpsirendepay",
121 GST_RANK_SECONDARY, GST_TYPE_RTP_SIREN_DEPAY);