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-icetransport
22 * @short_description: RTCIceTransport object
23 * @title: GstWebRTCICETransport
24 * @see_also: #GstWebRTCRTPSender, #GstWebRTCRTPReceiver, #GstWebRTCDTLSTransport
26 * <https://www.w3.org/TR/webrtc/#rtcicetransport>
33 #include "icetransport.h"
34 #include "webrtc-enumtypes.h"
36 #include "webrtc-priv.h"
38 #define GST_CAT_DEFAULT gst_webrtc_ice_transport_debug
39 GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
41 #define gst_webrtc_ice_transport_parent_class parent_class
42 /* We would inherit from GstBin however when combined with the dtls transport,
43 * this causes loops in the graph. */
44 G_DEFINE_ABSTRACT_TYPE_WITH_CODE (GstWebRTCICETransport,
45 gst_webrtc_ice_transport, GST_TYPE_OBJECT,
46 GST_DEBUG_CATEGORY_INIT (gst_webrtc_ice_transport_debug,
47 "webrtcicetransport", 0, "webrtcicetransport"););
52 ON_SELECTED_CANDIDATE_PAIR_CHANGE_SIGNAL,
53 ON_NEW_CANDIDATE_SIGNAL,
65 static guint gst_webrtc_ice_transport_signals[LAST_SIGNAL] = { 0 };
68 gst_webrtc_ice_transport_connection_state_change (GstWebRTCICETransport * ice,
69 GstWebRTCICEConnectionState new_state)
71 GST_OBJECT_LOCK (ice);
72 ice->state = new_state;
73 GST_OBJECT_UNLOCK (ice);
74 g_object_notify (G_OBJECT (ice), "state");
78 gst_webrtc_ice_transport_gathering_state_change (GstWebRTCICETransport * ice,
79 GstWebRTCICEGatheringState new_state)
81 GST_OBJECT_LOCK (ice);
82 ice->gathering_state = new_state;
83 GST_OBJECT_UNLOCK (ice);
84 g_object_notify (G_OBJECT (ice), "gathering-state");
88 gst_webrtc_ice_transport_selected_pair_change (GstWebRTCICETransport * ice)
91 gst_webrtc_ice_transport_signals
92 [ON_SELECTED_CANDIDATE_PAIR_CHANGE_SIGNAL], 0);
96 gst_webrtc_ice_transport_new_candidate (GstWebRTCICETransport * ice,
97 guint stream_id, GstWebRTCICEComponent component, gchar * attr)
99 g_signal_emit (ice, gst_webrtc_ice_transport_signals[ON_NEW_CANDIDATE_SIGNAL],
100 stream_id, component, attr);
104 gst_webrtc_ice_transport_set_property (GObject * object, guint prop_id,
105 const GValue * value, GParamSpec * pspec)
107 GstWebRTCICETransport *webrtc = GST_WEBRTC_ICE_TRANSPORT (object);
111 webrtc->component = g_value_get_enum (value);
114 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
120 gst_webrtc_ice_transport_get_property (GObject * object, guint prop_id,
121 GValue * value, GParamSpec * pspec)
123 GstWebRTCICETransport *webrtc = GST_WEBRTC_ICE_TRANSPORT (object);
127 g_value_set_enum (value, webrtc->component);
130 g_value_set_enum (value, webrtc->state);
132 case PROP_GATHERING_STATE:
133 g_value_set_enum (value, webrtc->gathering_state);
136 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
142 gst_webrtc_ice_transport_finalize (GObject * object)
144 // GstWebRTCICETransport *webrtc = GST_WEBRTC_ICE_TRANSPORT (object);
146 G_OBJECT_CLASS (parent_class)->finalize (object);
150 gst_webrtc_ice_transport_constructed (GObject * object)
152 // GstWebRTCICETransport *webrtc = GST_WEBRTC_ICE_TRANSPORT (object);
154 G_OBJECT_CLASS (parent_class)->constructed (object);
158 gst_webrtc_ice_transport_class_init (GstWebRTCICETransportClass * klass)
160 GObjectClass *gobject_class = (GObjectClass *) klass;
162 gobject_class->constructed = gst_webrtc_ice_transport_constructed;
163 gobject_class->get_property = gst_webrtc_ice_transport_get_property;
164 gobject_class->set_property = gst_webrtc_ice_transport_set_property;
165 gobject_class->finalize = gst_webrtc_ice_transport_finalize;
167 g_object_class_install_property (gobject_class,
169 g_param_spec_enum ("component",
170 "ICE component", "The ICE component of this transport",
171 GST_TYPE_WEBRTC_ICE_COMPONENT, 0,
172 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
174 g_object_class_install_property (gobject_class,
176 g_param_spec_enum ("state",
177 "ICE connection state", "The ICE connection state of this transport",
178 GST_TYPE_WEBRTC_ICE_CONNECTION_STATE, 0,
179 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
181 g_object_class_install_property (gobject_class,
182 PROP_GATHERING_STATE,
183 g_param_spec_enum ("gathering-state",
184 "ICE gathering state", "The ICE gathering state of this transport",
185 GST_TYPE_WEBRTC_ICE_GATHERING_STATE, 0,
186 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
189 * GstWebRTC::on-selected_candidate-pair-change:
190 * @object: the #GstWebRTCICETransport
192 gst_webrtc_ice_transport_signals[ON_SELECTED_CANDIDATE_PAIR_CHANGE_SIGNAL] =
193 g_signal_new ("on-selected-candidate-pair-change",
194 G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL,
198 * GstWebRTC::on-new-candidate:
199 * @object: the #GstWebRTCICETransport
201 gst_webrtc_ice_transport_signals[ON_NEW_CANDIDATE_SIGNAL] =
202 g_signal_new ("on-new-candidate",
203 G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL,
204 G_TYPE_NONE, 1, G_TYPE_STRING);
208 gst_webrtc_ice_transport_init (GstWebRTCICETransport * webrtc)