summaryrefslogtreecommitdiff
path: root/gst-libs/gst/webrtc/webrtc-priv.h
blob: cf8a081c2cb161d581129afdeb37d7cfad759827 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
/* GStreamer
 * Copyright (C) 2017 Matthew Waters <matthew@centricular.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

#ifndef __GST_WEBRTC_PRIV_H__
#define __GST_WEBRTC_PRIV_H__

#include <gst/gst.h>
#include <gst/webrtc/webrtc_fwd.h>
#include <gst/webrtc/rtpsender.h>
#include <gst/webrtc/rtpreceiver.h>

G_BEGIN_DECLS

/**
 * GstWebRTCRTPTransceiver:
 * @mline: the mline number this transceiver corresponds to
 * @mid: The media ID of the m-line associated with this
 * transceiver. This association is established, when possible,
 * whenever either a local or remote description is applied. This
 * field is NULL if neither a local or remote description has been
 * applied, or if its associated m-line is rejected by either a remote
 * offer or any answer.
 * @stopped: Indicates whether or not sending and receiving using the paired
 * #GstWebRTCRTPSender and #GstWebRTCRTPReceiver has been permanently disabled,
 * either due to SDP offer/answer
 * @sender: The #GstWebRTCRTPSender object responsible sending  data to the
 * remote peer
 * @receiver: The #GstWebRTCRTPReceiver object responsible for receiver data from
 * the remote peer.
 * @direction: The transceiver's desired direction.
 * @current_direction: The transceiver's current direction (read-only)
 * @codec_preferences: A caps representing the codec preferences (read-only)
 * @kind: Type of media (Since: 1.20)
 *
 * Mostly matches the WebRTC RTCRtpTransceiver interface.
 */
/**
 * GstWebRTCRTPTransceiver.kind:
 *
 * Type of media
 *
 * Since: 1.20
 */
struct _GstWebRTCRTPTransceiver
{
  GstObject                         parent;
  guint                             mline;
  gchar                            *mid;
  gboolean                          stopped;

  GstWebRTCRTPSender               *sender;
  GstWebRTCRTPReceiver             *receiver;

  GstWebRTCRTPTransceiverDirection  direction;
  GstWebRTCRTPTransceiverDirection  current_direction;

  GstCaps                          *codec_preferences;
  GstWebRTCKind                     kind;

  gpointer                          _padding[GST_PADDING];
};

struct _GstWebRTCRTPTransceiverClass
{
  GstObjectClass        parent_class;

  /* FIXME; reset */
  gpointer              _padding[GST_PADDING];
};

/**
 * GstWebRTCRTPSender:
 * @transport: The transport for RTP packets
 * @send_encodings: Unused
 * @priority: The priority of the stream (Since: 1.20)
 *
 * An object to track the sending aspect of the stream
 *
 * Mostly matches the WebRTC RTCRtpSender interface.
 */
/**
 * GstWebRTCRTPSender.priority:
 *
 * The priority of the stream
 *
 * Since: 1.20
 */
struct _GstWebRTCRTPSender
{
  GstObject                          parent;

  /* The MediStreamTrack is represented by the stream and is output into @transport as necessary */
  GstWebRTCDTLSTransport            *transport;

  GArray                            *send_encodings;
  GstWebRTCPriorityType              priority;

  gpointer                          _padding[GST_PADDING];
};

struct _GstWebRTCRTPSenderClass
{
  GstObjectClass        parent_class;

  gpointer              _padding[GST_PADDING];
};

GST_WEBRTC_API
GstWebRTCRTPSender *        gst_webrtc_rtp_sender_new                   (void);

/**
 * GstWebRTCRTPReceiver:
 * @transport: The transport for RTP packets
 *
 * An object to track the receiving aspect of the stream
 *
 * Mostly matches the WebRTC RTCRtpReceiver interface.
 */
struct _GstWebRTCRTPReceiver
{
  GstObject                          parent;

  /* The MediStreamTrack is represented by the stream and is output into @transport as necessary */
  GstWebRTCDTLSTransport            *transport;

  gpointer                          _padding[GST_PADDING];
};

struct _GstWebRTCRTPReceiverClass
{
  GstObjectClass            parent_class;

  gpointer                  _padding[GST_PADDING];
};

GST_WEBRTC_API
GstWebRTCRTPReceiver *      gst_webrtc_rtp_receiver_new                 (void);


/**
 * GstWebRTCICETransport:
 */
struct _GstWebRTCICETransport
{
  GstObject                          parent;

