Merge remote-tracking branch 'origin/master' into 0.11
[platform/upstream/gstreamer.git] / gst-libs / gst / rtsp / gstrtspconnection.h
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., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, 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 GstRTSPResult      gst_rtsp_connection_create         (const GstRTSPUrl *url, GstRTSPConnection **conn);
65 GstRTSPResult      gst_rtsp_connection_create_from_socket (GSocket * socket,
66                                                        const gchar * ip,
67                                                        guint16 port,
68                                                        const gchar * initial_buffer,
69                                                        GstRTSPConnection ** conn);
70 GstRTSPResult      gst_rtsp_connection_accept         (GSocket *socket, GstRTSPConnection **conn, GCancellable *cancellable);
71 GstRTSPResult      gst_rtsp_connection_connect        (GstRTSPConnection *conn, GTimeVal *timeout);
72 GstRTSPResult      gst_rtsp_connection_close          (GstRTSPConnection *conn);
73 GstRTSPResult      gst_rtsp_connection_free           (GstRTSPConnection *conn);
74
75
76 /* sending/receiving raw bytes */
77 GstRTSPResult      gst_rtsp_connection_read           (GstRTSPConnection * conn, guint8 * data,
78                                                        guint size, GTimeVal * timeout);
79 GstRTSPResult      gst_rtsp_connection_write          (GstRTSPConnection * conn, const guint8 * data,
80                                                        guint size, GTimeVal * timeout);
81
82 /* sending/receiving messages */
83 GstRTSPResult      gst_rtsp_connection_send           (GstRTSPConnection *conn, GstRTSPMessage *message,
84                                                        GTimeVal *timeout);
85 GstRTSPResult      gst_rtsp_connection_receive        (GstRTSPConnection *conn, GstRTSPMessage *message,
86                                                        GTimeVal *timeout);
87
88 /* status management */
89 GstRTSPResult      gst_rtsp_connection_poll           (GstRTSPConnection *conn, GstRTSPEvent events,
90                                                        GstRTSPEvent *revents, GTimeVal *timeout);
91
92 /* reset the timeout */
93 GstRTSPResult      gst_rtsp_connection_next_timeout   (GstRTSPConnection *conn, GTimeVal *timeout);
94 GstRTSPResult      gst_rtsp_connection_reset_timeout  (GstRTSPConnection *conn);
95
96 /* flushing state */
97 GstRTSPResult      gst_rtsp_connection_flush          (GstRTSPConnection *conn, gboolean flush);
98
99 /* HTTP proxy support */
100 GstRTSPResult      gst_rtsp_connection_set_proxy      (GstRTSPConnection *conn,
101                                                        const gchar *host, guint port);
102
103 /* configure authentication data */
104 GstRTSPResult      gst_rtsp_connection_set_auth       (GstRTSPConnection *conn, GstRTSPAuthMethod method,
105                                                        const gchar *user, const gchar *pass);
106
107 void               gst_rtsp_connection_set_auth_param    (GstRTSPConnection *conn,
108                                                           const gchar * param,
109                                                           const gchar *value);
110 void               gst_rtsp_connection_clear_auth_params (GstRTSPConnection *conn);
111
112 /* configure DSCP */
113 GstRTSPResult      gst_rtsp_connection_set_qos_dscp   (GstRTSPConnection *conn,
114                                                        guint qos_dscp);
115
116 /* accessors */
117 GstRTSPUrl *       gst_rtsp_connection_get_url        (const GstRTSPConnection *conn);
118 const gchar *      gst_rtsp_connection_get_ip         (const GstRTSPConnection *conn);
119 void               gst_rtsp_connection_set_ip         (GstRTSPConnection *conn, const gchar *ip);
120
121 GSocket *          gst_rtsp_connection_get_read_socket  (const GstRTSPConnection *conn);
122 GSocket *          gst_rtsp_connection_get_write_socket (const GstRTSPConnection *conn);
123
124 void               gst_rtsp_connection_set_http_mode  (GstRTSPConnection *conn,
125                                                        gboolean enable);
126
127 /* tunneling */
128 void               gst_rtsp_connection_set_tunneled   (GstRTSPConnection *conn, gboolean tunneled);
129 gboolean           gst_rtsp_connection_is_tunneled    (const GstRTSPConnection *conn);
130
131 const gchar *      gst_rtsp_connection_get_tunnelid   (const GstRTSPConnection *conn);
132 GstRTSPResult      gst_rtsp_connection_do_tunnel      (GstRTSPConnection *conn, GstRTSPConnection *conn2);
133
134 /* async IO */
135
136 /**
137  * GstRTSPWatch:
138  *
139  * Opaque RTSP watch object that can be used for asynchronous RTSP
140  * operations.
141  */
142 typedef struct _GstRTSPWatch GstRTSPWatch;
143
144 /**
145  * GstRTSPWatchFuncs:
146  * @message_received: callback when a message was received
147  * @message_sent: callback when a message was sent
148  * @closed: callback when the connection is closed
149  * @error: callback when an error occured
150  * @tunnel_start: a client started a tunneled connection. The tunnelid of the
151  *   connection must be saved.
152  * @tunnel_complete: a client finished a tunneled connection. In this callback
153  *   you usually pair the tunnelid of this connection with the saved one using
154  *   gst_rtsp_connection_do_tunnel().
155  * @error_full: callback when an error occured with more information than
156  *   the @error callback. Since 0.10.25
157  * @tunnel_lost: callback when the post connection of a tunnel is closed.
158  *   Since 0.10.29
159  *
160  * Callback functions from a #GstRTSPWatch.
161  *
162  * Since: 0.10.23
163  */
164 typedef struct {
165   GstRTSPResult     (*message_received) (GstRTSPWatch *watch, GstRTSPMessage *message,
166                                          gpointer user_data);
167   GstRTSPResult     (*message_sent)     (GstRTSPWatch *watch, guint id,
168                                          gpointer user_data);
169   GstRTSPResult     (*closed)           (GstRTSPWatch *watch, gpointer user_data);
170   GstRTSPResult     (*error)            (GstRTSPWatch *watch, GstRTSPResult result,
171                                          gpointer user_data);
172   GstRTSPStatusCode (*tunnel_start)     (GstRTSPWatch *watch, gpointer user_data);
173   GstRTSPResult     (*tunnel_complete)  (GstRTSPWatch *watch, gpointer user_data);
174   GstRTSPResult     (*error_full)       (GstRTSPWatch *watch, GstRTSPResult result,
175                                          GstRTSPMessage *message, guint id,
176                                          gpointer user_data);
177   GstRTSPResult     (*tunnel_lost)      (GstRTSPWatch *watch, gpointer user_data);
178
179   /*< private >*/
180   gpointer _gst_reserved[GST_PADDING];
181 } GstRTSPWatchFuncs;
182
183 GstRTSPWatch *     gst_rtsp_watch_new                (GstRTSPConnection *conn,
184                                                       GstRTSPWatchFuncs *funcs,
185                                                       gpointer user_data,
186                                                       GDestroyNotify notify);
187 void               gst_rtsp_watch_reset              (GstRTSPWatch *watch);
188 void               gst_rtsp_watch_unref              (GstRTSPWatch *watch);
189
190 guint              gst_rtsp_watch_attach             (GstRTSPWatch *watch,
191                                                       GMainContext *context);
192
193 GstRTSPResult      gst_rtsp_watch_write_data         (GstRTSPWatch *watch,
194                                                       const guint8 *data,
195                                                       guint size, guint *id);
196 GstRTSPResult      gst_rtsp_watch_send_message       (GstRTSPWatch *watch,
197                                                       GstRTSPMessage *message,
198                                                       guint *id);
199
200 G_END_DECLS
201
202 #endif /* __GST_RTSP_CONNECTION_H__ */