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(buf []byte) (*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 FactoryOfBufferFactory
- 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 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 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 LayerPresenceFromTrackInfo ¶ added in v1.2.1
func LayerPresenceFromTrackInfo(trackInfo *livekit.TrackInfo) *[livekit.VideoQuality_HIGH + 1]bool
func RidToSpatialLayer ¶ added in v1.2.1
func SpatialLayerToRid ¶ added in v1.2.1
func SpatialLayerToVideoQuality ¶ added in v1.2.1
func SpatialLayerToVideoQuality(layer int32, trackInfo *livekit.TrackInfo) livekit.VideoQuality
func VP8PictureIdSizeDiff ¶
func VideoQualityToRid ¶ added in v1.2.1
func VideoQualityToRid(quality livekit.VideoQuality, trackInfo *livekit.TrackInfo) string
func VideoQualityToSpatialLayer ¶ added in v1.2.1
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 ¶ 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) GetTemporalLayerFpsForSpatial ¶ added in v1.3.0
func (*Buffer) OnFpsChanged ¶ added in v1.3.0
func (b *Buffer) OnFpsChanged(f func())
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) 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 (*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 FactoryOfBufferFactory ¶ added in v1.3.2
type FactoryOfBufferFactory struct {
// contains filtered or unexported fields
}
func NewFactoryOfBufferFactory ¶ added in v1.3.2
func NewFactoryOfBufferFactory(trackingPackets int) *FactoryOfBufferFactory
func (*FactoryOfBufferFactory) CreateBufferFactory ¶ added in v1.3.2
func (f *FactoryOfBufferFactory) CreateBufferFactory() *Factory
type FrameRateCalculator ¶ added in v1.3.0
type FrameRateCalculatorDD ¶ added in v1.3.0
type FrameRateCalculatorDD struct {
// contains filtered or unexported fields
}
func NewFrameRateCalculatorDD ¶ added in v1.3.0
func NewFrameRateCalculatorDD(clockRate uint32, logger logger.Logger) *FrameRateCalculatorDD
func (*FrameRateCalculatorDD) Completed ¶ added in v1.3.0
func (f *FrameRateCalculatorDD) Completed() bool
func (*FrameRateCalculatorDD) GetFrameRateCalculatorForSpatial ¶ added in v1.3.0
func (f *FrameRateCalculatorDD) GetFrameRateCalculatorForSpatial(spatial int32) *FrameRateCalculatorForDDLayer
func (*FrameRateCalculatorDD) GetFrameRateForSpatial ¶ added in v1.3.0
func (f *FrameRateCalculatorDD) GetFrameRateForSpatial(spatial int32) []float32
func (*FrameRateCalculatorDD) RecvPacket ¶ added in v1.3.0
func (f *FrameRateCalculatorDD) RecvPacket(ep *ExtPacket) bool
func (*FrameRateCalculatorDD) SetMaxLayer ¶ added in v1.3.0
func (f *FrameRateCalculatorDD) SetMaxLayer(spatial, temporal int32)
type FrameRateCalculatorForDDLayer ¶ added in v1.3.0
type FrameRateCalculatorForDDLayer struct {
*FrameRateCalculatorDD
// contains filtered or unexported fields
}
func (*FrameRateCalculatorForDDLayer) GetFrameRate ¶ added in v1.3.0
func (f *FrameRateCalculatorForDDLayer) GetFrameRate() []float32
type FrameRateCalculatorVP8 ¶ added in v1.3.0
type FrameRateCalculatorVP8 struct {
// contains filtered or unexported fields
}
----------------------------- FrameRateCalculator based on PictureID in VP8
func NewFrameRateCalculatorVP8 ¶ added in v1.3.0
func NewFrameRateCalculatorVP8(clockRate uint32, logger logger.Logger) *FrameRateCalculatorVP8
func (*FrameRateCalculatorVP8) Completed ¶ added in v1.3.0
func (f *FrameRateCalculatorVP8) Completed() bool
func (*FrameRateCalculatorVP8) GetFrameRate ¶ added in v1.3.0
func (f *FrameRateCalculatorVP8) GetFrameRate() []float32
func (*FrameRateCalculatorVP8) RecvPacket ¶ added in v1.3.0
func (f *FrameRateCalculatorVP8) RecvPacket(ep *ExtPacket) bool
type IntervalStats ¶ added in v1.2.0
type IntervalStats struct {
// contains filtered or unexported fields
}
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) 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) ResyncOnNextPacket ¶ added in v1.2.1
func (r *RTPStats) ResyncOnNextPacket()
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 (r *RTPStats) UpdateFromReceiverReport(rr rtcp.ReceptionReport, rtt uint32)
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