gstreamermm  1.10.0
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Related Functions | List of all members
Gst::Task Class Reference

A class representing GStreamer streaming threads. More...

#include <gstreamermm/task.h>

Inheritance diagram for Gst::Task:
Inheritance graph
[legend]

Public Types

typedef sigc::slot< void > SlotTask
 For example, void on_do_task();. More...
 
typedef sigc::slot< void, const Glib::RefPtr< Gst::Task >&, Glib::Threads::Thread* > TaskThreadSlot
 Bidirectional slot. More...
 
typedef TaskThreadSlot SlotEnter
 For example, void on_enter(const Glib::RefPtr<Gst::Task>& task, Glib::Threads::Thread& thread);. More...
 
typedef TaskThreadSlot SlotLeave
 For example, void on_leave(const Glib::RefPtr<Gst::Task>& task, Glib::Threads::Thread& thread);. More...
 
- Public Types inherited from Glib::Object
typedef void(*)(gpointer data DestroyNotify)
 
- Public Types inherited from sigc::trackable
typedef internal::func_destroy_notify func_destroy_notify
 

Public Member Functions

 Task (Task&& src) noexcept
 
Taskoperator= (Task&& src) noexcept
 
 ~Task () noexcept override
 
GstTask* gobj ()
 Provides access to the underlying C GObject. More...
 
const GstTask* gobj () const
 Provides access to the underlying C GObject. More...
 
GstTask* gobj_copy ()
 Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More...
 
void set_lock (Glib::Threads::RecMutex& mutex)
 Set the mutex used by the task. More...
 
void set_pool (const Glib::RefPtr< Gst::TaskPool >& pool)
 Set pool as the new GstTaskPool for task. More...
 
Glib::RefPtr< Gst::TaskPoolget_pool ()
 Get the Gst::TaskPool that this task will use for its streaming threads. More...
 
Glib::RefPtr< const Gst::TaskPoolget_pool () const
 Get the Gst::TaskPool that this task will use for its streaming threads. More...
 
void set_enter_slot (const SlotEnter& enter_slot)
 Call enter_slot when the task function of task is entered. More...
 
void set_leave_slot (const SlotLeave& leave_slot)
 Call leave_func when the task function of task is left. More...
 
TaskState get_state () const
 Get the current state of the task. More...
 
void set_state (Gst::TaskState state)
 Sets the state of task to state. More...
 
bool pause ()
 Pauses task. More...
 
bool start ()
 Starts task. More...
 
bool stop ()
 Stops task. More...
 
bool join ()
 Joins task. More...
 
- Public Member Functions inherited from Gst::Object
 Object (Object&& src) noexcept
 
Objectoperator= (Object&& src) noexcept
 
 ~Object () noexcept override
 
GstObject* gobj ()
 Provides access to the underlying C GObject. More...
 
const GstObject* gobj () const
 Provides access to the underlying C GObject. More...
 
GstObject* gobj_copy ()
 Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More...
 
bool is_element () const
 
bool is_element_factory () const
 
bool is_pad () const
 
bool is_pad_template () const
 
bool is_bin () const
 
guint32 get_flags () const
 Returns the entire set of flags for the object. More...
 
bool set_name (const Glib::ustring& name)
 Sets the name of object, or gives object a guaranteed unique name (if name is nullptr). More...
 
Glib::ustring get_name () const
 Returns a copy of the name of object. More...
 
bool set_parent (const Glib::RefPtr< Gst::Object >& parent)
 Sets the parent of object to parent. More...
 
Glib::RefPtr< Gst::Objectget_parent ()
 Returns the parent of object. More...
 
Glib::RefPtr< const Gst::Objectget_parent () const
 Returns the parent of object. More...
 
void unparent ()
 Clear the parent of object, removing the associated reference. More...
 
void set_control_rate (Gst::ClockTime control_rate)
 Change the control-rate for this object. More...
 
Gst::ClockTime get_control_rate () const
 Obtain the control-rate for this object. More...
 
Gst::ClockTime suggest_next_sync () const
 Returns a suggestion for timestamps where buffers should be split to get best controller results. More...
 
bool sync_values (Gst::ClockTime timestamp)
 Sets the properties of the object, according to the Gst::ControlSources that (maybe) handle them and for the given timestamp. More...
 
void set_control_bindings_disabled (bool disabled)
 This function is used to disable all controlled properties of the object for some time, i.e. sync_values() will do nothing. More...
 
bool has_asctive_control_bindings () const
 Check if the object has an active controlled properties. More...
 
bool has_ancestor (const Glib::RefPtr< const Gst::Object >& ancestor) const
 Check if object has an ancestor ancestor somewhere up in the hierarchy. More...
 
bool has_as_ancestor (const Glib::RefPtr< Gst::Object >& ancestor) const
 Check if object has an ancestor ancestor somewhere up in the hierarchy. More...
 
bool has_as_parent (const Glib::RefPtr< Gst::Object >& parent) const
 Check if parent is the parent of object. More...
 
Glib::ustring get_path_string ()
 Generates a string describing the path of object in the object hierarchy. More...
 
