Thumbnail

rani/matterbridge.git

Clone URL: https://git.buni.party/rani/matterbridge.git

Viewing file on branch master

1package bmumble
2
3import (
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
15const (
16 audioCodecIDOpus = 4
17)
18
19func registerNullCodecAsOpus() {
20 codec := &NullCodec{
21 encoder: &NullAudioEncoder{},
22 decoder: &NullAudioDecoder{},
23 }
24 gumble.RegisterAudioCodec(audioCodecIDOpus, codec)
25}
26
27type NullCodec struct {
28 encoder *NullAudioEncoder
29 decoder *NullAudioDecoder
30}
31
32func (c *NullCodec) ID() int {
33 return audioCodecIDOpus
34}
35
36func (c *NullCodec) NewEncoder() gumble.AudioEncoder {
37 e := &NullAudioEncoder{}
38 return e
39}
40
41func (c *NullCodec) NewDecoder() gumble.AudioDecoder {
42 d := &NullAudioDecoder{}
43 return d
44}
45
46type NullAudioEncoder struct{}
47
48func (e *NullAudioEncoder) ID() int {
49 return audioCodecIDOpus
50}
51
52func (e *NullAudioEncoder) Encode(pcm []int16, mframeSize, maxDataBytes int) ([]byte, error) {
53 return nil, fmt.Errorf("not implemented")
54}
55
56func (e *NullAudioEncoder) Reset() {
57}
58
59type NullAudioDecoder struct{}
60
61func (d *NullAudioDecoder) ID() int {
62 return audioCodecIDOpus
63}
64
65func (d *NullAudioDecoder) Decode(data []byte, frameSize int) ([]int16, error) {
66 return nil, fmt.Errorf("not implemented")
67}
68
69func (d *NullAudioDecoder) Reset() {
70}
71