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