Skip to content

Commit

Permalink
fix read RTCP return no packets
Browse files Browse the repository at this point in the history
  • Loading branch information
tyohan committed Sep 19, 2024
1 parent 2a9a72d commit 8e0743e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"io"
"log"
"regexp"
"strings"
"sync"
Expand Down Expand Up @@ -1035,17 +1036,19 @@ func (c *Client) ClientTracks() map[string]iClientTrack {
}

func readRTCP(r *webrtc.RTPSender, b []byte) ([]rtcp.Packet, interceptor.Attributes, error) {
b = b[:0]
n, attributes, err := r.Read(b)
if err != nil {
return nil, nil, err
}

pkts, err := attributes.GetRTCPPackets(b[:n])
if err != nil {
b = b[:0]
return nil, nil, err
}

b = b[:0]

return pkts, attributes, nil
}

Expand Down Expand Up @@ -1073,12 +1076,15 @@ func (c *Client) enableReportAndStats(rtpSender *webrtc.RTPSender, track iClient
return
}

log.Println("rtcp packets PLI", rtcpPackets)
for _, p := range rtcpPackets {
switch p.(type) {
case *rtcp.PictureLossIndication:
log.Println("rtcp packets PLI", rtcpPackets)
track.RequestPLI()
case *rtcp.FullIntraRequest:
track.RequestPLI()
log.Println("rtcp packets FullI", rtcpPackets)
}
}
}
Expand Down

0 comments on commit 8e0743e

Please sign in to comment.