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 * - GstWebRTCICETransport
28 * See the [specification](https://www.w3.org/TR/webrtc/#rtcicetransport)
35 #include "icetransport.h"
36 #include "webrtc-enumtypes.h"
38 #include "webrtc-priv.h"
40 #define GST_CAT_DEFAULT gst_webrtc_ice_transport_debug
41 GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
43 #define gst_webrtc_ice_transport_parent_class parent_class
44 /* We would inherit from GstBin however when combined with the dtls transport,
45 * this causes loops in the graph. */
46 G_DEFINE_ABSTRACT_TYPE_WITH_CODE (GstWebRTCICETransport,
47 gst_webrtc_ice_transport, GST_TYPE_OBJECT,
48 GST_DEBUG_CATEGORY_INIT (gst_webrtc_ice_transport_debug,
49 "webrtcicetransport", 0, "webrtcicetransport"););
54 ON_SELECTED_CANDIDATE_PAIR_CHANGE_SIGNAL,
55 ON_NEW_CANDIDATE_SIGNAL,
67 static guint gst_webrtc_ice_transport_signals[LAST_SIGNAL] = { 0 };
70 gst_webrtc_ice_transport_connection_state_change (GstWebRTCICETransport * ice,
71 GstWebRTCICEConnectionState new_state)
73 GST_OBJECT_LOCK (ice);
74 ice->state = new_state;
75 GST_OBJECT_UNLOCK (ice);
76 g_object_notify (G_OBJECT (ice), "state");
80 gst_webrtc_ice_transport_gathering_state_change (GstWebRTCICETransport * ice,
81 GstWebRTCICEGatheringState new_state)
83 GST_OBJECT_LOCK (ice);
84 ice->gathering_state = new_state;
85 GST_OBJECT_UNLOCK (ice);
86 g_object_notify (G_OBJECT (ice), "gathering-state");
90 gst_webrtc_ice_transport_selected_pair_change (GstWebRTCICETransport * ice)
93 gst_webrtc_ice_transport_signals
94 [ON_SELECTED_CANDIDATE_PAIR_CHANGE_SIGNAL], 0);
98 gst_webrtc_ice_transport_new_candidate (GstWebRTCICETransport * ice,
99 guint stream_id, GstWebRTCICEComponent component, gchar * attr)
101 g_signal_emit (ice, gst_webrtc_ice_transport_signals[ON_NEW_CANDIDATE_SIGNAL],
102 stream_id, component, attr);
106 gst_webrtc_ice_transport_set_property (GObject * object, guint prop_id,
107 const GValue * value, GParamSpec * pspec)
109 GstWebRTCICETransport *webrtc = GST_WEBRTC_ICE_TRANSPORT (object);
113 webrtc->component = g_value_get_enum (value);
116 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
122 gst_webrtc_ice_transport_get_property (GObject * object, guint prop_id,
123 GValue * value, GParamSpec * pspec)
125 GstWebRTCICETransport *webrtc = GST_WEBRTC_ICE_TRANSPORT (object);
129 g_value_set_enum (value, webrtc->component);
132 g_value_set_enum (value, webrtc->state);
134 case PROP_GATHERING_STATE:
135 g_value_set_enum (value, webrtc->gathering_state);
138 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
144 gst_webrtc_ice_transport_finalize (GObject * object)
146 // GstWebRTCICETransport *webrtc = GST_WEBRTC_ICE_TRANSPORT (object);
148 G_OBJECT_CLASS (parent_class)->finalize (object);
152 gst_webrtc_ice_transport_constructed (GObject * object)
154 // GstWebRTCICETransport *webrtc = GST_WEBRTC_ICE_TRANSPORT (object);
156 G_OBJECT_CLASS (parent_class)->constructed (object);
160 gst_webrtc_ice_transport_class_init (GstWebRTCICETransportClass * klass)
162 GObjectClass *gobject_class = (GObjectClass *) klass;
164 gobject_class->constructed = gst_webrtc_ice_transport_constructed;
165 gobject_class->get_property = gst_webrtc_ice_transport_get_property;
166 gobject_class->set_property = gst_webrtc_ice_transport_set_property;
167 gobject_class->finalize = gst_webrtc_ice_transport_finalize;
169 g_object_class_install_property (gobject_class,
171 g_param_spec_enum ("component",
172 "ICE component", "The ICE component of this transport",
173 GST_TYPE_WEBRTC_ICE_COMPONENT, 0,
174 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
176 g_object_class_install_property (gobject_class,
178 g_param_spec_enum ("state",
179 "ICE connection state", "The ICE connection state of this transport",
180 GST_TYPE_WEBRTC_ICE_CONNECTION_STATE, 0,
181 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
183 g_object_class_install_property (gobject_class,
184 PROP_GATHERING_STATE,
185 g_param_spec_enum ("gathering-state",
186 "ICE gathering state", "The ICE gathering state of this transport",
187 GST_TYPE_WEBRTC_ICE_GATHERING_STATE, 0,
188 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
191 * GstWebRTC::on-selected_candidate-pair-change:
192 * @object: the #GstWebRTCICETransport
194 gst_webrtc_ice_transport_signals[ON_SELECTED_CANDIDATE_PAIR_CHANGE_SIGNAL] =
195 g_signal_new ("on-selected-candidate-pair-change",
196 G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL,
200 * GstWebRTC::on-new-candidate:
201 * @object: the #GstWebRTCICETransport
203 gst_webrtc_ice_transport_signals[ON_NEW_CANDIDATE_SIGNAL] =
204 g_signal_new ("on-new-candidate",
205 G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL,
206 G_TYPE_NONE, 1, G_TYPE_STRING);
210 gst_webrtc_ice_transport_init (GstWebRTCICETransport * webrtc)