Redesign codec

Resolves https://github.com/pion/mediadevices/issues/114

* Remove codec registrar
* Completely redesign how codec is being discovered, tuned, and built
* Update examples
* Update unit tests
This commit is contained in:
Lukas Herman
2020-03-14 21:59:32 -04:00
parent 475f8cc458
commit c9b90fb233
22 changed files with 518 additions and 377 deletions

30
pkg/codec/opus/params.go Normal file
View File

@@ -0,0 +1,30 @@
package opus
import (
"io"
"github.com/pion/mediadevices/pkg/codec"
"github.com/pion/mediadevices/pkg/io/audio"
"github.com/pion/mediadevices/pkg/prop"
"github.com/pion/webrtc/v2"
)
// Params stores opus specific encoding parameters.
type Params struct {
codec.BaseParams
}
// NewParams returns default opus codec specific parameters.
func NewParams() (Params, error) {
return Params{}, nil
}
// Name represents the codec name
func (p *Params) Name() string {
return webrtc.Opus
}
// BuildVideoEncoder builds x264 encoder with given params
func (p *Params) BuildAudioEncoder(r audio.Reader, property prop.Media) (io.ReadCloser, error) {
return newEncoder(r, property, *p)
}