GstTask

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_set_lock.

The task can be started, paused and stopped with gst_task_start, gst_task_pause and gst_task_stop respectively or with the gst_task_set_state function.

A GstTask will repeatedly call the GstTaskFunction with the user data that was provided when creating the task with gst_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_stop will not immediately make sure the task is not running anymore. Use gst_task_join to make sure the task is completely stopped and the thread is stopped.

After creating a GstTask, use gst_object_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.

GstTask

GObject
    ╰──GInitiallyUnowned
        ╰──GstObject
            ╰──GstTask

The GstTask object.

Members

object (GstObject) –
No description available
state (GstTaskState) –

the state of the task

cond (GCond) –

used to pause/resume the task

lock (GRecMutex *) –

The lock taken when iterating the task function

func (GstTaskFunction) –

the function executed by this task

user_data (gpointer) –

user_data passed to the task function

notify (GDestroyNotify) –

GDestroyNotify for user_data

running (gboolean) –

a flag indicating that the task is running


Class structure

GstTaskClass

Fields
parent_class (GstObjectClass) –
No description available

Gst.TaskClass

Attributes
parent_class (Gst.ObjectClass) –
No description available

Gst.TaskClass

Attributes
parent_class (Gst.ObjectClass) –
No description available

Gst.Task

GObject.Object
    ╰──GObject.InitiallyUnowned
        ╰──Gst.Object
            ╰──Gst.Task

The Gst.Task object.

Members

object (Gst.Object) –
No description available
state (Gst.TaskState) –

the state of the task

cond (GLib.Cond) –

used to pause/resume the task

lock (GLib.RecMutex) –

The lock taken when iterating the task function

func (Gst.TaskFunction) –

the function executed by this task

user_data (Object) –

user_data passed to the task function

notify (GLib.DestroyNotify) –

GDestroyNotify for user_data

running (Number) –

a flag indicating that the task is running


Gst.Task

GObject.Object
    ╰──GObject.InitiallyUnowned
        ╰──Gst.Object
            ╰──Gst.Task

The Gst.Task object.

Members

object (Gst.Object) –
No description available
state (Gst.TaskState) –

the state of the task

cond (GLib.Cond) –

used to pause/resume the task

lock (GLib.RecMutex) –

The lock taken when iterating the task function

func (Gst.TaskFunction) –

the function executed by this task

user_data (object) –

user_data passed to the task function

notify (GLib.DestroyNotify) –

GDestroyNotify for user_data

running (bool) –

a flag indicating that the task is running


Constructors

gst_task_new

GstTask *
gst_task_new (GstTaskFunction func,
              gpointer user_data,
              GDestroyNotify notify)

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.

The function cannot be changed after the task has been created. You must create a new GstTask to change the function.

This function will not yet create and start a thread. Use gst_task_start or gst_task_pause to create and start the GThread.

Before the task can be used, a GRecMutex must be configured using the gst_task_set_lock function. This lock will always be acquired while func is called.

Parameters:

func

The GstTaskFunction to use

user_data

User data to pass to func

notify

the function to call when user_data is no longer needed.

Returns ( [transfer: full])

A new GstTask.

MT safe.


Gst.Task.prototype.new

function Gst.Task.prototype.new(func: Gst.TaskFunction, user_data: Object): {
    // javascript wrapper for 'gst_task_new'
}

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.

The function cannot be changed after the task has been created. You must create a new Gst.Task to change the function.

This function will not yet create and start a thread. Use Gst.Task.prototype.start or Gst.Task.prototype.pause to create and start the GThread.

Before the task can be used, a GLib.RecMutex must be configured using the Gst.Task.prototype.set_lock function. This lock will always be acquired while func is called.

Parameters:

func (Gst.TaskFunction)

The Gst.TaskFunction to use

user_data (Object)

User data to pass to func

Returns (Gst.Task)

A new Gst.Task.

MT safe.


Gst.Task.new

def Gst.Task.new (func, *user_data):
    #python wrapper for 'gst_task_new'

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.

The function cannot be changed after the task has been created. You must create a new Gst.Task to change the function.

This function will not yet create and start a thread. Use Gst.Task.start or Gst.Task.pause to create and start the GThread.

Before the task can be used, a GLib.RecMutex must be configured using the Gst.Task.set_lock function. This lock will always be acquired while func is called.

Parameters:

func (Gst.TaskFunction)

The Gst.TaskFunction to use

user_data (variadic)

User data to pass to func

