Documentation
¶
Overview ¶
Package decoder provides video and audio decoder interfaces using libwebrtc.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrDecoderClosed = errors.New("decoder is closed") ErrInvalidData = errors.New("invalid encoded data") ErrDecodeFailed = errors.New("decode failed") ErrUnsupportedCodec = errors.New("unsupported codec") ErrNeedMoreData = errors.New("need more data to decode") ErrBufferTooSmall = errors.New("destination buffer too small") )
Common errors
Functions ¶
This section is empty.
Types ¶
type AudioDecoder ¶
type AudioDecoder interface {
// DecodeInto decodes encoded audio data into the destination frame.
// The dst frame must have pre-allocated Samples buffer of sufficient size.
// Returns the number of samples decoded per channel.
// Returns ErrNeedMoreData if the decoder accepted input but has not
// produced PCM output yet.
DecodeInto(src []byte, dst *frame.AudioFrame) (numSamples int, err error)
// MaxSamplesPerFrame returns the maximum samples per channel that can
// be decoded from a single encoded frame. Use this to size buffers.
MaxSamplesPerFrame() int
// Codec returns the codec type of this decoder.
Codec() codec.Type
// Close releases all decoder resources.
Close() error
}
AudioDecoder decodes compressed audio bitstream to raw samples. All operations are allocation-free - caller provides buffers.
func NewAudioDecoder ¶
func NewAudioDecoder(codecType codec.Type, sampleRate, channels int) (AudioDecoder, error)
NewAudioDecoder creates an audio decoder for the specified codec.
func NewOpusDecoder ¶
func NewOpusDecoder(sampleRate, channels int) (AudioDecoder, error)
NewOpusDecoder creates an Opus audio decoder for the requested output format.
type VideoDecoder ¶
type VideoDecoder interface {
// DecodeInto decodes encoded video data into the destination frame.
// The dst frame must have pre-allocated Data buffers of sufficient size.
// Use frame.NewI420Frame(width, height) to create a properly sized frame.
// Returns ErrNeedMoreData if more data is required (e.g., B-frames).
DecodeInto(src []byte, dst *frame.VideoFrame, timestamp uint32, isKeyframe bool) error
// Codec returns the codec type of this decoder.
Codec() codec.Type
// Close releases all decoder resources.
Close() error
}
VideoDecoder decodes compressed video bitstream to raw frames. All operations are allocation-free - caller provides buffers.
func NewAV1Decoder ¶
func NewAV1Decoder() (VideoDecoder, error)
NewAV1Decoder creates an AV1 video decoder backed by libwebrtc.
func NewH264Decoder ¶
func NewH264Decoder() (VideoDecoder, error)
NewH264Decoder creates an H.264 video decoder backed by libwebrtc.
func NewVP8Decoder ¶
func NewVP8Decoder() (VideoDecoder, error)
NewVP8Decoder creates a VP8 video decoder backed by libwebrtc.
func NewVP9Decoder ¶
func NewVP9Decoder() (VideoDecoder, error)
NewVP9Decoder creates a VP9 video decoder backed by libwebrtc.
func NewVideoDecoder ¶
func NewVideoDecoder(codecType codec.Type) (VideoDecoder, error)
NewVideoDecoder creates a video decoder for the specified codec.