2 * Copyright (C) <2005,2009> Wim Taymans <wim.taymans@gmail.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.
20 * Unless otherwise indicated, Source Code is licensed under MIT license.
21 * See further explanation attached in License Statement (distributed in the file
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:
31 * The above copyright notice and this permission notice shall be included in all
32 * copies or substantial portions of the Software.
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
43 #ifndef __GST_RTSP_CONNECTION_H__
44 #define __GST_RTSP_CONNECTION_H__
48 #include <gst/gstconfig.h>
49 #include <gst/rtsp/gstrtspdefs.h>
50 #include <gst/rtsp/gstrtspurl.h>
51 #include <gst/rtsp/gstrtspmessage.h>
59 * Opaque RTSP connection object.
61 typedef struct _GstRTSPConnection GstRTSPConnection;
63 /* opening/closing a connection */
66 GstRTSPResult gst_rtsp_connection_create (const GstRTSPUrl *url, GstRTSPConnection **conn);
69 GstRTSPResult gst_rtsp_connection_create_from_socket (GSocket * socket,
72 const gchar * initial_buffer,
73 GstRTSPConnection ** conn);
76 GstRTSPResult gst_rtsp_connection_accept (GSocket * socket, GstRTSPConnection ** conn, GCancellable * cancellable);
79 GstRTSPResult gst_rtsp_connection_connect_usec (GstRTSPConnection * conn, gint64 timeout);
82 GstRTSPResult gst_rtsp_connection_connect_with_response_usec (GstRTSPConnection * conn, gint64 timeout, GstRTSPMessage * response);
85 GstRTSPResult gst_rtsp_connection_close (GstRTSPConnection *conn);
88 GstRTSPResult gst_rtsp_connection_free (GstRTSPConnection *conn);
93 GTlsConnection * gst_rtsp_connection_get_tls (GstRTSPConnection * conn, GError ** error);
96 gboolean gst_rtsp_connection_set_tls_validation_flags (GstRTSPConnection * conn, GTlsCertificateFlags flags);
99 GTlsCertificateFlags gst_rtsp_connection_get_tls_validation_flags (GstRTSPConnection * conn);
102 void gst_rtsp_connection_set_tls_database (GstRTSPConnection * conn, GTlsDatabase * database);
105 GTlsDatabase * gst_rtsp_connection_get_tls_database (GstRTSPConnection * conn);
108 void gst_rtsp_connection_set_tls_interaction (GstRTSPConnection * conn, GTlsInteraction * interaction);
111 GTlsInteraction * gst_rtsp_connection_get_tls_interaction (GstRTSPConnection * conn);
113 typedef gboolean (*GstRTSPConnectionAcceptCertificateFunc) (GTlsConnection *conn,
114 GTlsCertificate *peer_cert,
115 GTlsCertificateFlags errors,
118 void gst_rtsp_connection_set_accept_certificate_func (GstRTSPConnection * conn,
119 GstRTSPConnectionAcceptCertificateFunc func,
121 GDestroyNotify destroy_notify);
123 /* sending/receiving raw bytes */
126 GstRTSPResult gst_rtsp_connection_read_usec (GstRTSPConnection * conn, guint8 * data,
127 guint size, gint64 timeout);
130 GstRTSPResult gst_rtsp_connection_write_usec (GstRTSPConnection * conn, const guint8 * data,
131 guint size, gint64 timeout);
133 /* sending/receiving messages */
136 GstRTSPResult gst_rtsp_connection_send_usec (GstRTSPConnection *conn, GstRTSPMessage *message,
140 GstRTSPResult gst_rtsp_connection_send_messages_usec (GstRTSPConnection *conn, GstRTSPMessage *messages, guint n_messages,
144 GstRTSPResult gst_rtsp_connection_receive_usec (GstRTSPConnection *conn, GstRTSPMessage *message,
147 /* status management */
150 GstRTSPResult gst_rtsp_connection_poll_usec (GstRTSPConnection *conn, GstRTSPEvent events,
151 GstRTSPEvent *revents, gint64 timeout);
153 /* reset the timeout */
156 gint64 gst_rtsp_connection_next_timeout_usec (GstRTSPConnection *conn);
159 GstRTSPResult gst_rtsp_connection_reset_timeout (GstRTSPConnection *conn);
164 GstRTSPResult gst_rtsp_connection_flush (GstRTSPConnection *conn, gboolean flush);
166 /* HTTP proxy support */
169 GstRTSPResult gst_rtsp_connection_set_proxy (GstRTSPConnection *conn,
170 const gchar *host, guint port);
172 /* configure authentication data */
175 GstRTSPResult gst_rtsp_connection_set_auth (GstRTSPConnection *conn, GstRTSPAuthMethod method,
176 const gchar *user, const gchar *pass);
179 void gst_rtsp_connection_set_auth_param (GstRTSPConnection *conn,
184 void gst_rtsp_connection_clear_auth_params (GstRTSPConnection *conn);
189 GstRTSPResult gst_rtsp_connection_set_qos_dscp (GstRTSPConnection *conn,
192 /* Content-Length limit */
194 void gst_rtsp_connection_set_content_length_limit (GstRTSPConnection *conn,
200 GstRTSPUrl * gst_rtsp_connection_get_url (const GstRTSPConnection *conn);
203 const gchar * gst_rtsp_connection_get_ip (const GstRTSPConnection *conn);
206 void gst_rtsp_connection_set_ip (GstRTSPConnection *conn, const gchar *ip);
209 GSocket * gst_rtsp_connection_get_read_socket (const GstRTSPConnection *conn);
212 GSocket * gst_rtsp_connection_get_write_socket (const GstRTSPConnection *conn);
215 void gst_rtsp_connection_set_http_mode (GstRTSPConnection *conn,
221 void gst_rtsp_connection_set_tunneled (GstRTSPConnection *conn, gboolean tunneled);
224 gboolean gst_rtsp_connection_is_tunneled (const GstRTSPConnection *conn);
227 const gchar * gst_rtsp_connection_get_tunnelid (const GstRTSPConnection *conn);
230 GstRTSPResult gst_rtsp_connection_do_tunnel (GstRTSPConnection *conn, GstRTSPConnection *conn2);
233 void gst_rtsp_connection_set_remember_session_id (GstRTSPConnection *conn, gboolean remember);
236 gboolean gst_rtsp_connection_get_remember_session_id (GstRTSPConnection *conn);
239 void gst_rtsp_connection_set_ignore_x_server_reply (GstRTSPConnection *conn, gboolean ignore);
242 gboolean gst_rtsp_connection_get_ignore_x_server_reply (const GstRTSPConnection *conn);
249 * Opaque RTSP watch object that can be used for asynchronous RTSP
252 typedef struct _GstRTSPWatch GstRTSPWatch;
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.
272 * Callback functions from a #GstRTSPWatch.
275 GstRTSPResult (*message_received) (GstRTSPWatch *watch, GstRTSPMessage *message,
277 GstRTSPResult (*message_sent) (GstRTSPWatch *watch, guint id,
279 GstRTSPResult (*closed) (GstRTSPWatch *watch, gpointer user_data);
280 GstRTSPResult (*error) (GstRTSPWatch *watch, GstRTSPResult result,
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,
287 GstRTSPResult (*tunnel_lost) (GstRTSPWatch *watch, gpointer user_data);
288 GstRTSPResult (*tunnel_http_response) (GstRTSPWatch *watch,
289 GstRTSPMessage *request,
290 GstRTSPMessage *response,
294 gpointer _gst_reserved[GST_PADDING-1];
298 GstRTSPWatch * gst_rtsp_watch_new (GstRTSPConnection *conn,
299 GstRTSPWatchFuncs *funcs,
301 GDestroyNotify notify);
304 void gst_rtsp_watch_reset (GstRTSPWatch *watch);
307 void gst_rtsp_watch_unref (GstRTSPWatch *watch);
310 guint gst_rtsp_watch_attach (GstRTSPWatch *watch,
311 GMainContext *context);
314 void gst_rtsp_watch_set_send_backlog (GstRTSPWatch *watch,
315 gsize bytes, guint messages);
318 void gst_rtsp_watch_get_send_backlog (GstRTSPWatch *watch,
319 gsize *bytes, guint *messages);
322 GstRTSPResult gst_rtsp_watch_write_data (GstRTSPWatch *watch,
324 guint size, guint *id);
327 GstRTSPResult gst_rtsp_watch_send_message (GstRTSPWatch *watch,
328 GstRTSPMessage *message,
332 GstRTSPResult gst_rtsp_watch_send_messages (GstRTSPWatch *watch,
333 GstRTSPMessage *messages,
338 GstRTSPResult gst_rtsp_watch_wait_backlog_usec (GstRTSPWatch * watch,
342 void gst_rtsp_watch_set_flushing (GstRTSPWatch * watch,
345 #ifndef GST_DISABLE_DEPRECATED
348 G_GNUC_BEGIN_IGNORE_DEPRECATIONS
350 GST_RTSP_DEPRECATED_FOR (gst_rtsp_connection_connect_usec)
351 GstRTSPResult gst_rtsp_connection_connect (GstRTSPConnection * conn, GTimeVal * timeout);
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);
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);
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);
366 GST_RTSP_DEPRECATED_FOR (gst_rtsp_connection_send_usec)
367 GstRTSPResult gst_rtsp_connection_send (GstRTSPConnection *conn, GstRTSPMessage *message,
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,
374 GST_RTSP_DEPRECATED_FOR (gst_rtsp_connection_receive_usec)
375 GstRTSPResult gst_rtsp_connection_receive (GstRTSPConnection *conn, GstRTSPMessage *message,
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);
382 GST_RTSP_DEPRECATED_FOR (gst_rtsp_connection_next_timeout_usec)
383 GstRTSPResult gst_rtsp_connection_next_timeout (GstRTSPConnection *conn, GTimeVal *timeout);
385 GST_RTSP_DEPRECATED_FOR (gst_rtsp_watch_wait_backlog_usec)
386 GstRTSPResult gst_rtsp_watch_wait_backlog (GstRTSPWatch * watch,
389 G_GNUC_END_IGNORE_DEPRECATIONS
391 #endif /* GST_DISABLE_DEPRECATED */
395 #endif /* __GST_RTSP_CONNECTION_H__ */