2 * Copyright (C) <2007> Wim Taymans <wim@fluendo.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.
21 * SECTION:element-rtpbin
22 * @short_description: handle media from one RTP bin
23 * @see_also: rtpjitterbuffer, rtpclient, rtpsession
28 * <title>Example pipelines</title>
31 * gst-launch -v filesrc location=sine.ogg ! oggdemux ! vorbisdec ! audioconvert ! alsasink
36 * Last reviewed on 2007-04-02 (0.10.6)
44 #include "gstrtpbin.h"
46 /* elementfactory information */
47 static const GstElementDetails rtpbin_details = GST_ELEMENT_DETAILS ("RTP Bin",
48 "Filter/Editor/Video",
49 "Implement an RTP bin",
50 "Wim Taymans <wim@fluendo.com>");
53 static GstStaticPadTemplate rtpbin_recv_rtp_sink_template =
54 GST_STATIC_PAD_TEMPLATE ("recv_rtp_sink_%d",
57 GST_STATIC_CAPS ("application/x-rtp")
60 static GstStaticPadTemplate rtpbin_recv_rtcp_sink_template =
61 GST_STATIC_PAD_TEMPLATE ("recv_rtcp_sink_%d",
64 GST_STATIC_CAPS ("application/x-rtcp")
67 static GstStaticPadTemplate rtpbin_send_rtp_sink_template =
68 GST_STATIC_PAD_TEMPLATE ("send_rtp_sink_%d",
71 GST_STATIC_CAPS ("application/x-rtp")
75 static GstStaticPadTemplate rtpbin_recv_rtp_src_template =
76 GST_STATIC_PAD_TEMPLATE ("recv_rtp_src_%d_%d_%d",
79 GST_STATIC_CAPS ("application/x-rtp")
82 static GstStaticPadTemplate rtpbin_send_rtcp_src_template =
83 GST_STATIC_PAD_TEMPLATE ("send_rtcp_src_%d",
86 GST_STATIC_CAPS ("application/x-rtcp")
89 static GstStaticPadTemplate rtpbin_send_rtp_src_template =
90 GST_STATIC_PAD_TEMPLATE ("send_rtp_src_%d",
93 GST_STATIC_CAPS ("application/x-rtp")
96 #define GST_RTP_BIN_GET_PRIVATE(obj) \
97 (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GST_TYPE_RTP_BIN, GstRTPBinPrivate))
99 struct _GstRTPBinPrivate
103 /* signals and args */
115 /* GObject vmethods */
116 static void gst_rtp_bin_finalize (GObject * object);
117 static void gst_rtp_bin_set_property (GObject * object, guint prop_id,
118 const GValue * value, GParamSpec * pspec);
119 static void gst_rtp_bin_get_property (GObject * object, guint prop_id,
120 GValue * value, GParamSpec * pspec);
122 /* GstElement vmethods */
123 static GstStateChangeReturn gst_rtp_bin_change_state (GstElement * element,
124 GstStateChange transition);
125 static GstPad *gst_rtp_bin_request_new_pad (GstElement * element,
126 GstPadTemplate * templ, const gchar * name);
127 static void gst_rtp_bin_release_pad (GstElement * element, GstPad * pad);
129 /*static guint gst_rtp_bin_signals[LAST_SIGNAL] = { 0 }; */
131 GST_BOILERPLATE (GstRTPBin, gst_rtp_bin, GstBin, GST_TYPE_BIN);
134 gst_rtp_bin_base_init (gpointer klass)
136 GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
139 gst_element_class_add_pad_template (element_class,
140 gst_static_pad_template_get (&rtpbin_recv_rtp_sink_template));
141 gst_element_class_add_pad_template (element_class,
142 gst_static_pad_template_get (&rtpbin_recv_rtcp_sink_template));
143 gst_element_class_add_pad_template (element_class,
144 gst_static_pad_template_get (&rtpbin_send_rtp_sink_template));
147 gst_element_class_add_pad_template (element_class,
148 gst_static_pad_template_get (&rtpbin_recv_rtp_src_template));
149 gst_element_class_add_pad_template (element_class,
150 gst_static_pad_template_get (&rtpbin_send_rtcp_src_template));
151 gst_element_class_add_pad_template (element_class,
152 gst_static_pad_template_get (&rtpbin_send_rtp_src_template));
154 gst_element_class_set_details (element_class, &rtpbin_details);
158 gst_rtp_bin_class_init (GstRTPBinClass * klass)
160 GObjectClass *gobject_class;
161 GstElementClass *gstelement_class;
163 gobject_class = (GObjectClass *) klass;
164 gstelement_class = (GstElementClass *) klass;
166 g_type_class_add_private (klass, sizeof (GstRTPBinPrivate));
168 gobject_class->finalize = gst_rtp_bin_finalize;
169 gobject_class->set_property = gst_rtp_bin_set_property;
170 gobject_class->get_property = gst_rtp_bin_get_property;
172 gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_rtp_bin_change_state);
173 gstelement_class->request_new_pad =
174 GST_DEBUG_FUNCPTR (gst_rtp_bin_request_new_pad);
175 gstelement_class->release_pad = GST_DEBUG_FUNCPTR (gst_rtp_bin_release_pad);
179 gst_rtp_bin_init (GstRTPBin * rtpbin, GstRTPBinClass * klass)
181 rtpbin->priv = GST_RTP_BIN_GET_PRIVATE (rtpbin);
185 gst_rtp_bin_finalize (GObject * object)
189 rtpbin = GST_RTP_BIN (object);
191 G_OBJECT_CLASS (parent_class)->finalize (object);
195 gst_rtp_bin_set_property (GObject * object, guint prop_id,
196 const GValue * value, GParamSpec * pspec)
200 rtpbin = GST_RTP_BIN (object);
204 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
210 gst_rtp_bin_get_property (GObject * object, guint prop_id,
211 GValue * value, GParamSpec * pspec)
215 rtpbin = GST_RTP_BIN (object);
219 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
224 static GstStateChangeReturn
225 gst_rtp_bin_change_state (GstElement * element, GstStateChange transition)
227 GstStateChangeReturn res;
230 rtpbin = GST_RTP_BIN (element);
232 switch (transition) {
233 case GST_STATE_CHANGE_NULL_TO_READY:
235 case GST_STATE_CHANGE_READY_TO_PAUSED:
237 case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
243 res = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
245 switch (transition) {
246 case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
248 case GST_STATE_CHANGE_PAUSED_TO_READY:
250 case GST_STATE_CHANGE_READY_TO_NULL:
261 gst_rtp_bin_request_new_pad (GstElement * element,
262 GstPadTemplate * templ, const gchar * name)
265 GstElementClass *klass;
267 g_return_val_if_fail (templ != NULL, NULL);
268 g_return_val_if_fail (GST_IS_RTP_BIN (element), NULL);
270 rtpbin = GST_RTP_BIN (element);
271 klass = GST_ELEMENT_GET_CLASS (element);
277 gst_rtp_bin_release_pad (GstElement * element, GstPad * pad)