Android multimedia development [11] -- OpenMax implementation in android [2] openma in AwesomePlayer

Source: Internet
Author: User

AwesomePlayer has a variable.
OMXClient mClient;
Let's take a look at OMXClient.
Class OMXClient {
OMXClient ();
Status_t connect ();
Void disconnect ();
Sp <IOMX> interface (){
Return mOMX;
OMXClient (const OMXClient &);
OMXClient & operator = (const OMXClient &);
The OMXClient has an IOMX variable mOMX, which is used to communicate with the OMX service in binder mode.
The AwesomePlayer constructor calls
CHECK_EQ (mClient. connect (), (status_t) OK );
Status_t OMXClient: connect (){
Sp <IServiceManager> sm = defaultServiceManager ();
Sp <IBinder> binder = sm-> getService (String16 ("media. player "));
Sp <IMediaPlayerService> service = interface_cast <IMediaPlayerService> (binder );
CHECK (service. get ()! = NULL );
MOMX = service-> getOMX ();
CHECK (mOMX. get ()! = NULL );
If (! MOMX-> livesLocally (NULL/* node */, getpid ())){
ALOGI ("Using client-side OMX mux .");
MOMX = new MuxOMX (mOMX );
Return OK;
[Cpp] view plaincopy
Sp <IOMX> MediaPlayerService: getOMX (){
Mutex: Autolock autoLock (mLock );
If (mOMX. get () = NULL ){
MOMX = new OMX;
Return mOMX;

OMXClient: The connect function obtains MediaPlayerService through the binder Mechanism, and then creates OMX instances through MediaPlayerService. In this way, the OMXClient obtains the OMX entry, and then obtains the services provided by OMX through the binder Mechanism.
That is to say, OMXClient is the openmax entry in android.

When you create audio/video decoding mVideoSource and mAudioSource, the sp <IOMX> mOMX instance in the OMXClient is sent to mVideoSource and mAudioSource to share the OMX entry.
That is to say, an AwesomePlayer corresponds to an IOMX variable. The audio/video decoder in AwesomePlayer shares this IOMX variable to obtain the OMX service.
Sp <IOMX> interface (){
Return mOMX;
MAudioSource = OMXCodec: Create (
MClient. interface (), mAudioTrack-> getFormat (),
False, // createEncoder
MAudioTrack );
MVideoSource = OMXCodec: Create (
MClient. interface (), mVideoTrack-> getFormat (),
False, // createEncoder
NULL, flags, USE_SURFACE_ALLOC? MNativeWindow: NULL );

Related Article

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: 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.