rtpreceiver

package
v5.5.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 24, 2026 License: MIT Imports: 6 Imported by: 2

Documentation

Overview

Package rtpreceiver contains a utility to receive RTP packets.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Receiver

type Receiver struct {
	// Track clock rate.
	ClockRate int

	// Local SSRC
	LocalSSRC uint32

	// Whether the transport is unrealiable.
	// When this is enabled, duplicate packets are removed, and packets are reordered.
	UnrealiableTransport bool

	// Size of the buffer for reordering packets.
	// It defaults to 64.
	BufferSize int

	// Period of RTCP receiver reports.
	Period time.Duration

	// time.Now function.
	TimeNow func() time.Time

	// Called when a RTCP receiver report is ready to be written.
	WritePacketRTCP func(rtcp.Packet)
	// contains filtered or unexported fields
}

Receiver is a utility to receive RTP packets. It is in charge of: - removing duplicate packets (when transport is unreliable) - reordering packets (when transport is unrealiable) - counting received and lost packets - generating RTCP receiver reports

func (*Receiver) Close

func (rr *Receiver) Close()

Close closes the Receiver.

func (*Receiver) Initialize

func (rr *Receiver) Initialize() error

Initialize initializes Receiver.

func (*Receiver) PacketNTP

func (rr *Receiver) PacketNTP(ts uint32) (time.Time, bool)

PacketNTP returns the NTP (absolute timestamp) of the packet.

func (*Receiver) ProcessPacket deprecated

func (rr *Receiver) ProcessPacket(
	pkt *rtp.Packet,
	system time.Time,
	ptsEqualsDTS bool,
) ([]*rtp.Packet, uint64, error)

ProcessPacket processes an inbound RTP packet. It returns reordered packets and number of lost packets.

Deprecated: replaced by ProcessPacket2.

func (*Receiver) ProcessPacket2 added in v5.2.0

func (rr *Receiver) ProcessPacket2(
	pkt *rtp.Packet,
	system time.Time,
	ptsEqualsDTS bool,
) ([]*rtp.Packet, uint64)

ProcessPacket2 processes an inbound RTP packet. It returns reordered packets and number of lost packets.

func (*Receiver) ProcessSenderReport

func (rr *Receiver) ProcessSenderReport(sr *rtcp.SenderReport, system time.Time)

ProcessSenderReport processes an inbound RTCP sender report.

func (*Receiver) Stats

func (rr *Receiver) Stats() *Stats

Stats returns statistics.

type Stats

type Stats struct {
	// inbound RTP packets correctly received and processed.
	Received uint64
	// lost inbound RTP packets.
	Lost uint64
	// Jitter of inbound RTP packets.
	Jitter float64
	// Last sequence number of inbound RTP packets.
	LastSequenceNumber uint16
	// Last RTP time of inbound RTP packets.
	LastRTP uint32
	// Last NTP time of inbound RTP packets.
	LastNTP time.Time

	// Deprecated: use Received.
	TotalReceived uint64
	// Deprecated: use Lost.
	TotalLost uint64
	// Deprecated: will be removed in next version.
	RemoteSSRC uint32
}

Stats are statistics.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL