stats

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package stats provides an interceptor that records RTP/RTCP stream statistics

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Getter

type Getter interface {
	Get(ssrc uint32) *Stats
}

Getter returns the most recent stats of a stream

type InboundRTPStreamStats

type InboundRTPStreamStats struct {
	ReceivedRTPStreamStats

	LastPacketReceivedTimestamp time.Time
	HeaderBytesReceived         uint64
	BytesReceived               uint64
	FIRCount                    uint32
	PLICount                    uint32
	NACKCount                   uint32
}

InboundRTPStreamStats contains stats of inbound RTP streams

func (InboundRTPStreamStats) String

func (s InboundRTPStreamStats) String() string

String returns a string representation of InboundRTPStreamStats

type Interceptor

type Interceptor struct {
	interceptor.NoOp

	RecorderFactory RecorderFactory
	// contains filtered or unexported fields
}

Interceptor is the interceptor that collects stream stats

func (*Interceptor) BindLocalStream

func (r *Interceptor) BindLocalStream(info *interceptor.StreamInfo, writer interceptor.RTPWriter) interceptor.RTPWriter

BindLocalStream lets you modify any outgoing RTP packets. It is called once for per LocalStream. The returned method will be called once per rtp packet.

func (*Interceptor) BindRTCPReader

func (r *Interceptor) BindRTCPReader(reader interceptor.RTCPReader) interceptor.RTCPReader

BindRTCPReader lets you modify any incoming RTCP packets. It is called once per sender/receiver, however this might change in the future. The returned method will be called once per packet batch.

func (*Interceptor) BindRTCPWriter

func (r *Interceptor) BindRTCPWriter(writer interceptor.RTCPWriter) interceptor.RTCPWriter

BindRTCPWriter lets you modify any outgoing RTCP packets. It is called once per PeerConnection. The returned method will be called once per packet batch.

func (*Interceptor) BindRemoteStream

func (r *Interceptor) BindRemoteStream(info *interceptor.StreamInfo, reader interceptor.RTPReader) interceptor.RTPReader

BindRemoteStream lets you modify any incoming RTP packets. It is called once for per RemoteStream. The returned method will be called once per rtp packet.

func (*Interceptor) Close

func (r *Interceptor) Close() error

Close closes the interceptor and associated stats recorders

func (*Interceptor) Get

func (r *Interceptor) Get(ssrc uint32) *Stats

Get returns the statistics for the stream with ssrc

type InterceptorFactory

type InterceptorFactory struct {
	// contains filtered or unexported fields
}

InterceptorFactory is a interceptor.Factory for a stats Interceptor

func NewInterceptor

func NewInterceptor(opts ...Option) (*InterceptorFactory, error)

NewInterceptor creates a new InterceptorFactory

func (*InterceptorFactory) NewInterceptor

func (r *InterceptorFactory) NewInterceptor(id string) (interceptor.Interceptor, error)

NewInterceptor creates a new Interceptor

func (*InterceptorFactory) OnNewPeerConnection

func (r *InterceptorFactory) OnNewPeerConnection(cb NewPeerConnectionCallback)

OnNewPeerConnection sets the callback that is called when a new PeerConnection is created.

type NewPeerConnectionCallback

type NewPeerConnectionCallback func(string, Getter)

NewPeerConnectionCallback receives a new StatsGetter for a newly created PeerConnection

type Option

type Option func(*Interceptor) error

Option can be used to configure the stats interceptor

func SetNowFunc

func SetNowFunc(now func() time.Time) Option

SetNowFunc sets the function the interceptor uses to get a current timestamp. This is mostly useful for testing.

func SetRecorderFactory

func SetRecorderFactory(f RecorderFactory) Option

SetRecorderFactory sets the factory that is used to create new stats recorders for new streams

type OutboundRTPStreamStats

type OutboundRTPStreamStats struct {
	SentRTPStreamStats

	HeaderBytesSent uint64
	NACKCount       uint32
	FIRCount        uint32
	PLICount        uint32
}

OutboundRTPStreamStats contains stats of outbound RTP streams

func (OutboundRTPStreamStats) String

func (s OutboundRTPStreamStats) String() string

String returns a string representation of OutboundRTPStreamStats

type ReceivedRTPStreamStats

type ReceivedRTPStreamStats struct {
	PacketsReceived uint64
	PacketsLost     int64
	Jitter          float64
}

ReceivedRTPStreamStats contains common receiver stats of RTP streams

func (ReceivedRTPStreamStats) String

func (s ReceivedRTPStreamStats) String() string

String returns a string representation of ReceivedRTPStreamStats

type Recorder

type Recorder interface {
	QueueIncomingRTP(ts time.Time, buf []byte, attr interceptor.Attributes)
	QueueIncomingRTCP(ts time.Time, buf []byte, attr interceptor.Attributes)
	QueueOutgoingRTP(ts time.Time, header *rtp.Header, payload []byte, attr interceptor.Attributes)
	QueueOutgoingRTCP(ts time.Time, pkts []rtcp.Packet, attr interceptor.Attributes)
	GetStats() Stats
	Stop()
	Start()
}

Recorder is the interface of a statistics recorder

type RecorderFactory

type RecorderFactory func(ssrc uint32, clockRate float64) Recorder

RecorderFactory creates new Recorders to be used by the interceptor

type RemoteInboundRTPStreamStats

type RemoteInboundRTPStreamStats struct {
	ReceivedRTPStreamStats

	RoundTripTime             time.Duration
	TotalRoundTripTime        time.Duration
	FractionLost              float64
	RoundTripTimeMeasurements uint64
}

RemoteInboundRTPStreamStats contains stats of inbound RTP streams of the remote peer

func (RemoteInboundRTPStreamStats) String

String returns a string representation of RemoteInboundRTPStreamStats

type RemoteOutboundRTPStreamStats

type RemoteOutboundRTPStreamStats struct {
	SentRTPStreamStats

	RemoteTimeStamp           time.Time
	ReportsSent               uint64
	RoundTripTime             time.Duration
	TotalRoundTripTime        time.Duration
	RoundTripTimeMeasurements uint64
}

RemoteOutboundRTPStreamStats contains stats of outbound RTP streams of the remote peer

func (RemoteOutboundRTPStreamStats) String

String returns a string representation of RemoteOutboundRTPStreamStats

type SentRTPStreamStats

type SentRTPStreamStats struct {
	PacketsSent uint64
	BytesSent   uint64
}

SentRTPStreamStats contains common sender stats of RTP streams

func (SentRTPStreamStats) String

func (s SentRTPStreamStats) String() string

String returns a string representation of SentRTPStreamStats

type Stats

Stats contains all the available statistics of RTP streams

Jump to

Keyboard shortcuts

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