Documentation
¶
Index ¶
- Constants
- Variables
- func IsH264Keyframe(payload []byte) bool
- func IsLaterTimestamp(timestamp1 uint32, timestamp2 uint32) bool
- func IsNewerUint16(val1, val2 uint16) bool
- func IsTimestampWrapAround(timestamp1 uint32, timestamp2 uint32) bool
- func VP8PictureIdSizeDiff(mBit1 bool, mBit2 bool) int
- type Bucket
- type Buffer
- func (b *Buffer) Bind(params webrtc.RTPParameters, codec webrtc.RTPCodecCapability, o Options)
- func (b *Buffer) Bitrate() int64
- func (b *Buffer) BitrateTemporalCumulative() []int64
- func (b *Buffer) Close() error
- func (b *Buffer) GetClockRate() uint32
- func (b *Buffer) GetLatestTimestamp() (latestTimestamp uint32, latestTimestampTimeInNanosSinceEpoch int64)
- func (b *Buffer) GetMediaSSRC() uint32
- func (b *Buffer) GetPacket(buff []byte, sn uint16) (int, error)
- func (b *Buffer) GetSenderReportData() (rtpTime uint32, ntpTime uint64, lastReceivedTimeInNanosSinceEpoch int64)
- func (b *Buffer) GetStats() (stats Stats)
- func (b *Buffer) OnAudioLevel(fn func(level uint8, durationMs uint32))
- func (b *Buffer) OnClose(fn func())
- func (b *Buffer) OnFeedback(fn func(fb []rtcp.Packet))
- func (b *Buffer) OnTransportWideCC(fn func(sn uint16, timeNS int64, marker bool))
- func (b *Buffer) Read(buff []byte) (n int, err error)
- func (b *Buffer) ReadExtended() (*ExtPacket, error)
- func (b *Buffer) SetLastFractionLostReport(lost uint8)
- func (b *Buffer) SetSenderReportData(rtpTime uint32, ntpTime uint64)
- func (b *Buffer) SetStatsTestOnly(stats Stats)
- func (b *Buffer) Write(pkt []byte) (n int, err error)
- type ExtPacket
- type Factory
- type NackQueue
- type Options
- type RTCPReader
- type SeqWrapHandler
- type Stats
- type VP8
Constants ¶
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 Logger = logr.Discard()
Logger is an implementation of logr.Logger. If is not provided - will be turned off.
Functions ¶
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 IsLaterTimestamp ¶
IsLaterTimestamp returns true if timestamp1 is later in time than timestamp2 factoring in timestamp wrap-around
func IsNewerUint16 ¶ added in v0.15.0
func IsTimestampWrapAround ¶
IsTimestampWrapAround returns true if wrap around happens from timestamp1 to timestamp2
func VP8PictureIdSizeDiff ¶
Types ¶
type Bucket ¶
type Bucket struct {
// contains filtered or unexported fields
}
type Buffer ¶
Buffer contains all packets
func (*Buffer) Bind ¶
func (b *Buffer) Bind(params webrtc.RTPParameters, codec webrtc.RTPCodecCapability, o Options)
func (*Buffer) BitrateTemporalCumulative ¶
BitrateTemporalCumulative returns the current publisher stream bitrate temporal layer accumulated with lower temporal layers.
func (*Buffer) GetClockRate ¶
GetClockRate returns the RTP clock rate
func (*Buffer) GetLatestTimestamp ¶
func (b *Buffer) GetLatestTimestamp() (latestTimestamp uint32, latestTimestampTimeInNanosSinceEpoch int64)
GetLatestTimestamp returns the latest RTP timestamp factoring in potential RTP timestamp wrap-around
func (*Buffer) GetMediaSSRC ¶
GetMediaSSRC returns the associated SSRC of the RTP stream
func (*Buffer) GetSenderReportData ¶
func (b *Buffer) GetSenderReportData() (rtpTime uint32, ntpTime uint64, lastReceivedTimeInNanosSinceEpoch int64)
GetSenderReportData returns the rtp, ntp and nanos of the last sender report
func (*Buffer) OnAudioLevel ¶
func (*Buffer) OnFeedback ¶
func (*Buffer) OnTransportWideCC ¶
func (*Buffer) ReadExtended ¶
func (*Buffer) SetLastFractionLostReport ¶
func (*Buffer) SetSenderReportData ¶
func (*Buffer) SetStatsTestOnly ¶ added in v0.15.2
Used only in tests
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 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 SeqWrapHandler ¶
type SeqWrapHandler struct {
// contains filtered or unexported fields
}
func (*SeqWrapHandler) Cycles ¶
func (s *SeqWrapHandler) Cycles() uint32
func (*SeqWrapHandler) MaxSeqNo ¶
func (s *SeqWrapHandler) MaxSeqNo() uint32
func (*SeqWrapHandler) Unwrap ¶
func (s *SeqWrapHandler) Unwrap(seq uint16) (uint32, bool)
unwrap seq and update the maxSeqNo. return unwrapped value, and whether seq is newer
func (*SeqWrapHandler) UpdateMaxSeq ¶
func (s *SeqWrapHandler) UpdateMaxSeq(extSeq uint32)
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) +-+-+-+-+-+-+-+-+