From c420dc9170ff08c2d3f3a602114ab0af82e09b8d Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Mon, 8 Aug 2022 11:32:27 +0200 Subject: [PATCH] #3592 use namespace for audio caps --- xpra/client/mixins/audio.py | 15 ++++++++++++--- xpra/client/mixins/clipboard.py | 1 + xpra/server/source/audio_mixin.py | 29 +++++++++++++++++++++-------- xpra/server/source/avsync_mixin.py | 15 +++++++++++---- 4 files changed, 45 insertions(+), 15 deletions(-) diff --git a/xpra/client/mixins/audio.py b/xpra/client/mixins/audio.py index ab99804e80..faeacd4b07 100644 --- a/xpra/client/mixins/audio.py +++ b/xpra/client/mixins/audio.py @@ -157,8 +157,14 @@ def get_info(self) -> dict: def get_caps(self) -> dict: d = {} - updict(d, "av-sync", self.get_avsync_capabilities()) - updict(d, "sound", self.get_audio_capabilities()) + avcaps = self.get_avsync_capabilities() + acaps = self.get_audio_capabilities() + #legacy flat format: + updict(d, "av-sync", avcaps) + updict(d, "sound", acaps) + #v4.4 namespace: + d["av-sync"] = avcaps + d["audio"] = acaps return d def get_audio_capabilities(self) -> dict: @@ -180,9 +186,12 @@ def get_audio_capabilities(self) -> dict: def get_avsync_capabilities(self) -> dict: if not self.av_sync: return {} + delay = max(0, DEFAULT_AV_SYNC_DELAY + AV_SYNC_DELTA) return { "" : True, - "delay.default" : max(0, DEFAULT_AV_SYNC_DELAY + AV_SYNC_DELTA), + "enabled" : True, + "delay.default" : delay, + "delay" : delay, } diff --git a/xpra/client/mixins/clipboard.py b/xpra/client/mixins/clipboard.py index 9fc2b0470a..ef6e61e86f 100644 --- a/xpra/client/mixins/clipboard.py +++ b/xpra/client/mixins/clipboard.py @@ -87,6 +87,7 @@ def get_caps(self) -> dict: return {} ccaps = { "" : True, + "enabled" : True, "notifications" : True, "selections" : CLIPBOARDS, #buggy osx clipboards: diff --git a/xpra/server/source/audio_mixin.py b/xpra/server/source/audio_mixin.py index a473371436..b97bd21e91 100644 --- a/xpra/server/source/audio_mixin.py +++ b/xpra/server/source/audio_mixin.py @@ -88,13 +88,24 @@ def stop_new_stream_notification(self, proc): def parse_client_caps(self, c): self.wants_sound = c.boolget("wants_sound", True) - self.pulseaudio_id = c.strget("sound.pulseaudio.id") - self.pulseaudio_cookie_hash = c.strget("sound.pulseaudio.cookie-hash") - self.pulseaudio_server = c.strget("sound.pulseaudio.server") - self.sound_decoders = c.strtupleget("sound.decoders", []) - self.sound_encoders = c.strtupleget("sound.encoders", []) - self.sound_receive = c.boolget("sound.receive") - self.sound_send = c.boolget("sound.send") + audio = c.dictget("audio") + if audio: + self.pulseaudio_id = audio.strget("pulseaudio.id") + self.pulseaudio_cookie_hash = audio.strget("pulseaudio.cookie-hash") + self.pulseaudio_server = audio.strget("pulseaudio.server") + self.sound_decoders = audio.strtupleget("decoders", []) + self.sound_encoders = audio.strtupleget("encoders", []) + self.sound_receive = audio.boolget("receive") + self.sound_send = audio.boolget("send") + else: + #pre v4.4: + self.pulseaudio_id = c.strget("sound.pulseaudio.id") + self.pulseaudio_cookie_hash = c.strget("sound.pulseaudio.cookie-hash") + self.pulseaudio_server = c.strget("sound.pulseaudio.server") + self.sound_decoders = c.strtupleget("sound.decoders", []) + self.sound_encoders = c.strtupleget("sound.encoders", []) + self.sound_receive = c.boolget("sound.receive") + self.sound_send = c.boolget("sound.send") log("pulseaudio id=%s, cookie-hash=%s, server=%s, sound decoders=%s, sound encoders=%s, receive=%s, send=%s", self.pulseaudio_id, self.pulseaudio_cookie_hash, self.pulseaudio_server, self.sound_decoders, self.sound_encoders, self.sound_receive, self.sound_send) @@ -110,7 +121,9 @@ def get_caps(self) -> dict: "send" : self.supports_speaker and len(self.speaker_codecs)>0, "receive" : self.supports_microphone and len(self.microphone_codecs)>0, }) - return flatten_dict({"sound" : sound_props}) + caps = flatten_dict({"sound" : sound_props}) + caps["audio"] = sound_props + return caps def audio_loop_check(self, mode="speaker") -> bool: diff --git a/xpra/server/source/avsync_mixin.py b/xpra/server/source/avsync_mixin.py index 9a42c7a041..e96316e0a7 100644 --- a/xpra/server/source/avsync_mixin.py +++ b/xpra/server/source/avsync_mixin.py @@ -51,11 +51,18 @@ def get_info(self) -> dict: } def parse_client_caps(self, c : typedict): - av_sync = c.boolget("av-sync") - self.av_sync_enabled = self.av_sync and av_sync - self.set_av_sync_delay(int(self.av_sync_enabled) * c.intget("av-sync.delay.default", DEFAULT_AV_SYNC_DELAY)) + av_sync = c.get("av-sync") + if isinstance(av_sync, dict): + av_sync = typedict(av_sync) + enabled = av_sync.boolget("enabled") + delay = typedict(av_sync.dictget("delay", {})).get("default", DEFAULT_AV_SYNC_DELAY) + else: + enabled = bool(av_sync) + delay = c.intget("av-sync.delay.default", DEFAULT_AV_SYNC_DELAY) + self.av_sync_enabled = self.av_sync and enabled + self.set_av_sync_delay(int(self.av_sync_enabled) * delay) log("av-sync: server=%s, client=%s, enabled=%s, total=%s", - self.av_sync, av_sync, self.av_sync_enabled, self.av_sync_delay_total) + self.av_sync, enabled, self.av_sync_enabled, self.av_sync_delay_total) def set_av_sync_delta(self, delta):