Process RTCP Packets in OnTrack examples

TWCC and Receiver Reports are needed for a good default experience
This commit is contained in:
Sean DuBois
2021-12-17 12:03:39 -05:00
parent b8489a8f7e
commit 080d7b8427
6 changed files with 75 additions and 2 deletions

View File

@@ -116,6 +116,18 @@ func main() {
}
}()
// Read incoming RTCP packets
// Before these packets are returned they are processed by interceptors. For things
// like TWCC and RTCP Reports this needs to be called.
go func() {
rtcpBuf := make([]byte, 1500)
for {
if _, _, rtcpErr := receiver.Read(rtcpBuf); rtcpErr != nil {
return
}
}
}()
codec := track.Codec()
if strings.EqualFold(codec.MimeType, webrtc.MimeTypeOpus) {
fmt.Println("Got Opus track, saving to disk as output.opus (48 kHz, 2 channels)")