Initial release including wifi display based on gst-rtsp-server-1.4.1
[platform/upstream/gst-rtsp-server.git] / gst / rtsp-server / rtsp-session-pool.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 #ifndef __GST_RTSP_SESSION_POOL_H__
23 #define __GST_RTSP_SESSION_POOL_H__
24
25 G_BEGIN_DECLS
26
27 typedef struct _GstRTSPSessionPool GstRTSPSessionPool;
28 typedef struct _GstRTSPSessionPoolClass GstRTSPSessionPoolClass;
29 typedef struct _GstRTSPSessionPoolPrivate GstRTSPSessionPoolPrivate;
30
31 #include "rtsp-session.h"
32
33 #define GST_TYPE_RTSP_SESSION_POOL              (gst_rtsp_session_pool_get_type ())
34 #define GST_IS_RTSP_SESSION_POOL(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_RTSP_SESSION_POOL))
35 #define GST_IS_RTSP_SESSION_POOL_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_RTSP_SESSION_POOL))
36 #define GST_RTSP_SESSION_POOL_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTSP_SESSION_POOL, GstRTSPSessionPoolClass))
37 #define GST_RTSP_SESSION_POOL(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_RTSP_SESSION_POOL, GstRTSPSessionPool))
38 #define GST_RTSP_SESSION_POOL_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_RTSP_SESSION_POOL, GstRTSPSessionPoolClass))
39 #define GST_RTSP_SESSION_POOL_CAST(obj)         ((GstRTSPSessionPool*)(obj))
40 #define GST_RTSP_SESSION_POOL_CLASS_CAST(klass) ((GstRTSPSessionPoolClass*)(klass))
41
42 /**
43  * GstRTSPSessionPool:
44  *
45  * An object that keeps track of the active sessions. This object is usually
46  * attached to a #GstRTSPServer object to manage the sessions in that server.
47  */
48 struct _GstRTSPSessionPool {
49   GObject       parent;
50
51   /*< private >*/
52   GstRTSPSessionPoolPrivate *priv;
53   gpointer _gst_reserved[GST_PADDING];
54 };
55
56 /**
57  * GstRTSPSessionPoolClass:
58  * @create_session_id: create a new random session id. Subclasses can create
59  *    custom session ids and should not check if the session exists.
60  * @create_session: make a new session object.
61  * @session_removed: a session was removed from the pool
62  */
63 struct _GstRTSPSessionPoolClass {
64   GObjectClass  parent_class;
65
66   gchar *          (*create_session_id)   (GstRTSPSessionPool *pool);
67   GstRTSPSession * (*create_session)      (GstRTSPSessionPool *pool, const gchar *id);
68
69   /* signals */
70   void             (*session_removed)     (GstRTSPSessionPool *pool,
71                                            GstRTSPSession *session);
72
73   /*< private >*/
74   gpointer _gst_reserved[GST_PADDING_LARGE - 1];
75 };
76
77 /**
78  * GstRTSPSessionPoolFunc:
79  * @pool: a #GstRTSPSessionPool object
80  * @user_data: user data that has been given when registering the handler
81  *
82  * The function that will be called from the GSource watch on the session pool.
83  *
84  * The function will be called when the pool must be cleaned up because one or
85  * more sessions timed out.
86  *
87  * Returns: %FALSE if the source should be removed.
88  */
89 typedef gboolean (*GstRTSPSessionPoolFunc)  (GstRTSPSessionPool *pool, gpointer user_data);
90
91 /**
92  * GstRTSPSessionPoolFilterFunc:
93  * @pool: a #GstRTSPSessionPool object
94  * @session: a #GstRTSPSession in @pool
95  * @user_data: user data that has been given to gst_rtsp_session_pool_filter()
96  *
97  * This function will be called by the gst_rtsp_session_pool_filter(). An
98  * implementation should return a value of #GstRTSPFilterResult.
99  *
100  * When this function returns #GST_RTSP_FILTER_REMOVE, @session will be removed
101  * from @pool.
102  *
103  * A return value of #GST_RTSP_FILTER_KEEP will leave @session untouched in
104  * @pool.
105  *
106  * A value of GST_RTSP_FILTER_REF will add @session to the result #GList of
107  * gst_rtsp_session_pool_filter().
108  *
109  * Returns: a #GstRTSPFilterResult.
110  */
111 typedef GstRTSPFilterResult (*GstRTSPSessionPoolFilterFunc)  (GstRTSPSessionPool *pool,
112                                                               GstRTSPSession *session,
113                                                               gpointer user_data);
114
115
116 GType                 gst_rtsp_session_pool_get_type          (void);
117
118 /* creating a session pool */
119 GstRTSPSessionPool *  gst_rtsp_session_pool_new               (void);
120
121 /* counting sessions */
122 void                  gst_rtsp_session_pool_set_max_sessions  (GstRTSPSessionPool *pool, guint max);
123 guint                 gst_rtsp_session_pool_get_max_sessions  (GstRTSPSessionPool *pool);
124
125 guint                 gst_rtsp_session_pool_get_n_sessions    (GstRTSPSessionPool *pool);
126
127 /* managing sessions */
128 GstRTSPSession *      gst_rtsp_session_pool_create            (GstRTSPSessionPool *pool);
129 GstRTSPSession *      gst_rtsp_session_pool_find              (GstRTSPSessionPool *pool,
130                                                                const gchar *sessionid);
131 gboolean              gst_rtsp_session_pool_remove            (GstRTSPSessionPool *pool,
132                                                                GstRTSPSession *sess);
133
134 /* perform session maintenance */
135 GList *               gst_rtsp_session_pool_filter            (GstRTSPSessionPool *pool,
136                                                                GstRTSPSessionPoolFilterFunc func,
137                                                                gpointer user_data);
138 guint                 gst_rtsp_session_pool_cleanup           (GstRTSPSessionPool *pool);
139 GSource *             gst_rtsp_session_pool_create_watch      (GstRTSPSessionPool *pool);
140
141 G_END_DECLS
142
143 #endif /* __GST_RTSP_SESSION_POOL_H__ */