Kodi Community Forum
Towards open source support of airplay mirroring - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Kodi Application (https://forum.kodi.tv/forumdisplay.php?fid=93)
+--- Thread: Towards open source support of airplay mirroring (/showthread.php?tid=224877)



Towards open source support of airplay mirroring - foxsen - 2015-04-20

Dear all,

I have spent some time to look into Apple's airplay mirroring support, which is encrypted by fairplay protocol. After investigating several existing commercial applications I have finally managed to get a way of decrypting fairplay protected streams.
I have extended the shairplay code to demostrate this ability. Please look at https://github.com/foxsen/shairplay, parts of the README.md:

Update by foxsen, 2015/4/20: Experimental support for fairplay protocol and airplay:

* fairplay encrpted audio is supported (et == 3)
* AAC-ELD audio is supported(untested yet)
* airplay service framework is added, up to the point that the mirroring connection starts streaming. But the UI and callbacks to be done.
* fairplay support is performed via interactions with a server

Because I have no enough time and knowledge to do all the other necessary coding to make a full open source solution that support mirroring, I hope people can help to continue the project or port my code into other projects like kodi. I am willing to help with related issues.

The dirty work is hidden in my server app. During a session with fairplay, we need to interact with the server for three times to get the job done. You can read the code above to learn how. When I get more time, I prepare the write something about this part of work. Basically it involves some reverse engineering and a lot of tricks to rebuild a relocatable object from part of a binary.

Public access to that app is open and free for personal visits now. If anybody wants to use it in commercial environment, you can contact me.

Happy hacking.

Regards


RE: Towards open source support of airplay mirroring - foxsen - 2015-04-21

Since I am not so expert on kodi and its airplay implemention, I hope people here can help to implement a full mirroring support. I can help to provide airplay/fairplay protocol related details.

A quick attempt shows that we need to:

1, patch the httpd server parsing code to support binary data in http sessions. (not just String)
2, patch the shairport library, which I have finished most part of the job(there is a github link in the above post).


RE: Towards open source support of airplay mirroring - Mettbrot - 2015-04-21

You want to talk to @Memphiz in particular since he is the one who did the current airplay implementation. Keep in mind that your code has to be opensource with a proper licence to get integrated into kodi.


RE: Towards open source support of airplay mirroring - Memphiz - 2015-04-21

I guess you are using a similar approach like espes (who did a complete mirroring implementation in python) by emulating an arm core and using the handshake functions of the airtunes binary (taken from a decrypted ios firmware image).

I also guess that that is what your server app does (getting the handshake and key decryption done - after that use the normal aes decryption we already know about).

If you can confirm my assumptions then i have to tell you that its a great thing to have this approach working. Unfortunately espes python code doesn't work well with all ios versions.

Sadly the approach on contacting a server for doing the key decryption is not acceptable for us. Using the airtunes binary is also hard on the edge (we might be able to think of some addon solution where this binary is fetched from somewhere but even providing this binary for download might be illegal).


RE: Towards open source support of airplay mirroring - foxsen - 2015-04-21

The server part is a native daemon written in C running on linux/x86. It does integrate part of binary code from other commercial apps, but no full binaries are used and no emulator. Basically what I do is a combination of reverse engineer and binary manipulation. I can completely reverse it in to C, but it will be too tedious. So instead I rebuilt a relocatable file from some binary code trunks and link it into my program.

It is a pity that you don't accept a networked approach. I can provide a dynamic library instead, but with limited platforms, and that won't be acceptable since there is binary trunk without source.


RE: Towards open source support of airplay mirroring - juhovh - 2015-04-21

I already PM'd foxsen, but let's work on this together to get as much of the code as possible included on the shairplay library. One possibility is to have some compile time option which is disabled by default, but one would be able to replace the libshairplay dynamic library with one that would use a server. Being able to rip out the fairplay handshake library from the binary and making it relocatable is already cool in itself. Let's try to find some middle ground both from code and from legal perspective.


RE: Towards open source support of airplay mirroring - tripkip - 2015-06-16

How is it going guys?