Binder Bp is used in a variety of processes

Source: Internet
Author: User

Scene:

1) IMediaPlayer.cpp

Bp, Bn

Sp<igraphicbufferproducer> Bufferproducer =

Interface_cast<igraphicbufferproducer> (Data.readstrongbinder ());

Reply->writeint32 (Setvideosurfacetexture (bufferproducer));

Use in Mediaplayerservice
sp<igraphicbufferproducer>& Bufferproducer the BP interacts with Bn

2) Pass the BP object in the Mediaplayerservice process to another process using the

Virtual status_t Connect (const sp<igraphicbufferproducer> &bufferproduce, Sp<iremotedisplayclient> & Amp;sinkclient)

{

Parcel data, reply;

Data.writeinterfacetoken (Iremotedisplay::getinterfacedescriptor ());

Data.writestrongbinder (Iinterface::asbinder (bufferproduce));

Data.writestrongbinder (Iinterface::asbinder (sinkclient));

Remote ()->transact (CONNECT, data, &reply);

return Reply.readint32 ();

}

status_t bnremotedisplay::ontransact (...). ){.........

Case connect:{

Check_interface (iremotedisplay, data, reply);

sp<igraphicbufferproducer> bufferproducer = Igraphicbufferproducer::asinterface (Data.readStrongBinder ()); //The BP object obtained from the Mediaplayerservice process can also be used here

sp<iremotedisplayclient> Clientsink = interface_cast<iremotedisplayclient> (Data.readStrongBinder ());

Reply->writeint32 (Connect (bufferproducer,clientsink));

return no_error;

}


3) A bnxx can be inherited by multiple classes and then obtained at different interfaces by BP

Return interface_cast<iremotedisplay> (Reply.readstrongbinder ());

Can distinguish between the corresponding class of Bn

<IRemoteDisplay> corresponds to Remotedisplay not one by one, Iremotedisplay may correspond to multiple classes

This article from "Flyingbear" blog, reproduced please contact the author!

Binder Bp is used in a variety of processes

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.