Ejemplo n.º 1
0
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()
Ejemplo n.º 2
0
 async def setUpAsync(self):
     self.service = CompanionService(self.fake_atv.get_port(Protocol.Companion))
     self.conf = AppleTV(IPv4Address("127.0.0.1"), "Test device")
     self.conf.add_service(
         MrpService("mrp_id", self.fake_atv.get_port(Protocol.MRP))
     )
     self.conf.add_service(self.service)
Ejemplo n.º 3
0
    def setUp(self):
        AioHTTPTestCase.setUp(self)

        self.service = MrpService(CLIENT_IDENTIFIER,
                                  self.fake_atv.get_port(Protocol.MRP))
        self.conf = AppleTV("127.0.0.1", "Apple TV")
        self.conf.add_service(self.service)
Ejemplo n.º 4
0
 async def setUpAsync(self):
     await super().setUpAsync()
     self.conf = AppleTV('127.0.0.1', 'Test device')
     self.conf.add_service(MrpService('mrp_id', self.fake_atv.port))
     self.conf.add_service(
         AirPlayService('airplay_id', self.server.port, DEVICE_CREDENTIALS))
     self.atv = await self.get_connected_device()
Ejemplo n.º 5
0
 async def setUpAsync(self):
     await super().setUpAsync()
     self.conf = AppleTV(IPv4Address("127.0.0.1"), "Test device")
     self.conf.add_service(
         MrpService("mrp_id", self.fake_atv.get_port(Protocol.MRP)))
     self.conf.add_service(
         AirPlayService("airplay_id", self.server.port, DEVICE_CREDENTIALS))
     self.atv = await self.get_connected_device()
Ejemplo n.º 6
0
 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()
Ejemplo n.º 7
0
 async def setUpAsync(self):
     await super().setUpAsync()
     self.conf = AppleTV(IPv4Address("127.0.0.1"), "Test device")
     self.conf.add_service(
         MrpService("mrp_id", self.fake_atv.get_port(Protocol.MRP)))
     self.conf.add_service(
         CompanionService(
             self.fake_atv.get_port(Protocol.Companion),
             credentials=CLIENT_CREDENTIALS,
         ))
     self.atv = await self.get_connected_device()
Ejemplo n.º 8
0
def _manual_device(args):
    config = AppleTV(args.address, args.name)
    if args.dmap_credentials or args.protocol == const.Protocol.DMAP:
        config.add_service(
            DmapService(args.id, args.dmap_credentials, port=args.port))
    if args.mrp_credentials or args.protocol == const.Protocol.MRP:
        config.add_service(
            MrpService(args.id, args.port, credentials=args.mrp_credentials))
    if args.airplay_credentials:
        config.add_service(
            AirPlayService(args.id, credentials=args.airplay_credentials))
    return config
Ejemplo n.º 9
0
    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)
Ejemplo n.º 10
0
def _manual_device(args):
    config = AppleTV(IPv4Address(args.address), args.name)
    if args.dmap_credentials or args.protocol == const.Protocol.DMAP:
        config.add_service(
            DmapService(args.id, args.dmap_credentials, port=args.port))
    if args.mrp_credentials or args.protocol == const.Protocol.MRP:
        config.add_service(
            MrpService(args.id, args.port, credentials=args.mrp_credentials))
    if args.airplay_credentials or args.protocol == const.Protocol.AirPlay:
        config.add_service(
            AirPlayService(args.id, credentials=args.airplay_credentials))
    if args.companion_credentials or args.protocol == const.Protocol.Companion:
        config.add_service(
            CompanionService(args.port,
                             credentials=args.companion_credentials))
    if args.raop_credentials or args.protocol == const.Protocol.RAOP:
        config.add_service(
            RaopService(args.id, args.port, credentials=args.raop_credentials))
    return config
Ejemplo n.º 11
0
def _handle_commands(args, loop):
    details = AppleTV(args.address, args.name)
    if args.protocol == const.PROTOCOL_DMAP:
        details.add_service(DmapService(args.login_id, port=args.port))
    elif args.protocol == const.PROTOCOL_MRP:
        details.add_service(MrpService(args.port))

    atv = pyatv.connect_to_apple_tv(details, loop, protocol=args.protocol)
    atv.push_updater.listener = PushListener()

    try:
        if args.airplay_credentials is not None:
            yield from atv.airplay.load_credentials(args.airplay_credentials)

        for cmd in args.command:
            ret = yield from _handle_device_command(args, cmd, atv, loop)
            if ret != 0:
                return ret
    finally:
        yield from atv.logout()

    return 0
Ejemplo n.º 12
0
 def get_connected_device(self, port):
     conf = AppleTV('127.0.0.1', 'Test device')
     conf.add_service(MrpService(port))
     conf.add_service(AirPlayService(self.server.port))
     return connect_to_apple_tv(conf, loop=self.loop)
Ejemplo n.º 13
0
    def setUp(self):
        AioHTTPTestCase.setUp(self)

        self.service = MrpService(CLIENT_IDENTIFIER, self.fake_atv.port)
        self.conf = AppleTV('127.0.0.1', 'Apple TV')
        self.conf.add_service(self.service)