2 * Copyright (C) <2005> Wim Taymans <wim.taymans@gmail.com>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
19 /* Element-Checklist-Version: 5 */
21 #include "gstrtpdepay.h"
23 GST_DEBUG_CATEGORY_STATIC (rtpdepay_debug);
24 #define GST_CAT_DEFAULT (rtpdepay_debug)
26 static GstStaticPadTemplate gst_rtp_depay_src_rtp_template =
27 GST_STATIC_PAD_TEMPLATE ("srcrtp",
30 GST_STATIC_CAPS ("application/x-rtp")
33 static GstStaticPadTemplate gst_rtp_depay_src_rtcp_template =
34 GST_STATIC_PAD_TEMPLATE ("srcrtcp",
37 GST_STATIC_CAPS ("application/x-rtcp")
40 static GstStaticPadTemplate gst_rtp_depay_sink_rtp_template =
41 GST_STATIC_PAD_TEMPLATE ("sinkrtp",
44 GST_STATIC_CAPS ("application/x-rtp")
47 static GstStaticPadTemplate gst_rtp_depay_sink_rtcp_template =
48 GST_STATIC_PAD_TEMPLATE ("sinkrtcp",
51 GST_STATIC_CAPS ("application/x-rtcp")
54 static GstCaps *gst_rtp_depay_getcaps (GstPad * pad);
55 static GstFlowReturn gst_rtp_depay_chain_rtp (GstPad * pad, GstBuffer * buffer);
56 static GstFlowReturn gst_rtp_depay_chain_rtcp (GstPad * pad,
59 GST_BOILERPLATE (GstRTPDepay, gst_rtp_depay, GstElement, GST_TYPE_ELEMENT);
62 gst_rtp_depay_base_init (gpointer klass)
64 GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
66 gst_element_class_add_pad_template (gstelement_class,
67 gst_static_pad_template_get (&gst_rtp_depay_src_rtp_template));
68 gst_element_class_add_pad_template (gstelement_class,
69 gst_static_pad_template_get (&gst_rtp_depay_src_rtcp_template));
70 gst_element_class_add_pad_template (gstelement_class,
71 gst_static_pad_template_get (&gst_rtp_depay_sink_rtp_template));
72 gst_element_class_add_pad_template (gstelement_class,
73 gst_static_pad_template_get (&gst_rtp_depay_sink_rtcp_template));
74 gst_element_class_set_details_simple (gstelement_class,
75 "Dummy RTP session manager", "Codec/Depayloader/Network/RTP",
76 "Accepts raw RTP and RTCP packets and sends them forward",
77 "Wim Taymans <wim.taymans@gmail.com>");
81 gst_rtp_depay_class_init (GstRTPDepayClass * klass)
83 GST_DEBUG_CATEGORY_INIT (rtpdepay_debug, "rtpdepay", 0, "RTP decoder");
87 gst_rtp_depay_init (GstRTPDepay * rtpdepay, GstRTPDepayClass * klass)
89 /* the input rtp pad */
91 gst_pad_new_from_static_template (&gst_rtp_depay_sink_rtp_template,
93 gst_element_add_pad (GST_ELEMENT (rtpdepay), rtpdepay->sink_rtp);
94 gst_pad_set_getcaps_function (rtpdepay->sink_rtp, gst_rtp_depay_getcaps);
95 gst_pad_set_chain_function (rtpdepay->sink_rtp, gst_rtp_depay_chain_rtp);
97 /* the input rtcp pad */
99 gst_pad_new_from_static_template (&gst_rtp_depay_sink_rtcp_template,
101 gst_element_add_pad (GST_ELEMENT (rtpdepay), rtpdepay->sink_rtcp);
102 gst_pad_set_chain_function (rtpdepay->sink_rtcp, gst_rtp_depay_chain_rtcp);
104 /* the output rtp pad */
106 gst_pad_new_from_static_template (&gst_rtp_depay_src_rtp_template,
108 gst_pad_set_getcaps_function (rtpdepay->src_rtp, gst_rtp_depay_getcaps);
109 gst_element_add_pad (GST_ELEMENT (rtpdepay), rtpdepay->src_rtp);
111 /* the output rtcp pad */
113 gst_pad_new_from_static_template (&gst_rtp_depay_src_rtcp_template,
115 gst_element_add_pad (GST_ELEMENT (rtpdepay), rtpdepay->src_rtcp);
119 gst_rtp_depay_getcaps (GstPad * pad)
125 src = GST_RTP_DEPAY (GST_PAD_PARENT (pad));
127 other = pad == src->src_rtp ? src->sink_rtp : src->src_rtp;
129 caps = gst_pad_peer_get_caps (other);
132 caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
138 gst_rtp_depay_chain_rtp (GstPad * pad, GstBuffer * buffer)
142 src = GST_RTP_DEPAY (GST_PAD_PARENT (pad));
144 GST_DEBUG ("got rtp packet");
145 return gst_pad_push (src->src_rtp, buffer);
149 gst_rtp_depay_chain_rtcp (GstPad * pad, GstBuffer * buffer)
151 GST_DEBUG ("got rtcp packet");
153 gst_buffer_unref (buffer);
158 gst_rtp_depay_plugin_init (GstPlugin * plugin)
160 return gst_element_register (plugin, "rtpdepay",
161 GST_RANK_SECONDARY, GST_TYPE_RTP_DEPAY);