summaryrefslogtreecommitdiffstats
path: root/bridge/mumble/codec.go
diff options
context:
space:
mode:
authorSebastian P <5564491+s3lph@users.noreply.github.com>2022-03-19 21:32:00 +0100
committerGitHub <noreply@github.com>2022-03-19 21:32:00 +0100
commit663850a2b825e762667f930cd5a4ee87de853444 (patch)
tree69b4f14fcd9342390f9928b1aa99e91f0f591683 /bridge/mumble/codec.go
parentc51753cab1319f6df9f859896b7ad9aa9e104041 (diff)
downloadmatterbridge-msglm-663850a2b825e762667f930cd5a4ee87de853444.tar.gz
matterbridge-msglm-663850a2b825e762667f930cd5a4ee87de853444.tar.bz2
matterbridge-msglm-663850a2b825e762667f930cd5a4ee87de853444.zip
Implement a workaround to signal Opus support (mumble) (#1764)
* Mumble: Implement a workaround to signal Opus support without pulling in the CGO gopus dependency. * mumble: lowercase error messages * mumble: Add link to #1750 in bridge/mumble/codec.go
Diffstat (limited to 'bridge/mumble/codec.go')
-rw-r--r--bridge/mumble/codec.go70
1 files changed, 70 insertions, 0 deletions
diff --git a/bridge/mumble/codec.go b/bridge/mumble/codec.go
new file mode 100644
index 00000000..1306e408
--- /dev/null
+++ b/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() {
+}