openairplay / airplay2-receiver

AirPlay 2 Receiver - Python implementation
2.13k stars 133 forks source link

Interesting data point #22

Closed Neustradamus closed 3 years ago

Neustradamus commented 3 years ago

Originally: https://github.com/ckdo/airplay2-receiver/issues/15

@systemcrash commented Mar 17, 2021 •

Mac (also running the local copy of receiver):

'osBuildVersion': '19H524', 'osName': 'Mac OS X', 'osVersion': '10.15.7',

iOS:

'osBuildVersion': '18D61', 'osName': 'iPhone OS', 'osVersion': '14.4.1', 'senderSupportsRelay': True, 'sourceVersion': '535.3',

Summary: perhaps macOS requires a different feature bitmask?

When the first device connecting after startup is my mac I get all kinds of weird hangups and even:

{'streams': [{'audioFormat': 262144, 'audioMode': 'default', 'controlPort': 63126, 'ct': 2, 'isMedia': True, 'latencyMax': 88200, 'latencyMin': 11025, 'spf': 352, 'streamConnectionID': 8502940700034419006, 'supportsDynamicStreamID': True, 'type': 96}]} Sending CONTROL/DATA:

Exception happened during processing of request from ('192.168.19.118', 58615) Traceback (most recent call last): File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/socketserver.py", line 316, in _handle_request_noblock self.process_request(request, client_address) File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/socketserver.py", line 347, in process_request self.finish_request(request, client_address) File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/socketserver.py", line 360, in finish_request self.RequestHandlerClass(request, client_address, self) File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/socketserver.py", line 720, in init self.handle() File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/http/server.py", line 429, in handle self.handle_one_request() File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/http/server.py", line 415, in handle_one_request method() File "ap2-receiver.py", line 294, in do_SETUP stream = Stream(plist["streams"][0]) File "/Users/paul/git/airplay2-receiver/ap2/connections/stream.py", line 14, in init self.session_key = stream["shk"] KeyError: 'shk'

Sometimes it makes it all the way to

Now plaing DAAP info. (need a daap parser here) Content-Length: 128 Content-Type: application/x-apple-binary-plist CSeq: 14 DACP-ID: B845E79B45E42834 Active-Remote: 462096351 User-Agent: AirPlay/425.1

POST /command {'params': {'mrSupportedCommandsFromSender': []}, 'type': 'updateMRSupportedCommands'}

and just sits there. No error message from macos, but macos has no connection to airplay device either. Remains on speaker output.

Still occasionally gets stuck at the below, on successive connect attempts, even with PR #11

POST /pair-setup 00000000: 00 01 00 06 01 01 13 01 10 ......... ----- Pair-Setup [1/2] 00000000: 07 E9 C1 08 F4 37 5A F2 1F 24 81 09 01 96 BB 63 .....7Z..$.....c 00000010: 01 B3 D4 EA 75 4D DC 27 41 CC E4 45 33 A8 8A 15 ....uM.'A..E3... 00000020: 46 ED B8 24 9E C5 4E 17 36 BE 5A 03 70 A1 A5 16 F..$..N.6.Z.p... 00000030: 1A E7 0B B7 67 29 44 23 FA 1E 73 14 BC E9 4D C5 ....g)D#..s...M. ----- ENCRYPTED CHANNEL -----

My iOS Music player will connect, often fine. Only after my iOS device has connected and disconnected, then my local mac has no problem connecting. Seems some object state left over from the previous connection helps. Could not get any supported audio media types to play from my mac, however. Logs just repeat this:

Content-Length: 1225 Content-Type: application/x-apple-binary-plist CSeq: 153 DACP-ID: 714F31E66394D075 Active-Remote: 826932078 User-Agent: AirPlay/425.1

POST /command {'params': {'mrSupportedCommandsFromSender': [{'kCommandInfoCommandKey': 0, 'kCommandInfoEnabledKey': True}, {'kCommandInfoCommandKey': 9, 'kCommandInfoEnabledKey': True}, {'kCommandInfoCommandKey': 1, 'kCommandInfoEnabledKey': True}, {'kCommandInfoCommandKey': 10, 'kCommandInfoEnabledKey': True}, {'kCommandInfoCommandKey': 19, 'kCommandInfoEnabledKey': True}, {'kCommandInfoCommandKey': 2, 'kCommandInfoEnabledKey': True}, {'kCommandInfoCommandKey': 11, 'kCommandInfoEnabledKey': True}, {'kCommandInfoCommandKey': 24, 'kCommandInfoEnabledKey': True}, {'kCommandInfoCommandKey': 3, 'kCommandInfoEnabledKey': True}, {'kCommandInfoCommandKey': 8, 'kCommandInfoEnabledKey': True}]}, 'type': 'updateMRSupportedCommands'} Content-Length: 1225 Content-Type: application/x-apple-binary-plist CSeq: 154 DACP-ID: 714F31E66394D075 Active-Remote: 826932078 User-Agent: AirPlay/425.1

POST /command {'params': {'mrSupportedCommandsFromSender': [{'kCommandInfoCommandKey': 0, 'kCommandInfoEnabledKey': True}, {'kCommandInfoCommandKey': 9, 'kCommandInfoEnabledKey': True}, {'kCommandInfoCommandKey': 1, 'kCommandInfoEnabledKey': True}, {'kCommandInfoCommandKey': 10, 'kCommandInfoEnabledKey': True}, {'kCommandInfoCommandKey': 19, 'kCommandInfoEnabledKey': True}, {'kCommandInfoCommandKey': 2, 'kCommandInfoEnabledKey': True}, {'kCommandInfoCommandKey': 11, 'kCommandInfoEnabledKey': True}, {'kCommandInfoCommandKey': 24, 'kCommandInfoEnabledKey': True}, {'kCommandInfoCommandKey': 3, 'kCommandInfoEnabledKey': True}, {'kCommandInfoCommandKey': 8, 'kCommandInfoEnabledKey': True}]}, 'type': 'updateMRSupportedCommands'}

I do note that after iOS has connected (remote device) - when my local mac connects, I no longer see the loopback IP so much in the logs - only its 192.168 IP. I propose a fix for this, will make a PR.

Tried playing some 5.1 media via VLC, which played (tho output was silent), but nothing was in the logs. VLC hung on exit XD

iOS plays fine. If I team it up with e.g. Sonos speakers, there's a bit of delay/difference from this receiver, i.e. the receiver is ~100msec behind Sonos speakers. I guess synch leaves a little something to be desired.

Anyway, good work 👍

@PaulWieland commented Mar 17, 2021

If I team it up with e.g. Sonos speakers, there's a bit of delay/difference from this receiver, i.e. the receiver is ~100msec behind Sonos speakers. I guess synch leaves a little something to be desired.

Audio Sync isn't implemented at all, so that's totally to be expected.

@systemcrash commented Mar 17, 2021 •

See https://github.com/ckdo/airplay2-receiver/pull/16 - this PR cleans up lots of weird startup/connect behaviour (for me, at least).

@systemcrash commented Mar 17, 2021

See here for IPv6 problems.... prometheus/client_python#567

systemcrash commented 3 years ago

You are welcome to pick from my branch https://github.com/systemcrash/airplay2-receiver/tree/set_interface_ip

I had to move the work from master to work on other things and my repo was getting messy. The branch works as is, although could be improved, as with anything. But better is the enemy of good, I suppose.

It seems to avoid some IPv6 problems/bugs, one must run Python v3.9 or 3.9.