Update examples to handle going to Closed

Relates to #1767
This commit is contained in:
Sean DuBois
2023-09-05 10:44:57 -04:00
committed by Sean DuBois
parent b9c3b86be0
commit f66b8b6ce2
16 changed files with 105 additions and 6 deletions

View File

@@ -31,10 +31,12 @@ func saveToDisk(i media.Writer, track *webrtc.TrackRemote) {
for {
rtpPacket, _, err := track.ReadRTP()
if err != nil {
panic(err)
fmt.Println(err)
return
}
if err := i.WriteRTP(rtpPacket); err != nil {
panic(err)
fmt.Println(err)
return
}
}
}
@@ -137,7 +139,7 @@ func main() {
if connectionState == webrtc.ICEConnectionStateConnected {
fmt.Println("Ctrl+C the remote client to stop the demo")
} else if connectionState == webrtc.ICEConnectionStateFailed {
} else if connectionState == webrtc.ICEConnectionStateFailed || connectionState == webrtc.ICEConnectionStateClosed {
if closeErr := oggFile.Close(); closeErr != nil {
panic(closeErr)
}