xbmc/xbmc — pull request #4414 by Memphiz (2014-03-13 17:13:11+00:00)
Title: [airplay] - fix regression introduced by ios7 clients

This fix is not yet confirmed by many users but in my test case it is 100% working.

Background. When using iOS7 clients or newer they might show XBMC as audio-only target. This can happen randomly and switching wifi on the ios7 device on and off might fix the problem for a while (until the wifi goes to sleep again).

I tried to find out the root cause with a lot of user help but we really didn't get any stable results until this post came up:

http://forum.xbmc.org/showthread.php?tid=179961&pid=1648329#pid1648329

Shortly - it matters in which order the ios7 device sees the zeroconf announcements. If it sees the airplay announcement (video/pictures) before the airtunes announcement (audio) then it shows XBMC as audio-only target. If it sees the announcements the other way around - it sees the full target (monitor symbol).

This fix adds the ability to force reannounce a zeroconf service without remove/add the service from zeroconf. As this isn't supported directly in the zeroconf protocol we achieve this by changing txt records. Depending on the zeroconf implementation the following leads to an reannouncement:

1. MDNS - add a fake txtrecord and diddle its value
2. OSX - take the txtrecord dicftionary parse it to data and back to dictionary and set it to the service
3. avahi - reverse the txtrecord list and set it to the service

We do this each 10 seconds (cause osx will throttle announcements if done more then 10 a minute) for the airplay announcement.

In wireshark this results in a "txt-record flush" message to the 224.0.0.251 multicast address. I have verified those network packages on all platforms.

Exception: Androids version of the embedded mdns has no implementation for the needed API call (returns "not implemented" which we just ignore). So android will not benefit from this fix. I have found one evidence in the interwebs that someone implemented that call - i tried to contact that person (not sure if i even got the right email address). If we don't hear anything back from him - this fix is not achievable for android until someone digs into apples mdnsresponder sources.

Since this regression is there since ios7 was released and airplay might be a wider used feature in XBMC - i propose it for gotham - but its up to the RMs. (doing a pr against Gotham branch only if approved).