• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef __GST_WEBRTC_PRIV_H__
21 #define __GST_WEBRTC_PRIV_H__
22 
23 #include <gst/gst.h>
24 #include <gst/webrtc/webrtc_fwd.h>
25 #include <gst/webrtc/rtpsender.h>
26 #include <gst/webrtc/rtpreceiver.h>
27 
28 G_BEGIN_DECLS
29 
30 /**
31  * GstWebRTCRTPTransceiver:
32  * @mline: the mline number this transceiver corresponds to
33  * @mid: The media ID of the m-line associated with this
34  * transceiver. This association is established, when possible,
35  * whenever either a local or remote description is applied. This
36  * field is NULL if neither a local or remote description has been
37  * applied, or if its associated m-line is rejected by either a remote
38  * offer or any answer.
39  * @stopped: Indicates whether or not sending and receiving using the paired
40  * #GstWebRTCRTPSender and #GstWebRTCRTPReceiver has been permanently disabled,
41  * either due to SDP offer/answer
42  * @sender: The #GstWebRTCRTPSender object responsible sending  data to the
43  * remote peer
44  * @receiver: The #GstWebRTCRTPReceiver object responsible for receiver data from
45  * the remote peer.
46  * @direction: The transceiver's desired direction.
47  * @current_direction: The transceiver's current direction (read-only)
48  * @codec_preferences: A caps representing the codec preferences (read-only)
49  * @kind: Type of media (Since: 1.20)
50  *
51  * Mostly matches the WebRTC RTCRtpTransceiver interface.
52  */
53 /**
54  * GstWebRTCRTPTransceiver.kind:
55  *
56  * Type of media
57  *
58  * Since: 1.20
59  */
60 struct _GstWebRTCRTPTransceiver
61 {
62   GstObject                         parent;
63   guint                             mline;
64   gchar                            *mid;
65   gboolean                          stopped;
66 
67   GstWebRTCRTPSender               *sender;
68   GstWebRTCRTPReceiver             *receiver;
69 
70   GstWebRTCRTPTransceiverDirection  direction;
71   GstWebRTCRTPTransceiverDirection  current_direction;
72 
73   GstCaps                          *codec_preferences;
74   GstWebRTCKind                     kind;
75 
76   gpointer                          _padding[GST_PADDING];
77 };
78 
79 struct _GstWebRTCRTPTransceiverClass
80 {
81   GstObjectClass        parent_class;
82 
83   /* FIXME; reset */
84   gpointer              _padding[GST_PADDING];
85 };
86 
87 /**
88  * GstWebRTCRTPSender:
89  * @transport: The transport for RTP packets
90  * @send_encodings: Unused
91  * @priority: The priority of the stream (Since: 1.20)
92  *
93  * An object to track the sending aspect of the stream
94  *
95  * Mostly matches the WebRTC RTCRtpSender interface.
96  */
97 /**
98  * GstWebRTCRTPSender.priority:
99  *
100  * The priority of the stream
101  *
102  * Since: 1.20
103  */
104 struct _GstWebRTCRTPSender
105 {
106   GstObject                          parent;
107 
108   /* The MediStreamTrack is represented by the stream and is output into @transport as necessary */
109   GstWebRTCDTLSTransport            *transport;
110 
111   GArray                            *send_encodings;
112   GstWebRTCPriorityType              priority;
113 
114   gpointer                          _padding[GST_PADDING];
115 };
116 
117 struct _GstWebRTCRTPSenderClass
118 {
119   GstObjectClass        parent_class;
120 
121   gpointer              _padding[GST_PADDING];
122 };
123 
124 GST_WEBRTC_API
125 GstWebRTCRTPSender *        gst_webrtc_rtp_sender_new                   (void);
126 
127 /**
128  * GstWebRTCRTPReceiver:
129  * @transport: The transport for RTP packets
130  *
131  * An object to track the receiving aspect of the stream
132  *
133  * Mostly matches the WebRTC RTCRtpReceiver interface.
134  */
135 struct _GstWebRTCRTPReceiver
136 {
137   GstObject                          parent;
138 
139   /* The MediStreamTrack is represented by the stream and is output into @transport as necessary */
140   GstWebRTCDTLSTransport            *transport;
141 
142   gpointer                          _padding[GST_PADDING];
143 };
144 
145 struct _GstWebRTCRTPReceiverClass
146 {
147   GstObjectClass            parent_class;
148 
149   gpointer                  _padding[GST_PADDING];
150 };
151 
152 GST_WEBRTC_API
153 GstWebRTCRTPReceiver *      gst_webrtc_rtp_receiver_new                 (void);
154 
155 
156 /**
157  * GstWebRTCICETransport:
158  */
159 struct _GstWebRTCICETransport
160 {
161   GstObject                          parent;
162 
163   GstWebRTCICERole                   role;
164   GstWebRTCICEComponent              component;
165 
166   GstWebRTCICEConnectionState        state;
167   GstWebRTCICEGatheringState         gathering_state;
168 
169   /* Filled by subclasses */
170   GstElement                        *src;
171   GstElement                        *sink;
172 
173   gpointer                          _padding[GST_PADDING];
174 };
175 
176 struct _GstWebRTCICETransportClass
177 {
178   GstObjectClass               parent_class;
179 
180   gboolean                  (*gather_candidates)        (GstWebRTCICETransport * transport);
181 
182   gpointer                  _padding[GST_PADDING];
183 };
184 
185 GST_WEBRTC_API
186 void            gst_webrtc_ice_transport_connection_state_change    (GstWebRTCICETransport * ice,
187                                                                      GstWebRTCICEConnectionState new_state);
188 GST_WEBRTC_API
189 void            gst_webrtc_ice_transport_gathering_state_change     (GstWebRTCICETransport * ice,
190                                                                      GstWebRTCICEGatheringState new_state);
191 GST_WEBRTC_API
192 void            gst_webrtc_ice_transport_selected_pair_change       (GstWebRTCICETransport * ice);
193 GST_WEBRTC_API
194 void            gst_webrtc_ice_transport_new_candidate              (GstWebRTCICETransport * ice, guint stream_id, GstWebRTCICEComponent component, gchar * attr);
195 
196 /**
197  * GstWebRTCDTLSTransport:
198  */
199 struct _GstWebRTCDTLSTransport
200 {
201   GstObject                          parent;
202 
203   GstWebRTCICETransport             *transport;
204   GstWebRTCDTLSTransportState        state;
205 
206   gboolean                           client;
207   guint                              session_id;
208   GstElement                        *dtlssrtpenc;
209   GstElement                        *dtlssrtpdec;
210 
211   gpointer                          _padding[GST_PADDING];
212 };
213 
214 struct _GstWebRTCDTLSTransportClass
215 {
216   GstObjectClass               parent_class;
217 
218   gpointer                  _padding[GST_PADDING];
219 };
220 
221 GST_WEBRTC_API
222 GstWebRTCDTLSTransport *    gst_webrtc_dtls_transport_new               (guint session_id);
223 
224 GST_WEBRTC_API
225 void                        gst_webrtc_dtls_transport_set_transport     (GstWebRTCDTLSTransport * transport,
226                                                                          GstWebRTCICETransport * ice);
227 
228 #define GST_WEBRTC_DATA_CHANNEL_LOCK(channel) g_mutex_lock(&((GstWebRTCDataChannel *)(channel))->lock)
229 #define GST_WEBRTC_DATA_CHANNEL_UNLOCK(channel) g_mutex_unlock(&((GstWebRTCDataChannel *)(channel))->lock)
230 
231 /**
232  * GstWebRTCDataChannel:
233  *
234  * Since: 1.18
235  */
236 struct _GstWebRTCDataChannel
237 {
238   GObject                           parent;
239 
240   GMutex                            lock;
241 
242   gchar                            *label;
243   gboolean                          ordered;
244   guint                             max_packet_lifetime;
245   guint                             max_retransmits;
246   gchar                            *protocol;
247   gboolean                          negotiated;
248   gint                              id;
249   GstWebRTCPriorityType             priority;
250   GstWebRTCDataChannelState         ready_state;
251   guint64                           buffered_amount;
252   guint64                           buffered_amount_low_threshold;
253 
254   gpointer                         _padding[GST_PADDING];
255 };
256 
257 /**
258  * GstWebRTCDataChannelClass:
259  *
260  * Since: 1.18
261  */
262 struct _GstWebRTCDataChannelClass
263 {
264   GObjectClass        parent_class;
265 
266   void              (*send_data)   (GstWebRTCDataChannel * channel, GBytes *data);
267   void              (*send_string) (GstWebRTCDataChannel * channel, const gchar *str);
268   void              (*close)       (GstWebRTCDataChannel * channel);
269 
270   gpointer           _padding[GST_PADDING];
271 };
272 
273 GST_WEBRTC_API
274 void gst_webrtc_data_channel_on_open (GstWebRTCDataChannel * channel);
275 
276 GST_WEBRTC_API
277 void gst_webrtc_data_channel_on_close (GstWebRTCDataChannel * channel);
278 
279 GST_WEBRTC_API
280 void gst_webrtc_data_channel_on_error (GstWebRTCDataChannel * channel, GError * error);
281 
282 GST_WEBRTC_API
283 void gst_webrtc_data_channel_on_message_data (GstWebRTCDataChannel * channel, GBytes * data);
284 
285 GST_WEBRTC_API
286 void gst_webrtc_data_channel_on_message_string (GstWebRTCDataChannel * channel, const gchar * str);
287 
288 GST_WEBRTC_API
289 void gst_webrtc_data_channel_on_buffered_amount_low (GstWebRTCDataChannel * channel);
290 
291 
292 /**
293  * GstWebRTCSCTPTransport:
294  *
295  * Since: 1.20
296  */
297 struct _GstWebRTCSCTPTransport
298 {
299   GstObject                     parent;
300 };
301 
302 /**
303  * GstWebRTCSCTPTransportClass:
304  *
305  * Since: 1.20
306  */
307 struct _GstWebRTCSCTPTransportClass
308 {
309   GstObjectClass                parent_class;
310 };
311 
312 
313 G_END_DECLS
314 
315 #endif /* __GST_WEBRTC_PRIV_H__ */
316