GStreamer Application Development Manual (0.8.1) | ||
---|---|---|
<<< Previous | Next >>> |
Cothreads are user-space threads that greatly reduce context switching overhead introduced by regular kernel threads. Cothreads are also used to handle the more complex elements. They differ from other user-space threading libraries in that they are scheduled explictly by GStreamer.
A cothread is created by a GstBin
whenever an element is found
inside the bin that has one or more of the following properties:
The element is loop-based instead of chain-based
The element has multiple input pads
The element has the MULTI_IN flag set
GstBin
will create a cothread context for all the elements
in the bin so that the elements will interact in cooperative
multithreading.
Before proceding to the concept of loop-based elements we will first explain the chain-based elements.
Chain based elements receive a buffer of data and are supposed to handle the data and perform a gst_pad_push.
The basic main function of a chain-based element is like:
static void chain_function (GstPad *pad, GstBuffer *buffer) { GstBuffer *outbuffer; .... // process the buffer, create a new outbuffer ... gst_pad_push (srcpad, outbuffer); } |
Chain based function are mainly used for elements that have a one to one relation between their input and output behaviour. An example of such an element can be a simple video blur filter. The filter takes a buffer in, performs the blur operation on it and sends out the resulting buffer.
Another element, for example, is a volume filter. The filter takes audio samples as input, performs the volume effect and sends out the resulting buffer.
<<< Previous | Home | Next >>> |
Queues | Up | Loop-based elements |