mirror of
https://github.com/bluenviron/mediamtx
synced 2025-03-25 04:18:48 +00:00
webrtc: print lost packets (#2468)
This commit is contained in:
parent
a6f929d111
commit
c37fd38f5c
@ -7,11 +7,14 @@ import (
|
||||
|
||||
"github.com/bluenviron/gortsplib/v4/pkg/description"
|
||||
"github.com/bluenviron/gortsplib/v4/pkg/format"
|
||||
"github.com/bluenviron/gortsplib/v4/pkg/liberrors"
|
||||
"github.com/bluenviron/gortsplib/v4/pkg/rtplossdetector"
|
||||
"github.com/bluenviron/gortsplib/v4/pkg/rtptime"
|
||||
"github.com/pion/rtcp"
|
||||
"github.com/pion/rtp"
|
||||
"github.com/pion/webrtc/v3"
|
||||
|
||||
"github.com/bluenviron/mediamtx/internal/logger"
|
||||
"github.com/bluenviron/mediamtx/internal/stream"
|
||||
)
|
||||
|
||||
@ -112,7 +115,8 @@ func (webrtcTrackWrapper) PTSEqualsDTS(*rtp.Packet) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (t *webRTCIncomingTrack) start(stream *stream.Stream, timeDecoder *rtptime.GlobalDecoder) {
|
||||
func (t *webRTCIncomingTrack) start(stream *stream.Stream, timeDecoder *rtptime.GlobalDecoder, log logger.Writer) {
|
||||
lossDetector := rtplossdetector.New()
|
||||
trackWrapper := &webrtcTrackWrapper{clockRate: int(t.track.Codec().ClockRate)}
|
||||
|
||||
go func() {
|
||||
@ -122,6 +126,12 @@ func (t *webRTCIncomingTrack) start(stream *stream.Stream, timeDecoder *rtptime.
|
||||
return
|
||||
}
|
||||
|
||||
lost := lossDetector.Process(pkt)
|
||||
if lost != 0 {
|
||||
log.Log(logger.Warn, (liberrors.ErrClientRTPPacketsLost{Lost: lost}).Error())
|
||||
// do not return
|
||||
}
|
||||
|
||||
// sometimes Chrome sends empty RTP packets. ignore them.
|
||||
if len(pkt.Payload) == 0 {
|
||||
continue
|
||||
|
@ -410,7 +410,7 @@ func (s *webRTCSession) runPublish() (int, error) {
|
||||
timeDecoder := rtptime.NewGlobalDecoder()
|
||||
|
||||
for _, track := range tracks {
|
||||
track.start(rres.stream, timeDecoder)
|
||||
track.start(rres.stream, timeDecoder, s)
|
||||
}
|
||||
|
||||
select {
|
||||
|
@ -158,7 +158,7 @@ func (s *webRTCSource) run(ctx context.Context, cnf *conf.PathConf, _ chan *conf
|
||||
timeDecoder := rtptime.NewGlobalDecoder()
|
||||
|
||||
for _, track := range tracks {
|
||||
track.start(rres.stream, timeDecoder)
|
||||
track.start(rres.stream, timeDecoder, s)
|
||||
}
|
||||
|
||||
select {
|
||||
|
Loading…
Reference in New Issue
Block a user