Mumble: Implement a workaround to signal Opus support without pulling in the CGO gopus dependency.
This commit is contained in:
69
bridge/mumble/codec.go
Normal file
69
bridge/mumble/codec.go
Normal file
@@ -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() {
|
||||||
|
}
|
||||||
@@ -185,6 +185,7 @@ func (b *Bmumble) doConnect() error {
|
|||||||
gumbleConfig.Password = password
|
gumbleConfig.Password = password
|
||||||
}
|
}
|
||||||
|
|
||||||
|
registerNullCodecAsOpus()
|
||||||
client, err := gumble.DialWithDialer(new(net.Dialer), b.GetString("Server"), gumbleConfig, &b.tlsConfig)
|
client, err := gumble.DialWithDialer(new(net.Dialer), b.GetString("Server"), gumbleConfig, &b.tlsConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
Reference in New Issue
Block a user