docs: def connect_to_apple_tv(details, loop, protocol=None, session=None):
      """Connect and logins to an Apple TV."""
      service = _get_service_used_to_connect(details, protocol)
  
      # If no session is given, create a default one
      if session is None:
          session = ClientSession(loop=loop)
  
      # AirPlay service is the same for both DMAP and MRP
      airplay = _setup_airplay(loop, session, details)
  
      # Create correct implementation depending on protocol
      if service.protocol == PROTOCOL_DMAP:
          return DmapAppleTV(loop, session, details, airplay)
  
      return MrpAppleTV(loop, session, details, airplay)