Documentation
¶
Index ¶
- Constants
- Variables
- func AggregateRTPStats(statsList []*livekit.RTPStats) *livekit.RTPStats
- func IsAV1Keyframe(payload []byte) bool
- func IsH264Keyframe(payload []byte) bool
- func IsVp9Keyframe(payload []byte) bool
- func VP8PictureIdSizeDiff(mBit1 bool, mBit2 bool) int
- type Bucket
- type Buffer
- func (b *Buffer) Bind(params webrtc.RTPParameters, codec webrtc.RTPCodecCapability)
- func (b *Buffer) Close() error
- func (b *Buffer) GetAudioLevel() (float64, bool)
- func (b *Buffer) GetClockRate() uint32
- func (b *Buffer) GetDeltaStats() *StreamStatsWithLayers
- func (b *Buffer) GetMediaSSRC() uint32
- func (b *Buffer) GetPacket(buff []byte, sn uint16) (int, error)
- func (b *Buffer) GetStats() *livekit.RTPStats
- func (b *Buffer) OnClose(fn func())
- func (b *Buffer) OnMaxLayerChanged(fn func(int32, int32))
- func (b *Buffer) OnRtcpFeedback(fn func(fb []rtcp.Packet))
- func (b *Buffer) Read(buff []byte) (n int, err error)
- func (b *Buffer) ReadExtended() (*ExtPacket, error)
- func (b *Buffer) SendPLI(force bool)
- func (b *Buffer) SetAudioLevelParams(audioLevelParams audio.AudioLevelParams)
- func (b *Buffer) SetLastFractionLostReport(lost uint8)
- func (b *Buffer) SetLogger(logger logger.Logger)
- func (b *Buffer) SetPLIThrottle(duration int64)
- func (b *Buffer) SetRTT(rtt uint32)
- func (b *Buffer) SetSenderReportData(rtpTime uint32, ntpTime uint64)
- func (b *Buffer) SetTWCC(twcc *twcc.Responder)
- func (b *Buffer) Write(pkt []byte) (n int, err error)
- type DataStats
- type DataStatsParam
- type DependencyDescriptorParser
- type ExtPacket
- type Factory
- type IntervalStats
- type NackQueue
- type NtpTime
- type Options
- type RTCPReader
- type RTPDeltaInfo
- type RTPFlowState
- type RTPStats
- func (r *RTPStats) DeltaInfo(snapshotId uint32) *RTPDeltaInfo
- func (r *RTPStats) ForceUpdateLastPacket(rtph *rtp.Header, packetTime int64)
- func (r *RTPStats) GetRtcpSenderReport(ssrc uint32) *rtcp.SenderReport
- func (r *RTPStats) GetRtt() uint32
- func (r *RTPStats) GetTotalPacketsPrimary() uint32
- func (r *RTPStats) IsActive() bool
- func (r *RTPStats) LastPli() time.Time
- func (r *RTPStats) NewSnapshotId() uint32
- func (r *RTPStats) SetLogger(logger logger.Logger)
- func (r *RTPStats) SetRtcpSenderReportData(rtpTS uint32, ntpTS NtpTime, arrival time.Time)
- func (r *RTPStats) SnapshotRtcpReceptionReport(ssrc uint32, proxyFracLost uint8, snapshotId uint32) *rtcp.ReceptionReport
- func (r *RTPStats) Stop()
- func (r *RTPStats) TimeSinceLastPli() int64
- func (r *RTPStats) ToProto() *livekit.RTPStats
- func (r *RTPStats) ToString() string
- func (r *RTPStats) Update(rtph *rtp.Header, payloadSize int, paddingSize int, packetTime int64) (flowState RTPFlowState)
- func (r *RTPStats) UpdateFir(firCount uint32)
- func (r *RTPStats) UpdateFirTime()
- func (r *RTPStats) UpdateFromReceiverReport(extHighestSN uint32, packetsLost uint32, rtt uint32, jitter float64)
- func (r *RTPStats) UpdateKeyFrame(kfCount uint32)
- func (r *RTPStats) UpdateLayerLockPliAndTime(pliCount uint32)
- func (r *RTPStats) UpdateNack(nackCount uint32)
- func (r *RTPStats) UpdateNackProcessed(nackAckCount uint32, nackMissCount uint32, nackRepeatedCount uint32)
- func (r *RTPStats) UpdatePli(pliCount uint32)
- func (r *RTPStats) UpdatePliAndTime(pliCount uint32)
- func (r *RTPStats) UpdatePliTime()
- func (r *RTPStats) UpdateRtt(rtt uint32)
- type RTPStatsParams
- type SnInfo
- type Snapshot
- type StreamStatsWithLayers
- type VP8
- type VideoLayer
Constants ¶
const ( GapHistogramNumBins = 101 NumSequenceNumbers = 65536 FirstSnapshotId = 1 SnInfoSize = 2048 SnInfoMask = SnInfoSize - 1 )
const ( InvalidLayerSpatial = int32(-1) InvalidLayerTemporal = int32(-1) DefaultMaxLayerSpatial = int32(2) DefaultMaxLayerTemporal = int32(3) )
const (
ReportDelta = 1e9
)
Variables ¶
var ( ErrPacketNotFound = errors.New("packet not found in cache") ErrBufferTooSmall = errors.New("buffer too small") ErrPacketTooOld = errors.New("received packet too old") ErrRTXPacket = errors.New("packet already received") )
var ( InvalidLayers = VideoLayer{ Spatial: InvalidLayerSpatial, Temporal: InvalidLayerTemporal, } )
Functions ¶
func AggregateRTPStats ¶ added in v0.15.6
func IsAV1Keyframe ¶ added in v0.15.7
IsAV1Keyframe detects if av1 payload is a keyframe taken from https://github.com/jech/galene/blob/master/codecs/codecs.go all credits belongs to Juliusz Chroboczek @jech and the awesome Galene SFU
func IsH264Keyframe ¶ added in v0.15.0
IsH264Keyframe detects if h264 payload is a keyframe this code was taken from https://github.com/jech/galene/blob/codecs/rtpconn/rtpreader.go#L45 all credits belongs to Juliusz Chroboczek @jech and the awesome Galene SFU
func IsVp9Keyframe ¶ added in v0.15.7
IsAV1Keyframe detects if vp9 payload is a keyframe taken from https://github.com/jech/galene/blob/master/codecs/codecs.go all credits belongs to Juliusz Chroboczek @jech and the awesome Galene SFU
func VP8PictureIdSizeDiff ¶
Types ¶
type Buffer ¶
Buffer contains all packets
func (*Buffer) Bind ¶
func (b *Buffer) Bind(params webrtc.RTPParameters, codec webrtc.RTPCodecCapability)
func (*Buffer) GetAudioLevel ¶ added in v0.15.7
func (*Buffer) GetClockRate ¶
GetClockRate returns the RTP clock rate
func (*Buffer) GetDeltaStats ¶ added in v0.15.7
func (b *Buffer) GetDeltaStats() *StreamStatsWithLayers
func (*Buffer) GetMediaSSRC ¶
GetMediaSSRC returns the associated SSRC of the RTP stream
func (*Buffer) OnMaxLayerChanged ¶ added in v1.0.0
TODO : now we rely on stream tracker for layer change, dependency still work for that too. Do we keep it unchange or use both methods?
func (*Buffer) OnRtcpFeedback ¶ added in v0.15.7
func (*Buffer) ReadExtended ¶
func (*Buffer) SetAudioLevelParams ¶ added in v0.15.7
func (b *Buffer) SetAudioLevelParams(audioLevelParams audio.AudioLevelParams)
func (*Buffer) SetLastFractionLostReport ¶
func (*Buffer) SetPLIThrottle ¶ added in v0.15.4
func (*Buffer) SetSenderReportData ¶
type DataStats ¶ added in v0.15.6
type DataStats struct {
// contains filtered or unexported fields
}
func NewDataStats ¶ added in v0.15.6
func NewDataStats(params DataStatsParam) *DataStats
func (*DataStats) ToProtoActive ¶ added in v0.15.6
func (*DataStats) ToProtoAggregateOnly ¶ added in v0.15.6
type DataStatsParam ¶ added in v0.15.6
type DependencyDescriptorParser ¶ added in v1.0.0
type DependencyDescriptorParser struct {
// contains filtered or unexported fields
}
func NewDependencyDescriptorParser ¶ added in v1.0.0
func (*DependencyDescriptorParser) Parse ¶ added in v1.0.0
func (r *DependencyDescriptorParser) Parse(pkt *rtp.Packet) (*dd.DependencyDescriptor, VideoLayer, error)
type ExtPacket ¶
type ExtPacket struct { VideoLayer Arrival int64 Packet *rtp.Packet Payload interface{} KeyFrame bool RawPacket []byte DependencyDescriptor *dd.DependencyDescriptor }
type Factory ¶
func NewBufferFactory ¶
func (*Factory) GetBufferPair ¶
func (f *Factory) GetBufferPair(ssrc uint32) (*Buffer, *RTCPReader)
func (*Factory) GetOrNew ¶
func (f *Factory) GetOrNew(packetType packetio.BufferPacketType, ssrc uint32) io.ReadWriteCloser
func (*Factory) GetRTCPReader ¶
func (f *Factory) GetRTCPReader(ssrc uint32) *RTCPReader
type IntervalStats ¶ added in v1.2.0
type IntervalStats struct {
// contains filtered or unexported fields
}
type NackQueue ¶ added in v0.15.0
type NackQueue struct {
// contains filtered or unexported fields
}
func NewNACKQueue ¶ added in v0.15.0
func NewNACKQueue() *NackQueue
type Options ¶
type Options struct {
MaxBitRate uint64
}
BufferOptions provides configuration options for the buffer
type RTCPReader ¶
type RTCPReader struct {
// contains filtered or unexported fields
}
func NewRTCPReader ¶
func NewRTCPReader(ssrc uint32) *RTCPReader
func (*RTCPReader) Close ¶
func (r *RTCPReader) Close() error
func (*RTCPReader) OnClose ¶
func (r *RTCPReader) OnClose(fn func())
func (*RTCPReader) OnPacket ¶
func (r *RTCPReader) OnPacket(f func([]byte))
type RTPDeltaInfo ¶ added in v0.15.7
type RTPDeltaInfo struct { Duration time.Duration Packets uint32 Bytes uint64 HeaderBytes uint64 PacketsDuplicate uint32 BytesDuplicate uint64 HeaderBytesDuplicate uint64 PacketsPadding uint32 BytesPadding uint64 HeaderBytesPadding uint64 PacketsLost uint32 Frames uint32 RttMax uint32 JitterMax float64 Nacks uint32 Plis uint32 Firs uint32 }
type RTPFlowState ¶ added in v0.15.6
type RTPStats ¶ added in v0.15.6
type RTPStats struct {
// contains filtered or unexported fields
}
func NewRTPStats ¶ added in v0.15.6
func NewRTPStats(params RTPStatsParams) *RTPStats
func (*RTPStats) DeltaInfo ¶ added in v0.15.7
func (r *RTPStats) DeltaInfo(snapshotId uint32) *RTPDeltaInfo
func (*RTPStats) ForceUpdateLastPacket ¶ added in v1.2.0
func (*RTPStats) GetRtcpSenderReport ¶ added in v0.15.6
func (r *RTPStats) GetRtcpSenderReport(ssrc uint32) *rtcp.SenderReport
func (*RTPStats) GetTotalPacketsPrimary ¶ added in v0.15.6
func (*RTPStats) NewSnapshotId ¶ added in v0.15.6
func (*RTPStats) SetRtcpSenderReportData ¶ added in v0.15.6
func (*RTPStats) SnapshotRtcpReceptionReport ¶ added in v0.15.6
func (*RTPStats) TimeSinceLastPli ¶ added in v0.15.6
func (*RTPStats) UpdateFirTime ¶ added in v0.15.6
func (r *RTPStats) UpdateFirTime()
func (*RTPStats) UpdateFromReceiverReport ¶ added in v0.15.7
func (*RTPStats) UpdateKeyFrame ¶ added in v0.15.6
func (*RTPStats) UpdateLayerLockPliAndTime ¶ added in v0.15.6
func (*RTPStats) UpdateNack ¶ added in v0.15.6
func (*RTPStats) UpdateNackProcessed ¶ added in v1.0.0
func (*RTPStats) UpdatePliAndTime ¶ added in v0.15.6
func (*RTPStats) UpdatePliTime ¶ added in v0.15.6
func (r *RTPStats) UpdatePliTime()
type RTPStatsParams ¶ added in v0.15.6
type StreamStatsWithLayers ¶ added in v0.15.4
type StreamStatsWithLayers struct { RTPStats *RTPDeltaInfo Layers map[int32]*RTPDeltaInfo }
type VP8 ¶
type VP8 struct { FirstByte byte PictureIDPresent int PictureID uint16 /* 8 or 16 bits, picture ID */ MBit bool TL0PICIDXPresent int TL0PICIDX uint8 /* 8 bits temporal level zero index */ // Optional Header If either of the T or K bits are set to 1, // the TID/Y/KEYIDX extension field MUST be present. TIDPresent int TID uint8 /* 2 bits temporal layer idx */ Y uint8 KEYIDXPresent int KEYIDX uint8 /* 5 bits of key frame idx */ HeaderSize int // IsKeyFrame is a helper to detect if current packet is a keyframe IsKeyFrame bool }
VP8 is a helper to get temporal data from VP8 packet header
VP8 Payload Descriptor 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ |X|R|N|S|R| PID | (REQUIRED) |X|R|N|S|R| PID | (REQUIRED) +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ X: |I|L|T|K| RSV | (OPTIONAL) X: |I|L|T|K| RSV | (OPTIONAL) +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ I: |M| PictureID | (OPTIONAL) I: |M| PictureID | (OPTIONAL) +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ L: | TL0PICIDX | (OPTIONAL) | PictureID | +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ T/K:|TID|Y| KEYIDX | (OPTIONAL) L: | TL0PICIDX | (OPTIONAL) +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ T/K:|TID|Y| KEYIDX | (OPTIONAL) +-+-+-+-+-+-+-+-+
type VideoLayer ¶ added in v1.0.0
func (VideoLayer) GreaterThan ¶ added in v1.0.0
func (v VideoLayer) GreaterThan(v2 VideoLayer) bool
func (VideoLayer) IsValid ¶ added in v1.0.0
func (v VideoLayer) IsValid() bool
func (VideoLayer) SpatialGreaterThanOrEqual ¶ added in v1.0.0
func (v VideoLayer) SpatialGreaterThanOrEqual(v2 VideoLayer) bool
func (VideoLayer) String ¶ added in v1.0.0
func (v VideoLayer) String() string