Documentation ¶
Index ¶
- Constants
- Variables
- func AggregateRTPStats(statsList []*livekit.RTPStats) *livekit.RTPStats
- func IsAV1Keyframe(payload []byte) bool
- func IsH264Keyframe(payload []byte) bool
- func LayerPresenceFromTrackInfo(trackInfo *livekit.TrackInfo) *[livekit.VideoQuality_HIGH + 1]bool
- func RidToSpatialLayer(rid string, trackInfo *livekit.TrackInfo) int32
- func SpatialLayerToRid(layer int32, trackInfo *livekit.TrackInfo) string
- func SpatialLayerToVideoQuality(layer int32, trackInfo *livekit.TrackInfo) livekit.VideoQuality
- func VP8PictureIdSizeDiff(mBit1 bool, mBit2 bool) int
- func VideoQualityToRid(quality livekit.VideoQuality, trackInfo *livekit.TrackInfo) string
- func VideoQualityToSpatialLayer(quality livekit.VideoQuality, trackInfo *livekit.TrackInfo) int32
- 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) GetTemporalLayerFpsForSpatial(layer int32) []float32
- func (b *Buffer) OnClose(fn func())
- func (b *Buffer) OnFpsChanged(f 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 FrameRateCalculator
- type FrameRateCalculatorDD
- func (f *FrameRateCalculatorDD) Completed() bool
- func (f *FrameRateCalculatorDD) GetFrameRateCalculatorForSpatial(spatial int32) *FrameRateCalculatorForDDLayer
- func (f *FrameRateCalculatorDD) GetFrameRateForSpatial(spatial int32) []float32
- func (f *FrameRateCalculatorDD) RecvPacket(ep *ExtPacket) bool
- func (f *FrameRateCalculatorDD) SetMaxLayer(spatial, temporal int32)
- type FrameRateCalculatorForDDLayer
- type FrameRateCalculatorVP8
- type IntervalStats
- type Options
- type RTCPReader
- type RTPDeltaInfo
- type RTPFlowState
- type RTPStats
- func (r *RTPStats) DeltaInfo(snapshotId uint32) *RTPDeltaInfo
- 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) ResyncOnNextPacket()
- func (r *RTPStats) Seed(from *RTPStats)
- func (r *RTPStats) SetLogger(logger logger.Logger)
- func (r *RTPStats) SetRtcpSenderReportData(rtpTS uint32, ntpTS mediatransportutil.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(rr rtcp.ReceptionReport, rtt uint32)
- 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 ( QuarterResolution = "q" HalfResolution = "h" FullResolution = "f" )
const (
ReportDelta = 1e9
)
Variables ¶
var ( InvalidLayers = VideoLayer{ Spatial: InvalidLayerSpatial, Temporal: InvalidLayerTemporal, } )
Functions ¶
func IsAV1Keyframe ¶
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 ¶
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 LayerPresenceFromTrackInfo ¶
func LayerPresenceFromTrackInfo(trackInfo *livekit.TrackInfo) *[livekit.VideoQuality_HIGH + 1]bool
func SpatialLayerToVideoQuality ¶
func SpatialLayerToVideoQuality(layer int32, trackInfo *livekit.TrackInfo) livekit.VideoQuality
func VP8PictureIdSizeDiff ¶
func VideoQualityToRid ¶
func VideoQualityToRid(quality livekit.VideoQuality, trackInfo *livekit.TrackInfo) string
func VideoQualityToSpatialLayer ¶
func VideoQualityToSpatialLayer(quality livekit.VideoQuality, trackInfo *livekit.TrackInfo) int32
Types ¶
type Buffer ¶
Buffer contains all packets
func (*Buffer) Bind ¶
func (b *Buffer) Bind(params webrtc.RTPParameters, codec webrtc.RTPCodecCapability)
func (*Buffer) GetAudioLevel ¶
func (*Buffer) GetClockRate ¶
GetClockRate returns the RTP clock rate
func (*Buffer) GetDeltaStats ¶
func (b *Buffer) GetDeltaStats() *StreamStatsWithLayers
func (*Buffer) GetMediaSSRC ¶
GetMediaSSRC returns the associated SSRC of the RTP stream
func (*Buffer) GetTemporalLayerFpsForSpatial ¶
func (*Buffer) OnFpsChanged ¶
func (b *Buffer) OnFpsChanged(f func())
func (*Buffer) OnMaxLayerChanged ¶
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 ¶
func (*Buffer) ReadExtended ¶
func (*Buffer) SetAudioLevelParams ¶
func (b *Buffer) SetAudioLevelParams(audioLevelParams audio.AudioLevelParams)
func (*Buffer) SetLastFractionLostReport ¶
func (*Buffer) SetPLIThrottle ¶
func (*Buffer) SetSenderReportData ¶
type DataStats ¶
type DataStats struct {
// contains filtered or unexported fields
}
func NewDataStats ¶
func NewDataStats(params DataStatsParam) *DataStats
func (*DataStats) ToProtoActive ¶
func (*DataStats) ToProtoAggregateOnly ¶
type DataStatsParam ¶
type DependencyDescriptorParser ¶
type DependencyDescriptorParser struct {
// contains filtered or unexported fields
}
func (*DependencyDescriptorParser) Parse ¶
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 FrameRateCalculator ¶
type FrameRateCalculatorDD ¶
type FrameRateCalculatorDD struct {
// contains filtered or unexported fields
}
func NewFrameRateCalculatorDD ¶
func NewFrameRateCalculatorDD(clockRate uint32, logger logger.Logger) *FrameRateCalculatorDD
func (*FrameRateCalculatorDD) Completed ¶
func (f *FrameRateCalculatorDD) Completed() bool
func (*FrameRateCalculatorDD) GetFrameRateCalculatorForSpatial ¶
func (f *FrameRateCalculatorDD) GetFrameRateCalculatorForSpatial(spatial int32) *FrameRateCalculatorForDDLayer
func (*FrameRateCalculatorDD) GetFrameRateForSpatial ¶
func (f *FrameRateCalculatorDD) GetFrameRateForSpatial(spatial int32) []float32
func (*FrameRateCalculatorDD) RecvPacket ¶
func (f *FrameRateCalculatorDD) RecvPacket(ep *ExtPacket) bool
func (*FrameRateCalculatorDD) SetMaxLayer ¶
func (f *FrameRateCalculatorDD) SetMaxLayer(spatial, temporal int32)
type FrameRateCalculatorForDDLayer ¶
type FrameRateCalculatorForDDLayer struct { *FrameRateCalculatorDD // contains filtered or unexported fields }
func (*FrameRateCalculatorForDDLayer) GetFrameRate ¶
func (f *FrameRateCalculatorForDDLayer) GetFrameRate() []float32
type FrameRateCalculatorVP8 ¶
type FrameRateCalculatorVP8 struct {
// contains filtered or unexported fields
}
----------------------------- FrameRateCalculator based on PictureID in VP8
func NewFrameRateCalculatorVP8 ¶
func NewFrameRateCalculatorVP8(clockRate uint32, logger logger.Logger) *FrameRateCalculatorVP8
func (*FrameRateCalculatorVP8) Completed ¶
func (f *FrameRateCalculatorVP8) Completed() bool
func (*FrameRateCalculatorVP8) GetFrameRate ¶
func (f *FrameRateCalculatorVP8) GetFrameRate() []float32
func (*FrameRateCalculatorVP8) RecvPacket ¶
func (f *FrameRateCalculatorVP8) RecvPacket(ep *ExtPacket) bool
type IntervalStats ¶
type IntervalStats struct {
// contains filtered or unexported fields
}
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 ¶
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 ¶
type RTPStats ¶
type RTPStats struct {
// contains filtered or unexported fields
}
func NewRTPStats ¶
func NewRTPStats(params RTPStatsParams) *RTPStats
func (*RTPStats) DeltaInfo ¶
func (r *RTPStats) DeltaInfo(snapshotId uint32) *RTPDeltaInfo
func (*RTPStats) GetRtcpSenderReport ¶
func (r *RTPStats) GetRtcpSenderReport(ssrc uint32) *rtcp.SenderReport
func (*RTPStats) GetTotalPacketsPrimary ¶
func (*RTPStats) NewSnapshotId ¶
func (*RTPStats) ResyncOnNextPacket ¶
func (r *RTPStats) ResyncOnNextPacket()
func (*RTPStats) SetRtcpSenderReportData ¶
func (*RTPStats) SnapshotRtcpReceptionReport ¶
func (*RTPStats) TimeSinceLastPli ¶
func (*RTPStats) UpdateFirTime ¶
func (r *RTPStats) UpdateFirTime()
func (*RTPStats) UpdateFromReceiverReport ¶
func (r *RTPStats) UpdateFromReceiverReport(rr rtcp.ReceptionReport, rtt uint32)
func (*RTPStats) UpdateKeyFrame ¶
func (*RTPStats) UpdateLayerLockPliAndTime ¶
func (*RTPStats) UpdateNack ¶
func (*RTPStats) UpdateNackProcessed ¶
func (*RTPStats) UpdatePliAndTime ¶
func (*RTPStats) UpdatePliTime ¶
func (r *RTPStats) UpdatePliTime()
type RTPStatsParams ¶
type StreamStatsWithLayers ¶
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 ¶
func (VideoLayer) GreaterThan ¶
func (v VideoLayer) GreaterThan(v2 VideoLayer) bool
func (VideoLayer) IsValid ¶
func (v VideoLayer) IsValid() bool
func (VideoLayer) SpatialGreaterThanOrEqual ¶
func (v VideoLayer) SpatialGreaterThanOrEqual(v2 VideoLayer) bool
func (VideoLayer) String ¶
func (v VideoLayer) String() string