• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GStreamer
2  * Copyright (C) <2005,2009> Wim Taymans <wim.taymans@gmail.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  * Unless otherwise indicated, Source Code is licensed under MIT license.
21  * See further explanation attached in License Statement (distributed in the file
22  * LICENSE).
23  *
24  * Permission is hereby granted, free of charge, to any person obtaining a copy of
25  * this software and associated documentation files (the "Software"), to deal in
26  * the Software without restriction, including without limitation the rights to
27  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
28  * of the Software, and to permit persons to whom the Software is furnished to do
29  * so, subject to the following conditions:
30  *
31  * The above copyright notice and this permission notice shall be included in all
32  * copies or substantial portions of the Software.
33  *
34  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
35  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
36  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
37  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
38  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
39  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
40  * SOFTWARE.
41  */
42 
43 #ifndef __GST_RTSP_CONNECTION_H__
44 #define __GST_RTSP_CONNECTION_H__
45 
46 #include <glib.h>
47 
48 #include <gst/gstconfig.h>
49 #include <gst/rtsp/gstrtspdefs.h>
50 #include <gst/rtsp/gstrtspurl.h>
51 #include <gst/rtsp/gstrtspmessage.h>
52 #include <gio/gio.h>
53 
54 G_BEGIN_DECLS
55 
56 /**
57  * GstRTSPConnection:
58  *
59  * Opaque RTSP connection object.
60  */
61 typedef struct _GstRTSPConnection GstRTSPConnection;
62 
63 /* opening/closing a connection */
64 
65 GST_RTSP_API
66 GstRTSPResult      gst_rtsp_connection_create         (const GstRTSPUrl *url, GstRTSPConnection **conn);
67 
68 GST_RTSP_API
69 GstRTSPResult      gst_rtsp_connection_create_from_socket (GSocket * socket,
70                                                        const gchar * ip,
71                                                        guint16 port,
72                                                        const gchar * initial_buffer,
73                                                        GstRTSPConnection ** conn);
74 
75 GST_RTSP_API
76 GstRTSPResult      gst_rtsp_connection_accept                 (GSocket * socket, GstRTSPConnection ** conn, GCancellable * cancellable);
77 
78 GST_RTSP_API
79 GstRTSPResult      gst_rtsp_connection_connect_usec           (GstRTSPConnection * conn, gint64 timeout);
80 
81 GST_RTSP_API
82 GstRTSPResult      gst_rtsp_connection_connect_with_response_usec (GstRTSPConnection * conn, gint64 timeout, GstRTSPMessage * response);
83 
84 GST_RTSP_API
85 GstRTSPResult      gst_rtsp_connection_close                  (GstRTSPConnection *conn);
86 
87 GST_RTSP_API
88 GstRTSPResult      gst_rtsp_connection_free                   (GstRTSPConnection *conn);
89 
90 /* TLS connections */
91 
92 GST_RTSP_API
93 GTlsConnection *     gst_rtsp_connection_get_tls                  (GstRTSPConnection * conn, GError ** error);
94 
95 GST_RTSP_API
96 gboolean             gst_rtsp_connection_set_tls_validation_flags (GstRTSPConnection * conn, GTlsCertificateFlags flags);
97 
98 GST_RTSP_API
99 GTlsCertificateFlags gst_rtsp_connection_get_tls_validation_flags (GstRTSPConnection * conn);
100 
101 GST_RTSP_API
102 void                 gst_rtsp_connection_set_tls_database (GstRTSPConnection * conn, GTlsDatabase * database);
103 
104 GST_RTSP_API
105 GTlsDatabase *       gst_rtsp_connection_get_tls_database (GstRTSPConnection * conn);
106 
107 GST_RTSP_API
108 void                 gst_rtsp_connection_set_tls_interaction (GstRTSPConnection * conn, GTlsInteraction * interaction);
109 
110 GST_RTSP_API
111 GTlsInteraction *    gst_rtsp_connection_get_tls_interaction (GstRTSPConnection * conn);
112 
113 typedef gboolean (*GstRTSPConnectionAcceptCertificateFunc) (GTlsConnection *conn,
114                                                             GTlsCertificate *peer_cert,
115                                                             GTlsCertificateFlags errors,
116                                                             gpointer user_data);
117 GST_RTSP_API
118 void                 gst_rtsp_connection_set_accept_certificate_func (GstRTSPConnection * conn,
119                                                                       GstRTSPConnectionAcceptCertificateFunc func,
120                                                                       gpointer user_data,
121                                                                       GDestroyNotify destroy_notify);
122 
123 /* sending/receiving raw bytes */
124 
125 GST_RTSP_API
126 GstRTSPResult      gst_rtsp_connection_read_usec      (GstRTSPConnection * conn, guint8 * data,
127                                                        guint size, gint64 timeout);
128 
129 GST_RTSP_API
130 GstRTSPResult      gst_rtsp_connection_write_usec     (GstRTSPConnection * conn, const guint8 * data,
131                                                        guint size, gint64 timeout);
132 
133 /* sending/receiving messages */
134 
135 GST_RTSP_API
136 GstRTSPResult      gst_rtsp_connection_send_usec      (GstRTSPConnection *conn, GstRTSPMessage *message,
137                                                        gint64 timeout);
138 
139 GST_RTSP_API
140 GstRTSPResult      gst_rtsp_connection_send_messages_usec (GstRTSPConnection *conn, GstRTSPMessage *messages, guint n_messages,
141                                                        gint64 timeout);
142 
143 GST_RTSP_API
144 GstRTSPResult      gst_rtsp_connection_receive_usec    (GstRTSPConnection *conn, GstRTSPMessage *message,
145                                                        gint64 timeout);
146 
147 /* status management */
148 
149 GST_RTSP_API
150 GstRTSPResult      gst_rtsp_connection_poll_usec      (GstRTSPConnection *conn, GstRTSPEvent events,
151                                                        GstRTSPEvent *revents, gint64 timeout);
152 
153 /* reset the timeout */
154 
155 GST_RTSP_API
156 gint64             gst_rtsp_connection_next_timeout_usec (GstRTSPConnection *conn);
157 
158 GST_RTSP_API
159 GstRTSPResult      gst_rtsp_connection_reset_timeout  (GstRTSPConnection *conn);
160 
161 /* flushing state */
162 
163 GST_RTSP_API
164 GstRTSPResult      gst_rtsp_connection_flush          (GstRTSPConnection *conn, gboolean flush);
165 
166 /* HTTP proxy support */
167 
168 GST_RTSP_API
169 GstRTSPResult      gst_rtsp_connection_set_proxy      (GstRTSPConnection *conn,
170                                                        const gchar *host, guint port);
171 
172 /* configure authentication data */
173 
174 GST_RTSP_API
175 GstRTSPResult      gst_rtsp_connection_set_auth       (GstRTSPConnection *conn, GstRTSPAuthMethod method,
176                                                        const gchar *user, const gchar *pass);
177 
178 GST_RTSP_API
179 void               gst_rtsp_connection_set_auth_param    (GstRTSPConnection *conn,
180                                                           const gchar * param,
181                                                           const gchar *value);
182 
183 GST_RTSP_API
184 void               gst_rtsp_connection_clear_auth_params (GstRTSPConnection *conn);
185 
186 /* configure DSCP */
187 
188 GST_RTSP_API
189 GstRTSPResult      gst_rtsp_connection_set_qos_dscp   (GstRTSPConnection *conn,
190                                                        guint qos_dscp);
191 
192 /* Content-Length limit */
193 GST_RTSP_API
194 void               gst_rtsp_connection_set_content_length_limit (GstRTSPConnection *conn,
195                                                                  guint limit);
196 
197 /* accessors */
198 
199 GST_RTSP_API
200 GstRTSPUrl *       gst_rtsp_connection_get_url        (const GstRTSPConnection *conn);
201 
202 GST_RTSP_API
203 const gchar *      gst_rtsp_connection_get_ip         (const GstRTSPConnection *conn);
204 
205 GST_RTSP_API
206 void               gst_rtsp_connection_set_ip         (GstRTSPConnection *conn, const gchar *ip);
207 
208 GST_RTSP_API
209 GSocket *          gst_rtsp_connection_get_read_socket  (const GstRTSPConnection *conn);
210 
211 GST_RTSP_API
212 GSocket *          gst_rtsp_connection_get_write_socket (const GstRTSPConnection *conn);
213 
214 GST_RTSP_API
215 void               gst_rtsp_connection_set_http_mode  (GstRTSPConnection *conn,
216                                                        gboolean enable);
217 
218 /* tunneling */
219 
220 GST_RTSP_API
221 void               gst_rtsp_connection_set_tunneled   (GstRTSPConnection *conn, gboolean tunneled);
222 
223 GST_RTSP_API
224 gboolean           gst_rtsp_connection_is_tunneled    (const GstRTSPConnection *conn);
225 
226 GST_RTSP_API
227 const gchar *      gst_rtsp_connection_get_tunnelid   (const GstRTSPConnection *conn);
228 
229 GST_RTSP_API
230 GstRTSPResult      gst_rtsp_connection_do_tunnel      (GstRTSPConnection *conn, GstRTSPConnection *conn2);
231 
232 GST_RTSP_API
233 void               gst_rtsp_connection_set_remember_session_id (GstRTSPConnection *conn, gboolean remember);
234 
235 GST_RTSP_API
236 gboolean           gst_rtsp_connection_get_remember_session_id (GstRTSPConnection *conn);
237 
238 GST_RTSP_API
239 void               gst_rtsp_connection_set_ignore_x_server_reply (GstRTSPConnection *conn, gboolean ignore);
240 
241 GST_RTSP_API
242 gboolean           gst_rtsp_connection_get_ignore_x_server_reply (const GstRTSPConnection *conn);
243 
244 /* async IO */
245 
246 /**
247  * GstRTSPWatch:
248  *
249  * Opaque RTSP watch object that can be used for asynchronous RTSP
250  * operations.
251  */
252 typedef struct _GstRTSPWatch GstRTSPWatch;
253 
254 /**
255  * GstRTSPWatchFuncs:
256  * @message_received: callback when a message was received
257  * @message_sent: callback when a message was sent
258  * @closed: callback when the connection is closed
259  * @error: callback when an error occurred
260  * @tunnel_start: a client started a tunneled connection. The tunnelid of the
261  *   connection must be saved.
262  * @tunnel_complete: a client finished a tunneled connection. In this callback
263  *   you usually pair the tunnelid of this connection with the saved one using
264  *   gst_rtsp_connection_do_tunnel().
265  * @error_full: callback when an error occurred with more information than
266  *   the @error callback.
267  * @tunnel_lost: callback when the post connection of a tunnel is closed.
268  * @tunnel_http_response: callback when an HTTP response to the GET request
269  *   is about to be sent for a tunneled connection. The response can be
270  *   modified in the callback. Since: 1.4.
271  *
272  * Callback functions from a #GstRTSPWatch.
273  */
274 typedef struct {
275   GstRTSPResult     (*message_received) (GstRTSPWatch *watch, GstRTSPMessage *message,
276                                          gpointer user_data);
277   GstRTSPResult     (*message_sent)     (GstRTSPWatch *watch, guint id,
278                                          gpointer user_data);
279   GstRTSPResult     (*closed)           (GstRTSPWatch *watch, gpointer user_data);
280   GstRTSPResult     (*error)            (GstRTSPWatch *watch, GstRTSPResult result,
281                                          gpointer user_data);
282   GstRTSPStatusCode (*tunnel_start)     (GstRTSPWatch *watch, gpointer user_data);
283   GstRTSPResult     (*tunnel_complete)  (GstRTSPWatch *watch, gpointer user_data);
284   GstRTSPResult     (*error_full)       (GstRTSPWatch *watch, GstRTSPResult result,
285                                          GstRTSPMessage *message, guint id,
286                                          gpointer user_data);
287   GstRTSPResult     (*tunnel_lost)      (GstRTSPWatch *watch, gpointer user_data);
288   GstRTSPResult     (*tunnel_http_response) (GstRTSPWatch *watch,
289                                              GstRTSPMessage *request,
290                                              GstRTSPMessage *response,
291                                              gpointer user_data);
292 
293   /*< private >*/
294   gpointer _gst_reserved[GST_PADDING-1];
295 } GstRTSPWatchFuncs;
296 
297 GST_RTSP_API
298 GstRTSPWatch *     gst_rtsp_watch_new                (GstRTSPConnection *conn,
299                                                       GstRTSPWatchFuncs *funcs,
300                                                       gpointer user_data,
301                                                       GDestroyNotify notify);
302 
303 GST_RTSP_API
304 void               gst_rtsp_watch_reset              (GstRTSPWatch *watch);
305 
306 GST_RTSP_API
307 void               gst_rtsp_watch_unref              (GstRTSPWatch *watch);
308 
309 GST_RTSP_API
310 guint              gst_rtsp_watch_attach             (GstRTSPWatch *watch,
311                                                       GMainContext *context);
312 
313 GST_RTSP_API
314 void               gst_rtsp_watch_set_send_backlog  (GstRTSPWatch *watch,
315                                                      gsize bytes, guint messages);
316 
317 GST_RTSP_API
318 void               gst_rtsp_watch_get_send_backlog  (GstRTSPWatch *watch,
319                                                      gsize *bytes, guint *messages);
320 
321 GST_RTSP_API
322 GstRTSPResult      gst_rtsp_watch_write_data         (GstRTSPWatch *watch,
323                                                       const guint8 *data,
324                                                       guint size, guint *id);
325 
326 GST_RTSP_API
327 GstRTSPResult      gst_rtsp_watch_send_message       (GstRTSPWatch *watch,
328                                                       GstRTSPMessage *message,
329                                                       guint *id);
330 
331 GST_RTSP_API
332 GstRTSPResult      gst_rtsp_watch_send_messages      (GstRTSPWatch *watch,
333                                                       GstRTSPMessage *messages,
334                                                       guint n_messages,
335                                                       guint *id);
336 
337 GST_RTSP_API
338 GstRTSPResult      gst_rtsp_watch_wait_backlog_usec  (GstRTSPWatch * watch,
339                                                       gint64 timeout);
340 
341 GST_RTSP_API
342 void               gst_rtsp_watch_set_flushing       (GstRTSPWatch * watch,
343                                                       gboolean flushing);
344 
345 #ifndef GST_DISABLE_DEPRECATED
346 
347 /* Deprecated */
348 G_GNUC_BEGIN_IGNORE_DEPRECATIONS
349 
350 GST_RTSP_DEPRECATED_FOR (gst_rtsp_connection_connect_usec)
351 GstRTSPResult      gst_rtsp_connection_connect                (GstRTSPConnection * conn, GTimeVal * timeout);
352 
353 GST_RTSP_DEPRECATED_FOR (gst_rtsp_connection_connect_with_response_usec)
354 GstRTSPResult      gst_rtsp_connection_connect_with_response  (GstRTSPConnection * conn, GTimeVal * timeout, GstRTSPMessage * response);
355 
356 
357 GST_RTSP_DEPRECATED_FOR (gst_rtsp_connection_read_usec)
358 GstRTSPResult      gst_rtsp_connection_read           (GstRTSPConnection * conn, guint8 * data,
359                                                        guint size, GTimeVal * timeout);
360 
361 
362 GST_RTSP_DEPRECATED_FOR (gst_rtsp_connection_write_usec)
363 GstRTSPResult      gst_rtsp_connection_write          (GstRTSPConnection * conn, const guint8 * data,
364                                                        guint size, GTimeVal * timeout);
365 
366 GST_RTSP_DEPRECATED_FOR (gst_rtsp_connection_send_usec)
367 GstRTSPResult      gst_rtsp_connection_send           (GstRTSPConnection *conn, GstRTSPMessage *message,
368                                                        GTimeVal *timeout);
369 
370 GST_RTSP_DEPRECATED_FOR (gst_rtsp_connection_send_messages_usec)
371 GstRTSPResult      gst_rtsp_connection_send_messages  (GstRTSPConnection *conn, GstRTSPMessage *messages, guint n_messages,
372                                                        GTimeVal *timeout);
373 
374 GST_RTSP_DEPRECATED_FOR (gst_rtsp_connection_receive_usec)
375 GstRTSPResult      gst_rtsp_connection_receive        (GstRTSPConnection *conn, GstRTSPMessage *message,
376                                                        GTimeVal *timeout);
377 
378 GST_RTSP_DEPRECATED_FOR (gst_rtsp_connection_poll_usec)
379 GstRTSPResult      gst_rtsp_connection_poll           (GstRTSPConnection *conn, GstRTSPEvent events,
380                                                        GstRTSPEvent *revents, GTimeVal *timeout);
381 
382 GST_RTSP_DEPRECATED_FOR (gst_rtsp_connection_next_timeout_usec)
383 GstRTSPResult      gst_rtsp_connection_next_timeout   (GstRTSPConnection *conn, GTimeVal *timeout);
384 
385 GST_RTSP_DEPRECATED_FOR (gst_rtsp_watch_wait_backlog_usec)
386 GstRTSPResult      gst_rtsp_watch_wait_backlog       (GstRTSPWatch * watch,
387                                                       GTimeVal *timeout);
388 
389 G_GNUC_END_IGNORE_DEPRECATIONS
390 
391 #endif /* GST_DISABLE_DEPRECATED */
392 
393 G_END_DECLS
394 
395 #endif /* __GST_RTSP_CONNECTION_H__ */
396