209637ba7b6e64ca5126fdca5fdc59853cd2075a
[platform/core/multimedia/gst-rtsp-server-wfd.git] / src / include / rtsp-client.h
1 /* GStreamer
2  * Copyright (C) 2008 Wim Taymans <wim.taymans at gmail.com>
3
4 * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  *
21
22 * * Modifications by Samsung Electronics Co., Ltd.
23
24 * 1. Applied Miracast WFD Server function
25 */
26
27 #include <gst/gst.h>
28 #include <gst/rtsp/gstrtspconnection.h>
29
30
31 #ifndef __GST_RTSP_CLIENT_H__
32 #define __GST_RTSP_CLIENT_H__
33
34 G_BEGIN_DECLS
35
36 typedef struct _GstRTSPClient GstRTSPClient;
37 typedef struct _GstRTSPClientClass GstRTSPClientClass;
38 typedef struct _GstRTSPClientState GstRTSPClientState;
39 typedef struct _GstRTSPClientSrcBin GstRTSPClientSrcBin;
40
41 #include "wfdconfigmessage.h"
42 #include "rtsp-server.h"
43 #include "rtsp-media.h"
44 #include "rtsp-media-mapping.h"
45 #include "rtsp-session-pool.h"
46 #include "rtsp-auth.h"
47
48 #define GST_TYPE_RTSP_CLIENT              (gst_rtsp_client_get_type ())
49 #define GST_IS_RTSP_CLIENT(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_RTSP_CLIENT))
50 #define GST_IS_RTSP_CLIENT_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_RTSP_CLIENT))
51 #define GST_RTSP_CLIENT_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTSP_CLIENT, GstRTSPClientClass))
52 #define GST_RTSP_CLIENT(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_RTSP_CLIENT, GstRTSPClient))
53 #define GST_RTSP_CLIENT_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_RTSP_CLIENT, GstRTSPClientClass))
54 #define GST_RTSP_CLIENT_CAST(obj)         ((GstRTSPClient*)(obj))
55 #define GST_RTSP_CLIENT_CLASS_CAST(klass) ((GstRTSPClientClass*)(klass))
56
57 typedef enum {
58   CLIENT_STATE_UNKNOWN = -1,
59   CLIENT_STATE_CONNECTING = 0,
60   CLIENT_STATE_CONNECTED = 1,
61 }ClientState;
62
63 typedef enum {
64   WFD_MESSAGE_UNKNOWN,
65   WFD_MESSAGE_1,
66   WFD_MESSAGE_2,
67   WFD_MESSAGE_3,
68   WFD_MESSAGE_4,
69   WFD_MESSAGE_5,
70   WFD_MESSAGE_6,
71   WFD_MESSAGE_7,
72   WFD_MESSAGE_8,
73   WFD_MESSAGE_9,
74   WFD_MESSAGE_10,
75   WFD_MESSAGE_11,
76   WFD_MESSAGE_12,
77   WFD_MESSAGE_13,
78   WFD_MESSAGE_14,
79   WFD_MESSAGE_15,
80   WFD_MESSAGE_16,
81 }WFDMessageType;
82
83 typedef enum __wfd_ini_videosink_element
84 {
85   WFD_INI_VSINK_V4l2SINK = 0,
86   WFD_INI_VSINK_XIMAGESINK,
87   WFD_INI_VSINK_XVIMAGESINK,
88   WFD_INI_VSINK_FAKESINK,
89   WFD_INI_VSINK_EVASIMAGESINK,
90   WFD_INI_VSINK_GLIMAGESINK,
91   WFD_INI_VSINK_NUM
92 }WFD_INI_VSINK_ELEMENT;
93
94 typedef enum __wfd_ini_videosrc_element
95 {
96   WFD_INI_VSRC_XVIMAGESRC,
97   WFD_INI_VSRC_FILESRC,
98   WFD_INI_VSRC_CAMERASRC,
99   WFD_INI_VSRC_VIDEOTESTSRC,
100   WFD_INI_VSRC_NUM
101 }WFD_INI_VSRC_ELEMENT;
102
103 typedef enum __wfd_ini_session_mode
104 {
105   WFD_INI_AUDIO_VIDEO_MUXED,
106   WFD_INI_VIDEO_ONLY,
107   WFD_INI_AUDIO_ONLY,
108   WFD_INI_AUDIO_VIDEO_SAPERATE
109 }WFD_INI_SESSION_MODE;
110
111 /**
112  * GstRTSPClientState:
113  * @request: the complete request
114  * @uri: the complete url parsed from @request
115  * @method: the parsed method of @uri
116  * @session: the session, can be NULL
117  * @sessmedia: the session media for the url can be NULL
118  * @factory: the media factory for the url, can be NULL.
119  * @media: the session media for the url can be NULL
120  * @response: the response
121  *
122  * Information passed around containing the client state of a request.
123  */
124 struct _GstRTSPClientState{
125   GstRTSPMessage      *request;
126   GstRTSPUrl          *uri;
127   GstRTSPMethod        method;
128   GstRTSPSession      *session;
129   GstRTSPSessionMedia *sessmedia;
130   GstRTSPMediaFactory *factory;
131   GstRTSPMedia        *media;
132   GstRTSPMessage      *response;
133 };
134
135 struct _GstRTSPClientSrcBin{
136   GstBin *srcbin;
137   GstElement *vqueue;
138   GstElement *aqueue;
139   GstElement *tee_0;
140   GstElement *venc;
141   GstPad *mux_vsinkpad;
142   GstPad *mux_asinkpad;
143   GstElement *vparse;
144
145 };
146
147 /**
148  * GstRTSPClient:
149  *
150  * @connection: the connection object handling the client request.
151  * @watch: watch for the connection
152  * @watchid: id of the watch
153  * @ip: ip address used by the client to connect to us
154  * @session_pool: handle to the session pool used by the client.
155  * @media_mapping: handle to the media mapping used by the client.
156  * @uri: cached uri
157  * @media: cached media
158  * @streams: a list of streams using @connection.
159  * @sessions: a list of sessions managed by @connection.
160  *
161  * The client structure.
162  */
163 struct _GstRTSPClient {
164   GObject       parent;
165
166   GstRTSPConnection *connection;
167   GstRTSPWatch      *watch;
168   guint            watchid;
169   gchar           *server_ip;
170   gboolean      is_ipv6;
171   gchar         *wfdsink_ip;
172
173   GstRTSPServer        *server;
174   GstRTSPSessionPool   *session_pool;
175   gchar * sessionid;
176   GstRTSPMediaMapping  *media_mapping;
177   GstRTSPAuth          *auth;
178
179   GstRTSPUrl     *uri;
180   GstRTSPMedia   *media;
181
182   GList *streams;
183   GList *sessions;
184
185   /* supported methods */
186   gint               methods;
187
188   GstRTSPClientSrcBin *srcbin;
189
190   int videosrc_type;
191   gint session_mode;
192   gchar *infile;
193
194   GMutex *state_lock;
195   GCond *state_wait;
196   ClientState client_state;
197
198   WFDAudioFormats caCodec;
199   WFDAudioFreq cFreq;
200   WFDAudioChannels cChanels;
201   guint cBitwidth;
202   guint caLatency;
203   WFDVideoCodecs cvCodec;
204   WFDVideoNativeResolution cNative;
205   guint64 cNativeResolution;
206   WFDVideoCEAResolution cCEAResolution;
207   WFDVideoVESAResolution cVESAResolution;
208   WFDVideoHHResolution cHHResolution;
209   WFDVideoH264Profile cProfile;
210   WFDVideoH264Level cLevel;
211   guint32 cMaxHeight;
212   guint32 cMaxWidth;
213   guint32 cmin_slice_size;
214   guint32 cslice_enc_params;
215   guint cframe_rate_control;
216   guint bitrate;
217   guint MTUsize;
218   guint cvLatency;
219   WFDRTSPTransMode ctrans;
220   WFDRTSPProfile cprofile;
221   WFDRTSPLowerTrans clowertrans;
222   guint32 crtp_port0;
223   guint32 crtp_port1;
224   gint tcpsock;
225   gchar *sessionID;
226   WFDHDCPProtection hdcp_version;
227   guint32 hdcp_tcpport;
228   gboolean hdcp_support;
229 #ifdef STANDBY_RESUME_CAPABILITY
230   gboolean standby_resume_capability_support;
231 #endif
232   guint cseq;
233   gboolean keep_alive_flag;
234   GMutex *keep_alive_lock;
235
236 };
237
238 struct _GstRTSPClientClass {
239   GObjectClass  parent_class;
240
241   /* signals */
242   void     (*closed)        (GstRTSPClient *client);
243   void     (*on_error)      (GstRTSPClient *client);
244 };
245
246 GType                 gst_rtsp_client_get_type          (void);
247
248 GstRTSPClient *       gst_rtsp_client_new               (void);
249
250 void                  gst_rtsp_client_set_server        (GstRTSPClient * client, GstRTSPServer * server);
251 GstRTSPServer *       gst_rtsp_client_get_server        (GstRTSPClient * client);
252
253 void                  gst_rtsp_client_set_session_pool  (GstRTSPClient *client,
254                                                          GstRTSPSessionPool *pool);
255 GstRTSPSessionPool *  gst_rtsp_client_get_session_pool  (GstRTSPClient *client);
256
257 void                  gst_rtsp_client_set_media_mapping (GstRTSPClient *client,
258                                                          GstRTSPMediaMapping *mapping);
259 GstRTSPMediaMapping * gst_rtsp_client_get_media_mapping (GstRTSPClient *client);
260
261 void                  gst_rtsp_client_set_auth          (GstRTSPClient *client, GstRTSPAuth *auth);
262 GstRTSPAuth *         gst_rtsp_client_get_auth          (GstRTSPClient *client);
263
264 #if 0
265 gboolean              gst_rtsp_client_accept            (GstRTSPClient *client, int sock);
266 #else
267 gboolean
268 gst_rtsp_client_accept (GstRTSPClient * client, GIOChannel * channel, GSource *source);
269 #endif
270 gboolean gst_rtsp_client_negotiate (GstRTSPClient * client);
271 gboolean gst_rtsp_client_start (GstRTSPClient * client);
272 gboolean gst_rtsp_client_pause (GstRTSPClient * client);
273 gboolean gst_rtsp_client_resume (GstRTSPClient * client);
274 gboolean gst_rtsp_client_standby (GstRTSPClient * client);
275 gboolean gst_rtsp_client_stop (GstRTSPClient * client);
276 void gst_rtsp_client_set_params (GstRTSPClient *client, int videosrc_type, gint session_mode, int videobitrate, gint mtu_size, gchar *infile);
277
278 G_END_DECLS
279
280 #endif /* __GST_RTSP_CLIENT_H__ */