  GstWebRTCICERole                   role;
  GstWebRTCICEComponent              component;

  GstWebRTCICEConnectionState        state;
  GstWebRTCICEGatheringState         gathering_state;

  /* Filled by subclasses */
  GstElement                        *src;
  GstElement                        *sink;

  gpointer                          _padding[GST_PADDING];
};

struct _GstWebRTCICETransportClass
{
  GstObjectClass               parent_class;

  gboolean                  (*gather_candidates)        (GstWebRTCICETransport * transport);

  gpointer                  _padding[GST_PADDING];
};

GST_WEBRTC_API
void            gst_webrtc_ice_transport_connection_state_change    (GstWebRTCICETransport * ice,
                                                                     GstWebRTCICEConnectionState new_state);
GST_WEBRTC_API
void            gst_webrtc_ice_transport_gathering_state_change     (GstWebRTCICETransport * ice,
                                                                     GstWebRTCICEGatheringState new_state);
GST_WEBRTC_API
void            gst_webrtc_ice_transport_selected_pair_change       (GstWebRTCICETransport * ice);
GST_WEBRTC_API
void            gst_webrtc_ice_transport_new_candidate              (GstWebRTCICETransport * ice, guint stream_id, GstWebRTCICEComponent component, gchar * attr);

/**
 * GstWebRTCDTLSTransport:
 */
struct _GstWebRTCDTLSTransport
{
  GstObject                          parent;

  GstWebRTCICETransport             *transport;
  GstWebRTCDTLSTransportState        state;

  gboolean                           client;
  guint                              session_id;
  GstElement                        *dtlssrtpenc;
  GstElement                        *dtlssrtpdec;

  gpointer                          _padding[GST_PADDING];
};

struct _GstWebRTCDTLSTransportClass
{
  GstObjectClass               parent_class;

  gpointer                  _padding[GST_PADDING];
};

GST_WEBRTC_API
GstWebRTCDTLSTransport *    gst_webrtc_dtls_transport_new               (guint session_id);

GST_WEBRTC_API
void                        gst_webrtc_dtls_transport_set_transport     (GstWebRTCDTLSTransport * transport,
                                                                         GstWebRTCICETransport * ice);

#define GST_WEBRTC_DATA_CHANNEL_LOCK(channel) g_mutex_lock(&((GstWebRTCDataChannel *)(channel))->lock)
#define GST_WEBRTC_DATA_CHANNEL_UNLOCK(channel) g_mutex_unlock(&((GstWebRTCDataChannel *)(channel))->lock)

/**
 * GstWebRTCDataChannel:
 *
 * Since: 1.18
 */
struct _GstWebRTCDataChannel
{
  GObject                           parent;

  GMutex                            lock;

  gchar                            *label;
  gboolean                          ordered;
  guint                             max_packet_lifetime;
  guint                             max_retransmits;
  gchar                            *protocol;
  gboolean                          negotiated;
  gint                              id;
  GstWebRTCPriorityType             priority;
  GstWebRTCDataChannelState         ready_state;
  guint64                           buffered_amount;
  guint64                           buffered_amount_low_threshold;

  gpointer                         _padding[GST_PADDING];
};

/**
 * GstWebRTCDataChannelClass:
 *
 * Since: 1.18
 */
struct _GstWebRTCDataChannelClass
{
  GObjectClass        parent_class;

  void              (*send_data)   (GstWebRTCDataChannel * channel, GBytes *data);
  void              (*send_string) (GstWebRTCDataChannel * channel, const gchar *str);
  void              (*close)       (GstWebRTCDataChannel * channel);

  gpointer           _padding[GST_PADDING];
};

GST_WEBRTC_API
void gst_webrtc_data_channel_on_open (GstWebRTCDataChannel * channel);

GST_WEBRTC_API
void gst_webrtc_data_channel_on_close (GstWebRTCDataChannel * channel);

GST_WEBRTC_API
void gst_webrtc_data_channel_on_error (GstWebRTCDataChannel * channel, GError * error);

GST_WEBRTC_API
void gst_webrtc_data_channel_on_message_data (GstWebRTCDataChannel * channel, GBytes * data);

GST_WEBRTC_API
void gst_webrtc_data_channel_on_message_string (GstWebRTCDataChannel * channel, const gchar * str);

GST_WEBRTC_API
void gst_webrtc_data_channel_on_buffered_amount_low (GstWebRTCDataChannel * channel);


G_END_DECLS

#endif /* __GST_WEBRTC_PRIV_H__ */