From 037205ad0a134d5eb1b55b1fe96c8d5b87d14d9c Mon Sep 17 00:00:00 2001 From: s3lph <5564491+s3lph@users.noreply.github.com> Date: Wed, 16 Mar 2022 00:10:05 +0100 Subject: [PATCH] Add client config flag to explicitly signal Opus support even when the Opus audio codec is not loaded. --- gumble/client.go | 5 ++++- gumble/config.go | 5 +++++ gumble/doc.go | 6 ++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/gumble/client.go b/gumble/client.go index 2256f5f..49e253b 100644 --- a/gumble/client.go +++ b/gumble/client.go @@ -115,6 +115,9 @@ func DialWithDialer(dialer *net.Dialer, addr string, config *Config, tlsConfig * go client.readRoutine() + // If Opus support was not explicitly enabled, set Opus flag + // based on the presence of the Opus audio codec. + opus := client.Config.Opus || getAudioCodec(audioCodecIDOpus) != nil // Initial packets versionPacket := MumbleProto.Version{ Version: proto.Uint32(ClientVersion), @@ -125,7 +128,7 @@ func DialWithDialer(dialer *net.Dialer, addr string, config *Config, tlsConfig * authenticationPacket := MumbleProto.Authenticate{ Username: &client.Config.Username, Password: &client.Config.Password, - Opus: proto.Bool(getAudioCodec(audioCodecIDOpus) != nil), + Opus: proto.Bool(opus), Tokens: client.Config.Tokens, } client.Conn.WriteProto(&versionPacket) diff --git a/gumble/config.go b/gumble/config.go index 4960388..e495b4c 100644 --- a/gumble/config.go +++ b/gumble/config.go @@ -26,6 +26,11 @@ type Config struct { // The event listeners used when client events are triggered. Listeners Listeners AudioListeners AudioListeners + + // If true, explicitly signals presence of Opus support. If + // false, this is determined automatically by the presence of + // an Opus codec implementation. + Opus bool } // NewConfig returns a new Config struct with default values set. diff --git a/gumble/doc.go b/gumble/doc.go index 2911542..6d33be3 100644 --- a/gumble/doc.go +++ b/gumble/doc.go @@ -36,6 +36,12 @@ // // opusthreshold=0 // +// If your client is not processing audio at all, you can still claim +// to support Opus so that the Mumble server won't force usage of the +// legacy CELT codec: +// +// config.Opus = true +// // Thread safety // // As a general rule, a Client everything that is associated with it