Skip to content
This repository was archived by the owner on Apr 15, 2026. It is now read-only.

Commit 5a2d6c3

Browse files
s3lphwbonis
authored andcommitted
Implement a workaround to signal Opus support (mumble) (42wim#1764)
* Mumble: Implement a workaround to signal Opus support without pulling in the CGO gopus dependency. * mumble: lowercase error messages * mumble: Add link to 42wim#1750 in bridge/mumble/codec.go
1 parent e333c76 commit 5a2d6c3

2 files changed

Lines changed: 71 additions & 0 deletions

File tree

bridge/mumble/codec.go

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package bmumble
2+
3+
import (
4+
"fmt"
5+
6+
"layeh.com/gumble/gumble"
7+
)
8+
9+
// This is a dummy implementation of a Gumble audio codec which claims
10+
// to implement Opus, but does not actually do anything. This serves
11+
// as a workaround until https://github.com/layeh/gumble/pull/61 is
12+
// merged.
13+
// See https://github.com/42wim/matterbridge/issues/1750 for details.
14+
15+
const (
16+
audioCodecIDOpus = 4
17+
)
18+
19+
func registerNullCodecAsOpus() {
20+
codec := &NullCodec{
21+
encoder: &NullAudioEncoder{},
22+
decoder: &NullAudioDecoder{},
23+
}
24+
gumble.RegisterAudioCodec(audioCodecIDOpus, codec)
25+
}
26+
27+
type NullCodec struct {
28+
encoder *NullAudioEncoder
29+
decoder *NullAudioDecoder
30+
}
31+
32+
func (c *NullCodec) ID() int {
33+
return audioCodecIDOpus
34+
}
35+
36+
func (c *NullCodec) NewEncoder() gumble.AudioEncoder {
37+
e := &NullAudioEncoder{}
38+
return e
39+
}
40+
41+
func (c *NullCodec) NewDecoder() gumble.AudioDecoder {
42+
d := &NullAudioDecoder{}
43+
return d
44+
}
45+
46+
type NullAudioEncoder struct{}
47+
48+
func (e *NullAudioEncoder) ID() int {
49+
return audioCodecIDOpus
50+
}
51+
52+
func (e *NullAudioEncoder) Encode(pcm []int16, mframeSize, maxDataBytes int) ([]byte, error) {
53+
return nil, fmt.Errorf("not implemented")
54+
}
55+
56+
func (e *NullAudioEncoder) Reset() {
57+
}
58+
59+
type NullAudioDecoder struct{}
60+
61+
func (d *NullAudioDecoder) ID() int {
62+
return audioCodecIDOpus
63+
}
64+
65+
func (d *NullAudioDecoder) Decode(data []byte, frameSize int) ([]int16, error) {
66+
return nil, fmt.Errorf("not implemented")
67+
}
68+
69+
func (d *NullAudioDecoder) Reset() {
70+
}

bridge/mumble/mumble.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ func (b *Bmumble) doConnect() error {
185185
gumbleConfig.Password = password
186186
}
187187

188+
registerNullCodecAsOpus()
188189
client, err := gumble.DialWithDialer(new(net.Dialer), b.GetString("Server"), gumbleConfig, &b.tlsConfig)
189190
if err != nil {
190191
return err

0 commit comments

Comments
 (0)