OpenWrt GStreamer Example Learning notes (three. In-depth understanding of the Element of GStreamer)

Source: Internet
Author: User
Tags autoloader gstreamer

In the previous section, we briefly introduced gstelementfactory can be used to create an instance of element, but gstelementfactory not only do it, gstelementfactory as a GStreamer A basic type in the registration system that describes all the plug-ins (plugins) and the element created by GStreamer. This means that gstelementfactory can be applied to some automatic element instances, such as an automatic plug-in (autopluggers); or create a list of available element, like a pipe-to-application operation like GStreamer Editor.

1. Obtaining the element information via Gstelementfactory

Tools like Gst-inspect can give a summary of an element: the author of the plugin (plugin), the descriptive element name (or abbreviation), the level of element (rank), and the category of element. A category can be used to get the type of an element that was created when the element was created using Gstelementfactory. For example, the category can be Codec/decoder/video (video decoder), Source/video (Video generator), Sink/video (video output). Audio also has a similar category. There are also codec/demuxer and codec/muxer, and even more categories. Gst-inspect will list all current factory objects, Gst-inspect <factory-name> will list all the profile information for a particular factory object.

All the profile information for a particular factory object will be listed.

#include <gst/gst.h>

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

{

Gstelementfactory *factory;

/* Init GStreamer */

Gst_init (&ARGC, &ARGV);

/* Get factory */

Factory = Gst_element_factory_find ("Audioconvert");

if (!factory) {

G_print ("You don't have the ' audioconvert ' element installed!\n");

return-1;

}

/* Display information */

G_print ("The '%s ' element is a member of the category%s.\n"

"Description:%s\n",

Gst_plugin_feature_get_name (Gst_plugin_feature (Factory)),

Gst_element_factory_get_klass (Factory),

Gst_element_factory_get_description (Factory));

return 0;

}

2. Find the pads contained in element

The most useful feature of gstelementfactory may be that it contains a detailed description of the pads that can be generated by element, as well as the functions of these pads (in other words, the type of media supported by these pads), and getting this information does not require all plugins (plugins) are loaded into memory. This can be used to give an encoder a list of encodings, or to play a role when the multimedia player automatically loads the plugin. All GStreamer-based multimedia players and Autoloader (Autoplugger) are currently working in this way.

3. LINK element

You can set up a media pipeline by linking a source element, 0 or more like filter element, and a recv element. The data will flow between these element. This is the basic concept of handling media in GStreamer.

By linking these three element, we create a simple element chain. The output of the source element ("Element1") in the element chain will be the input to the like filter element ("Element2"). The like filter element will perform certain operations on the data and then output the data to the final recv element ("Element3").

4.element status

Once an element is created, it will not perform any action. So you need to change the state of element so that it can do something. In GStreamer, there are four states of a component, each of which has a specific meaning. These four states are:

1) Gst_state_null: Default state. This state will reclaim all resources that are consumed by the element.

2) Gst_state_ready: Ready state. Element will get all the required global resources that will be used by the data stream of the element. such as opening devices, assigning caches, and so on. However, in this state, the data stream is still not started to be processed, so the location information of the data stream should be automatically set to 0. If the data stream was previously opened, it should be closed and its location information and attribute information should be reset to its original state.

3) Gt_state_paused: In this state, the element has already been processed by convection, but is now paused. Thus the element can modify the position information of the stream, read or process the stream data, and once the state becomes PLAYING, the stream can replay the data stream. In this case, the clock is forbidden to run. In short, the PAUSED state is the same as the PLAYING state except that it cannot run the clock. The element in the PAUSED state is quickly transformed to the PLAYING state. For example, the video or audio output element waits for the data to arrive and presses them into the queue. Once the state changes, the element processes the received data. Similarly, the video receive element is able to play the first frame of the data. (because this does not affect the clock). The autoloader (autopluggers) can perform this state transition for plug-ins that have already been loaded into the pipeline. The other element, like codecs or filters, does not need to do anything in this state.

4) The gt_state_playing:playing state is identical to the PAUSED state in addition to the current running clock. You can change the state of an element by using the function gst_element_set_state (). If you explicitly change the state of an element, GStreamer may cause it to pass through some intermediate states inside. For example, if you set an element from a NULL state to a PLAYING state, GStreamer inside will cause the element to experience the ready and PAUSED state.

When in the Gst_state_playing state, the pipeline processes the data automatically. They do not require any form of iteration. GStreamer will open a new thread to process the data. GStreamer can also use Gstbus to interact information between pipeline threads and applications out-of-the-box

OpenWrt GStreamer Example Learning notes (three. In-depth understanding of the Element of GStreamer)

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.