gst.task

Module for [Task] class

Types 3

#GstTask is used by #GstElement and #GstPad to provide the data passing threads in a #GstPipeline.

A #GstPad will typically start a #GstTask to push or pull data to/from the peer pads. Most source elements start a #GstTask to push data. In some cases a demuxer element can start a #GstTask to pull data from a peer element. This is typically done when the demuxer can perform random access on the upstream peer element for improved performance.

Although convenience functions exist on #GstPad to start/pause/stop tasks, it might sometimes be needed to create a #GstTask manually if it is not related to a #GstPad.

Before the #GstTask can be run, it needs a #GRecMutex that can be set with [gst.task.Task.setLock].

The task can be started, paused and stopped with [gst.task.Task.start], [gst.task.Task.pause] and [gst.task.Task.stop] respectively or with the [gst.task.Task.setState] function.

A #GstTask will repeatedly call the #GstTaskFunction with the user data that was provided when creating the task with [gst.task.Task.new_]. While calling the function it will acquire the provided lock. The provided lock is released when the task pauses or stops.

Stopping a task with [gst.task.Task.stop] will not immediately make sure the task is not running anymore. Use [gst.task.Task.join] to make sure the task is completely stopped and the thread is stopped.

After creating a #GstTask, use [gst.object.ObjectWrap.unref] to free its resources. This can only be done when the task is not running anymore.

Task functions can send a #GstMessage to send out-of-band data to the application. The application can receive messages from the #GstBus in its mainloop.

For debugging purposes, the task will configure its object name as the thread name on Linux. Please note that the object name should be configured before the task is started; changing the object name after the task has been started, has no effect on the thread name.

Methods
GType _gType() @property
Task self()Returns `this`, for use in `with` statements.
TaskGidBuilder builder()Get builder for [gst.task.Task] Returns: New builder object
void cleanupAll()Wait for all tasks to be stopped. This is mainly used internally to ensure proper cleanup of internal data structures in test suites.
gst.task_pool.TaskPool getPool()Get the #GstTaskPool that this task will use for its streaming threads.
gst.types.TaskState getState()Get the current state of the task. Returns: The #GstTaskState of the task
bool join()Joins task. After this call, it is safe to unref the task and clean up the lock set with [gst.task.Task.setLock].
bool pause()Pauses task. This method can also be called on a task in the stopped state, in which case a thread will be started and will remain in the paused state. This function does not wait for the task to c...
bool resume()Resume task in case it was paused. If the task was stopped, it will remain in that state and this function will return false. Returns: true if the task could be resumed.
void setEnterCallback(gst.types.TaskThreadFunc enterFunc)Call enterfunc when the task function of task is entered. userdata will be passed to enterfunc and notify will be called when userdata is no longer referenced.
void setLeaveCallback(gst.types.TaskThreadFunc leaveFunc)Call leavefunc when the task function of task is left. userdata will be passed to leavefunc and notify will be called when userdata is no longer referenced.
void setPool(gst.task_pool.TaskPool pool)Set pool as the new GstTaskPool for task. Any new streaming threads that will be created by task will now use pool.
bool setState(gst.types.TaskState state)Sets the state of task to state.
bool start()Starts task. The task must have a lock associated with it using [gst.task.Task.setLock] or this function will return false. Returns: true if the task could be started.
bool stop()Stops task. This method merely schedules the task to stop and will not wait for the task to have completely stopped. Use [gst.task.Task.join] to stop and wait for completion. Returns: true if the t...
Constructors
this(void * ptr, Flag!"Take" take)
this(gst.types.TaskFunction func)Create a new Task that will repeatedly call the provided func with user_data as a parameter. Typically the task will run in a new thread.

Fluent builder for [gst.task.Task]

Methods