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