factory-uri: add some debug
[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., 51 Franklin St, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19
20 #include <gst/gst.h>
21
22 #include <gst/rtsp/gstrtsptransport.h>
23
24 #ifndef __GST_RTSP_SESSION_H__
25 #define __GST_RTSP_SESSION_H__
26
27 G_BEGIN_DECLS
28
29 #define GST_TYPE_RTSP_SESSION              (gst_rtsp_session_get_type ())
30 #define GST_IS_RTSP_SESSION(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_RTSP_SESSION))
31 #define GST_IS_RTSP_SESSION_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_RTSP_SESSION))
32 #define GST_RTSP_SESSION_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTSP_SESSION, GstRTSPSessionClass))
33 #define GST_RTSP_SESSION(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_RTSP_SESSION, GstRTSPSession))
34 #define GST_RTSP_SESSION_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_RTSP_SESSION, GstRTSPSessionClass))
35 #define GST_RTSP_SESSION_CAST(obj)         ((GstRTSPSession*)(obj))
36 #define GST_RTSP_SESSION_CLASS_CAST(klass) ((GstRTSPSessionClass*)(klass))
37
38 typedef struct _GstRTSPSession GstRTSPSession;
39 typedef struct _GstRTSPSessionClass GstRTSPSessionClass;
40
41 #include "rtsp-media.h"
42 #include "rtsp-session-media.h"
43
44 /**
45  * GstRTSPSession:
46  * @parent: the parent GObject
47  * @sessionid: the session id of the session
48  * @timeout: the timeout of the session
49  * @create_time: the time when the session was created
50  * @last_access: the time the session was last accessed
51  * @expire_count: the expire prevention counter
52  * @medias: a list of #GstRTSPSessionMedia managed in this session
53  *
54  * Session information kept by the server for a specific client.
55  * One client session, identified with a session id, can handle multiple medias
56  * identified with the url of a media.
57  */
58 struct _GstRTSPSession {
59   GObject       parent;
60
61   GMutex        lock;
62   gchar        *sessionid;
63
64   guint         timeout;
65   GTimeVal      create_time;
66   GTimeVal      last_access;
67   gint          expire_count;
68
69   GList        *medias;
70 };
71
72 struct _GstRTSPSessionClass {
73   GObjectClass  parent_class;
74 };
75
76 GType                  gst_rtsp_session_get_type             (void);
77
78 /* create a new session */
79 GstRTSPSession *       gst_rtsp_session_new                  (const gchar *sessionid);
80
81 const gchar *          gst_rtsp_session_get_sessionid        (GstRTSPSession *session);
82
83 gchar *                gst_rtsp_session_get_header           (GstRTSPSession *session);
84
85 void                   gst_rtsp_session_set_timeout          (GstRTSPSession *session, guint timeout);
86 guint                  gst_rtsp_session_get_timeout          (GstRTSPSession *session);
87
88 /* session timeout stuff */
89 void                   gst_rtsp_session_touch                (GstRTSPSession *session);
90 void                   gst_rtsp_session_prevent_expire       (GstRTSPSession *session);
91 void                   gst_rtsp_session_allow_expire         (GstRTSPSession *session);
92 gint                   gst_rtsp_session_next_timeout         (GstRTSPSession *session, GTimeVal *now);
93 gboolean               gst_rtsp_session_is_expired           (GstRTSPSession *session, GTimeVal *now);
94
95 /* handle media in a session */
96 GstRTSPSessionMedia *  gst_rtsp_session_manage_media         (GstRTSPSession *sess,
97                                                               const GstRTSPUrl *uri,
98                                                               GstRTSPMedia *media);
99 gboolean               gst_rtsp_session_release_media        (GstRTSPSession *sess,
100                                                               GstRTSPSessionMedia *media);
101 /* get media in a session */
102 GstRTSPSessionMedia *  gst_rtsp_session_get_media            (GstRTSPSession *sess,
103                                                               const GstRTSPUrl *url);
104
105 G_END_DECLS
106
107 #endif /* __GST_RTSP_SESSION_H__ */