Update from io.ReadCloser to codec.ReadCloser

This commit is contained in:
Lukas Herman
2020-03-25 20:50:26 -04:00
committed by Lukas Herman
parent e9ad427815
commit 354f2710b5
14 changed files with 99 additions and 33 deletions
+10 -4
View File
@@ -2,12 +2,12 @@ package opus
import (
"fmt"
"io"
"math"
"reflect"
"unsafe"
"github.com/lherman-cs/opus"
"github.com/pion/mediadevices/pkg/codec"
"github.com/pion/mediadevices/pkg/io/audio"
"github.com/pion/mediadevices/pkg/prop"
)
@@ -20,9 +20,7 @@ type encoder struct {
var latencies = []float64{5, 10, 20, 40, 60}
var _ io.ReadCloser = &encoder{}
func newEncoder(r audio.Reader, p prop.Media, params Params) (io.ReadCloser, error) {
func newEncoder(r audio.Reader, p prop.Media, params Params) (codec.ReadCloser, error) {
if p.SampleRate == 0 {
return nil, fmt.Errorf("opus: inProp.SampleRate is required")
}
@@ -98,6 +96,14 @@ func (e *encoder) Read(p []byte) (n int, err error) {
return n, nil
}
func (e *encoder) SetBitRate(b int) error {
panic("SetBitRate is not implemented")
}
func (e *encoder) ForceKeyFrame() error {
panic("ForceKeyFrame is not implemented")
}
func (e *encoder) Close() error {
return nil
}
+2 -4
View File
@@ -1,8 +1,6 @@
package opus
import (
"io"
"github.com/pion/mediadevices/pkg/codec"
"github.com/pion/mediadevices/pkg/io/audio"
"github.com/pion/mediadevices/pkg/prop"
@@ -24,7 +22,7 @@ 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) {
// BuildAudioEncoder builds opus encoder with given params
func (p *Params) BuildAudioEncoder(r audio.Reader, property prop.Media) (codec.ReadCloser, error) {
return newEncoder(r, property, *p)
}