add new-session signal to rtsp-client (fixes #683058)
[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., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, 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
32 #include "rtsp-server.h"
33 #include "rtsp-media.h"
34 #include "rtsp-media-mapping.h"
35 #include "rtsp-session-pool.h"
36 #include "rtsp-auth.h"
37 #include "rtsp-sdp.h"
38
39 #define GST_TYPE_RTSP_CLIENT              (gst_rtsp_client_get_type ())
40 #define GST_IS_RTSP_CLIENT(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_RTSP_CLIENT))
41 #define GST_IS_RTSP_CLIENT_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_RTSP_CLIENT))
42 #define GST_RTSP_CLIENT_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTSP_CLIENT, GstRTSPClientClass))
43 #define GST_RTSP_CLIENT(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_RTSP_CLIENT, GstRTSPClient))
44 #define GST_RTSP_CLIENT_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_RTSP_CLIENT, GstRTSPClientClass))
45 #define GST_RTSP_CLIENT_CAST(obj)         ((GstRTSPClient*)(obj))
46 #define GST_RTSP_CLIENT_CLASS_CAST(klass) ((GstRTSPClientClass*)(klass))
47
48 /**
49  * GstRTSPClientState:
50  * @request: the complete request
51  * @uri: the complete url parsed from @request
52  * @method: the parsed method of @uri
53  * @session: the session, can be NULL
54  * @sessmedia: the session media for the url can be NULL
55  * @factory: the media factory for the url, can be NULL.
56  * @media: the session media for the url can be NULL
57  * @response: the response
58  *
59  * Information passed around containing the client state of a request.
60  */
61 struct _GstRTSPClientState{
62   GstRTSPMessage      *request;
63   GstRTSPUrl          *uri;
64   GstRTSPMethod        method;
65   GstRTSPSession      *session;
66   GstRTSPSessionMedia *sessmedia;
67   GstRTSPMediaFactory *factory;
68   GstRTSPMedia        *media;
69   GstRTSPMessage      *response;
70 };
71
72 /**
73  * GstRTSPClient:
74  *
75  * @connection: the connection object handling the client request.
76  * @watch: watch for the connection
77  * @watchid: id of the watch
78  * @ip: ip address used by the client to connect to us
79  * @session_pool: handle to the session pool used by the client.
80  * @media_mapping: handle to the media mapping used by the client.
81  * @uri: cached uri
82  * @media: cached media
83  * @streams: a list of streams using @connection.
84  * @sessions: a list of sessions managed by @connection.
85  *
86  * The client structure.
87  */
88 struct _GstRTSPClient {
89   GObject       parent;
90
91   GstRTSPConnection *connection;
92   GstRTSPWatch      *watch;
93   guint              watchid;
94   gchar             *server_ip;
95   gboolean           is_ipv6;
96
97   GstRTSPServer        *server;
98   GstRTSPSessionPool   *session_pool;
99   GstRTSPMediaMapping  *media_mapping;
100   GstRTSPAuth          *auth;
101
102   GstRTSPUrl     *uri;
103   GstRTSPMedia   *media;
104
105   GList *streams;
106   GList *sessions;
107 };
108
109 struct _GstRTSPClientClass {
110   GObjectClass  parent_class;
111
112   GstSDPMessage * (*create_sdp) (GstRTSPClient *client, GstRTSPMedia *media);
113
114   /* signals */
115   void     (*closed)        (GstRTSPClient *client);
116   void     (*new_session)   (GstRTSPClient *client, GstRTSPSession *session);
117 };
118
119 GType                 gst_rtsp_client_get_type          (void);
120
121 GstRTSPClient *       gst_rtsp_client_new               (void);
122
123 void                  gst_rtsp_client_set_server        (GstRTSPClient * client, GstRTSPServer * server);
124 GstRTSPServer *       gst_rtsp_client_get_server        (GstRTSPClient * client);
125
126 void                  gst_rtsp_client_set_session_pool  (GstRTSPClient *client,
127                                                          GstRTSPSessionPool *pool);
128 GstRTSPSessionPool *  gst_rtsp_client_get_session_pool  (GstRTSPClient *client);
129
130 void                  gst_rtsp_client_set_media_mapping (GstRTSPClient *client,
131                                                          GstRTSPMediaMapping *mapping);
132 GstRTSPMediaMapping * gst_rtsp_client_get_media_mapping (GstRTSPClient *client);
133
134 void                  gst_rtsp_client_set_auth          (GstRTSPClient *client, GstRTSPAuth *auth);
135 GstRTSPAuth *         gst_rtsp_client_get_auth          (GstRTSPClient *client);
136
137
138 gboolean              gst_rtsp_client_accept            (GstRTSPClient *client,
139                                                          GSocket *socket,
140                                                          GCancellable *cancellable,
141                                                          GError **error);
142
143 gboolean              gst_rtsp_client_create_from_socket(GstRTSPClient * client,
144                                                          GSocket *socket,
145                                                          const gchar * ip,
146                                                          gint port,
147                                                          const gchar *initial_buffer,
148                                                          GError **error);
149
150 G_END_DECLS
151
152 #endif /* __GST_RTSP_CLIENT_H__ */