From 70c6ca6d0f92dbd4c11226c2f4de8e948b4fc3a2 Mon Sep 17 00:00:00 2001 From: s3lph <5564491+s3lph@users.noreply.github.com> Date: Wed, 16 Mar 2022 00:39:12 +0100 Subject: [PATCH 1/3] Mumble: Implement a workaround to signal Opus support without pulling in the CGO gopus dependency. --- bridge/mumble/codec.go | 69 +++++++++++++++++++++++++++++++++++++++++ bridge/mumble/mumble.go | 1 + 2 files changed, 70 insertions(+) create mode 100644 bridge/mumble/codec.go diff --git a/bridge/mumble/codec.go b/bridge/mumble/codec.go new file mode 100644 index 0000000000..1cf67da667 --- /dev/null +++ b/bridge/mumble/codec.go @@ -0,0 +1,69 @@ +package bmumble + +import ( + "fmt" + + "layeh.com/gumble/gumble" +) + +// This is a dummy implementation of a Gumble audio codec which claims +// to implement Opus, but does not actually do anything. This serves +// as a workaround until https://github.com/layeh/gumble/pull/61 is +// merged. + +const ( + audioCodecIDOpus = 4 +) + +func registerNullCodecAsOpus() { + codec := &NullCodec{ + encoder: &NullAudioEncoder{}, + decoder: &NullAudioDecoder{}, + } + gumble.RegisterAudioCodec(audioCodecIDOpus, codec) +} + +type NullCodec struct { + encoder *NullAudioEncoder + decoder *NullAudioDecoder +} + +func (c *NullCodec) ID() int { + return audioCodecIDOpus +} + +func (c *NullCodec) NewEncoder() gumble.AudioEncoder { + e := &NullAudioEncoder{} + return e +} + +func (c *NullCodec) NewDecoder() gumble.AudioDecoder { + d := &NullAudioDecoder{} + return d +} + +type NullAudioEncoder struct{} + +func (e *NullAudioEncoder) ID() int { + return audioCodecIDOpus +} + +func (e *NullAudioEncoder) Encode(pcm []int16, mframeSize, maxDataBytes int) ([]byte, error) { + return nil, fmt.Errorf("Not implemented") +} + +func (e *NullAudioEncoder) Reset() { +} + +type NullAudioDecoder struct{} + +func (d *NullAudioDecoder) ID() int { + return audioCodecIDOpus +} + +func (d *NullAudioDecoder) Decode(data []byte, frameSize int) ([]int16, error) { + return nil, fmt.Errorf("Not implemented") +} + +func (d *NullAudioDecoder) Reset() { +} diff --git a/bridge/mumble/mumble.go b/bridge/mumble/mumble.go index d27d8caa8e..1943bd39b0 100644 --- a/bridge/mumble/mumble.go +++ b/bridge/mumble/mumble.go @@ -185,6 +185,7 @@ func (b *Bmumble) doConnect() error { gumbleConfig.Password = password } + registerNullCodecAsOpus() client, err := gumble.DialWithDialer(new(net.Dialer), b.GetString("Server"), gumbleConfig, &b.tlsConfig) if err != nil { return err From 6c4c97d37963d4df5806165400bc45840db31712 Mon Sep 17 00:00:00 2001 From: s3lph <5564491+s3lph@users.noreply.github.com> Date: Sat, 19 Mar 2022 17:17:01 +0100 Subject: [PATCH 2/3] mumble: lowercase error messages --- bridge/mumble/codec.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bridge/mumble/codec.go b/bridge/mumble/codec.go index 1cf67da667..687a28d9b9 100644 --- a/bridge/mumble/codec.go +++ b/bridge/mumble/codec.go @@ -49,7 +49,7 @@ func (e *NullAudioEncoder) ID() int { } func (e *NullAudioEncoder) Encode(pcm []int16, mframeSize, maxDataBytes int) ([]byte, error) { - return nil, fmt.Errorf("Not implemented") + return nil, fmt.Errorf("not implemented") } func (e *NullAudioEncoder) Reset() { @@ -62,7 +62,7 @@ func (d *NullAudioDecoder) ID() int { } func (d *NullAudioDecoder) Decode(data []byte, frameSize int) ([]int16, error) { - return nil, fmt.Errorf("Not implemented") + return nil, fmt.Errorf("not implemented") } func (d *NullAudioDecoder) Reset() { From 8f083f996475be4f28590c0daec4a0b5c8b8f3eb Mon Sep 17 00:00:00 2001 From: s3lph <5564491+s3lph@users.noreply.github.com> Date: Sat, 19 Mar 2022 17:18:31 +0100 Subject: [PATCH 3/3] mumble: Add link to #1750 in bridge/mumble/codec.go --- bridge/mumble/codec.go | 1 + 1 file changed, 1 insertion(+) diff --git a/bridge/mumble/codec.go b/bridge/mumble/codec.go index 687a28d9b9..1306e40828 100644 --- a/bridge/mumble/codec.go +++ b/bridge/mumble/codec.go @@ -10,6 +10,7 @@ import ( // to implement Opus, but does not actually do anything. This serves // as a workaround until https://github.com/layeh/gumble/pull/61 is // merged. +// See https://github.com/42wim/matterbridge/issues/1750 for details. const ( audioCodecIDOpus = 4