Returns (Gst.Task)

A new Gst.Task.

MT safe.


Methods

gst_task_get_pool

GstTaskPool *
gst_task_get_pool (GstTask * task)

Get the GstTaskPool that this task will use for its streaming threads.

MT safe.

Parameters:

task

a GstTask

Returns ( [transfer: full])

the GstTaskPool used by task. gst_object_unref after usage.


Gst.Task.prototype.get_pool

function Gst.Task.prototype.get_pool(): {
    // javascript wrapper for 'gst_task_get_pool'
}

Get the Gst.TaskPool that this task will use for its streaming threads.

MT safe.

Parameters:

task (Gst.Task)

a Gst.Task

Returns (Gst.TaskPool)

the Gst.TaskPool used by task. Gst.Object.prototype.unref after usage.


Gst.Task.get_pool

def Gst.Task.get_pool (self):
    #python wrapper for 'gst_task_get_pool'

Get the Gst.TaskPool that this task will use for its streaming threads.

MT safe.

Parameters:

task (Gst.Task)

a Gst.Task

Returns (Gst.TaskPool)

the Gst.TaskPool used by task. Gst.Object.unref after usage.


gst_task_get_state

GstTaskState
gst_task_get_state (GstTask * task)

Get the current state of the task.

Parameters:

task

The GstTask to query

Returns

The GstTaskState of the task

MT safe.


Gst.Task.prototype.get_state

function Gst.Task.prototype.get_state(): {
    // javascript wrapper for 'gst_task_get_state'
}

Get the current state of the task.

Parameters:

task (Gst.Task)

The Gst.Task to query

Returns (Gst.TaskState)

The Gst.TaskState of the task

MT safe.


Gst.Task.get_state

def Gst.Task.get_state (self):
    #python wrapper for 'gst_task_get_state'

Get the current state of the task.

Parameters:

task (Gst.Task)

The Gst.Task to query

Returns (Gst.TaskState)

The Gst.TaskState of the task

MT safe.


gst_task_join

gboolean
gst_task_join (GstTask * task)

Joins task. After this call, it is safe to unref the task and clean up the lock set with gst_task_set_lock.

The task will automatically be stopped with this call.

This function cannot be called from within a task function as this would cause a deadlock. The function will detect this and print a g_warning.

Parameters:

task

The GstTask to join

Returns

TRUE if the task could be joined.

MT safe.


Gst.Task.prototype.join

function Gst.Task.prototype.join(): {
    // javascript wrapper for 'gst_task_join'
}

Joins task. After this call, it is safe to unref the task and clean up the lock set with Gst.Task.prototype.set_lock.

The task will automatically be stopped with this call.

This function cannot be called from within a task function as this would cause a deadlock. The function will detect this and print a g_warning.

Parameters:

task (Gst.Task)

The Gst.Task to join

Returns (Number)

true if the task could be joined.

MT safe.


Gst.Task.join

def Gst.Task.join (self):
    #python wrapper for 'gst_task_join'

Joins task. After this call, it is safe to unref the task and clean up the lock set with Gst.Task.set_lock.

The task will automatically be stopped with this call.

This function cannot be called from within a task function as this would cause a deadlock. The function will detect this and print a g_warning.

Parameters:

task (Gst.Task)

The Gst.Task to join

Returns (bool)

True if the task could be joined.

MT safe.


gst_task_pause

gboolean
gst_task_pause (GstTask * task)

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 complete the paused state.

Parameters:

task

The GstTask to pause

Returns

TRUE if the task could be paused.

MT safe.


Gst.Task.prototype.pause

