diff --git a/go.mod b/go.mod index cf64ce80..6b1f2285 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/alecthomas/kong v0.7.1 github.com/asticode/go-astits v1.11.0 github.com/bluenviron/gohlslib v0.1.1 - github.com/bluenviron/gortsplib/v3 v3.0.0 + github.com/bluenviron/gortsplib/v3 v3.1.0 github.com/bluenviron/mediacommon v0.2.0 github.com/fsnotify/fsnotify v1.6.0 github.com/gin-gonic/gin v1.9.0 diff --git a/go.sum b/go.sum index 539916ea..735929d7 100644 --- a/go.sum +++ b/go.sum @@ -12,8 +12,8 @@ github.com/asticode/go-astits v1.11.0 h1:GTHUXht0ZXAJXsVbsLIcyfHr1Bchi4QQwMARw2Z github.com/asticode/go-astits v1.11.0/go.mod h1:QSHmknZ51pf6KJdHKZHJTLlMegIrhega3LPWz3ND/iI= github.com/bluenviron/gohlslib v0.1.1 h1:rUwMsILN8Wkxx9NxZYKx3CdDZIIuMpfVNe7IXLxe26A= github.com/bluenviron/gohlslib v0.1.1/go.mod h1:jPRjSDyELabTOcVXkI/H3U3/sCMQZzpBL+8+GAlquPE= -github.com/bluenviron/gortsplib/v3 v3.0.0 h1:1H1+Z/U5VDgn30XhUO/BjJUbBoVxg/miMwSPs7I3BxI= -github.com/bluenviron/gortsplib/v3 v3.0.0/go.mod h1:hqJ4DffxUbzVj+PM9ilPwr0jlBMwqqoCe58eoLCHG+w= +github.com/bluenviron/gortsplib/v3 v3.1.0 h1:GSzIHzYzxnvrFlnI7hmV+sML2W45/nBBH9DqcZDOIB4= +github.com/bluenviron/gortsplib/v3 v3.1.0/go.mod h1:gAN1zD0tywu09WKNdHfXWU17VBJUVchXnhc4s+2H9Sc= github.com/bluenviron/mediacommon v0.2.0 h1:XEuIr8FA5bfzjsQhrITd6ILgN9JCl0e0Cu8IVFEp5Hk= github.com/bluenviron/mediacommon v0.2.0/go.mod h1:t0dqPsWUTchyvib0MhixIwXEgvDX4V9G+I0GzWLQRb8= github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= diff --git a/internal/core/core_test.go b/internal/core/core_test.go index 4b16db23..48b1e3d8 100644 --- a/internal/core/core_test.go +++ b/internal/core/core_test.go @@ -133,7 +133,7 @@ func TestCorePathAutoDeletion(t *testing.T) { require.NoError(t, err) require.Equal(t, base.StatusNotFound, res.StatusCode) } else { - u, err := url.Parse("rtsp://localhost:8554/mypath/mediaUUID=xxx") + u, err := url.Parse("rtsp://localhost:8554/mypath/trackID=0") require.NoError(t, err) byts, _ := base.Request{ diff --git a/internal/core/rtsp_server.go b/internal/core/rtsp_server.go index 2fa08932..80469f8a 100644 --- a/internal/core/rtsp_server.go +++ b/internal/core/rtsp_server.go @@ -351,10 +351,16 @@ func (s *rtspServer) OnPause(ctx *gortsplib.ServerHandlerOnPauseCtx) (*base.Resp return se.onPause(ctx) } -// OnDecodeError implements gortsplib.ServerHandlerOnWarning. -func (s *rtspServer) OnWarning(ctx *gortsplib.ServerHandlerOnWarningCtx) { +// OnPacketLost implements gortsplib.ServerHandlerOnDecodeError. +func (s *rtspServer) OnPacketLost(ctx *gortsplib.ServerHandlerOnPacketLostCtx) { se := ctx.Session.UserData().(*rtspSession) - se.onWarning(ctx) + se.onPacketLost(ctx) +} + +// OnDecodeError implements gortsplib.ServerHandlerOnDecodeError. +func (s *rtspServer) OnDecodeError(ctx *gortsplib.ServerHandlerOnDecodeErrorCtx) { + se := ctx.Session.UserData().(*rtspSession) + se.onDecodeError(ctx) } // apiConnsList is called by api and metrics. diff --git a/internal/core/rtsp_session.go b/internal/core/rtsp_session.go index aa152e8e..4f0d65a3 100644 --- a/internal/core/rtsp_session.go +++ b/internal/core/rtsp_session.go @@ -470,7 +470,12 @@ func (s *rtspSession) apiSourceDescribe() interface{} { }{typ, s.uuid.String()} } -// onWarning is called by rtspServer. -func (s *rtspSession) onWarning(ctx *gortsplib.ServerHandlerOnWarningCtx) { - s.log(logger.Warn, "%v", ctx.Error) +// onPacketLost is called by rtspServer. +func (s *rtspSession) onPacketLost(ctx *gortsplib.ServerHandlerOnPacketLostCtx) { + s.log(logger.Warn, ctx.Error.Error()) +} + +// onDecodeError is called by rtspServer. +func (s *rtspSession) onDecodeError(ctx *gortsplib.ServerHandlerOnDecodeErrorCtx) { + s.log(logger.Warn, ctx.Error.Error()) } diff --git a/internal/core/rtsp_source.go b/internal/core/rtsp_source.go index de267cad..f7d2ed15 100644 --- a/internal/core/rtsp_source.go +++ b/internal/core/rtsp_source.go @@ -88,8 +88,14 @@ func (s *rtspSource) run(ctx context.Context, cnf *conf.PathConf, reloadConf cha OnResponse: func(res *base.Response) { s.Log(logger.Debug, "s->c %v", res) }, - Log: func(level gortsplib.LogLevel, format string, args ...interface{}) { - s.Log(logger.Warn, format, args...) + OnTransportSwitch: func(err error) { + s.Log(logger.Warn, err.Error()) + }, + OnPacketLost: func(err error) { + s.Log(logger.Warn, err.Error()) + }, + OnDecodeError: func(err error) { + s.Log(logger.Warn, err.Error()) }, }