Klasse Task

Alle implementierten Schnittstellen:
PointerInterface

public class Task extends PropertyHolder
#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.

https://gstreamer.freedesktop.org/documentation/gstreamer/gi-index.html

  • Konstruktordetails

    • Task

      public Task(PointerContainer pointer)
    • Task

      public Task(Task.OnTaskFunction func, @Nullable Pointer user_data, Task.OnDestroyNotify 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.
      Parameter:
      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.
  • Methodendetails

    • getClassHandler

      public static ClassHandler getClassHandler()
    • getPool

      public TaskPool getPool()
      Get the #GstTaskPool that this task will use for its streaming
      threads.

      MT safe.
      Gibt zurück:
      the #GstTaskPool used by @task. gst_object_unref() after usage.
    • getState

      public int getState()
      Get the current state of the task.
      Gibt zurück:
      The #GstTaskState of the task MT safe.
    • join

      public boolean 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.
      Gibt zurück:
      %TRUE if the task could be joined. MT safe.
    • pause

      public boolean 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.
      Gibt zurück:
      %TRUE if the task could be paused. MT safe.
    • resume

      public boolean 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.
      Gibt zurück:
      %TRUE if the task could be resumed. MT safe.
    • setEnterCallback

      public void setEnterCallback(Task.OnTaskThreadFunc enter_func, @Nullable Pointer user_data, Task.OnDestroyNotify 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.
      Parameter:
      enter_func - a #GstTaskThreadFunc
      user_data - user data passed to @enter_func
      notify - called when @user_data is no longer referenced
    • setLeaveCallback

      public void setLeaveCallback(Task.OnTaskThreadFunc leave_func, @Nullable Pointer user_data, Task.OnDestroyNotify 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.
      Parameter:
      leave_func - a #GstTaskThreadFunc
      user_data - user data passed to @leave_func
      notify - called when @user_data is no longer referenced
    • setLock

      public void setLock(@Nonnull RecMutex 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.
      Parameter:
      mutex - The #GRecMutex to use
    • setPool

      public void setPool(@Nonnull 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.
      Parameter:
      pool - a #GstTaskPool
    • setState

      public boolean setState(int 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.
      Parameter:
      state - the new task state
      Gibt zurück:
      %TRUE if the state could be changed.
    • start

      public boolean start()
      Starts @task. The @task must have a lock associated with it using
      gst_task_set_lock() or this function will return %FALSE.
      Gibt zurück:
      %TRUE if the task could be started. MT safe.
    • stop

      public boolean 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.
      Gibt zurück:
      %TRUE if the task could be stopped. MT safe.
    • cleanupAll

      public static 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.

      MT safe.
    • getTypeID

      public static long getTypeID()
    • getParentTypeID

      public static long getParentTypeID()
    • getTypeSize

      public static TypeSystem.TypeSize getTypeSize()
    • getParentTypeSize

      public static TypeSystem.TypeSize getParentTypeSize()
    • getInstanceSize

      public static int getInstanceSize()