mirror of
https://github.com/pion/mediadevices.git
synced 2024-05-31 14:03:35 +08:00
cd6aaa1393
Also make the ReadCloser an Controllable allows to uncouple the controller implementation from the encoder. This is not needed for the 2 codec controller already implemented (openh264 and vpx) but is more future proof in case it required for other codecs.
31 lines
634 B
Go
31 lines
634 B
Go
package mediadevices
|
|
|
|
import (
|
|
"github.com/pion/mediadevices/pkg/codec"
|
|
"github.com/pion/rtp"
|
|
)
|
|
|
|
type RTPReadCloser interface {
|
|
Read() (pkts []*rtp.Packet, release func(), err error)
|
|
Close() error
|
|
codec.Controllable
|
|
}
|
|
|
|
type rtpReadCloserImpl struct {
|
|
readFn func() ([]*rtp.Packet, func(), error)
|
|
closeFn func() error
|
|
controllerFn func() codec.EncoderController
|
|
}
|
|
|
|
func (r *rtpReadCloserImpl) Read() ([]*rtp.Packet, func(), error) {
|
|
return r.readFn()
|
|
}
|
|
|
|
func (r *rtpReadCloserImpl) Close() error {
|
|
return r.closeFn()
|
|
}
|
|
|
|
func (r *rtpReadCloserImpl) Controller() codec.EncoderController {
|
|
return r.controllerFn()
|
|
}
|