MCPcopy Create free account
hub / github.com/livekit/livekit / patchExtPacket

Method patchExtPacket

pkg/sfu/buffer/buffer_base.go:1180–1211  ·  view source on GitHub ↗
(ep *ExtPacket, buf []byte)

Source from the content-addressed store, hash-verified

1178}
1179
1180func (b *BufferBase) patchExtPacket(ep *ExtPacket, buf []byte) *ExtPacket {
1181 n, err := b.getPacketLocked(buf, ep.ExtSequenceNumber)
1182 if err != nil {
1183 packetNotFoundCount := b.packetNotFoundCount.Inc()
1184 if (packetNotFoundCount-1)%20 == 0 {
1185 b.logger.Warnw(
1186 "could not get packet from bucket", err,
1187 "sn", ep.Packet.SequenceNumber,
1188 "headSN", b.bucket.HeadSequenceNumber(),
1189 "count", packetNotFoundCount,
1190 "rtpStats", b.rtpStats,
1191 "rtpStatsLite", b.rtpStatsLite,
1192 "snRangeMap", b.snRangeMap,
1193 )
1194 }
1195 return nil
1196 }
1197 ep.RawPacket = buf[:n]
1198
1199 // patch RTP packet to point payload to new buffer
1200 pkt := *ep.Packet
1201 payloadStart := ep.Packet.Header.MarshalSize()
1202 payloadEnd := payloadStart + len(ep.Packet.Payload)
1203 if payloadEnd > n {
1204 b.logger.Warnw("unexpected marshal size", nil, "max", n, "need", payloadEnd)
1205 return nil
1206 }
1207 pkt.Payload = buf[payloadStart:payloadEnd]
1208 ep.Packet = &pkt
1209
1210 return ep
1211}
1212
1213func (b *BufferBase) flushExtPackets() {
1214 b.Lock()

Callers 1

ReadExtendedMethod · 0.95

Calls 2

getPacketLockedMethod · 0.95
MarshalSizeMethod · 0.45

Tested by

no test coverage detected