• Stars
    star
    323
  • Rank 130,051 (Top 3 %)
  • Language
    Java
  • License
    MIT License
  • Created almost 5 years ago
  • Updated almost 2 years ago

Reviews

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

Repository Details

Acts like Apple TV

java-airplay-server

build Release ViewCount License




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


This is example of java-airplay-lib usage.

It's under development.

How to use?

  • Add java-airplay-server dependency to your project

  • Implement AirplayDataConsumer and start AirPlayServer, for example:

FileChannel videoFileChannel = FileChannel.open(Paths.get("video.h264"), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.WRITE);
FileChannel audioFileChannel = FileChannel.open(Paths.get("audio.pcm"), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.WRITE);

AirplayDataConsumer dumper = new AirplayDataConsumer() {
    
    @Override
    public void onVideo(byte[] video) {
        videoFileChannel.write(ByteBuffer.wrap(video));
    }

    
    @Override
    public void onAudio(byte[] audio) {
        if (FdkAacLib.isInitialized()) {
            byte[] audioDecoded = new byte[480 * 4];
            FdkAacLib.decodeFrame(audio, audioDecoded);
            audioFileChannel.write(ByteBuffer.wrap(audioDecoded));
        }
    }
};

String serverName = "AirPlayServer";
int airPlayPort = 15614;
int airTunesPort = 5001;
new AirPlayServer(serverName, airPlayPort, airTunesPort, dumper).start();

More examples

see repo java-airplay-server-examples