As you can imagine, more complex functions lead to more complex pipelines. If you find your code is getting messy, the best thing to do is to chuck it in a Bin! Fear not, we aren’t recommending you give up your career as an application developer, a Bin is a special element that encapsulates a whole gstreamer pipeline. This keeps this tidy and makes code reuse much easier.
GStreamer ships with several handy Bins that implement common use cases, such as:
- Playbin: Plays a given media file to the given audio/video sinks (what gst-play-1.0 uses under the hood)
- Camerabin: Implements a video recording device
Don’t forget that GStreamer pipelines are automatically assigned a state of GST_STATE_NULL upon creation. To actually use the pipeline you must set it to GST_STATE_PLAYING.
The four simple states for pipelines are:
- NULL: Default initial state (stopped)
- READY: The element will transition to PAUSED after startup
- PAUSED: The elements will accept and process data, however, the pipeline’s sink will block
- PLAYING: The sink will perform rendering/writing