2 * Copyright (C) 2017 Matthew Waters <matthew@centricular.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., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
21 * SECTION:gstwebrtc-transceiver
22 * @short_description: RTCRtpTransceiver object
23 * @title: GstWebRTCRTPTransceiver
24 * @see_also: #GstWebRTCRTPSender, #GstWebRTCRTPReceiver
26 * <https://www.w3.org/TR/webrtc/#rtcrtptransceiver-interface>
33 #include "rtptransceiver.h"
35 #include "webrtc-priv.h"
37 #define GST_CAT_DEFAULT gst_webrtc_rtp_transceiver_debug
38 GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
40 #define gst_webrtc_rtp_transceiver_parent_class parent_class
41 G_DEFINE_ABSTRACT_TYPE_WITH_CODE (GstWebRTCRTPTransceiver,
42 gst_webrtc_rtp_transceiver, GST_TYPE_OBJECT,
43 GST_DEBUG_CATEGORY_INIT (gst_webrtc_rtp_transceiver_debug,
44 "webrtcrtptransceiver", 0, "webrtcrtptransceiver");
61 PROP_CURRENT_DIRECTION,
63 PROP_CODEC_PREFERENCES,
64 PROP_STOPPED, // FIXME
67 //static guint gst_webrtc_rtp_transceiver_signals[LAST_SIGNAL] = { 0 };
70 gst_webrtc_rtp_transceiver_set_property (GObject * object, guint prop_id,
71 const GValue * value, GParamSpec * pspec)
73 GstWebRTCRTPTransceiver *webrtc = GST_WEBRTC_RTP_TRANSCEIVER (object);
77 webrtc->sender = g_value_dup_object (value);
80 webrtc->receiver = g_value_dup_object (value);
83 webrtc->mline = g_value_get_uint (value);
86 GST_OBJECT_LOCK (webrtc);
87 webrtc->direction = g_value_get_enum (value);
88 GST_OBJECT_UNLOCK (webrtc);
90 case PROP_CODEC_PREFERENCES:
91 GST_OBJECT_LOCK (webrtc);
92 gst_caps_replace (&webrtc->codec_preferences, g_value_get_boxed (value));
93 GST_OBJECT_UNLOCK (webrtc);
96 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
102 gst_webrtc_rtp_transceiver_get_property (GObject * object, guint prop_id,
103 GValue * value, GParamSpec * pspec)
105 GstWebRTCRTPTransceiver *webrtc = GST_WEBRTC_RTP_TRANSCEIVER (object);
109 g_value_set_string (value, webrtc->mid);
112 g_value_set_object (value, webrtc->sender);
115 g_value_set_object (value, webrtc->receiver);
118 g_value_set_uint (value, webrtc->mline);
121 GST_OBJECT_LOCK (webrtc);
122 g_value_set_enum (value, webrtc->direction);
123 GST_OBJECT_UNLOCK (webrtc);
125 case PROP_CURRENT_DIRECTION:
126 g_value_set_enum (value, webrtc->current_direction);
129 g_value_set_enum (value, webrtc->kind);
131 case PROP_CODEC_PREFERENCES:
132 GST_OBJECT_LOCK (webrtc);
133 gst_value_set_caps (value, webrtc->codec_preferences);
134 GST_OBJECT_UNLOCK (webrtc);
137 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
143 gst_webrtc_rtp_transceiver_constructed (GObject * object)
145 GstWebRTCRTPTransceiver *webrtc = GST_WEBRTC_RTP_TRANSCEIVER (object);
147 gst_object_set_parent (GST_OBJECT (webrtc->sender), GST_OBJECT (webrtc));
148 gst_object_set_parent (GST_OBJECT (webrtc->receiver), GST_OBJECT (webrtc));
150 G_OBJECT_CLASS (parent_class)->constructed (object);
154 gst_webrtc_rtp_transceiver_dispose (GObject * object)
156 GstWebRTCRTPTransceiver *webrtc = GST_WEBRTC_RTP_TRANSCEIVER (object);
158 if (webrtc->sender) {
159 GST_OBJECT_PARENT (webrtc->sender) = NULL;
160 gst_object_unref (webrtc->sender);
162 webrtc->sender = NULL;
163 if (webrtc->receiver) {
164 GST_OBJECT_PARENT (webrtc->receiver) = NULL;
165 gst_object_unref (webrtc->receiver);
167 webrtc->receiver = NULL;
169 G_OBJECT_CLASS (parent_class)->dispose (object);
173 gst_webrtc_rtp_transceiver_finalize (GObject * object)
175 GstWebRTCRTPTransceiver *webrtc = GST_WEBRTC_RTP_TRANSCEIVER (object);
177 g_free (webrtc->mid);
178 if (webrtc->codec_preferences)
179 gst_caps_unref (webrtc->codec_preferences);
181 G_OBJECT_CLASS (parent_class)->finalize (object);
185 gst_webrtc_rtp_transceiver_class_init (GstWebRTCRTPTransceiverClass * klass)
187 GObjectClass *gobject_class = (GObjectClass *) klass;
189 gobject_class->get_property = gst_webrtc_rtp_transceiver_get_property;
190 gobject_class->set_property = gst_webrtc_rtp_transceiver_set_property;
191 gobject_class->constructed = gst_webrtc_rtp_transceiver_constructed;
192 gobject_class->dispose = gst_webrtc_rtp_transceiver_dispose;
193 gobject_class->finalize = gst_webrtc_rtp_transceiver_finalize;
195 g_object_class_install_property (gobject_class,
197 g_param_spec_object ("sender", "Sender",
198 "The RTP sender for this transceiver",
199 GST_TYPE_WEBRTC_RTP_SENDER,
200 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
202 g_object_class_install_property (gobject_class,
204 g_param_spec_object ("receiver", "Receiver",
205 "The RTP receiver for this transceiver",
206 GST_TYPE_WEBRTC_RTP_RECEIVER,
207 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
209 g_object_class_install_property (gobject_class,
211 g_param_spec_uint ("mlineindex", "Media Line Index",
212 "Index in the SDP of the Media",
214 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
217 * GstWebRTCRTPTransceiver:direction:
219 * Direction of the transceiver.
223 g_object_class_install_property (gobject_class,
225 g_param_spec_enum ("direction", "Direction",
226 "Transceiver direction",
227 GST_TYPE_WEBRTC_RTP_TRANSCEIVER_DIRECTION,
228 GST_WEBRTC_RTP_TRANSCEIVER_DIRECTION_NONE,
229 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
232 * GstWebRTCRTPTransceiver:mid:
234 * The media ID of the m-line associated with this transceiver. This
235 * association is established, when possible, whenever either a
236 * local or remote description is applied. This field is null if
237 * neither a local or remote description has been applied, or if its
238 * associated m-line is rejected by either a remote offer or any
243 g_object_class_install_property (gobject_class,
245 g_param_spec_string ("mid", "Media ID",
246 "The media ID of the m-line associated with this transceiver. This "
247 " association is established, when possible, whenever either a local"
248 " or remote description is applied. This field is null if neither a"
249 " local or remote description has been applied, or if its associated"
250 " m-line is rejected by either a remote offer or any answer.",
251 NULL, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
254 * GstWebRTCRTPTransceiver:current-direction:
256 * The transceiver's current directionality, or none if the
257 * transceiver is stopped or has never participated in an exchange
258 * of offers and answers. To change the transceiver's
259 * directionality, set the value of the direction property.
263 g_object_class_install_property (gobject_class,
265 g_param_spec_enum ("current-direction", "Current Direction",
266 "Transceiver current direction",
267 GST_TYPE_WEBRTC_RTP_TRANSCEIVER_DIRECTION,
268 GST_WEBRTC_RTP_TRANSCEIVER_DIRECTION_NONE,
269 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
272 * GstWebRTCRTPTransceiver:kind:
274 * The kind of media this transceiver transports
278 g_object_class_install_property (gobject_class,
280 g_param_spec_enum ("kind", "Media Kind",
281 "Kind of media this transceiver transports",
282 GST_TYPE_WEBRTC_KIND, GST_WEBRTC_KIND_UNKNOWN,
283 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
286 * GstWebRTCRTPTransceiver:codec-preferences:
288 * Caps representing the codec preferences.
292 g_object_class_install_property (gobject_class,
293 PROP_CODEC_PREFERENCES,
294 g_param_spec_boxed ("codec-preferences", "Codec Preferences",
295 "Caps representing the codec preferences.",
296 GST_TYPE_CAPS, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
300 gst_webrtc_rtp_transceiver_init (GstWebRTCRTPTransceiver * webrtc)
302 webrtc->direction = GST_WEBRTC_RTP_TRANSCEIVER_DIRECTION_NONE;