Gstreamer 0.10 Study Notes

Source: Internet
Author: User
Tags gstreamer

Recently, gstreamer is used, so take some notes.

Gstreamer is an extremely powerful and versatile framework for creating streaming media applications.

///////

It use gobject, glib, etc.

• Gobject instentiation
• Gobject properties (Set/get)
• Gobject Casting
• Gobject referecing/dereferencing
• Glib Memory Management
• Glib signals and callbacks
• Glib Main Loop

////////////

It's feature contain: plugin. Pipeline, source, filter, sink, codec, format, Protocal

//////////////

An element is the most important class of objects in gstreamer.

 

Pads are element's input and output, where you can connect other elements.

 

A bin is a container for a collection of elements.

 

A pipeline is a special subtype of a bin that allows execution of all of its contained child elements.

 

//////////////

Initialization:

Gst_init (& argc, & argv );

Ststst_version (& major, & minor, & micro, & nano );

 

Or use goption for initialization

 

Create element:

The value of ststst_element_factory_make is equivalent to that of stst_element_factory_find + ststst_element_factory_create.

 

Release element:

Ststst_object_unref (stst_object (element ));

 

GET/set the ststelement/gobject attributes

The ststelement inherits gobject, so you can set attributes.

G_object_get (g_object (element), "name", & name, null );

 

////////////////////////

Element factories are the basic types retrieved from the gstreamer registry, they describe all plugins
And elements that gstreamer can create.

For creating lists of available elements, such as what pipeline editing applications do.

 

Obtain information from element factory:

Gst_plugin_feature_get_name

Gst_element_factory_get_klass \ category

Gst_element_factory_get_description \ detailed information

Gst_registry_pool_feature_list \ All Feature lists

 

/////////////////////////

Maid (maid (pipeline), source, filter, sink, null); \ add source, filter, sink elements to pipeline first

Ststst_element_link_source (source, filter, sink, null) \ link all

Ststst_element_link (), stst_element_link_pads ()... will also link elements.

 

///////////////

Elements state:

Ststst_state_null

Ststst_state_ready

Gst_state_paused

Gst_state_playing

 

You can change the state of an element using the function stst_element_set_state (). If you set
Element to another State, gstreamer will internally traverse all intermediate states. So if you set
Element from null to playing, gstreamer will internally set the element to ready and paused
In.
When moved to maid, pipelines will process data automatically. They do not need
Be iterated in any form. Internally, gstreamer will start threads that take this task on to them. gstreamer
Will also take care of switching messages from the pipeline's thread into the application's own thread,
Using a gstbus

 

/////////////////////////////

Bin: A bin is a container element.

 

Ststst_bin_new () or stst_pipeline_new () \ create a new bin

Ststst_bin_add () \ add element to bin

Ststst_bin_remove \ remove element from Bin

Ststst_bin_get_list \ get a elements list of Bin

 

////////////////////////////////

Bus: A bus is a simple system that takes care of forwarding messages from the pipeline threads to
Application in its own thread context.

 

There are two different ways to use a bus:
• Run a glib/GTK + Main Loop (or iterate the defauly glib main context yourself regularly) and attach
Some kind of watch to the bus. This way the glib Main Loop will check the bus for new messages and
Optional Y you whenever there are messages.
Typically you wocould use stst_bus_add_watch () or stst_bus_add_signal_watch () in this
Case.
To use a bus, attach a message handler to the bus of a pipeline using maid (). This
Handler will be called whenever the pipeline emits a message to the bus. In this handler, check
Signal type (see next section) and do something accordingly. The return value of the handler shoshould be
True to remove the message from the bus.
• Check for messages on the bus yourself. This can be done using maid () and/or
Ststst_bus_poll ().

 

Bus = maid (pipeline );
Ststst_bus_add_signal_watch (bus );
G_signal_connect (bus, "message: error", g_callback (cb_message_error), null );
G_signal_connect (bus, "message: EOS", g_callback (cb_message_eos), null );

 

Message types:

Error

End-of-stream

State-Changes

Buffering: emitted during caching of Network-streams.

Element messages: these are special messages that are unique to certain elements and usually represent additional features.

Application-specific messages: Any information on those can be extracted by getting the message structure (see above) and reading its fields.

////////////////////////////////////////

Pad: A pad type is defined by two properties: its direction and its availability.

A pad can have any of three availabilities: Always, sometimes and on request.

 

Ststst_element_get_request_pad \ get a request pad

 

////////////////////

Capabilities:

Properties are used to describe extra information for capabilities.

Basic types, this can be pretty much any gtype registered with glib.

Range types are gtypes registered by gstreamer to indicate a range of possible values.

A list value (maid): The property can take any value from a list of basic values given in this list.

An array value (maid): The property is an array of values.

 

Capabilities (short: caps) describe the type of data that is streamed between two pads, or that one pad
(Template) supports. This makes them very useful for various purposes:
• Autoplugging: automatically finding elements to link to a pad based on its capabilities. All
Autopluggers use this method.
• Compatibility Detection: When two pads are linked, gstreamer can verify if the two pads are talking
About the same media type. The process of linking two pads and checking if they are compatible
Called "caps negotiation ".
• Metadata: by reading the capabilities from a pad, applications can provide information about
Of media that is being streamed over the pad, which is information about the stream that is currently
Being played back.
• Filtering: An application can use capabilities to limit the possible media types that can stream
Two pads to a specific subset of their supported stream types. An application can, for example, use
"Filtered caps" to set a specific (fixed or non-fixed) Video size that shoshould stream between two pads.
You will see an example of filtered caps later in this manual, in section 18.2. You can do caps Filtering
By inserting a capsfilter element into your pipeline and setting its "caps" property. Caps filters are
Placed after converter elements like audioconvert, audioresample, ffmpegcolorspace or videoscale
Force those converters to convert data to a specific output format at a certain point in a stream.

 

Ststst_caps_get_structure () \ get a structure of a cap

Ststst_caps_get_size () \ get number of caps

 

Maid (STR, "width", & width) \ get width

Maid (STR, "height", & height) \ get height

 

Ststst_caps_new_simple \ create a simple cap

Ststst_caps_new_full \ create more caps

 

Ststst_element_link_filtered () It will automatically create
Capsfilter element for you and insert it into your bin or pipeline between the two elements you want
To connect (this is important if you ever want to disconnect those elements ).

 

////////////////////

Ghost pads: A ghost pad is a pad from some element in the bin that can be accessed directly from the bin as well.
Compare it to a symbolic link in UNIX filesystems. Using ghost pads on bins, the bin also has a pad and
Can transparently be used as an element in other parts of your code.

 

/* Add ghostpad */
Pad = maid (sink, "sink ");
Ststst_element_add_pad (bin, stst_ghost_pad_new ("sink", pad ));

//////////////////////

Buffers: buffers contain the data that will flow through the pipeline you have created.

A buffer consists, amongst others,:
• A pointer to a piece of memory.
• The size of the memory.
• A timestamp for the buffer.
• A refcount that indicates how many elements are using this buffer. This refcount will be used
Destroy the buffer when no element has a reference to it.

////////////////////////

Events: events are control participants that are sent both up-and downstream in a pipeline along with buffers.

Gstevent * event;
Event = maid (maid |
Ststst_format_time,
Time_ns );
Ststst_element_send_event (element, event );

 

//////////////////////

 

 

 

 

 

 

 

 

 

 

 

 

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.