2 * Copyright (C) 2010 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_THREAD_POOL_H__
23 #define __GST_RTSP_THREAD_POOL_H__
25 typedef struct _GstRTSPThread GstRTSPThread;
26 typedef struct _GstRTSPThreadPool GstRTSPThreadPool;
27 typedef struct _GstRTSPThreadPoolClass GstRTSPThreadPoolClass;
28 typedef struct _GstRTSPThreadPoolPrivate GstRTSPThreadPoolPrivate;
30 #include "rtsp-client.h"
34 #define GST_TYPE_RTSP_THREAD_POOL (gst_rtsp_thread_pool_get_type ())
35 #define GST_IS_RTSP_THREAD_POOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_RTSP_THREAD_POOL))
36 #define GST_IS_RTSP_THREAD_POOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_RTSP_THREAD_POOL))
37 #define GST_RTSP_THREAD_POOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTSP_THREAD_POOL, GstRTSPThreadPoolClass))
38 #define GST_RTSP_THREAD_POOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_RTSP_THREAD_POOL, GstRTSPThreadPool))
39 #define GST_RTSP_THREAD_POOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_RTSP_THREAD_POOL, GstRTSPThreadPoolClass))
40 #define GST_RTSP_THREAD_POOL_CAST(obj) ((GstRTSPThreadPool*)(obj))
41 #define GST_RTSP_THREAD_POOL_CLASS_CAST(klass) ((GstRTSPThreadPoolClass*)(klass))
43 GType gst_rtsp_thread_get_type (void);
45 #define GST_TYPE_RTSP_THREAD (gst_rtsp_thread_get_type ())
46 #define GST_IS_RTSP_THREAD(obj) (GST_IS_MINI_OBJECT_TYPE (obj, GST_TYPE_RTSP_THREAD))
47 #define GST_RTSP_THREAD_CAST(obj) ((GstRTSPThread*)(obj))
48 #define GST_RTSP_THREAD(obj) (GST_RTSP_THREAD_CAST(obj))
52 * @GST_RTSP_THREAD_TYPE_CLIENT: a thread to handle the client communication
53 * @GST_RTSP_THREAD_TYPE_MEDIA: a thread to handle media
55 * Different thread types
59 GST_RTSP_THREAD_TYPE_CLIENT,
60 GST_RTSP_THREAD_TYPE_MEDIA
65 * @mini_object: parent #GstMiniObject
66 * @type: the thread type
67 * @context: a #GMainContext
70 * Structure holding info about a mainloop running in a thread
72 struct _GstRTSPThread {
73 GstMiniObject mini_object;
75 GstRTSPThreadType type;
76 GMainContext *context;
80 GstRTSPThread * gst_rtsp_thread_new (GstRTSPThreadType type);
82 gboolean gst_rtsp_thread_reuse (GstRTSPThread * thread);
83 void gst_rtsp_thread_stop (GstRTSPThread * thread);
86 * gst_rtsp_thread_ref:
87 * @thread: The thread to refcount
89 * Increase the refcount of this thread.
91 * Returns: (transfer full): @thread (for convenience when doing assignments)
94 G_INLINE_FUNC GstRTSPThread * gst_rtsp_thread_ref (GstRTSPThread * thread);
97 static inline GstRTSPThread *
98 gst_rtsp_thread_ref (GstRTSPThread * thread)
100 return (GstRTSPThread *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (thread));
104 * gst_rtsp_thread_unref:
105 * @thread: (transfer full): the thread to refcount
107 * Decrease the refcount of an thread, freeing it if the refcount reaches 0.
109 #ifdef _FOOL_GTK_DOC_
110 G_INLINE_FUNC void gst_rtsp_thread_unref (GstRTSPPermissions * thread);
115 gst_rtsp_thread_unref (GstRTSPThread * thread)
117 gst_mini_object_unref (GST_MINI_OBJECT_CAST (thread));
123 * The thread pool structure.
125 struct _GstRTSPThreadPool {
129 GstRTSPThreadPoolPrivate *priv;
130 gpointer _gst_reserved[GST_PADDING];
134 * GstRTSPThreadPoolClass:
135 * @pool: a #GThreadPool used internally
136 * @get_thread: this function should make or reuse an existing thread that runs
138 * @configure_thread: configure a thread object. this vmethod is called when
139 * a new thread has been created and should be configured.
140 * @thread_enter: called from the thread when it is entered
141 * @thread_leave: called from the thread when it is left
143 * Class for managing threads.
145 struct _GstRTSPThreadPoolClass {
146 GObjectClass parent_class;
150 GstRTSPThread * (*get_thread) (GstRTSPThreadPool *pool,
151 GstRTSPThreadType type,
152 GstRTSPContext *ctx);
153 void (*configure_thread) (GstRTSPThreadPool *pool,
154 GstRTSPThread * thread,
155 GstRTSPContext *ctx);
157 void (*thread_enter) (GstRTSPThreadPool *pool,
158 GstRTSPThread *thread);
159 void (*thread_leave) (GstRTSPThreadPool *pool,
160 GstRTSPThread *thread);
163 gpointer _gst_reserved[GST_PADDING];
166 GType gst_rtsp_thread_pool_get_type (void);
168 GstRTSPThreadPool * gst_rtsp_thread_pool_new (void);
170 void gst_rtsp_thread_pool_set_max_threads (GstRTSPThreadPool * pool, gint max_threads);
171 gint gst_rtsp_thread_pool_get_max_threads (GstRTSPThreadPool * pool);
173 GstRTSPThread * gst_rtsp_thread_pool_get_thread (GstRTSPThreadPool *pool,
174 GstRTSPThreadType type,
175 GstRTSPContext *ctx);
176 void gst_rtsp_thread_pool_cleanup (void);
179 #endif /* __GST_RTSP_THREAD_POOL_H__ */