Files
mediadevices/rtpreader.go
Valentin Cocaud 419afd453a Add an interface for easier customization of the EncoderController
Making 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.
2022-03-01 14:39:12 +01:00

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()
}