• Stars
    star
    176
  • Rank 209,325 (Top 5 %)
  • Language
    Java
  • License
    MIT License
  • Created over 4 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

This library is intended to easily create AirPlay2 servers acting like Apple TV

java-airplay-lib

build Release ViewCount License




14.12.2022: Check out new java-airplay project: https://github.com/serezhka/java-airplay


This library is intended to easily create AirPlay2 servers acting like Apple TV. Tested with iPhone X (iOS 14.0.1)

How to use?

  • Add java-airplay-lib dependency to your project

  • Make your server discoverable by Bonjour

  String serverName = "@srzhka";
  int airPlayPort = 5001;
  int airTunesPort = 7001;
  AirPlayBonjour airPlayBonjour = new AirPlayBonjour(serverName);
  airPlayBonjour.start(airPlayPort, airTunesPort);
  ...
  airPlayBonjour.stop();

  • Listen airTunesPort and handle RTSP requests. Pass request content bytes to the library and respond with provided content bytes.
  RTSP GET | POST

  String uri = ...
  byte[] requestContent = ...
  switch (uri) {
    case "/info": {
      airPlay.info(.. byte output stream ..);
      // RTSP OK + provided bytes 
    }
    case "/pair-setup": {
      airPlay.pairSetup(.. byte output stream ..);
      // RTSP OK + provided bytes 
    }
    case "/pair-verify": {
      airPlay.pairVerify(.. requestContent input stream ..,
        .. byte output stream ..);
      // RTSP OK + provided bytes 
    }
    case "/fp-setup": {
      airPlay.fairPlaySetup(.. requestContent input stream ..,
        .. byte output stream ..);
      // RTSP OK + provided bytes
    }
    case "/feedback": {
      // RTSP OK
    }
  }
  
  RTSP SETUP
  
    airPlay.rtspSetup(.. requestContent input stream ..,
      .. byte output stream .., int videoDataPort, int videoEventPort,
      int videoTimingPort, int audioDataPort, int audioControlPort); 
    // RTSP OK + provided bytes
      
    if (airPlay.isFairPlayVideoDecryptorReady()) {
      // start listening video data on videoDataPort 
    }
    
    if (airPlay.isFairPlayAudioDecryptorReady()) {
      // start listening audio data on audioDataPort 
    }
  
  RTSP GET_PARAMETER, RECORD, SET_PARAMETER, TEARDOWN
  
  ...
  
  DECRYPT MIRROR DATA
    
    airPlay.decryptVideo(byte[] video);
    
    airPlay.decryptAudio(byte[] audio, int audioLength);

Example server

java-airplay-server with Netty

Links

Analysis of AirPlay2 Technology

Info

Inspired by many other open source projects analyzing AirPlay2 protocol. Special thanks to OmgHax.c's author ๐Ÿคฏ