async def mrp_protocol(event_loop, mrp_atv): port = mrp_atv.get_port(Protocol.MRP) service = MrpService("mrp_id", port) connection = MrpConnection("127.0.0.1", port, event_loop) protocol = MrpProtocol(connection, SRPAuthHandler(), service) yield protocol protocol.stop()
def __init__( self, loop: asyncio.AbstractEventLoop, session_manager: ClientSessionManager, config: conf.AppleTV, airplay: Stream, ) -> None: """Initialize a new Apple TV.""" super().__init__() self._session_manager = session_manager self._config = config self._mrp_service = config.get_service(Protocol.MRP) assert self._mrp_service is not None self._connection = MrpConnection(config.address, self._mrp_service.port, loop, atv=self) self._srp = SRPAuthHandler() self._protocol = MrpProtocol(self._connection, self._srp, self._mrp_service) self._psm = PlayerStateManager(self._protocol, loop) self._mrp_remote = MrpRemoteControl(loop, self._psm, self._protocol) self._mrp_metadata = MrpMetadata(self._protocol, self._psm, config.identifier) self._mrp_power = MrpPower(loop, self._protocol, self._mrp_remote) self._mrp_push_updater = MrpPushUpdater(loop, self._mrp_metadata, self._psm) self._mrp_features = MrpFeatures(self._config, self._psm) self._airplay = airplay
async def start(self, address, port, credentials): """Start the proxy instance.""" self.connection = MrpConnection(address, port, self.loop) protocol = MrpProtocol( self.loop, self.connection, SRPAuthHandler(), MrpService(None, port, credentials=credentials)) await protocol.start(skip_initial_messages=True) self.connection.listener = self self._process_buffer()
def __init__(self, config, session, loop): """Initialize a new MrpPairingHandler.""" super().__init__(session, config.get_service(Protocol.MRP)) self.connection = MrpConnection(config.address, self.service.port, loop) self.srp = SRPAuthHandler() self.protocol = MrpProtocol(loop, self.connection, self.srp, self.service) self.pairing_procedure = MrpPairingProcedure(self.protocol, self.srp) self.pin_code = None
def start(self, address, port): """Start the proxy instance.""" # Establish connection to ATV self.connection = MrpConnection(address, port, self.loop) protocol = MrpProtocol( self.loop, self.connection, SRPAuthHandler(), MrpService(None, port, credentials=self.credentials)) self.loop.run_until_complete( protocol.start(skip_initial_messages=True)) self.connection.listener = self # Setup server used to publish a fake MRP server coro = self.loop.create_server(lambda: self, '0.0.0.0') self.server = self.loop.run_until_complete(coro) _LOGGER.info('Started MRP server at port %d', self.port)
def __init__(self, loop, session, details, airplay): """Initialize a new Apple TV.""" super().__init__() self._session = session self._mrp_service = details.usable_service() self._connection = MrpConnection(details.address, self._mrp_service.port, loop) self._srp = SRPAuthHandler() self._protocol = MrpProtocol(loop, self._connection, self._srp, self._mrp_service) self._mrp_remote = MrpRemoteControl(loop, self._protocol) self._mrp_metadata = MrpMetadata(self._protocol) self._mrp_push_updater = MrpPushUpdater(loop, self._mrp_metadata, self._protocol) self._mrp_pairing = MrpPairingHandler(self._protocol, self._srp, self._mrp_service) self._airplay = airplay
def __init__(self, loop, session, config, airplay): """Initialize a new Apple TV.""" super().__init__() self._session = session self._mrp_service = config.get_service(Protocol.MRP) self._connection = MrpConnection(config.address, self._mrp_service.port, loop, atv=self) self._srp = SRPAuthHandler() self._protocol = MrpProtocol(loop, self._connection, self._srp, self._mrp_service) self._psm = PlayerStateManager(self._protocol, loop) self._mrp_remote = MrpRemoteControl(loop, self._protocol) self._mrp_metadata = MrpMetadata(self._protocol, self._psm, config.identifier) self._mrp_push_updater = MrpPushUpdater(loop, self._mrp_metadata, self._psm) self._airplay = airplay