auth: add support for multiple basic auth tokens
[platform/upstream/gstreamer.git] / gst / rtsp-server / rtsp-client.h
1 /* GStreamer
2  * Copyright (C) 2008 Wim Taymans <wim.taymans at 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 #include <gst/gst.h>
21 #include <gst/rtsp/gstrtspconnection.h>
22
23 #ifndef __GST_RTSP_CLIENT_H__
24 #define __GST_RTSP_CLIENT_H__
25
26 G_BEGIN_DECLS
27
28 typedef struct _GstRTSPClient GstRTSPClient;
29 typedef struct _GstRTSPClientClass GstRTSPClientClass;
30 typedef struct _GstRTSPClientState GstRTSPClientState;
31 typedef struct _GstRTSPClientPrivate GstRTSPClientPrivate;
32
33 #include "rtsp-media.h"
34 #include "rtsp-mount-points.h"
35 #include "rtsp-session-pool.h"
36 #include "rtsp-session-media.h"
37 #include "rtsp-auth.h"
38 #include "rtsp-sdp.h"
39
40 #define GST_TYPE_RTSP_CLIENT              (gst_rtsp_client_get_type ())
41 #define GST_IS_RTSP_CLIENT(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_RTSP_CLIENT))
42 #define GST_IS_RTSP_CLIENT_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_RTSP_CLIENT))
43 #define GST_RTSP_CLIENT_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTSP_CLIENT, GstRTSPClientClass))
44 #define GST_RTSP_CLIENT(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_RTSP_CLIENT, GstRTSPClient))
45 #define GST_RTSP_CLIENT_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_RTSP_CLIENT, GstRTSPClientClass))
46 #define GST_RTSP_CLIENT_CAST(obj)         ((GstRTSPClient*)(obj))
47 #define GST_RTSP_CLIENT_CLASS_CAST(klass) ((GstRTSPClientClass*)(klass))
48
49 /**
50  * GstRTSPClientState:
51  * @request: the complete request
52  * @uri: the complete url parsed from @request
53  * @method: the parsed method of @uri
54  * @authgroup: authorisation group
55  * @session: the session, can be NULL
56  * @sessmedia: the session media for the url can be NULL
57  * @factory: the media factory for the url, can be NULL.
58  * @media: the media for the url can be NULL
59  * @stream: the stream for the url can be NULL
60  * @response: the response
61  *
62  * Information passed around containing the client state of a request.
63  */
64 struct _GstRTSPClientState {
65   GstRTSPMessage      *request;
66   GstRTSPUrl          *uri;
67   GstRTSPMethod        method;
68   const gchar         *authgroup;
69   GstRTSPSession      *session;
70   GstRTSPSessionMedia *sessmedia;
71   GstRTSPMediaFactory *factory;
72   GstRTSPMedia        *media;
73   GstRTSPStream       *stream;
74   GstRTSPMessage      *response;
75 };
76
77 /**
78  * GstRTSPClientSendFunc:
79  * @client: a #GstRTSPClient
80  * @message: a #GstRTSPMessage
81  * @close: close the connection
82  * @user_data: user data when registering the callback
83  *
84  * This callback is called when @client wants to send @message. When @close is
85  * %TRUE, the connection should be closed when the message has been sent.
86  *
87  * Returns: %TRUE on success.
88  */
89 typedef gboolean (*GstRTSPClientSendFunc)      (GstRTSPClient *client,
90                                                 GstRTSPMessage *message,
91                                                 gboolean close,
92                                                 gpointer user_data);
93
94 /**
95  * GstRTSPClient:
96  *
97  * The client structure.
98  */
99 struct _GstRTSPClient {
100   GObject       parent;
101
102   GstRTSPClientPrivate *priv;
103 };
104
105 /**
106  * GstRTSPClientClass:
107  * @params_set: set parameters. This function should also initialize the
108  * RTSP response(state->response) via a call to gst_rtsp_message_init_response()
109  * @params_get: get parameters. This function should also initialize the
110  * RTSP response(state->response) via a call to gst_rtsp_message_init_response()
111  *
112  * The client class structure.
113  */
114 struct _GstRTSPClientClass {
115   GObjectClass  parent_class;
116
117   GstSDPMessage * (*create_sdp) (GstRTSPClient *client, GstRTSPMedia *media);
118   gboolean        (*configure_client_transport) (GstRTSPClient * client,
119                                                  GstRTSPClientState * state,
120                                                  GstRTSPTransport * ct);
121   GstRTSPResult   (*params_set) (GstRTSPClient *client, GstRTSPClientState *state);
122   GstRTSPResult   (*params_get) (GstRTSPClient *client, GstRTSPClientState *state);
123
124   /* signals */
125   void     (*closed)                  (GstRTSPClient *client);
126   void     (*new_session)             (GstRTSPClient *client, GstRTSPSession *session);
127   void     (*options_request)         (GstRTSPClient *client, GstRTSPClientState *state);
128   void     (*describe_request)        (GstRTSPClient *client, GstRTSPClientState *state);
129   void     (*setup_request)           (GstRTSPClient *client, GstRTSPClientState *state);
130   void     (*play_request)            (GstRTSPClient *client, GstRTSPClientState *state);
131   void     (*pause_request)           (GstRTSPClient *client, GstRTSPClientState *state);
132   void     (*teardown_request)        (GstRTSPClient *client, GstRTSPClientState *state);
133   void     (*set_parameter_request)   (GstRTSPClient *client, GstRTSPClientState *state);
134   void     (*get_parameter_request)   (GstRTSPClient *client, GstRTSPClientState *state);
135 };
136
137 GType                 gst_rtsp_client_get_type          (void);
138
139 GstRTSPClient *       gst_rtsp_client_new               (void);
140
141 void                  gst_rtsp_client_set_session_pool  (GstRTSPClient *client,
142                                                          GstRTSPSessionPool *pool);
143 GstRTSPSessionPool *  gst_rtsp_client_get_session_pool  (GstRTSPClient *client);
144
145 void                  gst_rtsp_client_set_mount_points  (GstRTSPClient *client,
146                                                          GstRTSPMountPoints *mounts);
147 GstRTSPMountPoints *  gst_rtsp_client_get_mount_points  (GstRTSPClient *client);
148
149 void                  gst_rtsp_client_set_use_client_settings (GstRTSPClient * client,
150                                                                gboolean use_client_settings);
151 gboolean              gst_rtsp_client_get_use_client_settings (GstRTSPClient * client);
152
153 void                  gst_rtsp_client_set_auth          (GstRTSPClient *client, GstRTSPAuth *auth);
154 GstRTSPAuth *         gst_rtsp_client_get_auth          (GstRTSPClient *client);
155
156 gboolean              gst_rtsp_client_set_connection    (GstRTSPClient *client, GstRTSPConnection *conn);
157 GstRTSPConnection *   gst_rtsp_client_get_connection    (GstRTSPClient *client);
158
159 void                  gst_rtsp_client_set_send_func     (GstRTSPClient *client,
160                                                          GstRTSPClientSendFunc func,
161                                                          gpointer user_data,
162                                                          GDestroyNotify notify);
163 GstRTSPResult         gst_rtsp_client_handle_message    (GstRTSPClient *client,
164                                                          GstRTSPMessage *message);
165
166 GstRTSPResult         gst_rtsp_client_send_request      (GstRTSPClient * client,
167                                                          GstRTSPSession *session,
168                                                          GstRTSPMessage *request);
169 guint                 gst_rtsp_client_attach            (GstRTSPClient *client,
170                                                          GMainContext *context);
171
172 /**
173  * GstRTSPClientSessionFilterFunc:
174  * @client: a #GstRTSPClient object
175  * @sess: a #GstRTSPSession in @client
176  * @user_data: user data that has been given to gst_rtsp_client_session_filter()
177  *
178  * This function will be called by the gst_rtsp_client_session_filter(). An
179  * implementation should return a value of #GstRTSPFilterResult.
180  *
181  * When this function returns #GST_RTSP_FILTER_REMOVE, @sess will be removed
182  * from @client.
183  *
184  * A return value of #GST_RTSP_FILTER_KEEP will leave @sess untouched in
185  * @client.
186  *
187  * A value of GST_RTSP_FILTER_REF will add @sess to the result #GList of
188  * gst_rtsp_client_session_filter().
189  *
190  * Returns: a #GstRTSPFilterResult.
191  */
192 typedef GstRTSPFilterResult (*GstRTSPClientSessionFilterFunc)  (GstRTSPClient *client,
193                                                                 GstRTSPSession *sess,
194                                                                 gpointer user_data);
195
196 GList *                gst_rtsp_client_session_filter    (GstRTSPClient *client,
197                                                           GstRTSPClientSessionFilterFunc func,
198                                                           gpointer user_data);
199
200
201
202 G_END_DECLS
203
204 #endif /* __GST_RTSP_CLIENT_H__ */