2 * Copyright (C) 2008 Wim Taymans <wim.taymans at gmail.com>
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.
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.
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.
22 #ifndef __GST_RTSP_SESSION_POOL_H__
23 #define __GST_RTSP_SESSION_POOL_H__
28 typedef struct _GstRTSPSessionPool GstRTSPSessionPool;
29 typedef struct _GstRTSPSessionPoolClass GstRTSPSessionPoolClass;
31 #include "rtsp-session.h"
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))
44 * @max_sessions: the maximum number of sessions.
45 * @lock: locking the session hashtable
46 * @sessions: hashtable of sessions indexed by the session id.
48 * An object that keeps track of the active sessions. This object is usually
49 * attached to a #GstRTSPServer object to manage the sessions in that server.
51 struct _GstRTSPSessionPool {
61 * GstRTSPSessionPoolClass:
62 * @create_session_id: create a new random session id. Subclasses can create
63 * custom session ids and should not check if the session exists.
65 struct _GstRTSPSessionPoolClass {
66 GObjectClass parent_class;
68 gchar * (*create_session_id) (GstRTSPSessionPool *pool);
72 * GstRTSPSessionPoolFunc:
73 * @pool: a #GstRTSPSessionPool object
74 * @user_data: user data that has been given when registering the handler
76 * The function that will be called from the GSource watch on the session pool.
78 * The function will be called when the pool must be cleaned up because one or
79 * more sessions timed out.
81 * Returns: %FALSE if the source should be removed.
83 typedef gboolean (*GstRTSPSessionPoolFunc) (GstRTSPSessionPool *pool, gpointer user_data);
86 * GstRTSPFilterResult:
87 * @GST_RTSP_FILTER_REMOVE: Remove session
88 * @GST_RTSP_FILTER_KEEP: Keep session in the pool
89 * @GST_RTSP_FILTER_REF: Ref session in the result list
91 * Possible return values for gst_rtsp_session_pool_filter().
95 GST_RTSP_FILTER_REMOVE,
98 } GstRTSPFilterResult;
101 * GstRTSPSessionFilterFunc:
102 * @pool: a #GstRTSPSessionPool object
103 * @session: a #GstRTSPSession in @pool
104 * @user_data: user data that has been given to gst_rtsp_session_pool_filter()
106 * This function will be called by the gst_rtsp_session_pool_filter(). An
107 * implementation should return a value of #GstRTSPFilterResult.
109 * When this function returns #GST_RTSP_FILTER_REMOVE, @session will be removed
112 * A return value of #GST_RTSP_FILTER_KEEP will leave @session untouched in
115 * A value of GST_RTSP_FILTER_REF will add @session to the result #GList of
116 * gst_rtsp_session_pool_filter().
118 * Returns: a #GstRTSPFilterResult.
120 typedef GstRTSPFilterResult (*GstRTSPSessionFilterFunc) (GstRTSPSessionPool *pool,
121 GstRTSPSession *session,
125 GType gst_rtsp_session_pool_get_type (void);
127 /* creating a session pool */
128 GstRTSPSessionPool * gst_rtsp_session_pool_new (void);
130 /* counting sessionss */
131 void gst_rtsp_session_pool_set_max_sessions (GstRTSPSessionPool *pool, guint max);
132 guint gst_rtsp_session_pool_get_max_sessions (GstRTSPSessionPool *pool);
134 guint gst_rtsp_session_pool_get_n_sessions (GstRTSPSessionPool *pool);
136 /* managing sessions */
137 GstRTSPSession * gst_rtsp_session_pool_create (GstRTSPSessionPool *pool);
138 GstRTSPSession * gst_rtsp_session_pool_find (GstRTSPSessionPool *pool,
139 const gchar *sessionid);
140 gboolean gst_rtsp_session_pool_remove (GstRTSPSessionPool *pool,
141 GstRTSPSession *sess);
143 /* perform session maintenance */
144 GList * gst_rtsp_session_pool_filter (GstRTSPSessionPool *pool,
145 GstRTSPSessionFilterFunc func,
147 guint gst_rtsp_session_pool_cleanup (GstRTSPSessionPool *pool);
148 GSource * gst_rtsp_session_pool_create_watch (GstRTSPSessionPool *pool);
152 #endif /* __GST_RTSP_SESSION_POOL_H__ */