There is a variable in the Awesomeplayer
[CPP]View Plaincopy
- Omxclient mclient;
Let's see omxclient.
[CPP]View Plaincopy
- Class Omxclient {
- Public
- Omxclient ();
- status_t Connect ();
- void Disconnect ();
- Sp<iomx> interface () {
- return MOMX;
- }
- Private
- Sp<iomx> MOMX;
- Omxclient (const omxclient &);
- Omxclient &operator= (const omxclient &);
- };
Omxclient has a IOMX variable MOMX, which is a binder communication with the OMX service. Called in the constructor of the Awesomeplayer.
[CPP]View Plaincopy
- Check_eq (Mclient.connect (), (status_t) OK);
[CPP]View Plaincopy
- 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;
- }
The Omxclient::connect function is obtained through the binder mechanism to mediaplayerservice and then through Mediaplayerservice to create an instance of OMX. In this way the omxclient gets to OMX's entrance, and the next step is to obtain the services that OMX provides through the binder mechanism. This means that omxclient is the OpenMAX entry in Android. In the creation of audio and video decoding Mvideosource, Maudiosource will be omxclient in the Sp<iomx> MOMX instance to Mvideosource, Maudiosource to share the use of the OMX portal. In other words, a awesomeplayer corresponds to a IOMX variable, and the audio and video decoder in Awesomeplayer uses this IOMX variable to obtain the OMX service.
[CPP]View Plaincopy
- Sp<iomx> interface () {
- return MOMX;
- }
[CPP]View Plaincopy
- Maudiosource = Omxcodec::create (
- Mclient.interface (), Maudiotrack->getformat (),
- false, //Createencoder
- Maudiotrack);
[CPP]View Plaincopy
- mvideosource = omxcodec::create (
- mclient.interface (), mVideoTrack- >getformat (),
- false, //&NBSP;CREATEENCODER&NBSP;&NBSP;
- mVideoTrack,
- null, Flags, use_surface_alloc ? mnativewindow : null);