mirror of
https://github.com/aler9/rtsp-simple-server
synced 2025-10-08 17:10:18 +08:00
webrtc: print lost packets (#2468)
This commit is contained in:
@@ -7,11 +7,14 @@ import (
|
|||||||
|
|
||||||
"github.com/bluenviron/gortsplib/v4/pkg/description"
|
"github.com/bluenviron/gortsplib/v4/pkg/description"
|
||||||
"github.com/bluenviron/gortsplib/v4/pkg/format"
|
"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/bluenviron/gortsplib/v4/pkg/rtptime"
|
||||||
"github.com/pion/rtcp"
|
"github.com/pion/rtcp"
|
||||||
"github.com/pion/rtp"
|
"github.com/pion/rtp"
|
||||||
"github.com/pion/webrtc/v3"
|
"github.com/pion/webrtc/v3"
|
||||||
|
|
||||||
|
"github.com/bluenviron/mediamtx/internal/logger"
|
||||||
"github.com/bluenviron/mediamtx/internal/stream"
|
"github.com/bluenviron/mediamtx/internal/stream"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -112,7 +115,8 @@ func (webrtcTrackWrapper) PTSEqualsDTS(*rtp.Packet) bool {
|
|||||||
return true
|
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)}
|
trackWrapper := &webrtcTrackWrapper{clockRate: int(t.track.Codec().ClockRate)}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
@@ -122,6 +126,12 @@ func (t *webRTCIncomingTrack) start(stream *stream.Stream, timeDecoder *rtptime.
|
|||||||
return
|
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.
|
// sometimes Chrome sends empty RTP packets. ignore them.
|
||||||
if len(pkt.Payload) == 0 {
|
if len(pkt.Payload) == 0 {
|
||||||
continue
|
continue
|
||||||
|
@@ -410,7 +410,7 @@ func (s *webRTCSession) runPublish() (int, error) {
|
|||||||
timeDecoder := rtptime.NewGlobalDecoder()
|
timeDecoder := rtptime.NewGlobalDecoder()
|
||||||
|
|
||||||
for _, track := range tracks {
|
for _, track := range tracks {
|
||||||
track.start(rres.stream, timeDecoder)
|
track.start(rres.stream, timeDecoder, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
|
@@ -158,7 +158,7 @@ func (s *webRTCSource) run(ctx context.Context, cnf *conf.PathConf, _ chan *conf
|
|||||||
timeDecoder := rtptime.NewGlobalDecoder()
|
timeDecoder := rtptime.NewGlobalDecoder()
|
||||||
|
|
||||||
for _, track := range tracks {
|
for _, track := range tracks {
|
||||||
track.start(rres.stream, timeDecoder)
|
track.start(rres.stream, timeDecoder, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
|
Reference in New Issue
Block a user