OpenMAX implementation of Android in "2" Awesomeplayer OpenMAX in the entrance

Source: Internet
Author: User

There is a variable in the Awesomeplayer

[CPP]View Plaincopy
    1. Omxclient mclient;
Let's see omxclient. [CPP]View Plaincopy
  1. Class Omxclient {
  2. Public
  3. Omxclient ();
  4. status_t Connect ();
  5. void Disconnect ();
  6. Sp<iomx> interface () {
  7. return MOMX;
  8. }
  9. Private
  10. Sp<iomx> MOMX;
  11. Omxclient (const omxclient &);
  12. Omxclient &operator= (const omxclient &);
  13. };
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
    1. Check_eq (Mclient.connect (), (status_t) OK);
[CPP]View Plaincopy
  1. status_t Omxclient::connect () {
  2. sp<iservicemanager> sm = Defaultservicemanager ();
  3. sp<ibinder> Binder = Sm->getservice (String16 ("Media.player"));
  4. sp<imediaplayerservice> service = interface_cast<imediaplayerservice> (binder);
  5. CHECK (Service.get ()! = NULL);
  6. MOMX = Service->getomx ();
  7. CHECK (Momx.get ()! = NULL);
  8. if (!momx->liveslocally (NULL/ * node */, Getpid ())) {
  9. Alogi ("Using client-side OMX mux.");
  10. MOMX = new Muxomx (MOMX);
  11. }
  12. return OK;
  13. }
[CPP]View Plaincopy
    1. Sp<iomx> Mediaplayerservice::getomx () {
    2. Mutex::autolock Autolock (MLock);
    3. if (momx.get () = = NULL) {
    4. MOMX = new OMX;
    5. }
    6. return MOMX;
    7. }
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
    1. Sp<iomx> interface () {
    2. return MOMX;
    3. }
[CPP]View Plaincopy
    1. Maudiosource = Omxcodec::create (
    2. Mclient.interface (), Maudiotrack->getformat (),
    3. false, //Createencoder
    4. Maudiotrack);
[CPP]View Plaincopy
    1. mvideosource = omxcodec::create (  
    2.             mclient.interface (),  mVideoTrack- >getformat (),   
    3.              false, //&NBSP;CREATEENCODER&NBSP;&NBSP;
    4.             mVideoTrack,   
    5.             null,  Flags, use_surface_alloc ? mnativewindow : null);  

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.