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