Documentation ¶
Index ¶
- Constants
- Variables
- func GetActiveDecodeTargetBitmask(layer VideoLayer, decodeTargets []DependencyDescriptorDecodeTarget) *uint32
- func IsAV1KeyFrame(payload []byte) bool
- func IsH264KeyFrame(payload []byte) bool
- func IsRedCodec(mime string) bool
- func IsSvcCodec(mime string) bool
- func IsVP9KeyFrame(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 VPxPictureIdSizeDiff(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, bitrates int)
- func (b *Buffer) Close() error
- func (b *Buffer) GetAudioLevel() (float64, bool)
- func (b *Buffer) GetClockRate() uint32
- func (b *Buffer) GetDeltaStats() *StreamStatsWithLayers
- func (b *Buffer) GetLastSenderReportTime() time.Time
- func (b *Buffer) GetMediaSSRC() uint32
- func (b *Buffer) GetPacket(buff []byte, esn uint64) (int, error)
- func (b *Buffer) GetSenderReportData() *livekit.RTCPSenderReportState
- func (b *Buffer) GetStats() *livekit.RTPStats
- func (b *Buffer) GetTemporalLayerFpsForSpatial(layer int32) []float32
- func (b *Buffer) OnClose(fn func())
- func (b *Buffer) OnFinalRtpStats(fn func(*livekit.RTPStats))
- func (b *Buffer) OnFpsChanged(f func())
- func (b *Buffer) OnRtcpFeedback(fn func(fb []rtcp.Packet))
- func (b *Buffer) OnRtcpSenderReport(fn func())
- 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) SetAudioLossProxying(enable bool)
- func (b *Buffer) SetLastFractionLostReport(lost uint8)
- func (b *Buffer) SetLogger(logger logger.Logger)
- func (b *Buffer) SetPLIThrottle(duration int64)
- func (b *Buffer) SetPaused(paused bool)
- func (b *Buffer) SetPrimaryBufferForRTX(primaryBuffer *Buffer)
- func (b *Buffer) SetRTT(rtt uint32)
- func (b *Buffer) SetSenderReportData(rtpTime uint32, ntpTime uint64, packets uint32, octets uint32)
- func (b *Buffer) SetTWCCAndExtID(twcc *twcc.Responder, extID uint8)
- func (b *Buffer) Write(pkt []byte) (n int, err error)
- type DataStats
- type DataStatsParam
- type DependencyDescriptorDecodeTarget
- type DependencyDescriptorParser
- type ExtDependencyDescriptor
- type ExtPacket
- type Factory
- func (f *Factory) GetBuffer(ssrc uint32) *Buffer
- func (f *Factory) GetBufferPair(ssrc uint32) (*Buffer, *RTCPReader)
- func (f *Factory) GetOrNew(packetType packetio.BufferPacketType, ssrc uint32) io.ReadWriteCloser
- func (f *Factory) GetRTCPReader(ssrc uint32) *RTCPReader
- func (f *Factory) SetRTXPair(repair, base uint32)
- type FactoryOfBufferFactory
- type FrameEntity
- type FrameIntegrityChecker
- 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 FrameRateCalculatorForVP9Layer
- type FrameRateCalculatorVP8
- type FrameRateCalculatorVP9
- func (f *FrameRateCalculatorVP9) Completed() bool
- func (f *FrameRateCalculatorVP9) GetFrameRateCalculatorForSpatial(spatial int32) *FrameRateCalculatorForVP9Layer
- func (f *FrameRateCalculatorVP9) GetFrameRateForSpatial(spatial int32) []float32
- func (f *FrameRateCalculatorVP9) RecvPacket(ep *ExtPacket) bool
- type PacketHistory
- type RTCPReader
- type StreamStatsWithLayers
- type VP8
- type VideoLayer
Constants ¶
const ( ReportDelta = 1e9 InitPacketBufferSizeVideo = 300 InitPacketBufferSizeAudio = 70 )
const ( InvalidLayerSpatial = int32(-1) InvalidLayerTemporal = int32(-1) DefaultMaxLayerSpatial = int32(2) DefaultMaxLayerTemporal = int32(3) )
const ( QuarterResolution = "q" HalfResolution = "h" FullResolution = "f" )
Variables ¶
var ( ErrFrameEarlierThanKeyFrame = fmt.Errorf("frame is earlier than current keyframe") ErrDDStructureAttachedToNonFirstPacket = fmt.Errorf("dependency descriptor structure is attached to non-first packet of a frame") )
var ( InvalidLayer = VideoLayer{ Spatial: InvalidLayerSpatial, Temporal: InvalidLayerTemporal, } DefaultMaxLayer = VideoLayer{ Spatial: DefaultMaxLayerSpatial, Temporal: DefaultMaxLayerTemporal, } )
Functions ¶
func GetActiveDecodeTargetBitmask ¶ added in v1.4.2
func GetActiveDecodeTargetBitmask(layer VideoLayer, decodeTargets []DependencyDescriptorDecodeTarget) *uint32
func IsAV1KeyFrame ¶ added in v1.4.2
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 v1.4.2
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 IsRedCodec ¶ added in v1.7.1
func IsSvcCodec ¶ added in v1.7.1
SVC-TODO: Have to use more conditions to differentiate between SVC-TODO: SVC and non-SVC (could be single layer or simulcast). SVC-TODO: May only need to differentiate between simulcast and non-simulcast SVC-TODO: i. e. may be possible to treat single layer as SVC to get proper/intended functionality.
func IsVP9KeyFrame ¶ added in v1.4.2
IsVP9KeyFrame 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 LayerPresenceFromTrackInfo ¶ added in v1.2.1
func LayerPresenceFromTrackInfo(trackInfo *livekit.TrackInfo) *[livekit.VideoQuality_HIGH + 1]bool
SIMULCAST-CODEC-TODO: these need to be codec mime aware if and when each codec suppports different layers
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 VPxPictureIdSizeDiff ¶ added in v1.4.2
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) 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) GetLastSenderReportTime ¶ added in v1.6.1
func (*Buffer) GetMediaSSRC ¶
GetMediaSSRC returns the associated SSRC of the RTP stream
func (*Buffer) GetSenderReportData ¶
func (b *Buffer) GetSenderReportData() *livekit.RTCPSenderReportState
func (*Buffer) GetTemporalLayerFpsForSpatial ¶ added in v1.3.0
func (*Buffer) OnFinalRtpStats ¶ added in v1.4.0
func (*Buffer) OnFpsChanged ¶ added in v1.3.0
func (b *Buffer) OnFpsChanged(f func())
func (*Buffer) OnRtcpFeedback ¶ added in v0.15.7
func (*Buffer) OnRtcpSenderReport ¶ added in v1.3.3
func (b *Buffer) OnRtcpSenderReport(fn func())
func (*Buffer) SetAudioLevelParams ¶ added in v0.15.7
func (b *Buffer) SetAudioLevelParams(audioLevelParams audio.AudioLevelParams)
func (*Buffer) SetAudioLossProxying ¶ added in v1.6.0
func (*Buffer) SetLastFractionLostReport ¶
func (*Buffer) SetPLIThrottle ¶ added in v0.15.4
func (*Buffer) SetPrimaryBufferForRTX ¶ added in v1.5.3
func (*Buffer) SetSenderReportData ¶
func (*Buffer) SetTWCCAndExtID ¶ added in v1.5.3
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 DependencyDescriptorDecodeTarget ¶ added in v1.4.2
type DependencyDescriptorDecodeTarget struct { Target int Layer VideoLayer }
func ProcessFrameDependencyStructure ¶ added in v1.4.2
func ProcessFrameDependencyStructure(structure *dd.FrameDependencyStructure) []DependencyDescriptorDecodeTarget
func (*DependencyDescriptorDecodeTarget) String ¶ added in v1.5.1
func (dt *DependencyDescriptorDecodeTarget) String() string
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) (*ExtDependencyDescriptor, VideoLayer, error)
type ExtDependencyDescriptor ¶ added in v1.4.4
type ExtDependencyDescriptor struct { Descriptor *dd.DependencyDescriptor DecodeTargets []DependencyDescriptorDecodeTarget StructureUpdated bool ActiveDecodeTargetsUpdated bool Integrity bool ExtFrameNum uint64 // the frame number of the keyframe which the current frame depends on ExtKeyFrameNum uint64 }
type ExtPacket ¶
type ExtPacket struct { VideoLayer Arrival int64 ExtSequenceNumber uint64 ExtTimestamp uint64 Packet *rtp.Packet Payload interface{} KeyFrame bool RawPacket []byte DependencyDescriptor *ExtDependencyDescriptor AbsCaptureTimeExt *act.AbsCaptureTime IsOutOfOrder bool }
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
func (*Factory) SetRTXPair ¶ added in v1.5.3
type FactoryOfBufferFactory ¶ added in v1.3.2
type FactoryOfBufferFactory struct {
// contains filtered or unexported fields
}
func NewFactoryOfBufferFactory ¶ added in v1.3.2
func NewFactoryOfBufferFactory(trackingPacketsVideo int, trackingPacketsAudio int) *FactoryOfBufferFactory
func (*FactoryOfBufferFactory) CreateBufferFactory ¶ added in v1.3.2
func (f *FactoryOfBufferFactory) CreateBufferFactory() *Factory
type FrameEntity ¶ added in v1.4.5
type FrameEntity struct {
// contains filtered or unexported fields
}
func (*FrameEntity) AddPacket ¶ added in v1.4.5
func (fe *FrameEntity) AddPacket(extSeq uint64, ddVal *dd.DependencyDescriptor)
func (*FrameEntity) Integrity ¶ added in v1.4.5
func (fe *FrameEntity) Integrity() bool
func (*FrameEntity) Reset ¶ added in v1.4.5
func (fe *FrameEntity) Reset()
type FrameIntegrityChecker ¶ added in v1.4.5
type FrameIntegrityChecker struct {
// contains filtered or unexported fields
}
func NewFrameIntegrityChecker ¶ added in v1.4.5
func NewFrameIntegrityChecker(frameCount, packetCount int) *FrameIntegrityChecker
func (*FrameIntegrityChecker) AddPacket ¶ added in v1.4.5
func (fc *FrameIntegrityChecker) AddPacket(extSeq uint64, extFrameNum uint64, ddVal *dd.DependencyDescriptor)
func (*FrameIntegrityChecker) FrameIntegrity ¶ added in v1.4.5
func (fc *FrameIntegrityChecker) FrameIntegrity(extFrameNum uint64) bool
type FrameRateCalculator ¶ added in v1.3.0
type FrameRateCalculatorDD ¶ added in v1.3.0
type FrameRateCalculatorDD struct {
// contains filtered or unexported fields
}
FrameRateCalculator based on Dependency descriptor
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 FrameRateCalculatorForVP9Layer ¶ added in v1.4.2
type FrameRateCalculatorForVP9Layer struct { *FrameRateCalculatorVP9 // contains filtered or unexported fields }
func (*FrameRateCalculatorForVP9Layer) GetFrameRate ¶ added in v1.4.2
func (f *FrameRateCalculatorForVP9Layer) 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 FrameRateCalculatorVP9 ¶ added in v1.4.2
type FrameRateCalculatorVP9 struct {
// contains filtered or unexported fields
}
FrameRateCalculator based on PictureID in VP9
func NewFrameRateCalculatorVP9 ¶ added in v1.4.2
func NewFrameRateCalculatorVP9(clockRate uint32, logger logger.Logger) *FrameRateCalculatorVP9
func (*FrameRateCalculatorVP9) Completed ¶ added in v1.4.2
func (f *FrameRateCalculatorVP9) Completed() bool
func (*FrameRateCalculatorVP9) GetFrameRateCalculatorForSpatial ¶ added in v1.4.2
func (f *FrameRateCalculatorVP9) GetFrameRateCalculatorForSpatial(spatial int32) *FrameRateCalculatorForVP9Layer
func (*FrameRateCalculatorVP9) GetFrameRateForSpatial ¶ added in v1.4.2
func (f *FrameRateCalculatorVP9) GetFrameRateForSpatial(spatial int32) []float32
func (*FrameRateCalculatorVP9) RecvPacket ¶ added in v1.4.2
func (f *FrameRateCalculatorVP9) RecvPacket(ep *ExtPacket) bool
type PacketHistory ¶ added in v1.4.5
type PacketHistory struct {
// contains filtered or unexported fields
}
func NewPacketHistory ¶ added in v1.4.5
func NewPacketHistory(packetCount int) *PacketHistory
func (*PacketHistory) AddPacket ¶ added in v1.4.5
func (ph *PacketHistory) AddPacket(extSeq uint64)
func (*PacketHistory) PacketsConsecutive ¶ added in v1.4.5
func (ph *PacketHistory) PacketsConsecutive(start, end uint64) bool
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 StreamStatsWithLayers ¶ added in v0.15.4
type StreamStatsWithLayers struct { RTPStats *rtpstats.RTPDeltaInfo Layers map[int32]*rtpstats.RTPDeltaInfo }
type VP8 ¶
type VP8 struct { FirstByte byte S bool I bool M bool PictureID uint16 /* 7 or 15 bits, picture ID */ L bool 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. T bool TID uint8 /* 2 bits temporal layer idx */ Y bool K bool 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