mirror of
https://github.com/aler9/rtsp-simple-server
synced 2025-10-16 20:50:58 +08:00
update golangci-lint (#1870)
This commit is contained in:
2
.github/workflows/lint.yml
vendored
2
.github/workflows/lint.yml
vendored
@@ -19,7 +19,7 @@ jobs:
|
|||||||
|
|
||||||
- uses: golangci/golangci-lint-action@v3
|
- uses: golangci/golangci-lint-action@v3
|
||||||
with:
|
with:
|
||||||
version: v1.50.1
|
version: v1.52.2
|
||||||
|
|
||||||
mod-tidy:
|
mod-tidy:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
|
2
Makefile
2
Makefile
@@ -1,5 +1,5 @@
|
|||||||
BASE_IMAGE = golang:1.20-alpine3.17
|
BASE_IMAGE = golang:1.20-alpine3.17
|
||||||
LINT_IMAGE = golangci/golangci-lint:v1.50.1
|
LINT_IMAGE = golangci/golangci-lint:v1.52.2
|
||||||
NODE_IMAGE = node:16-alpine3.17
|
NODE_IMAGE = node:16-alpine3.17
|
||||||
RPI32_IMAGE = balenalib/raspberry-pi:bullseye-run
|
RPI32_IMAGE = balenalib/raspberry-pi:bullseye-run
|
||||||
RPI64_IMAGE = balenalib/raspberrypi3-64:bullseye-run
|
RPI64_IMAGE = balenalib/raspberrypi3-64:bullseye-run
|
||||||
|
@@ -19,6 +19,9 @@ type ConfWatcher struct {
|
|||||||
inner *fsnotify.Watcher
|
inner *fsnotify.Watcher
|
||||||
watchedPath string
|
watchedPath string
|
||||||
|
|
||||||
|
// in
|
||||||
|
terminate chan struct{}
|
||||||
|
|
||||||
// out
|
// out
|
||||||
signal chan struct{}
|
signal chan struct{}
|
||||||
done chan struct{}
|
done chan struct{}
|
||||||
@@ -55,6 +58,7 @@ func New(confPath string) (*ConfWatcher, error) {
|
|||||||
w := &ConfWatcher{
|
w := &ConfWatcher{
|
||||||
inner: inner,
|
inner: inner,
|
||||||
watchedPath: absolutePath,
|
watchedPath: absolutePath,
|
||||||
|
terminate: make(chan struct{}),
|
||||||
signal: make(chan struct{}),
|
signal: make(chan struct{}),
|
||||||
done: make(chan struct{}),
|
done: make(chan struct{}),
|
||||||
}
|
}
|
||||||
@@ -66,11 +70,7 @@ func New(confPath string) (*ConfWatcher, error) {
|
|||||||
|
|
||||||
// Close closes a ConfWatcher.
|
// Close closes a ConfWatcher.
|
||||||
func (w *ConfWatcher) Close() {
|
func (w *ConfWatcher) Close() {
|
||||||
go func() {
|
close(w.terminate)
|
||||||
for range w.signal {
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
w.inner.Close()
|
|
||||||
<-w.done
|
<-w.done
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,15 +103,24 @@ outer:
|
|||||||
previousWatchedPath = currentWatchedPath
|
previousWatchedPath = currentWatchedPath
|
||||||
|
|
||||||
lastCalled = time.Now()
|
lastCalled = time.Now()
|
||||||
w.signal <- struct{}{}
|
|
||||||
|
select {
|
||||||
|
case w.signal <- struct{}{}:
|
||||||
|
case <-w.terminate:
|
||||||
|
break outer
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case <-w.inner.Errors:
|
case <-w.inner.Errors:
|
||||||
break outer
|
break outer
|
||||||
|
|
||||||
|
case <-w.terminate:
|
||||||
|
break outer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
close(w.signal)
|
close(w.signal)
|
||||||
|
w.inner.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Watch returns a channel that is called after the configuration file has changed.
|
// Watch returns a channel that is called after the configuration file has changed.
|
||||||
|
@@ -12,22 +12,22 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func pathConfCanBeUpdated(oldPathConf *conf.PathConf, newPathConf *conf.PathConf) bool {
|
func pathConfCanBeUpdated(oldPathConf *conf.PathConf, newPathConf *conf.PathConf) bool {
|
||||||
copy := oldPathConf.Clone()
|
clone := oldPathConf.Clone()
|
||||||
|
|
||||||
copy.RPICameraBrightness = newPathConf.RPICameraBrightness
|
clone.RPICameraBrightness = newPathConf.RPICameraBrightness
|
||||||
copy.RPICameraContrast = newPathConf.RPICameraContrast
|
clone.RPICameraContrast = newPathConf.RPICameraContrast
|
||||||
copy.RPICameraSaturation = newPathConf.RPICameraSaturation
|
clone.RPICameraSaturation = newPathConf.RPICameraSaturation
|
||||||
copy.RPICameraSharpness = newPathConf.RPICameraSharpness
|
clone.RPICameraSharpness = newPathConf.RPICameraSharpness
|
||||||
copy.RPICameraExposure = newPathConf.RPICameraExposure
|
clone.RPICameraExposure = newPathConf.RPICameraExposure
|
||||||
copy.RPICameraAWB = newPathConf.RPICameraAWB
|
clone.RPICameraAWB = newPathConf.RPICameraAWB
|
||||||
copy.RPICameraDenoise = newPathConf.RPICameraDenoise
|
clone.RPICameraDenoise = newPathConf.RPICameraDenoise
|
||||||
copy.RPICameraShutter = newPathConf.RPICameraShutter
|
clone.RPICameraShutter = newPathConf.RPICameraShutter
|
||||||
copy.RPICameraMetering = newPathConf.RPICameraMetering
|
clone.RPICameraMetering = newPathConf.RPICameraMetering
|
||||||
copy.RPICameraGain = newPathConf.RPICameraGain
|
clone.RPICameraGain = newPathConf.RPICameraGain
|
||||||
copy.RPICameraEV = newPathConf.RPICameraEV
|
clone.RPICameraEV = newPathConf.RPICameraEV
|
||||||
copy.RPICameraFPS = newPathConf.RPICameraFPS
|
clone.RPICameraFPS = newPathConf.RPICameraFPS
|
||||||
|
|
||||||
return newPathConf.Equal(copy)
|
return newPathConf.Equal(clone)
|
||||||
}
|
}
|
||||||
|
|
||||||
type pathManagerHLSManager interface {
|
type pathManagerHLSManager interface {
|
||||||
|
@@ -349,7 +349,7 @@ func (c *rtmpConn) runInner(ctx context.Context) error {
|
|||||||
if !publish {
|
if !publish {
|
||||||
return c.runRead(ctx, u)
|
return c.runRead(ctx, u)
|
||||||
}
|
}
|
||||||
return c.runPublish(ctx, u)
|
return c.runPublish(u)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *rtmpConn) runRead(ctx context.Context, u *url.URL) error {
|
func (c *rtmpConn) runRead(ctx context.Context, u *url.URL) error {
|
||||||
@@ -704,7 +704,7 @@ func (c *rtmpConn) findAudioFormat(stream *stream, ringBuffer *ringbuffer.RingBu
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *rtmpConn) runPublish(ctx context.Context, u *url.URL) error {
|
func (c *rtmpConn) runPublish(u *url.URL) error {
|
||||||
pathName, query, rawQuery := pathNameAndQuery(u)
|
pathName, query, rawQuery := pathNameAndQuery(u)
|
||||||
|
|
||||||
res := c.pathManager.publisherAdd(pathPublisherAddReq{
|
res := c.pathManager.publisherAdd(pathPublisherAddReq{
|
||||||
|
@@ -258,7 +258,7 @@ func (s *rtspSession) onSetup(c *rtspConn, ctx *gortsplib.ServerHandlerOnSetupCt
|
|||||||
}
|
}
|
||||||
|
|
||||||
// onPlay is called by rtspServer.
|
// onPlay is called by rtspServer.
|
||||||
func (s *rtspSession) onPlay(ctx *gortsplib.ServerHandlerOnPlayCtx) (*base.Response, error) {
|
func (s *rtspSession) onPlay(_ *gortsplib.ServerHandlerOnPlayCtx) (*base.Response, error) {
|
||||||
h := make(base.Header)
|
h := make(base.Header)
|
||||||
|
|
||||||
if s.session.State() == gortsplib.ServerSessionStatePrePlay {
|
if s.session.State() == gortsplib.ServerSessionStatePrePlay {
|
||||||
@@ -333,7 +333,7 @@ func (s *rtspSession) onRecord(ctx *gortsplib.ServerHandlerOnRecordCtx) (*base.R
|
|||||||
}
|
}
|
||||||
|
|
||||||
// onPause is called by rtspServer.
|
// onPause is called by rtspServer.
|
||||||
func (s *rtspSession) onPause(ctx *gortsplib.ServerHandlerOnPauseCtx) (*base.Response, error) {
|
func (s *rtspSession) onPause(_ *gortsplib.ServerHandlerOnPauseCtx) (*base.Response, error) {
|
||||||
switch s.session.State() {
|
switch s.session.State() {
|
||||||
case gortsplib.ServerSessionStatePlay:
|
case gortsplib.ServerSessionStatePlay:
|
||||||
if s.onReadCmd != nil {
|
if s.onReadCmd != nil {
|
||||||
|
@@ -122,7 +122,7 @@ func (s *udpSource) Log(level logger.Level, format string, args ...interface{})
|
|||||||
}
|
}
|
||||||
|
|
||||||
// run implements sourceStaticImpl.
|
// run implements sourceStaticImpl.
|
||||||
func (s *udpSource) run(ctx context.Context, cnf *conf.PathConf, reloadConf chan *conf.PathConf) error {
|
func (s *udpSource) run(ctx context.Context, cnf *conf.PathConf, _ chan *conf.PathConf) error {
|
||||||
s.Log(logger.Debug, "connecting")
|
s.Log(logger.Debug, "connecting")
|
||||||
|
|
||||||
hostPort := cnf.Source[len("udp://"):]
|
hostPort := cnf.Source[len("udp://"):]
|
||||||
|
@@ -34,7 +34,7 @@ func newGeneric(
|
|||||||
udpMaxPayloadSize int,
|
udpMaxPayloadSize int,
|
||||||
forma formats.Format,
|
forma formats.Format,
|
||||||
generateRTPPackets bool,
|
generateRTPPackets bool,
|
||||||
log logger.Writer,
|
_ logger.Writer,
|
||||||
) (*formatProcessorGeneric, error) {
|
) (*formatProcessorGeneric, error) {
|
||||||
if generateRTPPackets {
|
if generateRTPPackets {
|
||||||
return nil, fmt.Errorf("we don't know how to generate RTP packets of format %+v", forma)
|
return nil, fmt.Errorf("we don't know how to generate RTP packets of format %+v", forma)
|
||||||
@@ -45,7 +45,7 @@ func newGeneric(
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *formatProcessorGeneric) Process(unit Unit, hasNonRTSPReaders bool) error {
|
func (t *formatProcessorGeneric) Process(unit Unit, _ bool) error {
|
||||||
tunit := unit.(*UnitGeneric)
|
tunit := unit.(*UnitGeneric)
|
||||||
|
|
||||||
pkt := tunit.RTPPackets[0]
|
pkt := tunit.RTPPackets[0]
|
||||||
|
@@ -18,7 +18,7 @@ type testLogWriter struct {
|
|||||||
recv chan string
|
recv chan string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *testLogWriter) Log(level logger.Level, format string, args ...interface{}) {
|
func (w *testLogWriter) Log(_ logger.Level, format string, args ...interface{}) {
|
||||||
w.recv <- fmt.Sprintf(format, args...)
|
w.recv <- fmt.Sprintf(format, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -40,7 +40,7 @@ func newMPEG2Audio(
|
|||||||
udpMaxPayloadSize int,
|
udpMaxPayloadSize int,
|
||||||
forma *formats.MPEG2Audio,
|
forma *formats.MPEG2Audio,
|
||||||
generateRTPPackets bool,
|
generateRTPPackets bool,
|
||||||
log logger.Writer,
|
_ logger.Writer,
|
||||||
) (*formatProcessorMPEG2Audio, error) {
|
) (*formatProcessorMPEG2Audio, error) {
|
||||||
t := &formatProcessorMPEG2Audio{
|
t := &formatProcessorMPEG2Audio{
|
||||||
udpMaxPayloadSize: udpMaxPayloadSize,
|
udpMaxPayloadSize: udpMaxPayloadSize,
|
||||||
|
@@ -40,7 +40,7 @@ func newMPEG4Audio(
|
|||||||
udpMaxPayloadSize int,
|
udpMaxPayloadSize int,
|
||||||
forma *formats.MPEG4Audio,
|
forma *formats.MPEG4Audio,
|
||||||
generateRTPPackets bool,
|
generateRTPPackets bool,
|
||||||
log logger.Writer,
|
_ logger.Writer,
|
||||||
) (*formatProcessorMPEG4Audio, error) {
|
) (*formatProcessorMPEG4Audio, error) {
|
||||||
t := &formatProcessorMPEG4Audio{
|
t := &formatProcessorMPEG4Audio{
|
||||||
udpMaxPayloadSize: udpMaxPayloadSize,
|
udpMaxPayloadSize: udpMaxPayloadSize,
|
||||||
|
@@ -40,7 +40,7 @@ func newOpus(
|
|||||||
udpMaxPayloadSize int,
|
udpMaxPayloadSize int,
|
||||||
forma *formats.Opus,
|
forma *formats.Opus,
|
||||||
generateRTPPackets bool,
|
generateRTPPackets bool,
|
||||||
log logger.Writer,
|
_ logger.Writer,
|
||||||
) (*formatProcessorOpus, error) {
|
) (*formatProcessorOpus, error) {
|
||||||
t := &formatProcessorOpus{
|
t := &formatProcessorOpus{
|
||||||
udpMaxPayloadSize: udpMaxPayloadSize,
|
udpMaxPayloadSize: udpMaxPayloadSize,
|
||||||
|
@@ -40,7 +40,7 @@ func newVP8(
|
|||||||
udpMaxPayloadSize int,
|
udpMaxPayloadSize int,
|
||||||
forma *formats.VP8,
|
forma *formats.VP8,
|
||||||
generateRTPPackets bool,
|
generateRTPPackets bool,
|
||||||
log logger.Writer,
|
_ logger.Writer,
|
||||||
) (*formatProcessorVP8, error) {
|
) (*formatProcessorVP8, error) {
|
||||||
t := &formatProcessorVP8{
|
t := &formatProcessorVP8{
|
||||||
udpMaxPayloadSize: udpMaxPayloadSize,
|
udpMaxPayloadSize: udpMaxPayloadSize,
|
||||||
|
@@ -40,7 +40,7 @@ func newVP9(
|
|||||||
udpMaxPayloadSize int,
|
udpMaxPayloadSize int,
|
||||||
forma *formats.VP9,
|
forma *formats.VP9,
|
||||||
generateRTPPackets bool,
|
generateRTPPackets bool,
|
||||||
log logger.Writer,
|
_ logger.Writer,
|
||||||
) (*formatProcessorVP9, error) {
|
) (*formatProcessorVP9, error) {
|
||||||
t := &formatProcessorVP9{
|
t := &formatProcessorVP9{
|
||||||
udpMaxPayloadSize: udpMaxPayloadSize,
|
udpMaxPayloadSize: udpMaxPayloadSize,
|
||||||
|
@@ -18,8 +18,8 @@ type RPICamera struct{}
|
|||||||
|
|
||||||
// New allocates a RPICamera.
|
// New allocates a RPICamera.
|
||||||
func New(
|
func New(
|
||||||
params Params,
|
_ Params,
|
||||||
onData func(time.Duration, [][]byte),
|
_ func(time.Duration, [][]byte),
|
||||||
) (*RPICamera, error) {
|
) (*RPICamera, error) {
|
||||||
return nil, fmt.Errorf("server was compiled without support for the Raspberry Pi Camera")
|
return nil, fmt.Errorf("server was compiled without support for the Raspberry Pi Camera")
|
||||||
}
|
}
|
||||||
@@ -29,5 +29,5 @@ func (c *RPICamera) Close() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ReloadParams reloads the camera parameters.
|
// ReloadParams reloads the camera parameters.
|
||||||
func (c *RPICamera) ReloadParams(params Params) {
|
func (c *RPICamera) ReloadParams(_ Params) {
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user