Documentation
¶
Overview ¶
Package stats provides an interceptor that records RTP/RTCP stream statistics
Index ¶
- type Getter
- type InboundRTPStreamStats
- type Interceptor
- func (r *Interceptor) BindLocalStream(info *interceptor.StreamInfo, writer interceptor.RTPWriter) interceptor.RTPWriter
- func (r *Interceptor) BindRTCPReader(reader interceptor.RTCPReader) interceptor.RTCPReader
- func (r *Interceptor) BindRTCPWriter(writer interceptor.RTCPWriter) interceptor.RTCPWriter
- func (r *Interceptor) BindRemoteStream(info *interceptor.StreamInfo, reader interceptor.RTPReader) interceptor.RTPReader
- func (r *Interceptor) Close() error
- func (r *Interceptor) Get(ssrc uint32) *Stats
- type InterceptorFactory
- type NewPeerConnectionCallback
- type Option
- type OutboundRTPStreamStats
- type ReceivedRTPStreamStats
- type Recorder
- type RecorderFactory
- type RemoteInboundRTPStreamStats
- type RemoteOutboundRTPStreamStats
- type SentRTPStreamStats
- type Stats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
func (s RemoteInboundRTPStreamStats) String() 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 ¶
func (s RemoteOutboundRTPStreamStats) String() string
String returns a string representation of RemoteOutboundRTPStreamStats
type SentRTPStreamStats ¶
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 ¶
type Stats struct {
InboundRTPStreamStats
OutboundRTPStreamStats
RemoteInboundRTPStreamStats
RemoteOutboundRTPStreamStats
}
Stats contains all the available statistics of RTP streams