Skip to content

Commit

Permalink
#3592 use namespace for audio caps
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Aug 8, 2022
1 parent 5996b16 commit c420dc9
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 15 deletions.
15 changes: 12 additions & 3 deletions xpra/client/mixins/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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,
}


Expand Down
1 change: 1 addition & 0 deletions xpra/client/mixins/clipboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def get_caps(self) -> dict:
return {}
ccaps = {
"" : True,
"enabled" : True,
"notifications" : True,
"selections" : CLIPBOARDS,
#buggy osx clipboards:
Expand Down
29 changes: 21 additions & 8 deletions xpra/server/source/audio_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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:
Expand Down
15 changes: 11 additions & 4 deletions xpra/server/source/avsync_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit c420dc9

Please sign in to comment.