Cleaning up stream allocator data. (#2639)

* Cleaning up stream allocator data.

Marking it with STREAM-ALLOCATOR-DATA for easier use later if needed.

* clean up a bit more

* wire_gen

* wire_gen
This commit is contained in:
Raja Subramanian
2024-04-10 13:31:25 +05:30
committed by GitHub
parent 4b7e5dc1cc
commit c6ee34d083
6 changed files with 68 additions and 34 deletions
+17 -1
View File
@@ -144,11 +144,13 @@ func (d DownTrackState) String() string {
// -------------------------------------------------------------------
/* STREAM-ALLOCATOR-DATA
type NackInfo struct {
Timestamp uint32
SequenceNumber uint16
Attempts uint8
}
*/
type DownTrackStreamAllocatorListener interface {
// RTCP received
@@ -179,11 +181,13 @@ type DownTrackStreamAllocatorListener interface {
// packet(s) sent
OnPacketsSent(dt *DownTrack, size int)
/* STREAM-ALLOCATOR-DATA
// NACKs received
OnNACK(dt *DownTrack, nackInfos []NackInfo)
// RTCP Receiver Report received
OnRTCPReceiverReport(dt *DownTrack, rr rtcp.ReceptionReport)
*/
// check if track should participate in BWE
IsBWEEnabled(dt *DownTrack) bool
@@ -266,8 +270,10 @@ type DownTrack struct {
streamAllocatorListener DownTrackStreamAllocatorListener
streamAllocatorReportGeneration int
streamAllocatorBytesCounter atomic.Uint32
/* STREAM-ALLOCATOR-DATA
bytesSent atomic.Uint32
bytesRetransmitted atomic.Uint32
*/
playoutDelay *PlayoutDelayController
@@ -1538,9 +1544,11 @@ func (d *DownTrack) handleRTCP(bytes []byte) {
rttToReport = rtt
}
/* STREAM-ALLOCATOR-DATA
if sal := d.getStreamAllocatorListener(); sal != nil {
sal.OnRTCPReceiverReport(d, r)
}
*/
if d.playoutDelay != nil {
jitterMs := uint64(r.Jitter*1e3) / uint64(d.codec.ClockRate)
@@ -1655,18 +1663,20 @@ func (d *DownTrack) retransmitPackets(nacks []uint16) {
nackAcks := uint32(0)
nackMisses := uint32(0)
numRepeatedNACKs := uint32(0)
nackInfos := make([]NackInfo, 0, len(filtered))
// STREAM-ALLOCATOR-DATA nackInfos := make([]NackInfo, 0, len(filtered))
for _, epm := range d.sequencer.getExtPacketMetas(filtered) {
if disallowedLayers[epm.layer] {
continue
}
nackAcks++
/* STREAM-ALLOCATOR-DATA
nackInfos = append(nackInfos, NackInfo{
SequenceNumber: epm.targetSeqNo,
Timestamp: epm.timestamp,
Attempts: epm.nacked,
})
*/
pktBuff := *src
n, err := d.params.Receiver.ReadRTP(pktBuff, uint8(epm.layer), epm.sourceSeqNo)
@@ -1738,6 +1748,7 @@ func (d *DownTrack) retransmitPackets(nacks []uint16) {
d.totalRepeatedNACKs.Add(numRepeatedNACKs)
d.rtpStats.UpdateNackProcessed(nackAcks, nackMisses, numRepeatedNACKs)
/* STREAM-ALLOCATOR-DATA
// STREAM-ALLOCATOR-EXPERIMENTAL-TODO-START
// Need to check on the following
// - get all NACKs from sequencer even if SFU is not acknowledging,
@@ -1753,6 +1764,7 @@ func (d *DownTrack) retransmitPackets(nacks []uint16) {
if sal := d.getStreamAllocatorListener(); sal != nil && len(nackInfos) != 0 {
sal.OnNACK(d, nackInfos)
}
*/
}
func (d *DownTrack) getTranslatedRTPHeader(extPkt *buffer.ExtPacket, tp *TranslationParams) (*rtp.Header, error) {
@@ -1841,9 +1853,11 @@ func (d *DownTrack) GetNackStats() (totalPackets uint32, totalRepeatedNACKs uint
return
}
/* STREAM-ALLOCATOR-DATA
func (d *DownTrack) GetAndResetBytesSent() (uint32, uint32) {
return d.bytesSent.Swap(0), d.bytesRetransmitted.Swap(0)
}
*/
func (d *DownTrack) onBindAndConnectedChange() {
d.writable.Store(d.connected.Load() && d.bound.Load())
@@ -1981,11 +1995,13 @@ func (d *DownTrack) sendingPacket(hdr *rtp.Header, payloadSize int, spmd *sendPa
// STREAM-ALLOCATOR-TODO: remove this stream allocator bytes counter once stream allocator changes fully to pull bytes counter
size := uint32(hdrSize + payloadSize)
d.streamAllocatorBytesCounter.Add(size)
/* STREAM-ALLOCATOR-DATA
if spmd.isRTX {
d.bytesRetransmitted.Add(size)
} else {
d.bytesSent.Add(size)
}
*/
}
// update RTPStats