MCPcopy
hub / github.com/livekit/livekit / Bind

Method Bind

pkg/sfu/buffer/buffer.go:105–138  ·  view source on GitHub ↗
(params webrtc.RTPParameters, codec webrtc.RTPCodecCapability, bitrates int)

Source from the content-addressed store, hash-verified

103}
104
105func (b *Buffer) Bind(params webrtc.RTPParameters, codec webrtc.RTPCodecCapability, bitrates int) error {
106 b.Lock()
107 if b.isBound {
108 b.Unlock()
109 return nil
110 }
111
112 if err := b.BufferBase.BindLocked(params, codec, bitrates); err != nil {
113 b.Unlock()
114 return err
115 }
116
117 b.lastReportAt = mono.UnixNano()
118
119 if len(b.pPackets) != 0 {
120 b.logger.Debugw("releasing queued packets on bind", "count", len(b.pPackets))
121 }
122 var rtcpPackets []rtcp.Packet
123 for _, pp := range b.pPackets {
124 rtcpPackets = append(rtcpPackets, b.calc(pp.packet, nil, pp.arrivalTime, true, false)...)
125 }
126 b.pPackets = nil
127
128 b.isBound = true
129 b.Unlock()
130
131 if len(rtcpPackets) != 0 {
132 if cb := b.getOnRtcpFeedback(); cb != nil {
133 cb(rtcpPackets)
134 }
135 }
136
137 return nil
138}
139
140// Write adds an RTP Packet, ordering is not guaranteed, newer packets may arrive later
141func (b *Buffer) Write(pkt []byte) (n int, err error) {

Callers 4

TestNackFunction · 0.95
TestNewBufferFunction · 0.95
TestFractionLostReportFunction · 0.95
TestCodecChangeFunction · 0.95

Calls 3

calcMethod · 0.95
getOnRtcpFeedbackMethod · 0.95
BindLockedMethod · 0.80

Tested by 4

TestNackFunction · 0.76
TestNewBufferFunction · 0.76
TestFractionLostReportFunction · 0.76
TestCodecChangeFunction · 0.76