2008-10-09 12:29:12 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2008 Wim Taymans <wim.taymans at gmail.com>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
2012-11-04 00:14:25 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2008-10-09 12:29:12 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <gst/gst.h>
|
|
|
|
|
|
|
|
#ifndef __GST_RTSP_SESSION_POOL_H__
|
|
|
|
#define __GST_RTSP_SESSION_POOL_H__
|
|
|
|
|
2018-03-13 13:30:41 +00:00
|
|
|
#include "rtsp-server-prelude.h"
|
|
|
|
|
2008-10-09 12:29:12 +00:00
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
2011-01-12 12:57:09 +00:00
|
|
|
typedef struct _GstRTSPSessionPool GstRTSPSessionPool;
|
|
|
|
typedef struct _GstRTSPSessionPoolClass GstRTSPSessionPoolClass;
|
2012-11-29 10:11:05 +00:00
|
|
|
typedef struct _GstRTSPSessionPoolPrivate GstRTSPSessionPoolPrivate;
|
2011-01-12 12:57:09 +00:00
|
|
|
|
|
|
|
#include "rtsp-session.h"
|
|
|
|
|
2008-10-09 12:29:12 +00:00
|
|
|
#define GST_TYPE_RTSP_SESSION_POOL (gst_rtsp_session_pool_get_type ())
|
|
|
|
#define GST_IS_RTSP_SESSION_POOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_RTSP_SESSION_POOL))
|
|
|
|
#define GST_IS_RTSP_SESSION_POOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_RTSP_SESSION_POOL))
|
|
|
|
#define GST_RTSP_SESSION_POOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTSP_SESSION_POOL, GstRTSPSessionPoolClass))
|
|
|
|
#define GST_RTSP_SESSION_POOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_RTSP_SESSION_POOL, GstRTSPSessionPool))
|
|
|
|
#define GST_RTSP_SESSION_POOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_RTSP_SESSION_POOL, GstRTSPSessionPoolClass))
|
|
|
|
#define GST_RTSP_SESSION_POOL_CAST(obj) ((GstRTSPSessionPool*)(obj))
|
|
|
|
#define GST_RTSP_SESSION_POOL_CLASS_CAST(klass) ((GstRTSPSessionPoolClass*)(klass))
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GstRTSPSessionPool:
|
2009-01-20 18:41:53 +00:00
|
|
|
*
|
2009-01-22 17:35:17 +00:00
|
|
|
* An object that keeps track of the active sessions. This object is usually
|
|
|
|
* attached to a #GstRTSPServer object to manage the sessions in that server.
|
2008-10-09 12:29:12 +00:00
|
|
|
*/
|
|
|
|
struct _GstRTSPSessionPool {
|
|
|
|
GObject parent;
|
|
|
|
|
2013-07-11 10:18:26 +00:00
|
|
|
/*< private >*/
|
2012-11-29 10:11:05 +00:00
|
|
|
GstRTSPSessionPoolPrivate *priv;
|
2013-12-12 00:36:07 +00:00
|
|
|
gpointer _gst_reserved[GST_PADDING];
|
2008-10-09 12:29:12 +00:00
|
|
|
};
|
|
|
|
|
2009-01-20 18:41:53 +00:00
|
|
|
/**
|
|
|
|
* GstRTSPSessionPoolClass:
|
2009-01-22 17:35:17 +00:00
|
|
|
* @create_session_id: create a new random session id. Subclasses can create
|
2009-02-04 18:52:50 +00:00
|
|
|
* custom session ids and should not check if the session exists.
|
2013-07-11 14:28:09 +00:00
|
|
|
* @create_session: make a new session object.
|
2014-06-30 13:14:34 +00:00
|
|
|
* @session_removed: a session was removed from the pool
|
2009-01-20 18:41:53 +00:00
|
|
|
*/
|
2008-10-09 12:29:12 +00:00
|
|
|
struct _GstRTSPSessionPoolClass {
|
|
|
|
GObjectClass parent_class;
|
2009-01-20 18:41:53 +00:00
|
|
|
|
2013-07-11 14:28:09 +00:00
|
|
|
gchar * (*create_session_id) (GstRTSPSessionPool *pool);
|
|
|
|
GstRTSPSession * (*create_session) (GstRTSPSessionPool *pool, const gchar *id);
|
2013-12-12 00:36:07 +00:00
|
|
|
|
2014-06-30 13:14:34 +00:00
|
|
|
/* signals */
|
|
|
|
void (*session_removed) (GstRTSPSessionPool *pool,
|
|
|
|
GstRTSPSession *session);
|
|
|
|
|
2013-12-12 00:36:07 +00:00
|
|
|
/*< private >*/
|
2014-06-30 13:14:34 +00:00
|
|
|
gpointer _gst_reserved[GST_PADDING_LARGE - 1];
|
2008-10-09 12:29:12 +00:00
|
|
|
};
|
|
|
|
|
2009-02-13 18:58:17 +00:00
|
|
|
/**
|
|
|
|
* GstRTSPSessionPoolFunc:
|
|
|
|
* @pool: a #GstRTSPSessionPool object
|
|
|
|
* @user_data: user data that has been given when registering the handler
|
|
|
|
*
|
|
|
|
* The function that will be called from the GSource watch on the session pool.
|
|
|
|
*
|
|
|
|
* The function will be called when the pool must be cleaned up because one or
|
|
|
|
* more sessions timed out.
|
|
|
|
*
|
2010-12-11 09:48:25 +00:00
|
|
|
* Returns: %FALSE if the source should be removed.
|
2009-02-13 18:58:17 +00:00
|
|
|
*/
|
|
|
|
typedef gboolean (*GstRTSPSessionPoolFunc) (GstRTSPSessionPool *pool, gpointer user_data);
|
|
|
|
|
2009-06-30 19:27:53 +00:00
|
|
|
/**
|
2012-11-29 10:11:05 +00:00
|
|
|
* GstRTSPSessionPoolFilterFunc:
|
2009-06-30 19:27:53 +00:00
|
|
|
* @pool: a #GstRTSPSessionPool object
|
|
|
|
* @session: a #GstRTSPSession in @pool
|
|
|
|
* @user_data: user data that has been given to gst_rtsp_session_pool_filter()
|
|
|
|
*
|
|
|
|
* This function will be called by the gst_rtsp_session_pool_filter(). An
|
|
|
|
* implementation should return a value of #GstRTSPFilterResult.
|
|
|
|
*
|
|
|
|
* When this function returns #GST_RTSP_FILTER_REMOVE, @session will be removed
|
|
|
|
* from @pool.
|
|
|
|
*
|
|
|
|
* A return value of #GST_RTSP_FILTER_KEEP will leave @session untouched in
|
|
|
|
* @pool.
|
|
|
|
*
|
|
|
|
* A value of GST_RTSP_FILTER_REF will add @session to the result #GList of
|
|
|
|
* gst_rtsp_session_pool_filter().
|
|
|
|
*
|
|
|
|
* Returns: a #GstRTSPFilterResult.
|
|
|
|
*/
|
2012-11-29 10:11:05 +00:00
|
|
|
typedef GstRTSPFilterResult (*GstRTSPSessionPoolFilterFunc) (GstRTSPSessionPool *pool,
|
|
|
|
GstRTSPSession *session,
|
|
|
|
gpointer user_data);
|
2009-06-30 19:27:53 +00:00
|
|
|
|
2009-02-13 18:58:17 +00:00
|
|
|
|
2018-03-13 13:30:41 +00:00
|
|
|
GST_RTSP_SERVER_API
|
2008-10-09 12:29:12 +00:00
|
|
|
GType gst_rtsp_session_pool_get_type (void);
|
|
|
|
|
2009-02-04 18:52:50 +00:00
|
|
|
/* creating a session pool */
|
2017-05-18 09:35:18 +00:00
|
|
|
|
2018-03-13 13:30:41 +00:00
|
|
|
GST_RTSP_SERVER_API
|
2008-10-09 12:29:12 +00:00
|
|
|
GstRTSPSessionPool * gst_rtsp_session_pool_new (void);
|
|
|
|
|
2013-07-11 14:28:09 +00:00
|
|
|
/* counting sessions */
|
2017-05-18 09:35:18 +00:00
|
|
|
|
2018-03-13 13:30:41 +00:00
|
|
|
GST_RTSP_SERVER_API
|
2009-02-04 18:52:50 +00:00
|
|
|
void gst_rtsp_session_pool_set_max_sessions (GstRTSPSessionPool *pool, guint max);
|
2017-05-18 09:35:18 +00:00
|
|
|
|
2018-03-13 13:30:41 +00:00
|
|
|
GST_RTSP_SERVER_API
|
2009-02-04 18:52:50 +00:00
|
|
|
guint gst_rtsp_session_pool_get_max_sessions (GstRTSPSessionPool *pool);
|
|
|
|
|
2018-03-13 13:30:41 +00:00
|
|
|
GST_RTSP_SERVER_API
|
2009-02-04 18:52:50 +00:00
|
|
|
guint gst_rtsp_session_pool_get_n_sessions (GstRTSPSessionPool *pool);
|
|
|
|
|
|
|
|
/* managing sessions */
|
2017-05-18 09:35:18 +00:00
|
|
|
|
2018-03-13 13:30:41 +00:00
|
|
|
GST_RTSP_SERVER_API
|
2009-02-04 18:52:50 +00:00
|
|
|
GstRTSPSession * gst_rtsp_session_pool_create (GstRTSPSessionPool *pool);
|
2017-05-18 09:35:18 +00:00
|
|
|
|
2018-03-13 13:30:41 +00:00
|
|
|
GST_RTSP_SERVER_API
|
2008-10-09 12:29:12 +00:00
|
|
|
GstRTSPSession * gst_rtsp_session_pool_find (GstRTSPSessionPool *pool,
|
|
|
|
const gchar *sessionid);
|
2017-05-18 09:35:18 +00:00
|
|
|
|
2018-03-13 13:30:41 +00:00
|
|
|
GST_RTSP_SERVER_API
|
2009-02-04 18:52:50 +00:00
|
|
|
gboolean gst_rtsp_session_pool_remove (GstRTSPSessionPool *pool,
|
2008-10-09 12:29:12 +00:00
|
|
|
GstRTSPSession *sess);
|
|
|
|
|
2009-02-04 19:10:39 +00:00
|
|
|
/* perform session maintenance */
|
2017-05-18 09:35:18 +00:00
|
|
|
|
2018-03-13 13:30:41 +00:00
|
|
|
GST_RTSP_SERVER_API
|
2009-06-30 19:27:53 +00:00
|
|
|
GList * gst_rtsp_session_pool_filter (GstRTSPSessionPool *pool,
|
2012-11-29 10:11:05 +00:00
|
|
|
GstRTSPSessionPoolFilterFunc func,
|
2011-08-16 11:37:50 +00:00
|
|
|
gpointer user_data);
|
2017-05-18 09:35:18 +00:00
|
|
|
|
2018-03-13 13:30:41 +00:00
|
|
|
GST_RTSP_SERVER_API
|
2009-02-04 19:10:39 +00:00
|
|
|
guint gst_rtsp_session_pool_cleanup (GstRTSPSessionPool *pool);
|
2017-05-18 09:35:18 +00:00
|
|
|
|
2018-03-13 13:30:41 +00:00
|
|
|
GST_RTSP_SERVER_API
|
2009-02-13 18:58:17 +00:00
|
|
|
GSource * gst_rtsp_session_pool_create_watch (GstRTSPSessionPool *pool);
|
2009-02-04 19:10:39 +00:00
|
|
|
|
2015-11-10 19:17:18 +00:00
|
|
|
#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
|
|
|
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstRTSPSessionPool, gst_object_unref)
|
|
|
|
#endif
|
|
|
|
|
2008-10-09 12:29:12 +00:00
|
|
|
G_END_DECLS
|
|
|
|
|
|
|
|
#endif /* __GST_RTSP_SESSION_POOL_H__ */
|