Omxcodec and OMX Event processing flow

Source: Internet
Author: User

Learn to understand the Mutilmedia framework for some time, today idle down a little to tidy up. The OMXCodec.cpp class belongs to Libstagefright, which is quite omx on the entire mm PF for Awesomeplayer invocation, and omx.cpp,omxnoteinstance.cpp equal to OpenMAX in the OpenMAX IL, first of all Omxcodec and OMX callback event processing flow. Let's look at the timing diagram of the entire process:

From the timing diagram, first we want to establish a omxcodecobserver, the class is the inner class of Omxcodec, created in the CREATE function, and the corresponding omxcodec into their own observation range, the specific code is as follows:

Framework/base/media/libstagefright/omxcodec.cpp

Sp<mediasource> Omxcodec::create (
Const Sp<iomx> &OMX,
Const sp<metadata> &meta, BOOL Createencoder,
Const Sp<mediasource> &source,
const Char *matchcomponentname,
uint32_t flags) {

.....

sp<omxcodecobserver> observer = new Omxcodecobserver;

...............

Observer->setcodec (codec);

...................

}

Second, initialize its callback event and event dispatch handler function.

What are the main callback events of OMX? The Kcallbacks function in Framework/base/media/libstagefright/omx/omxnodeinstance.cpp is defined as follows:

Static
Omx_callbacktype omxnodeinstance::kcallbacks = {
&onevent, &onemptybufferdone, &onfillbufferdone
};

Where does the callback define it? Look at the framework/base/media/libstagefright/omx/omx.cpp.

status_t Omx::allocatenode (

.......................

Omxnodeinstance *instance = new Omxnodeinstance (this, observer);

Omx_componenttype *handle;
Omx_errortype err = mmaster->makecomponentinstance (
Name, &omxnodeinstance::kcallbacks,
instance, &handle);

..............

Mdispatchers.add (*node, new Callbackdispatcher (instance));

...................

}

That is, each component corresponds to a set of callback events.

What functions are returned by these callback? The specific definition in framework/base/media/libstagefright/openmax/omx_core.h

Callback EventHandler ()

#define Omx_sendcommand(                                    \
Hcomponent, \
CMD, \
Nparam, \
Pcmddata) \
((omx_componenttype*) hcomponent)->sendcommand (\
Hcomponent, \
CMD, \
Nparam, \
Pcmddata)

Emptybufferdone call back.

#define Omx_emptythisbuffer(                                \
Hcomponent, \
pbuffer) \
((omx_componenttype*) hcomponent)->emptythisbuffer (\
Hcomponent, \
pbuffer)/* Macro End */

Fillbufferdone Call Back

#define Omx_fillthisbuffer(                                 \
Hcomponent, \
pbuffer) \
((omx_componenttype*) hcomponent)->fillthisbuffer (\
Hcomponent, \
pbuffer)/* Macro End */

With the callback incident, how to dispatch it? In fact, we have defined our dispatch function in the Allocatenote function.

Mdispatchers.add (*node, new Callbackdispatcher (instance));

With Oberser, callback event, Callbackdispatcher, how does a callback event go from OMX to Omxcodec? Let's take a look at the emptybuffer process below, the timing diagram is as follows:

is not a bit like handle:)

Omxcodec and OMX Event processing flow

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.