webrtc: Fix documentaton moving symbols in the right pages
[platform/upstream/gstreamer.git] / subprojects / gst-plugins-bad / gst-libs / gst / webrtc / icetransport.c
1 /* GStreamer
2  * Copyright (C) 2017 Matthew Waters <matthew@centricular.com>
3  *
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.
8  *
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.
13  *
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.
18  */
19
20 /**
21  * SECTION:gstwebrtc-icetransport
22  * @short_description: RTCIceTransport object
23  * @title: GstWebRTCICETransport
24  * @see_also: #GstWebRTCRTPSender, #GstWebRTCRTPReceiver, #GstWebRTCDTLSTransport
25  * @symbols:
26  * - GstWebRTCICETransport
27  *
28  * See the [specification](https://www.w3.org/TR/webrtc/#rtcicetransport)
29  */
30
31 #ifdef HAVE_CONFIG_H
32 # include "config.h"
33 #endif
34
35 #include "icetransport.h"
36 #include "webrtc-enumtypes.h"
37
38 #include "webrtc-priv.h"
39
40 #define GST_CAT_DEFAULT gst_webrtc_ice_transport_debug
41 GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
42
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"););
50
51 enum
52 {
53   SIGNAL_0,
54   ON_SELECTED_CANDIDATE_PAIR_CHANGE_SIGNAL,
55   ON_NEW_CANDIDATE_SIGNAL,
56   LAST_SIGNAL,
57 };
58
59 enum
60 {
61   PROP_0,
62   PROP_COMPONENT,
63   PROP_STATE,
64   PROP_GATHERING_STATE,
65 };
66
67 static guint gst_webrtc_ice_transport_signals[LAST_SIGNAL] = { 0 };
68
69 void
70 gst_webrtc_ice_transport_connection_state_change (GstWebRTCICETransport * ice,
71     GstWebRTCICEConnectionState new_state)
72 {
73   GST_OBJECT_LOCK (ice);
74   ice->state = new_state;
75   GST_OBJECT_UNLOCK (ice);
76   g_object_notify (G_OBJECT (ice), "state");
77 }
78
79 void
80 gst_webrtc_ice_transport_gathering_state_change (GstWebRTCICETransport * ice,
81     GstWebRTCICEGatheringState new_state)
82 {
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");
87 }
88
89 void
90 gst_webrtc_ice_transport_selected_pair_change (GstWebRTCICETransport * ice)
91 {
92   g_signal_emit (ice,
93       gst_webrtc_ice_transport_signals
94       [ON_SELECTED_CANDIDATE_PAIR_CHANGE_SIGNAL], 0);
95 }
96
97 void
98 gst_webrtc_ice_transport_new_candidate (GstWebRTCICETransport * ice,
99     guint stream_id, GstWebRTCICEComponent component, gchar * attr)
100 {
101   g_signal_emit (ice, gst_webrtc_ice_transport_signals[ON_NEW_CANDIDATE_SIGNAL],
102       stream_id, component, attr);
103 }
104
105 static void
106 gst_webrtc_ice_transport_set_property (GObject * object, guint prop_id,
107     const GValue * value, GParamSpec * pspec)
108 {
109   GstWebRTCICETransport *webrtc = GST_WEBRTC_ICE_TRANSPORT (object);
110
111   switch (prop_id) {
112     case PROP_COMPONENT:
113       webrtc->component = g_value_get_enum (value);
114       break;
115     default:
116       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
117       break;
118   }
119 }
120
121 static void
122 gst_webrtc_ice_transport_get_property (GObject * object, guint prop_id,
123     GValue * value, GParamSpec * pspec)
124 {
125   GstWebRTCICETransport *webrtc = GST_WEBRTC_ICE_TRANSPORT (object);
126
127   switch (prop_id) {
128     case PROP_COMPONENT:
129       g_value_set_enum (value, webrtc->component);
130       break;
131     case PROP_STATE:
132       g_value_set_enum (value, webrtc->state);
133       break;
134     case PROP_GATHERING_STATE:
135       g_value_set_enum (value, webrtc->gathering_state);
136       break;
137     default:
138       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
139       break;
140   }
141 }
142
143 static void
144 gst_webrtc_ice_transport_finalize (GObject * object)
145 {
146 //  GstWebRTCICETransport *webrtc = GST_WEBRTC_ICE_TRANSPORT (object);
147
148   G_OBJECT_CLASS (parent_class)->finalize (object);
149 }
150
151 static void
152 gst_webrtc_ice_transport_constructed (GObject * object)
153 {
154 //  GstWebRTCICETransport *webrtc = GST_WEBRTC_ICE_TRANSPORT (object);
155
156   G_OBJECT_CLASS (parent_class)->constructed (object);
157 }
158
159 static void
160 gst_webrtc_ice_transport_class_init (GstWebRTCICETransportClass * klass)
161 {
162   GObjectClass *gobject_class = (GObjectClass *) klass;
163
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;
168
169   g_object_class_install_property (gobject_class,
170       PROP_COMPONENT,
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));
175
176   g_object_class_install_property (gobject_class,
177       PROP_STATE,
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));
182
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));
189
190   /**
191    * GstWebRTC::on-selected_candidate-pair-change:
192    * @object: the #GstWebRTCICETransport
193    */
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,
197       G_TYPE_NONE, 0);
198
199   /**
200    * GstWebRTC::on-new-candidate:
201    * @object: the #GstWebRTCICETransport
202    */
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);
207 }
208
209 static void
210 gst_webrtc_ice_transport_init (GstWebRTCICETransport * webrtc)
211 {
212 }