make reception report public
This commit is contained in:
@@ -292,6 +292,12 @@ func (c *RTCClient) ResumeLogs() {
|
|||||||
c.paused = false
|
c.paused = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *RTCClient) Receivers() []*rtc.Receiver {
|
||||||
|
c.lock.Lock()
|
||||||
|
defer c.lock.Unlock()
|
||||||
|
return append([]*rtc.Receiver{}, c.receivers...)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *RTCClient) SendRequest(msg *livekit.SignalRequest) error {
|
func (c *RTCClient) SendRequest(msg *livekit.SignalRequest) error {
|
||||||
payload, err := protojson.Marshal(msg)
|
payload, err := protojson.Marshal(msg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -456,7 +462,6 @@ func (c *RTCClient) consumeReceiver(r *rtc.Receiver) {
|
|||||||
c.AppendLog("consumed from peer",
|
c.AppendLog("consumed from peer",
|
||||||
"track", trackId, "peer", peerId,
|
"track", trackId, "peer", peerId,
|
||||||
"size", numBytes)
|
"size", numBytes)
|
||||||
numBytes = 0
|
|
||||||
lastUpdate = time.Now()
|
lastUpdate = time.Now()
|
||||||
}
|
}
|
||||||
case <-c.ctx.Done():
|
case <-c.ctx.Done():
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ type Receiver struct {
|
|||||||
buffer *sfu.Buffer
|
buffer *sfu.Buffer
|
||||||
rtpChan chan *rtp.Packet
|
rtpChan chan *rtp.Packet
|
||||||
once sync.Once
|
once sync.Once
|
||||||
|
bytesRead int64
|
||||||
|
|
||||||
onCloseHandler func(r *Receiver)
|
onCloseHandler func(r *Receiver)
|
||||||
}
|
}
|
||||||
@@ -95,6 +96,10 @@ func (r *Receiver) WriteBufferedPacket(sn uint16, track *webrtc.Track, snOffset
|
|||||||
return r.buffer.WritePacket(sn, track, snOffset, tsOffset, ssrc)
|
return r.buffer.WritePacket(sn, track, snOffset, tsOffset, ssrc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *Receiver) Stats() (sfu.BufferStats, rtcp.ReceptionReport) {
|
||||||
|
return r.buffer.Stats(), r.buffer.BuildReceptionReport()
|
||||||
|
}
|
||||||
|
|
||||||
// rtpWorker reads RTP stream, fills buffer and channel
|
// rtpWorker reads RTP stream, fills buffer and channel
|
||||||
func (r *Receiver) rtpWorker() {
|
func (r *Receiver) rtpWorker() {
|
||||||
defer func() {
|
defer func() {
|
||||||
|
|||||||
+1
-1
@@ -11,7 +11,7 @@ const (
|
|||||||
func UnpackPeerTrack(packed string) (peerId string, trackId string) {
|
func UnpackPeerTrack(packed string) (peerId string, trackId string) {
|
||||||
parts := strings.Split(packed, trackIdSeparator)
|
parts := strings.Split(packed, trackIdSeparator)
|
||||||
if len(parts) > 1 {
|
if len(parts) > 1 {
|
||||||
return parts[0], packed[len(parts[0]):]
|
return parts[0], packed[len(parts[0])+1:]
|
||||||
}
|
}
|
||||||
return "", packed
|
return "", packed
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-2
@@ -349,7 +349,7 @@ func (b *Buffer) buildTransportCCPacket() *rtcp.TransportLayerCC {
|
|||||||
return rtcpTCC
|
return rtcpTCC
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Buffer) buildReceptionReport() rtcp.ReceptionReport {
|
func (b *Buffer) BuildReceptionReport() rtcp.ReceptionReport {
|
||||||
extMaxSeq := b.cycles | uint32(b.maxSeqNo)
|
extMaxSeq := b.cycles | uint32(b.maxSeqNo)
|
||||||
expected := extMaxSeq - uint32(b.baseSN) + 1
|
expected := extMaxSeq - uint32(b.baseSN) + 1
|
||||||
lost := expected - b.packetCount
|
lost := expected - b.packetCount
|
||||||
@@ -402,7 +402,7 @@ func (b *Buffer) BuildRTCP() (rtcp.ReceptionReport, []rtcp.Packet) {
|
|||||||
var pkts []rtcp.Packet
|
var pkts []rtcp.Packet
|
||||||
var report rtcp.ReceptionReport
|
var report rtcp.ReceptionReport
|
||||||
|
|
||||||
report = b.buildReceptionReport()
|
report = b.BuildReceptionReport()
|
||||||
|
|
||||||
if b.remb {
|
if b.remb {
|
||||||
pkts = append(pkts, b.buildREMBPacket())
|
pkts = append(pkts, b.buildREMBPacket())
|
||||||
@@ -440,3 +440,15 @@ func (b *Buffer) onLostHandler(fn func(nack *rtcp.TransportLayerNack)) {
|
|||||||
b.pktQueue.onLost = fn
|
b.pktQueue.onLost = fn
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type BufferStats struct {
|
||||||
|
TotalBytes uint64
|
||||||
|
LastPacketTime int64
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Buffer) Stats() BufferStats {
|
||||||
|
return BufferStats{
|
||||||
|
TotalBytes: b.totalByte,
|
||||||
|
LastPacketTime: b.lastPacketTime,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user