b3797b13ceba70ff6160506ad84c99f5db8928d5
[platform/upstream/gstreamer.git] / gst / rtsp-server / rtsp-session.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
22 #include <gst/rtsp/gstrtsptransport.h>
23
24 #include "rtsp-media.h"
25
26 #ifndef __GST_RTSP_SESSION_H__
27 #define __GST_RTSP_SESSION_H__
28
29 G_BEGIN_DECLS
30
31 #define GST_TYPE_RTSP_SESSION              (gst_rtsp_session_get_type ())
32 #define GST_IS_RTSP_SESSION(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_RTSP_SESSION))
33 #define GST_IS_RTSP_SESSION_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_RTSP_SESSION))
34 #define GST_RTSP_SESSION_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTSP_SESSION, GstRTSPSessionClass))
35 #define GST_RTSP_SESSION(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_RTSP_SESSION, GstRTSPSession))
36 #define GST_RTSP_SESSION_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_RTSP_SESSION, GstRTSPSessionClass))
37 #define GST_RTSP_SESSION_CAST(obj)         ((GstRTSPSession*)(obj))
38 #define GST_RTSP_SESSION_CLASS_CAST(klass) ((GstRTSPSessionClass*)(klass))
39
40 typedef struct _GstRTSPSession GstRTSPSession;
41 typedef struct _GstRTSPSessionClass GstRTSPSessionClass;
42
43 typedef struct _GstRTSPSessionStream GstRTSPSessionStream;
44 typedef struct _GstRTSPSessionMedia GstRTSPSessionMedia;
45
46 /**
47  * GstRTSPSessionStream:
48  * @trans: the media transport
49  * @media_stream: the controlled media stream
50  *
51  * Configuration of a stream. A stream is an audio or video stream related to a
52  * media.
53  */
54 struct _GstRTSPSessionStream
55 {
56   GstRTSPMediaTrans trans;
57
58   /* the stream of the media */
59   GstRTSPMediaStream *media_stream;
60 };
61
62 /**
63  * GstRTSPSessionMedia:
64  *
65  * State of a client session regarding a specific media identified by uri.
66  */
67 struct _GstRTSPSessionMedia
68 {
69   /* the url of the media */
70   GstRTSPUrl   *url;
71
72   /* the pipeline for the media */
73   GstRTSPMedia *media;
74
75   /* the server state */
76   GstRTSPState  state;
77
78   /* configuration for the different streams */
79   GArray       *streams;
80 };
81
82 /**
83  * GstRTSPSession:
84  * @sessionid: the session id of the session
85  * @timeout: the timeout of the session
86  * @create_time: the time when the session was created
87  * @last_access: the time the session was last accessed
88  * @media: a list of #GstRTSPSessionMedia managed in this session
89  *
90  * Session information kept by the server for a specific client.
91  * One client session, identified with a session id, can handle multiple medias
92  * identified with the url of a media.
93  */
94 struct _GstRTSPSession {
95   GObject       parent;
96
97   gchar        *sessionid;
98
99   guint         timeout;
100   GTimeVal      create_time;
101   GTimeVal      last_access;
102
103   GList        *medias;
104 };
105
106 struct _GstRTSPSessionClass {
107   GObjectClass  parent_class;
108 };
109
110 GType                  gst_rtsp_session_get_type             (void);
111
112 /* create a new session */
113 GstRTSPSession *       gst_rtsp_session_new                  (const gchar *sessionid);
114
115 const gchar *          gst_rtsp_session_get_sessionid        (GstRTSPSession *session);
116
117 void                   gst_rtsp_session_set_timeout          (GstRTSPSession *session, guint timeout);
118 guint                  gst_rtsp_session_get_timeout          (GstRTSPSession *session);
119
120 /* session timeout stuff */
121 void                   gst_rtsp_session_touch                (GstRTSPSession *session);
122 gint                   gst_rtsp_session_next_timeout         (GstRTSPSession *session, GTimeVal *now);
123 gboolean               gst_rtsp_session_is_expired           (GstRTSPSession *session, GTimeVal *now);
124
125 /* handle media in a session */
126 GstRTSPSessionMedia *  gst_rtsp_session_manage_media         (GstRTSPSession *sess,
127                                                               const GstRTSPUrl *uri,
128                                                               GstRTSPMedia *media);
129 gboolean               gst_rtsp_session_release_media        (GstRTSPSession *sess,
130                                                               GstRTSPSessionMedia *media);
131 /* get media in a session */
132 GstRTSPSessionMedia *  gst_rtsp_session_get_media            (GstRTSPSession *sess,
133                                                               const GstRTSPUrl *uri);
134 /* control media */
135 gboolean               gst_rtsp_session_media_play           (GstRTSPSessionMedia *media);
136 gboolean               gst_rtsp_session_media_pause          (GstRTSPSessionMedia *media);
137 gboolean               gst_rtsp_session_media_stop           (GstRTSPSessionMedia *media);
138
139 /* get stream config */
140 GstRTSPSessionStream * gst_rtsp_session_media_get_stream     (GstRTSPSessionMedia *media,
141                                                               guint idx);
142
143 /* configure transport */
144 GstRTSPTransport *     gst_rtsp_session_stream_set_transport (GstRTSPSessionStream *stream,
145                                                               GstRTSPTransport *ct);
146
147 G_END_DECLS
148
149 #endif /* __GST_RTSP_SESSION_H__ */