Possible duplicate of Decoding AirPlay Mirroring Protocol.
As explained here basically the stream is encrypted using FairPlay™, the same technology that encrypts apps and movies purchased through iTunes.
In order to do what you want you would need to reverse-engineer FairPlay. That's the only way I can think of that the existing apps you mentioned are doing it, but I'm not sure... It would be interesting if someone could elaborate further. Regardless the point is, it's not trivial.
Here is the protocol: http://nto.github.com/AirPlay.html