add OnTransportSwitch, OnPacketLost, OnDecodeError to server and client (#225)

These new hooks replace the generic hooks Log() and OnWarning().
This commit is contained in:
Alessandro Ros
2023-04-04 17:10:37 +02:00
committed by GitHub
parent f905598d2e
commit 2fbba142cc
15 changed files with 185 additions and 92 deletions

View File

@@ -1,6 +1,7 @@
package gortsplib
import (
"fmt"
"time"
"github.com/pion/rtcp"
@@ -94,7 +95,7 @@ func (ct *clientFormat) writePacketRTPWithNTP(pkt *rtp.Packet, ntp time.Time) er
func (ct *clientFormat) readRTPUDP(pkt *rtp.Packet) {
packets, missing := ct.udpReorderer.Process(pkt)
if missing != 0 {
ct.c.Log(LogLevelWarn, "%d RTP packet(s) lost", missing)
ct.c.OnPacketLost(fmt.Errorf("%d RTP packet(s) lost", missing))
// do not return
}