Documentation
¶
Overview ¶
Package receiver implements WebRTC receiver functionality for bandwidth estimation tests.
Package receiver implements WebRTC receiver functionality for bandwidth estimation tests.
Index ¶
- Variables
- func IsKeyframe(payload []byte) bool
- func ParseVP8KeyframeDimensions(frameData []byte) (int, int, bool)
- type Option
- func DefaultInterceptors() Option
- func EnableVP8Decode(outputPath string) Option
- func EnableVP8DecodeWithMP4(basePath string, mp4BasePath string) Option
- func PacketLogWriter(rtpWriter, rtcpWriter io.Writer) Option
- func SaveVideo(basePath string) Option
- func SetLoggerFactory(loggerFactory plogging.LoggerFactory) Option
- func SetVideoWriterCallback(callback VideoWriterCallback) Option
- func SetVnet(v *vnet.Net, publicIPs []string) Option
- type Receiver
- type VP8Depayloader
- type VP8FrameAssembler
- type VP8FrameProcessor
- type VideoWriterCallback
Constants ¶
This section is empty.
Variables ¶
var ( // ErrDecoderCreationFailed is returned when VP8 decoder creation fails. ErrDecoderCreationFailed = errors.New("VP8 decoder creation failed") // ErrDecoderCloseFailed is returned when decoder close operation fails. ErrDecoderCloseFailed = errors.New("decoder close failed") )
Functions ¶
func IsKeyframe ¶
IsKeyframe checks if the VP8 frame is a keyframe. VP8 keyframes are identified by the P bit in the frame header. See https://tools.ietf.org/html/rfc6386#section-9.1.
Types ¶
type Option ¶
Option is a function that configures a Receiver.
func DefaultInterceptors ¶
func DefaultInterceptors() Option
DefaultInterceptors returns an Option that registers the default WebRTC interceptors.
func EnableVP8Decode ¶
EnableVP8Decode returns an Option that configures the receiver to decode VP8 frames and save them as PNG images. The outputPath should be the directory path where decoded frames will be saved (e.g., "decoded/").
func EnableVP8DecodeWithMP4 ¶
EnableVP8DecodeWithMP4 returns an Option that configures the receiver to decode VP8 frames and save as both PNG images and MP4 video. Uses a single base path - subdirectories will be created automatically (mp4/ and frames/).
func PacketLogWriter ¶
PacketLogWriter returns an Option that configures RTP and RTCP packet logging.
func SaveVideo ¶
SaveVideo returns an Option that enables video saving to IVF files. The basePath specifies the base filename for output files (without extension). For multiple tracks, files will be named as basePath_track-N.ivf.
func SetLoggerFactory ¶
func SetLoggerFactory(loggerFactory plogging.LoggerFactory) Option
SetLoggerFactory returns an Option that configures the logger factory.
func SetVideoWriterCallback ¶
func SetVideoWriterCallback(callback VideoWriterCallback) Option
SetVideoWriterCallback returns an Option that sets the callback for video frame processing.
type Receiver ¶
type Receiver struct {
// contains filtered or unexported fields
}
Receiver manages a WebRTC connection for receiving media.
func NewReceiver ¶
NewReceiver creates a new WebRTC receiver with the given options.
func (*Receiver) AcceptOffer ¶
func (r *Receiver) AcceptOffer(offer *webrtc.SessionDescription) (*webrtc.SessionDescription, error)
AcceptOffer processes a WebRTC offer from the remote peer and creates an answer.
func (*Receiver) SDPHandler ¶
func (r *Receiver) SDPHandler() http.HandlerFunc
SDPHandler returns an HTTP handler for WebRTC signaling.
func (*Receiver) SetupPeerConnection ¶
SetupPeerConnection initializes the WebRTC peer connection.
type VP8Depayloader ¶
type VP8Depayloader struct {
// contains filtered or unexported fields
}
VP8Depayloader handles VP8 RTP payloads using Pion's VP8Packet.
func NewVP8Depayloader ¶
func NewVP8Depayloader() *VP8Depayloader
NewVP8Depayloader creates a new VP8 depayloader.
func (*VP8Depayloader) FlushFrame ¶
func (d *VP8Depayloader) FlushFrame() ([]byte, bool, uint32)
FlushFrame forces completion of the current frame.
func (*VP8Depayloader) GetFrame ¶
func (d *VP8Depayloader) GetFrame() ([]byte, bool, uint32)
GetFrame returns the current complete frame and resets the assembler.
func (*VP8Depayloader) ProcessPacket ¶
ProcessPacket processes a VP8 RTP packet using Pion's VP8Packet. Returns complete frame data when a frame is complete.
type VP8FrameAssembler ¶
type VP8FrameAssembler struct {
// contains filtered or unexported fields
}
VP8FrameAssembler handles assembly of VP8 frames from RTP packets.
func NewVP8FrameAssembler ¶
func NewVP8FrameAssembler(logger logging.LeveledLogger) *VP8FrameAssembler
NewVP8FrameAssembler creates a new VP8 frame assembler.
func (*VP8FrameAssembler) FlushFrame ¶
func (a *VP8FrameAssembler) FlushFrame() (bool, []byte, bool, uint64)
FlushFrame forces completion of any in-progress frame.
func (*VP8FrameAssembler) ProcessPacket ¶
ProcessPacket processes an RTP packet and returns a complete frame if available. Returns: - bool: true if a complete frame is available - []byte: the complete frame data, or nil if no frame is available - bool: true if the frame is a keyframe - uint64: the timestamp of the frame.
type VP8FrameProcessor ¶
type VP8FrameProcessor struct {
// contains filtered or unexported fields
}
VP8FrameProcessor handles VP8 frame processing pipeline.
func NewVP8FrameProcessor ¶
func NewVP8FrameProcessor( width, height int, trackID string, frameCallback VideoWriterCallback, logger logging.LeveledLogger, ) (*VP8FrameProcessor, error)
NewVP8FrameProcessor creates a new VP8 frame processor with callback.
func (*VP8FrameProcessor) Close ¶
func (vp *VP8FrameProcessor) Close() error
Close stops the frame processor and cleans up resources.
func (*VP8FrameProcessor) Decode ¶
func (vp *VP8FrameProcessor) Decode(frameData []byte)
Decode processes a VP8 frame by feeding it to the decoder.
func (*VP8FrameProcessor) GetFrameCount ¶
func (vp *VP8FrameProcessor) GetFrameCount() int
GetFrameCount returns the number of processed frames.
func (*VP8FrameProcessor) HasFirstKeyFrame ¶
func (vp *VP8FrameProcessor) HasFirstKeyFrame() bool
HasFirstKeyFrame returns whether we got the first keyframe.
func (*VP8FrameProcessor) SetFirstKeyFrame ¶
func (vp *VP8FrameProcessor) SetFirstKeyFrame()
SetFirstKeyFrame marks that we got the first keyframe.