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