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 "gstrtpelements.h"
31 #include "gstrtpsirendepay.h"
32 #include "gstrtputils.h"
34 static GstStaticPadTemplate gst_rtp_siren_depay_sink_template =
35 GST_STATIC_PAD_TEMPLATE ("sink",
38 GST_STATIC_CAPS ("application/x-rtp, "
39 "media = (string) \"audio\", "
40 "clock-rate = (int) 16000, " "encoding-name = (string) \"SIREN\"")
41 /* This is the default, so the peer doesn't have to specify it */
42 /* " "dct-length = (int) 320") */
45 static GstStaticPadTemplate gst_rtp_siren_depay_src_template =
46 GST_STATIC_PAD_TEMPLATE ("src",
49 GST_STATIC_CAPS ("audio/x-siren, " "dct-length = (int) 320")
52 static GstBuffer *gst_rtp_siren_depay_process (GstRTPBaseDepayload *
53 depayload, GstRTPBuffer * rtp);
54 static gboolean gst_rtp_siren_depay_setcaps (GstRTPBaseDepayload *
55 depayload, GstCaps * caps);
57 G_DEFINE_TYPE (GstRTPSirenDepay, gst_rtp_siren_depay,
58 GST_TYPE_RTP_BASE_DEPAYLOAD);
59 GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (rtpsirendepay, "rtpsirendepay",
60 GST_RANK_SECONDARY, GST_TYPE_RTP_SIREN_DEPAY, rtp_element_init (plugin));
62 static void gst_rtp_siren_depay_class_init (GstRTPSirenDepayClass * klass)
64 GstElementClass *gstelement_class;
65 GstRTPBaseDepayloadClass *gstrtpbasedepayload_class;
67 gstelement_class = (GstElementClass *) klass;
68 gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) klass;
70 gstrtpbasedepayload_class->process_rtp_packet = gst_rtp_siren_depay_process;
71 gstrtpbasedepayload_class->set_caps = gst_rtp_siren_depay_setcaps;
73 gst_element_class_add_static_pad_template (gstelement_class,
74 &gst_rtp_siren_depay_src_template);
75 gst_element_class_add_static_pad_template (gstelement_class,
76 &gst_rtp_siren_depay_sink_template);
77 gst_element_class_set_static_metadata (gstelement_class,
78 "RTP Siren packet depayloader", "Codec/Depayloader/Network/RTP",
79 "Extracts Siren audio from RTP packets",
80 "Philippe Kalaf <philippe.kalaf@collabora.co.uk>");
84 gst_rtp_siren_depay_init (GstRTPSirenDepay * rtpsirendepay)
90 gst_rtp_siren_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
95 srccaps = gst_caps_new_simple ("audio/x-siren",
96 "dct-length", G_TYPE_INT, 320, NULL);
97 ret = gst_pad_set_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depayload), srccaps);
99 GST_DEBUG ("set caps on source: %" GST_PTR_FORMAT " (ret=%d)", srccaps, ret);
100 gst_caps_unref (srccaps);
102 /* always fixed clock rate of 16000 */
103 depayload->clock_rate = 16000;
109 gst_rtp_siren_depay_process (GstRTPBaseDepayload * depayload,
114 outbuf = gst_rtp_buffer_get_payload_buffer (rtp);
117 gst_rtp_drop_non_audio_meta (depayload, outbuf);