OpenWrt GStreamer Example Learning Note (four. GStreamer Bins)

Source: Internet
Author: User
Tags gstreamer

1) Overview

Bins is a container element. You can add an element to the bins. Since bins is also an element in itself, you can manipulate bins like a normal element. As a result, the contents of the previously closed element can also be applied to bins.

Bins allows you to combine a set of linked element into a large logical element. You no longer need to operate on a single element, only the bins. When you build a complex pipeline, you'll find bins's great advantage, because it allows you to break down complex pipelines into smaller chunks.

The bins can also be managed with the element contained therein. It calculates how the data flows into the bins and formulates an optimal plan for the incoming traffic (generate an optimal plan). Plan generation is one of the most complex steps in GStreamer.

Visualizing the bins:

A special bins that GStreamer programmers often use:

(Pipeline) Pipe: An ordinary container that allows the arrangement of the contained element (scheduling). The top level (toplevel) bins must be a pipe. Therefore, each GStreamer application requires at least one pipeline. When the application starts, the pipeline automatically runs in the background thread.

2) Create bins

You can create a bins, such as using Gstelementfactory, by using the method of creating other element. There are, of course, some more convenient functions to create bins-(Gst_bin_new () and Gst_pipeline_new ()). You can use Gst_bin_add () to add element to bins, and use Gst_bin_remove () to remove element from the bins. When you add an element to the bins, bins will have a dependency on the element, and when you destroy a bins, the element in the bins is also destroyed (dereferenced); When you remove an element from bins, The element is automatically destroyed (dereferenced).

#include <gst/gst.h>

int main (int argc, char *argv[])

{

Gstelement *bin, *pipeline, *source, *sink;

/* init */

Gst_init (&ARGC, &ARGV);

/* Create */

Pipeline = gst_pipeline_new ("My_pipeline");

Bin = gst_pipeline_new ("My_bin");

Source = Gst_element_factory_make ("fakesrc", "source");

Sink = Gst_element_factory_make ("Fakesink", "sink");

/* Set up pipeline */

Gst_bin_add_many (Gst_bin (bin), source, sink, NULL);

Gst_bin_add (Gst_bin (pipeline), bin);

Gst_element_link (source, sink);

[..]

}

3) Define Bins

Programmers can customize the bins to perform specific tasks. For example, you can refer to the following code to write a Ogg/vorbis decoder.

int main (int argc, char *argv[])

{

Gstelement *player;

/* init */

Gst_init (&ARGC, &ARGV);

/* Create player */

Player = Gst_element_factory_make ("Oggvorbisplayer", "player");

/* Set the source audio file */

G_object_set (player, "location", "Helloworld.ogg", NULL);

/* Start playback */

Gst_element_set_state (gst_element (player), gst_state_playing);

[..]

}

Custom bins can be created with a plug-in or XML interpreter. You can get more information on creating custom bins from the Plugin writers Guide. The Playbin and Decodebin elements in the gst-plugins-base are examples of custom cabinets.

OpenWrt GStreamer Example Learning Note (four. GStreamer Bins)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.