Glib::PropertyProxy< Glib::ustringproperty_name ()
 The name of the object. More...
 
Glib::PropertyProxy_ReadOnly< Glib::ustringproperty_name () const
 The name of the object. More...
 
Glib::PropertyProxy< Glib::RefPtr< Gst::Object > > property_parent ()
 The parent of the object. More...
 
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Gst::Object > > property_parent () const
 The parent of the object. More...
 
Glib::SignalProxy< void, const Glib::RefPtr< Gst::Object >&, GParamSpec* > signal_deep_notify ()
 
int get_refcount () const
 
- Public Member Functions inherited from Glib::Object
 Object (const Object &)=delete
 
Objectoperator= (const Object &)=delete
 
 Object (Object &&src) noexcept
 
Objectoperator= (Object &&src) noexcept
 
void * get_data (const QueryQuark &key)
 
void set_data (const Quark &key, void *data)
 
void set_data (const Quark &key, void *data, DestroyNotify notify)
 
void remove_data (const QueryQuark &quark)
 
void * steal_data (const QueryQuark &quark)
 
Glib::RefPtr< Glib::Objectwrap (GObject *object, bool take_copy=false)
 
- Public Member Functions inherited from Glib::ObjectBase
 ObjectBase (const ObjectBase &)=delete
 
ObjectBaseoperator= (const ObjectBase &)=delete
 
void set_property_value (const Glib::ustring &property_name, const Glib::ValueBase &value)
 
void get_property_value (const Glib::ustring &property_name, Glib::ValueBase &value) const
 
void set_property (const Glib::ustring &property_name, const PropertyType &value)
 
void get_property (const Glib::ustring &property_name, PropertyType &value) const
 
void connect_property_changed (const Glib::ustring &property_name, const sigc::slot< void > &slot)
 
void connect_property_changed (const Glib::ustring &property_name, sigc::slot< void > &&slot)
 
sigc::connection connect_property_changed_with_return (const Glib::ustring &property_name, const sigc::slot< void > &slot)
 
sigc::connection connect_property_changed_with_return (const Glib::ustring &property_name, sigc::slot< void > &&slot)
 
void freeze_notify ()
 
void thaw_notify ()
 
virtual void reference () const
 
virtual void unreference () const
 
GObject * gobj ()
 
const GObject * gobj () const
 
GObject * gobj_copy () const
 
- Public Member Functions inherited from sigc::trackable
 trackable () noexcept
 
 trackable (const trackable &src) noexcept
 
 trackable (trackable &&src)
 
 ~trackable ()
 
void add_destroy_notify_callback (void *data, func_destroy_notify func) const
 
void notify_callbacks ()
 
trackableoperator= (const trackable &src)
 
trackableoperator= (trackable &&src)
 
void remove_destroy_notify_callback (void *data) const
 

Static Public Member Functions

static GType get_type ()
 Get the GType for this class, for use with the underlying GObject type system. More...
 
static Glib::RefPtr< Taskcreate (const SlotTask& task_slot)
 Create a new Gst::Task that will repeatedly call the provided slot as a parameter. More...
 
static void cleanup_all ()
 Wait for all tasks to be stopped. More...
 
- Static Public Member Functions inherited from Gst::Object
static GType get_type ()
 Get the GType for this class, for use with the underlying GObject type system. More...
 
static bool check_uniqueness (const Glib::ListHandle< const Gst::Object >& list, const Glib::ustring& name)
 Checks to see if there is any object named name in list. More...
 

Protected Member Functions

 Task (const SlotTask& task_slot)
 
- Protected Member Functions inherited from Gst::Object
virtual void on_deep_notify (const Glib::RefPtr< Gst::Object >& prop_object, GParamSpec* prop)
 This is a default handler for the signal signal_deep_notify(). More...
 
- Protected Member Functions inherited from Glib::Object
 Object ()
 
 Object (const Glib::ConstructParams &construct_params)
 
 Object (GObject *castitem)
 
 ~Object () noexcept override
 
- Protected Member Functions inherited from Glib::ObjectBase
 ObjectBase ()
 
 ObjectBase (const char *custom_type_name)
 
 ObjectBase (const std::type_info &custom_type_info)
 
 ObjectBase (ObjectBase &&src) noexcept
 
ObjectBaseoperator= (ObjectBase &&src) noexcept
 
virtual ~ObjectBase () noexcept=0
 
void initialize (GObject *castitem)
 
void initialize_move (GObject *castitem, Glib::ObjectBase *previous_wrapper)
 

Related Functions

(Note that these are not member functions.)

Glib::RefPtr< Gst::Taskwrap (GstTask* object, bool take_copy=false)
 A Glib::wrap() method for this object. More...
 

Detailed Description

A class representing GStreamer streaming threads.

Gst::Task is used by Gst::Element and Gst::Pad to provide the data passing threads in a Gst::Pipeline.

