gstreamermm 0.10.11

- Main Page
- Modules
- Namespaces
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Related Functions
Gst::Task Class Reference

A class representing GStreamer streaming threads. More...

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

List of all members.

## Public Types

typedef sigc::slot< void > | SlotTask
| For example, void on_do_task();.
typedef sigc::slot< void, const Glib::RefPtr< Gst::Task > &, Glib::Threads::Thread* > | SlotEnter
| For example, void on_enter(const Glib::RefPtr<Gst::Task>& task, Glib::Threads::Thread& thread);.
typedef sigc::slot< void, const Glib::RefPtr< Gst::Task > &, Glib::Threads::Thread* > | SlotLeave
| For example, void on_leave(const Glib::RefPtr<Gst::Task>& task, Glib::Threads::Thread& thread);.

## Public Member Functions

virtual | ~Task ()
GstTask* | gobj ()
| Provides access to the underlying C GObject.
const GstTask* | gobj () const
| Provides access to the underlying C GObject.
GstTask* | gobj_copy ()
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
void | set_lock (Glib::StaticRecMutex& mutex)
| Set the mutex used by the task.
void | set_priority (Glib::ThreadPriority priority)
| Changes the priority of task to priority.
void | set_pool (const Glib::RefPtr< Gst::TaskPool >& pool)
| Set pool as the new GstTaskPool for task.
Glib::RefPtr< Gst::TaskPool > | get_pool ()
| Get the Gst::TaskPool that this task will use for its streaming threads.
Glib::RefPtr< const Gst::TaskPool > | get_pool () const
| Get the Gst::TaskPool that this task will use for its streaming threads.
void | set_thread_slots (const SlotEnter& enter_slot, const SlotLeave& leave_slot)
| Set slots which will be executed when a new thread is needed, the thread function is entered and left and when the thread is joined.
TaskState | get_state () const
| Get the current state of the task.
void | set_state (Gst::TaskState state)
| Sets the state of task to state.
bool | pause ()
| Pauses task.
bool | start ()
| Starts task.
bool | stop ()
| Stops task.
bool | join ()
| Joins task.

## Static Public Member Functions

static GType | get_type ()
| Get the GType for this class, for use with the underlying GObject type system.
static Glib::RefPtr< Task > | create (const SlotTask& task_slot)
| Create a new Gst::Task that will repeatedly call the provided slot as a parameter.
static void | cleanup_all ()
| Wait for all tasks to be stopped.

## Protected Member Functions

| Task (const SlotTask& task_slot)

## Related Functions

(Note that these are not member functions.)
Glib::RefPtr< Gst::Task > | wrap (GstTask* object, bool take_copy=false)
| A Glib::wrap() method for this object.

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

Last reviewed on 2006-02-13 (0.10.4)

## Member Typedef Documentation

typedef sigc::slot<void, const Glib::RefPtr<Gst::Task>&, Glib::Threads::Thread*> Gst::Task::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.

typedef sigc::slot<void, const Glib::RefPtr<Gst::Task>&, Glib::Threads::Thread*> Gst::Task::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.

typedef sigc::slot<void> Gst::Task::SlotTask

For example, void on_do_task();.

## Constructor & Destructor Documentation

virtual Gst::Task::~Task | ( |  | ) | `[virtual]`

Gst::Task::Task | ( | const SlotTask& | task_slot | ) | `[explicit, protected]`

## Member Function Documentation

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.

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_slot | The Gst::Task::SlotTask to use.

Returns:
  A new Gst::Task. MT safe.

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.

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.

TaskState Gst::Task::get_state | ( |  | ) | const

Get the current state of the task.

Returns:
  The Gst::TaskState of the task

MT safe.

static GType Gst::Task::get_type | ( |  | ) | `[static]`

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

Reimplemented from Gst::Object.

GstTask* Gst::Task::gobj | ( |  | ) | `[inline]`

Provides access to the underlying C GObject.

Reimplemented from Gst::Object.

const GstTask* Gst::Task::gobj | ( |  | ) | const`[inline]`

Provides access to the underlying C GObject.

Reimplemented from Gst::Object.

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.

Reimplemented from Gst::Object.

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.

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.

void Gst::Task::set_lock | ( | Glib::StaticRecMutex & | 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:

  mutex | The Mutex to use.

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:

  pool | A Gst::TaskPool.

void Gst::Task::set_priority | ( | Glib::ThreadPriority | priority | ) |

Changes the priority of task to priority.

Note:
  try not to depend on task priorities.

MT safe.

Parameters:

  priority | A new priority for task.

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:

  state | The new task state.

Returns:
  `true` if the state could be changed.

void Gst::Task::set_thread_slots | ( | const SlotEnter& | enter_slot,
|  | const SlotLeave& | leave_slot
| ) |  |

Set slots which will be executed when a new thread is needed, the thread function is entered and left and when the thread is joined.

By default a thread for the task will be created from a default thread pool.

Objects can use custom Glib::Threads::Thread or can perform additional configuration of the threads (such as changing the thread priority) by installing slots.

MT safe.

Parameters:

  enter_slot | A SlotEnter slot.
  leave_slot | A SlotLeave slot.

Since 0.10.24.

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.

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

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

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

Parameters:

  object | The C instance.
  take_copy | False 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.

The documentation for this class was generated from the following file:

- gstreamermm/task.h