Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mumble: Implement a workaround to signal Opus support #1764

Merged
merged 3 commits into from Mar 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
70 changes: 70 additions & 0 deletions bridge/mumble/codec.go
@@ -0,0 +1,70 @@
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.
// See https://github.com/42wim/matterbridge/issues/1750 for details.

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() {
}
1 change: 1 addition & 0 deletions bridge/mumble/mumble.go
Expand Up @@ -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
Expand Down