A Gst::Pad will typically start a Gst::Task to push or pull data to/from the peer pads. Most source elements start a Gst::Task to push data. In some cases a demuxer element can start a Gst::Task 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 Gst::Pad to start/pause/stop tasks, it might sometimes be needed to create a Gst::Task manually if it is not related to a Gst::Pad.

Before the Gst::Task can be run, it needs a Glib::StaticRecMutex that can be set with set_lock().

The task can be started, paused and stopped with start(), pause() and stop() respectively.

A Gst::Task will repeadedly call the Gst::Task::SlotTask that was provided when creating the task with create(). Before calling the function it will acquire the provided lock.

Stopping a task with stop() will not immediatly make sure the task is not running anymore. Use join() to make sure the task is completely stopped and the thread is stopped.

Task functions can send a Gst::Message to send out-of-band data to the application. The application can receive messages from the Gst::Bus 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.

Last reviewed on 2015-10-14 (1.5.2)

Member Typedef Documentation

◆ SlotEnter

For example, void on_enter(const Glib::RefPtr<Gst::Task>& task, Glib::Threads::Thread& thread);.

A thread is entered, this slot is called when the new thread enters its function.

◆ SlotLeave

For example, void on_leave(const Glib::RefPtr<Gst::Task>& task, Glib::Threads::Thread& thread);.

A thread is exiting, this is called when the thread is about to leave its function.

◆ SlotTask

For example, void on_do_task();.

◆ TaskThreadSlot

Bidirectional slot.

Constructor & Destructor Documentation

◆ Task() [1/2]

Gst::Task::Task ( Task&&  src)
noexcept

◆ ~Task()

Gst::Task::~Task ( )
overridenoexcept

◆ Task() [2/2]

Gst::Task::Task ( const SlotTask task_slot)
explicitprotected

Member Function Documentation

◆ cleanup_all()

static void Gst::Task::cleanup_all ( )
static

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.

◆ create()

static Glib::RefPtr<Task> Gst::Task::create ( const SlotTask task_slot)
static

Create a new Gst::Task that will repeatedly call the provided slot as a parameter.

Typically the task will run in a new thread.

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

Parameters
task_slotThe Gst::Task::SlotTask to use.
Returns
A new Gst::Task. MT safe.

◆ get_pool() [1/2]

Glib::RefPtr<Gst::TaskPool> Gst::Task::get_pool ( )

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

MT safe.

Returns
The Gst::TaskPool used by task. Gst::Object::unref() after usage.

◆ get_pool() [2/2]

Glib::RefPtr<const Gst::TaskPool> Gst::Task::get_pool ( ) const

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

MT safe.

Returns
The Gst::TaskPool used by task. Gst::Object::unref() after usage.

◆ get_state()

TaskState Gst::Task::get_state ( ) const

Get the current state of the task.

Returns
The Gst::TaskState of the task

MT safe.

◆ get_type()

static GType Gst::Task::get_type ( )
static

Get the GType for this class, for use with the underlying GObject type system.

◆ gobj() [1/2]

GstTask* Gst::Task::gobj ( )
inline

Provides access to the underlying C GObject.

◆ gobj() [2/2]

const GstTask* Gst::Task::gobj ( ) const
inline

Provides access to the underlying C GObject.

◆ gobj_copy()

GstTask* Gst::Task::gobj_copy ( )

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

◆ join()

bool Gst::Task::join ( )

Joins task.

After this call, it is safe to unref the task and clean up the lock set with 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.

Returns
true if the task could be joined.

MT safe.

◆ operator=()

Task& Gst::Task::operator= ( Task&&  src)
noexcept

◆ pause()

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

Returns
true if the task could be paused.

MT safe.

◆ set_enter_slot()

void Gst::Task::set_enter_slot ( const SlotEnter enter_slot)

Call enter_slot when the task function of task is entered.

Parameters
enter_slot

◆ set_leave_slot()

void Gst::Task::set_leave_slot ( const SlotLeave leave_slot)

Call leave_func when the task function of task is left.

Parameters
leave_slot

◆ set_lock()

void Gst::Task::set_lock ( Glib::Threads::RecMutex mutex)

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 pause() or start().

MT safe.

Parameters
mutexThe RecMutex to use.

◆ set_pool()

void Gst::Task::set_pool ( const Glib::RefPtr< Gst::TaskPool >&  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
poolA Gst::TaskPool.

◆ set_state()

void Gst::Task::set_state ( Gst::TaskState  state)

Sets the state of task to state.

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

MT safe.

Parameters
stateThe new task state.

◆ start()

bool Gst::Task::start ( )

Starts task.

The task must have a lock associated with it using set_lock() or this function will return false.

Returns
true if the task could be started.

MT safe.

◆ stop()

bool 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 join() to stop and wait for completion.

Returns
true if the task could be stopped.

MT safe.

Friends And Related Function Documentation

◆ wrap()

Glib::RefPtr< Gst::Task > wrap ( GstTask *  object,
bool  take_copy = false 
)
related

A Glib::wrap() method for this object.

Parameters
objectThe C instance.
take_copyFalse if the result should take ownership of the C instance. True if it should take a new copy or ref.
Returns
A C++ instance that wraps this C instance.