Top | ![]() |
![]() |
![]() |
![]() |
enum | GstRTSPThreadType |
struct | GstRTSPThread |
struct | GstRTSPThreadPool |
struct | GstRTSPThreadPoolClass |
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)
GstRTSPThread *
gst_rtsp_thread_new (GstRTSPThreadType type
);
Create a new thread object that can run a mainloop.
GstRTSPThread *
gst_rtsp_thread_ref (GstRTSPThread *thread
);
Increase the refcount of this thread.
void
gst_rtsp_thread_unref (GstRTSPThread *thread
);
Decrease the refcount of an thread, freeing it if the refcount reaches 0.
gboolean
gst_rtsp_thread_reuse (GstRTSPThread *thread
);
Reuse the mainloop of thread
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.
GstRTSPThreadPool *
gst_rtsp_thread_pool_new (void
);
Create a new GstRTSPThreadPool instance.
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()
.
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.
GstRTSPThread * gst_rtsp_thread_pool_get_thread (GstRTSPThreadPool *pool
,GstRTSPThreadType type
,GstRTSPContext *ctx
);
Get a new GstRTSPThread for type
and ctx
.
struct GstRTSPThread { GstMiniObject mini_object; GstRTSPThreadType type; GMainContext *context; GMainLoop *loop; };
Structure holding info about a mainloop running in a thread
GstMiniObject |
parent GstMiniObject |
|
GstRTSPThreadType |
the thread type |
|
GMainContext * |
||
GMainLoop * |
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.
GThreadPool * |
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 |
“max-threads”
property“max-threads” gint
The maximum amount of threads to use for client connections (0 = only mainloop, -1 = unlimited).
Flags: Read / Write
Allowed values: >= -1
Default value: 1