| GStreamer RTSP Server Reference Manual | ||||
|---|---|---|---|---|
| Top | Description | ||||
enum GstRTSPThreadType; struct GstRTSPThread; GstRTSPThread * gst_rtsp_thread_new (GstRTSPThreadType type); GstRTSPThread * gst_rtsp_thread_ref (GstRTSPThread *thread); void gst_rtsp_thread_unref (GstRTSPPermissions *thread); gboolean gst_rtsp_thread_reuse (GstRTSPThread *thread); void gst_rtsp_thread_stop (GstRTSPThread *thread); struct GstRTSPThreadPool; struct GstRTSPThreadPoolClass; GstRTSPThreadPool * gst_rtsp_thread_pool_new (void); gint gst_rtsp_thread_pool_get_max_threads (GstRTSPThreadPool *pool); void gst_rtsp_thread_pool_set_max_threads (GstRTSPThreadPool *pool,gint max_threads); GstRTSPThread * gst_rtsp_thread_pool_get_thread (GstRTSPThreadPool *pool,GstRTSPThreadType type,GstRTSPContext *ctx); void gst_rtsp_thread_pool_cleanup (void);
A GstRTSPThreadPool manages reusable threads for various server tasks. Currently the defined thread types can be found in GstRTSPThreadType.
Threads of type GST_RTSP_THREAD_TYPE_CLIENT are used to handle requests from
a connected client. With gst_rtsp_thread_pool_get_max_threads() a maximum
number of threads can be set after which the pool will start to reuse the
same thread for multiple clients.
Threads of type GST_RTSP_THREAD_TYPE_MEDIA will be used to perform the state changes of the media pipelines and handle its bus messages.
gst_rtsp_thread_pool_get_thread() can be used to create a GstRTSPThread
object of the right type. The thread object contains a mainloop and context
that run in a seperate thread and can be used to attached sources to.
gst_rtsp_thread_reuse() can be used to reuse a thread for multiple purposes.
If all gst_rtsp_thread_reuse() calls are matched with a
gst_rtsp_thread_stop() call, the mainloop will be quit and the thread will
stop.
To configure the threads, a subclass of this object should be made and the virtual methods should be overriden to implement the desired functionality.
Last reviewed on 2013-07-11 (1.0.0)
typedef enum {
GST_RTSP_THREAD_TYPE_CLIENT,
GST_RTSP_THREAD_TYPE_MEDIA
} GstRTSPThreadType;
Different thread types
struct GstRTSPThread {
GstMiniObject mini_object;
GstRTSPThreadType type;
GMainContext *context;
GMainLoop *loop;
};
Structure holding info about a mainloop running in a thread
| parent GstMiniObject | |
GstRTSPThreadType |
the thread type |
| a GMainContext | |
| a GMainLoop |
GstRTSPThread * gst_rtsp_thread_new (GstRTSPThreadType type);
Create a new thread object that can run a mainloop.
|
the thread type |
Returns : |
a GstRTSPThread. [transfer full] |
GstRTSPThread * gst_rtsp_thread_ref (GstRTSPThread *thread);
Increase the refcount of this thread.
|
The thread to refcount |
Returns : |
thread (for convenience when doing assignments). [transfer full]
|
void gst_rtsp_thread_unref (GstRTSPPermissions *thread);
Decrease the refcount of an thread, freeing it if the refcount reaches 0.
|
the thread to refcount. [transfer full] |
gboolean gst_rtsp_thread_reuse (GstRTSPThread *thread);
Reuse the mainloop of thread
|
a GstRTSPThread. [transfer none] |
Returns : |
TRUE if the mainloop could be reused |
void gst_rtsp_thread_stop (GstRTSPThread *thread);
Stop and unref thread. When no threads are using the mainloop, the thread
will be stopped and the final ref to thread will be released.
|
a GstRTSPThread. [transfer full] |
struct GstRTSPThreadPoolClass {
GObjectClass parent_class;
GThreadPool *pool;
GstRTSPThread * (*get_thread) (GstRTSPThreadPool *pool,
GstRTSPThreadType type,
GstRTSPContext *ctx);
void (*configure_thread) (GstRTSPThreadPool *pool,
GstRTSPThread * thread,
GstRTSPContext *ctx);
void (*thread_enter) (GstRTSPThreadPool *pool,
GstRTSPThread *thread);
void (*thread_leave) (GstRTSPThreadPool *pool,
GstRTSPThread *thread);
};
Class for managing threads.
| a GThreadPool used internally | |
| this function should make or reuse an existing thread that runs a mainloop. | |
| configure a thread object. this vmethod is called when a new thread has been created and should be configured. | |
| called from the thread when it is entered | |
| called from the thread when it is left |
GstRTSPThreadPool * gst_rtsp_thread_pool_new (void);
Create a new GstRTSPThreadPool instance.
Returns : |
a new GstRTSPThreadPool. [transfer full] |
gint gst_rtsp_thread_pool_get_max_threads
(GstRTSPThreadPool *pool);
Get the maximum number of threads used for client connections.
See gst_rtsp_thread_pool_set_max_threads().
|
a GstRTSPThreadPool |
Returns : |
the maximum number of threads. |
void gst_rtsp_thread_pool_set_max_threads (GstRTSPThreadPool *pool,gint max_threads);
Set the maximum threads used by the pool to handle client requests. A value of 0 will use the pool mainloop, a value of -1 will use an unlimited number of threads.
|
a GstRTSPThreadPool |
|
maximum threads |
GstRTSPThread * gst_rtsp_thread_pool_get_thread (GstRTSPThreadPool *pool,GstRTSPThreadType type,GstRTSPContext *ctx);
Get a new GstRTSPThread for type and ctx.
|
a GstRTSPThreadPool |
|
the GstRTSPThreadType |
|
a GstRTSPContext. [transfer none] |
Returns : |
a new GstRTSPThread, gst_rtsp_thread_stop() after usage. [transfer full]
|