function Gst.Task.prototype.pause(): {
    // javascript wrapper for 'gst_task_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 complete the paused state.

Parameters:

task (Gst.Task)

The Gst.Task to pause

Returns (Number)

true if the task could be paused.

MT safe.


Gst.Task.pause

def Gst.Task.pause (self):
    #python wrapper for 'gst_task_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 complete the paused state.

Parameters:

task (Gst.Task)

The Gst.Task to pause

Returns (bool)

True if the task could be paused.

MT safe.


gst_task_resume

gboolean
gst_task_resume (GstTask * task)

Resume task in case it was paused. If the task was stopped, it will remain in that state and this function will return FALSE.

Parameters:

task

The GstTask to resume

Returns

TRUE if the task could be resumed.

MT safe.

Since : 1.18


Gst.Task.prototype.resume

function Gst.Task.prototype.resume(): {
    // javascript wrapper for 'gst_task_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.

Parameters:

task (Gst.Task)

The Gst.Task to resume

Returns (Number)

true if the task could be resumed.

MT safe.

Since : 1.18


Gst.Task.resume

def Gst.Task.resume (self):
    #python wrapper for 'gst_task_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.

Parameters:

task (Gst.Task)

The Gst.Task to resume

Returns (bool)

True if the task could be resumed.

MT safe.

Since : 1.18


gst_task_set_enter_callback

gst_task_set_enter_callback (GstTask * task,
                             GstTaskThreadFunc enter_func,
                             gpointer user_data,
                             GDestroyNotify notify)

Call enter_func when the task function of task is entered. user_data will be passed to enter_func and notify will be called when user_data is no longer referenced.

Parameters:

task

The GstTask to use

enter_func ( [in])

a GstTaskThreadFunc

user_data

user data passed to enter_func

notify

called when user_data is no longer referenced


Gst.Task.prototype.set_enter_callback

function Gst.Task.prototype.set_enter_callback(enter_func: Gst.TaskThreadFunc, user_data: Object): {
    // javascript wrapper for 'gst_task_set_enter_callback'
}

Call enter_func when the task function of task is entered. user_data will be passed to enter_func and notify will be called when user_data is no longer referenced.

Parameters:

task (Gst.Task)

The Gst.Task to use

user_data (Object)

user data passed to enter_func


Gst.Task.set_enter_callback

def Gst.Task.set_enter_callback (self, enter_func, *user_data):
    #python wrapper for 'gst_task_set_enter_callback'

Call enter_func when the task function of task is entered. user_data will be passed to enter_func and notify will be called when user_data is no longer referenced.

Parameters:

task (Gst.Task)

The Gst.Task to use

user_data (variadic)

user data passed to enter_func


gst_task_set_leave_callback

gst_task_set_leave_callback (GstTask * task,
                             GstTaskThreadFunc leave_func,
                             gpointer user_data,
                             GDestroyNotify notify)

Call leave_func when the task function of task is left. user_data will be passed to leave_func and notify will be called when user_data is no longer referenced.

Parameters:

task

The GstTask to use

leave_func ( [in])

a GstTaskThreadFunc

user_data

user data passed to leave_func

notify

called when user_data is no longer referenced


Gst.Task.prototype.set_leave_callback

function Gst.Task.prototype.set_leave_callback(leave_func: Gst.TaskThreadFunc, user_data: Object): {
    // javascript wrapper for 'gst_task_set_leave_callback'
}

Call leave_func when the task function of task is left. user_data will be passed to leave_func and notify will be called when user_data is no longer referenced.

Parameters:

task (Gst.Task)

The Gst.Task to use

user_data (Object)

user data passed to leave_func


Gst.Task.set_leave_callback

def Gst.Task.set_leave_callback (self, leave_func, *user_data):
    #python wrapper for 'gst_task_set_leave_callback'

Call leave_func when the task function of task is left. user_data will be passed to leave_func and notify will be called when user_data is no longer referenced.

Parameters:

task (Gst.Task)

The Gst.Task to use

user_data (variadic)

user data passed to leave_func


gst_task_set_lock

gst_task_set_lock (GstTask * task,
                   GRecMutex * mutex)

Set the mutex used by the task. The mutex will be acquired before calling the GstTaskFunction.

This function has to be called before calling gst_task_pause or gst_task_start.

MT safe.

Parameters:

task

The GstTask to use

mutex

The GRecMutex to use


Gst.Task.prototype.set_lock

function Gst.Task.prototype.set_lock(mutex: GLib.RecMutex): {
    // javascript wrapper for 'gst_task_set_lock'
}

Set the mutex used by the task. The mutex will be acquired before calling the Gst.TaskFunction.

This function has to be called before calling Gst.Task.prototype.pause or Gst.Task.prototype.start.

MT safe.

Parameters:

task (Gst.Task)

The Gst.Task to use

mutex (GLib.RecMutex)

The GLib.RecMutex to use


Gst.Task.set_lock

def Gst.Task.set_lock (self, mutex):
    #python wrapper for 'gst_task_set_lock'

Set the mutex used by the task. The mutex will be acquired before calling the Gst.TaskFunction.

This function has to be called before calling Gst.Task.pause or Gst.Task.start.

MT safe.

Parameters:

task (Gst.Task)

The Gst.Task to use

mutex (GLib.RecMutex)

The GLib.RecMutex to use


gst_task_set_pool

gst_task_set_pool (GstTask * task,
                   GstTaskPool * pool)

Set pool as the new GstTaskPool for task. Any new streaming threads that will be created by task will now use pool.

MT safe.

Parameters:

task

a GstTask

pool ( [transfer: none])

a GstTaskPool


Gst.Task.prototype.set_pool

function Gst.Task.prototype.set_pool(pool: Gst.TaskPool): {
    // javascript wrapper for 'gst_task_set_pool'
}

Set pool as the new GstTaskPool for task. Any new streaming threads that will be created by task will now use pool.

MT safe.

Parameters:

task (Gst.Task)

a Gst.Task

pool (Gst.TaskPool)

a Gst.TaskPool


Gst.Task.set_pool

def Gst.Task.set_pool (self, pool):
    #python wrapper for 'gst_task_set_pool'

Set pool as the new GstTaskPool for task. Any new streaming threads that will be created by task will now use pool.

MT safe.

Parameters:

task (Gst.Task)

a Gst.Task

pool (Gst.TaskPool)

a Gst.TaskPool


gst_task_set_state

gboolean
gst_task_set_state (GstTask * task,
                    GstTaskState state)

Sets the state of task to state.

The task must have a lock associated with it using gst_task_set_lock when going to GST_TASK_STARTED or GST_TASK_PAUSED or this function will return FALSE.

MT safe.

Parameters:

task

a GstTask

state

the new task state

Returns

TRUE if the state could be changed.


Gst.Task.prototype.set_state

function Gst.Task.prototype.set_state(state: Gst.TaskState): {
    // javascript wrapper for 'gst_task_set_state'
}

Sets the state of task to state.

The task must have a lock associated with it using Gst.Task.prototype.set_lock when going to GST_TASK_STARTED or GST_TASK_PAUSED or this function will return false.

MT safe.

Parameters:

task (Gst.Task)

a Gst.Task

state (Gst.TaskState)

the new task state

Returns (Number)

true if the state could be changed.


Gst.Task.set_state

def Gst.Task.set_state (self, state):
    #python wrapper for 'gst_task_set_state'

Sets the state of task to state.

The task must have a lock associated with it using Gst.Task.set_lock when going to GST_TASK_STARTED or GST_TASK_PAUSED or this function will return False.

MT safe.

Parameters:

task (Gst.Task)

a Gst.Task

state (Gst.TaskState)

the new task state

Returns (bool)

True if the state could be changed.


gst_task_start

gboolean
gst_task_start (GstTask * task)

Starts task. The task must have a lock associated with it using gst_task_set_lock or this function will return FALSE.

Parameters:

task

The GstTask to start

Returns

TRUE if the task could be started.

MT safe.


Gst.Task.prototype.start

function Gst.Task.prototype.start(): {
    // javascript wrapper for 'gst_task_start'
}

Starts task. The task must have a lock associated with it using Gst.Task.prototype.set_lock or this function will return false.

Parameters:

task (Gst.Task)

The Gst.Task to start

Returns (Number)

true if the task could be started.

MT safe.


Gst.Task.start

def Gst.Task.start (self):
    #python wrapper for 'gst_task_start'

Starts task. The task must have a lock associated with it using Gst.Task.set_lock or this function will return False.

Parameters:

task (Gst.Task)

The Gst.Task to start

Returns (bool)

True if the task could be started.

MT safe.


gst_task_stop

gboolean
gst_task_stop (GstTask * task)

Stops task. This method merely schedules the task to stop and will not wait for the task to have completely stopped. Use gst_task_join to stop and wait for completion.

Parameters:

task

The GstTask to stop

Returns

TRUE if the task could be stopped.

MT safe.


Gst.Task.prototype.stop

function Gst.Task.prototype.stop(): {
    // javascript wrapper for 'gst_task_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.prototype.join to stop and wait for completion.

Parameters:

task (Gst.Task)

The Gst.Task to stop

Returns (Number)

true if the task could be stopped.

MT safe.


Gst.Task.stop

def Gst.Task.stop (self):
    #python wrapper for 'gst_task_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.join to stop and wait for completion.

Parameters:

task (Gst.Task)

The Gst.Task to stop

Returns (bool)

True if the task could be stopped.

MT safe.


Functions

gst_task_cleanup_all

gst_task_cleanup_all ()

Wait for all tasks to be stopped. This is mainly used internally to ensure proper cleanup of internal data structures in test suites.

MT safe.


Gst.Task.prototype.cleanup_all

function Gst.Task.prototype.cleanup_all(): {
    // javascript wrapper for 'gst_task_cleanup_all'
}

Wait for all tasks to be stopped. This is mainly used internally to ensure proper cleanup of internal data structures in test suites.

MT safe.


Gst.Task.cleanup_all

def Gst.Task.cleanup_all ():
    #python wrapper for 'gst_task_cleanup_all'

Wait for all tasks to be stopped. This is mainly used internally to ensure proper cleanup of internal data structures in test suites.

MT safe.


Function Macros

GST_TASK_BROADCAST

#define GST_TASK_BROADCAST(task)        g_cond_broadcast(GST_TASK_GET_COND (task))

Send a broadcast signal to all waiting task conds

Parameters:

task

Task to broadcast


GST_TASK_CAST

#define GST_TASK_CAST(task)             ((GstTask*)(task))

GST_TASK_GET_COND

#define GST_TASK_GET_COND(task)         (&GST_TASK_CAST(task)->cond)

Get access to the cond of the task.

Parameters:

task

Task to get the cond of


GST_TASK_GET_LOCK

#define GST_TASK_GET_LOCK(task)         (GST_TASK_CAST(task)->lock)

Get access to the task lock.

Parameters:

task

Task to get the lock of


GST_TASK_SIGNAL

#define GST_TASK_SIGNAL(task)           g_cond_signal(GST_TASK_GET_COND (task))

Signal the task cond

Parameters:

task

Task to signal


GST_TASK_STATE

#define GST_TASK_STATE(task)            (GST_TASK_CAST(task)->state)

Get access to the state of the task.

Parameters:

task

Task to get the state of


GST_TASK_WAIT

#define GST_TASK_WAIT(task)             g_cond_wait(GST_TASK_GET_COND (task), GST_OBJECT_GET_LOCK (task))

Wait for the task cond to be signalled

Parameters:

task

Task to wait for


Enumerations

GstTaskState

The different states a task can be in

Members
GST_TASK_STARTED (0) –

the task is started and running

GST_TASK_STOPPED (1) –

the task is stopped

GST_TASK_PAUSED (2) –

the task is paused


Gst.TaskState

The different states a task can be in

Members
Gst.TaskState.STARTED (0) –

the task is started and running

Gst.TaskState.STOPPED (1) –

the task is stopped

Gst.TaskState.PAUSED (2) –

the task is paused


Gst.TaskState

The different states a task can be in

Members
Gst.TaskState.STARTED (0) –

the task is started and running

Gst.TaskState.STOPPED (1) –

the task is stopped

Gst.TaskState.PAUSED (2) –

the task is paused


Callbacks

GstTaskFunction

(*GstTaskFunction) (gpointer user_data)

A function that will repeatedly be called in the thread created by a GstTask.

Parameters:

user_data

user data passed to the function


Gst.TaskFunction

function Gst.TaskFunction(user_data: Object): {
    // javascript wrapper for 'GstTaskFunction'
}

A function that will repeatedly be called in the thread created by a Gst.Task.

Parameters:

user_data (Object)

user data passed to the function


Gst.TaskFunction

def Gst.TaskFunction (*user_data):
    #python wrapper for 'GstTaskFunction'

A function that will repeatedly be called in the thread created by a Gst.Task.

Parameters:

user_data (variadic)

user data passed to the function


GstTaskThreadFunc

(*GstTaskThreadFunc) (GstTask * task,
                      GThread * thread,
                      gpointer user_data)

Custom GstTask thread callback functions that can be installed.

Parameters:

task

The GstTask

thread

The GThread

user_data

user data


Gst.TaskThreadFunc

function Gst.TaskThreadFunc(task: Gst.Task, thread: GLib.Thread, user_data: Object): {
    // javascript wrapper for 'GstTaskThreadFunc'
}

Custom GstTask thread callback functions that can be installed.

Parameters:

task (Gst.Task)

The Gst.Task

thread (GLib.Thread)

The GLib.Thread

user_data (Object)

user data


Gst.TaskThreadFunc

def Gst.TaskThreadFunc (task, thread, *user_data):
    #python wrapper for 'GstTaskThreadFunc'

Custom GstTask thread callback functions that can be installed.

Parameters:

task (Gst.Task)

The Gst.Task

thread (GLib.Thread)

The GLib.Thread

user_data (variadic)

user data


The results of the search are