Gst.Task

const Gst = imports.gi.Gst;

let task = new Gst.Task();
  

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.RecMutex that can be set with Gst.set_lock.

The task can be started, paused and stopped with Gst.start, Gst.pause and Gst.stop respectively or with the Gst.set_state function.

A Gst.Task will repeatedly call the Gst.TaskFunction with the user data that was provided when creating the task with Gst.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.stop will not immediately make sure the task is not running anymore. Use Gst.join to make sure the task is completely stopped and the thread is stopped.

After creating a Gst.Task, use Gst.Object.prototype.unref to free its resources. This can only be done when the task is not running anymore.

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 2012-03-29 (0.11.3)

Hierarchy

  • GObject.Object
    • GObject.InitiallyUnowned
      • Gst.Object
        • Gst.Task