Browse Source

update linter

pull/871/head
aler9 3 years ago committed by Alessandro Ros
parent
commit
0605a2f369
  1. 2
      .github/workflows/lint.yml
  2. 4
      Makefile
  3. 3
      internal/core/hls_muxer.go
  4. 3
      internal/core/hls_source.go
  5. 3
      internal/core/path.go
  6. 6
      internal/core/path_manager.go
  7. 9
      internal/core/rtmp_conn.go
  8. 3
      internal/core/rtmp_server.go
  9. 3
      internal/core/rtmp_source.go
  10. 6
      internal/core/rtsp_conn.go
  11. 3
      internal/core/rtsp_server.go
  12. 9
      internal/core/rtsp_session.go
  13. 3
      internal/core/rtsp_source.go
  14. 6
      internal/hls/client_audio_processor.go
  15. 6
      internal/hls/client_video_processor.go
  16. 3
      internal/hls/muxer.go
  17. 6
      internal/hls/muxer_ts_segment.go

2
.github/workflows/lint.yml

@ -15,7 +15,7 @@ jobs:
- uses: golangci/golangci-lint-action@v2 - uses: golangci/golangci-lint-action@v2
with: with:
version: v1.44.2 version: v1.45.2
mod-tidy: mod-tidy:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04

4
Makefile

@ -1,6 +1,6 @@
BASE_IMAGE = golang:1.17-alpine3.14 BASE_IMAGE = golang:1.17-alpine3.14
LINT_IMAGE = golangci/golangci-lint:v1.44.2 LINT_IMAGE = golangci/golangci-lint:v1.45.2
NODE_IMAGE = node:14-alpine3.14 NODE_IMAGE = node:14-alpine3.14
.PHONY: $(shell ls) .PHONY: $(shell ls)
@ -35,7 +35,7 @@ mod-tidy:
define DOCKERFILE_FORMAT define DOCKERFILE_FORMAT
FROM $(BASE_IMAGE) FROM $(BASE_IMAGE)
RUN go install mvdan.cc/gofumpt@v0.2.0 RUN go install mvdan.cc/gofumpt@v0.3.1
endef endef
export DOCKERFILE_FORMAT export DOCKERFILE_FORMAT

3
internal/core/hls_muxer.go

@ -159,7 +159,8 @@ func newHLSMuxer(
wg *sync.WaitGroup, wg *sync.WaitGroup,
pathName string, pathName string,
pathManager hlsMuxerPathManager, pathManager hlsMuxerPathManager,
parent hlsMuxerParent) *hlsMuxer { parent hlsMuxerParent,
) *hlsMuxer {
ctx, ctxCancel := context.WithCancel(parentCtx) ctx, ctxCancel := context.WithCancel(parentCtx)
m := &hlsMuxer{ m := &hlsMuxer{

3
internal/core/hls_source.go

@ -38,7 +38,8 @@ func newHLSSource(
ur string, ur string,
fingerprint string, fingerprint string,
wg *sync.WaitGroup, wg *sync.WaitGroup,
parent hlsSourceParent) *hlsSource { parent hlsSourceParent,
) *hlsSource {
ctx, ctxCancel := context.WithCancel(parentCtx) ctx, ctxCancel := context.WithCancel(parentCtx)
s := &hlsSource{ s := &hlsSource{

3
internal/core/path.go

@ -268,7 +268,8 @@ func newPath(
matches []string, matches []string,
wg *sync.WaitGroup, wg *sync.WaitGroup,
externalCmdPool *externalcmd.Pool, externalCmdPool *externalcmd.Pool,
parent pathParent) *path { parent pathParent,
) *path {
ctx, ctxCancel := context.WithCancel(parentCtx) ctx, ctxCancel := context.WithCancel(parentCtx)
pa := &path{ pa := &path{

6
internal/core/path_manager.go

@ -56,7 +56,8 @@ func newPathManager(
pathConfs map[string]*conf.PathConf, pathConfs map[string]*conf.PathConf,
externalCmdPool *externalcmd.Pool, externalCmdPool *externalcmd.Pool,
metrics *metrics, metrics *metrics,
parent pathManagerParent) *pathManager { parent pathManagerParent,
) *pathManager {
ctx, ctxCancel := context.WithCancel(parentCtx) ctx, ctxCancel := context.WithCancel(parentCtx)
pm := &pathManager{ pm := &pathManager{
@ -268,7 +269,8 @@ func (pm *pathManager) createPath(
pathConfName string, pathConfName string,
pathConf *conf.PathConf, pathConf *conf.PathConf,
name string, name string,
matches []string) { matches []string,
) {
pm.paths[name] = newPath( pm.paths[name] = newPath(
pm.ctx, pm.ctx,
pm.rtspAddress, pm.rtspAddress,

9
internal/core/rtmp_conn.go

@ -96,7 +96,8 @@ func newRTMPConn(
nconn net.Conn, nconn net.Conn,
externalCmdPool *externalcmd.Pool, externalCmdPool *externalcmd.Pool,
pathManager rtmpConnPathManager, pathManager rtmpConnPathManager,
parent rtmpConnParent) *rtmpConn { parent rtmpConnParent,
) *rtmpConn {
ctx, ctxCancel := context.WithCancel(parentCtx) ctx, ctxCancel := context.WithCancel(parentCtx)
c := &rtmpConn{ c := &rtmpConn{
@ -232,7 +233,8 @@ func (c *rtmpConn) runRead(ctx context.Context) error {
authenticate: func( authenticate: func(
pathIPs []interface{}, pathIPs []interface{},
pathUser conf.Credential, pathUser conf.Credential,
pathPass conf.Credential) error { pathPass conf.Credential,
) error {
return c.authenticate(pathName, pathIPs, pathUser, pathPass, "read", query, rawQuery) return c.authenticate(pathName, pathIPs, pathUser, pathPass, "read", query, rawQuery)
}, },
}) })
@ -472,7 +474,8 @@ func (c *rtmpConn) runPublish(ctx context.Context) error {
authenticate: func( authenticate: func(
pathIPs []interface{}, pathIPs []interface{},
pathUser conf.Credential, pathUser conf.Credential,
pathPass conf.Credential) error { pathPass conf.Credential,
) error {
return c.authenticate(pathName, pathIPs, pathUser, pathPass, "publish", query, rawQuery) return c.authenticate(pathName, pathIPs, pathUser, pathPass, "publish", query, rawQuery)
}, },
}) })

3
internal/core/rtmp_server.go

@ -83,7 +83,8 @@ func newRTMPServer(
externalCmdPool *externalcmd.Pool, externalCmdPool *externalcmd.Pool,
metrics *metrics, metrics *metrics,
pathManager *pathManager, pathManager *pathManager,
parent rtmpServerParent) (*rtmpServer, error) { parent rtmpServerParent,
) (*rtmpServer, error) {
l, err := net.Listen("tcp", address) l, err := net.Listen("tcp", address)
if err != nil { if err != nil {
return nil, err return nil, err

3
internal/core/rtmp_source.go

@ -44,7 +44,8 @@ func newRTMPSource(
readTimeout conf.StringDuration, readTimeout conf.StringDuration,
writeTimeout conf.StringDuration, writeTimeout conf.StringDuration,
wg *sync.WaitGroup, wg *sync.WaitGroup,
parent rtmpSourceParent) *rtmpSource { parent rtmpSourceParent,
) *rtmpSource {
ctx, ctxCancel := context.WithCancel(parentCtx) ctx, ctxCancel := context.WithCancel(parentCtx)
s := &rtmpSource{ s := &rtmpSource{

6
internal/core/rtsp_conn.go

@ -53,7 +53,8 @@ func newRTSPConn(
externalCmdPool *externalcmd.Pool, externalCmdPool *externalcmd.Pool,
pathManager *pathManager, pathManager *pathManager,
conn *gortsplib.ServerConn, conn *gortsplib.ServerConn,
parent rtspConnParent) *rtspConn { parent rtspConnParent,
) *rtspConn {
c := &rtspConn{ c := &rtspConn{
externalAuthenticationURL: externalAuthenticationURL, externalAuthenticationURL: externalAuthenticationURL,
rtspAddress: rtspAddress, rtspAddress: rtspAddress,
@ -248,7 +249,8 @@ func (c *rtspConn) onDescribe(ctx *gortsplib.ServerHandlerOnDescribeCtx,
authenticate: func( authenticate: func(
pathIPs []interface{}, pathIPs []interface{},
pathUser conf.Credential, pathUser conf.Credential,
pathPass conf.Credential) error { pathPass conf.Credential,
) error {
return c.authenticate(ctx.Path, pathIPs, pathUser, pathPass, "read", ctx.Request, ctx.Query) return c.authenticate(ctx.Path, pathIPs, pathUser, pathPass, "read", ctx.Request, ctx.Query)
}, },
}) })

3
internal/core/rtsp_server.go

@ -98,7 +98,8 @@ func newRTSPServer(
externalCmdPool *externalcmd.Pool, externalCmdPool *externalcmd.Pool,
metrics *metrics, metrics *metrics,
pathManager *pathManager, pathManager *pathManager,
parent rtspServerParent) (*rtspServer, error) { parent rtspServerParent,
) (*rtspServer, error) {
ctx, ctxCancel := context.WithCancel(parentCtx) ctx, ctxCancel := context.WithCancel(parentCtx)
s := &rtspServer{ s := &rtspServer{

9
internal/core/rtsp_session.go

@ -56,7 +56,8 @@ func newRTSPSession(
sc *gortsplib.ServerConn, sc *gortsplib.ServerConn,
externalCmdPool *externalcmd.Pool, externalCmdPool *externalcmd.Pool,
pathManager rtspSessionPathManager, pathManager rtspSessionPathManager,
parent rtspSessionParent) *rtspSession { parent rtspSessionParent,
) *rtspSession {
s := &rtspSession{ s := &rtspSession{
isTLS: isTLS, isTLS: isTLS,
protocols: protocols, protocols: protocols,
@ -132,7 +133,8 @@ func (s *rtspSession) onAnnounce(c *rtspConn, ctx *gortsplib.ServerHandlerOnAnno
authenticate: func( authenticate: func(
pathIPs []interface{}, pathIPs []interface{},
pathUser conf.Credential, pathUser conf.Credential,
pathPass conf.Credential) error { pathPass conf.Credential,
) error {
return c.authenticate(ctx.Path, pathIPs, pathUser, pathPass, "publish", ctx.Request, ctx.Query) return c.authenticate(ctx.Path, pathIPs, pathUser, pathPass, "publish", ctx.Request, ctx.Query)
}, },
}) })
@ -191,7 +193,8 @@ func (s *rtspSession) onSetup(c *rtspConn, ctx *gortsplib.ServerHandlerOnSetupCt
authenticate: func( authenticate: func(
pathIPs []interface{}, pathIPs []interface{},
pathUser conf.Credential, pathUser conf.Credential,
pathPass conf.Credential) error { pathPass conf.Credential,
) error {
return c.authenticate(ctx.Path, pathIPs, pathUser, pathPass, "read", ctx.Request, ctx.Query) return c.authenticate(ctx.Path, pathIPs, pathUser, pathPass, "read", ctx.Request, ctx.Query)
}, },
}) })

3
internal/core/rtsp_source.go

@ -57,7 +57,8 @@ func newRTSPSource(
readBufferCount int, readBufferCount int,
readBufferSize int, readBufferSize int,
wg *sync.WaitGroup, wg *sync.WaitGroup,
parent rtspSourceParent) *rtspSource { parent rtspSourceParent,
) *rtspSource {
ctx, ctxCancel := context.WithCancel(parentCtx) ctx, ctxCancel := context.WithCancel(parentCtx)
s := &rtspSource{ s := &rtspSource{

6
internal/hls/client_audio_processor.go

@ -56,7 +56,8 @@ func (p *clientAudioProcessor) run() error {
func (p *clientAudioProcessor) doProcess( func (p *clientAudioProcessor) doProcess(
data []byte, data []byte,
pts time.Duration) error { pts time.Duration,
) error {
adtsPkts, err := aac.DecodeADTS(data) adtsPkts, err := aac.DecodeADTS(data)
if err != nil { if err != nil {
return err return err
@ -101,7 +102,8 @@ func (p *clientAudioProcessor) doProcess(
func (p *clientAudioProcessor) process( func (p *clientAudioProcessor) process(
data []byte, data []byte,
pts time.Duration) { pts time.Duration,
) {
select { select {
case p.queue <- clientAudioProcessorData{data, pts}: case p.queue <- clientAudioProcessorData{data, pts}:
case <-p.ctx.Done(): case <-p.ctx.Done():

6
internal/hls/client_video_processor.go

@ -65,7 +65,8 @@ func (p *clientVideoProcessor) run() error {
func (p *clientVideoProcessor) doProcess( func (p *clientVideoProcessor) doProcess(
data []byte, data []byte,
pts time.Duration, pts time.Duration,
dts time.Duration) error { dts time.Duration,
) error {
elapsed := time.Since(p.clockStartRTC) elapsed := time.Since(p.clockStartRTC)
if dts > elapsed { if dts > elapsed {
select { select {
@ -142,7 +143,8 @@ func (p *clientVideoProcessor) doProcess(
func (p *clientVideoProcessor) process( func (p *clientVideoProcessor) process(
data []byte, data []byte,
pts time.Duration, pts time.Duration,
dts time.Duration) { dts time.Duration,
) {
select { select {
case p.queue <- clientVideoProcessorData{data, pts, dts}: case p.queue <- clientVideoProcessorData{data, pts, dts}:
case <-p.ctx.Done(): case <-p.ctx.Done():

3
internal/hls/muxer.go

@ -21,7 +21,8 @@ func NewMuxer(
hlsSegmentDuration time.Duration, hlsSegmentDuration time.Duration,
hlsSegmentMaxSize uint64, hlsSegmentMaxSize uint64,
videoTrack *gortsplib.TrackH264, videoTrack *gortsplib.TrackH264,
audioTrack *gortsplib.TrackAAC) (*Muxer, error) { audioTrack *gortsplib.TrackAAC,
) (*Muxer, error) {
if videoTrack != nil { if videoTrack != nil {
if videoTrack.SPS() == nil || videoTrack.PPS() == nil { if videoTrack.SPS() == nil || videoTrack.PPS() == nil {
return nil, fmt.Errorf("invalid H264 track: SPS or PPS not provided into the SDP") return nil, fmt.Errorf("invalid H264 track: SPS or PPS not provided into the SDP")

6
internal/hls/muxer_ts_segment.go

@ -73,7 +73,8 @@ func (t *muxerTSSegment) writeH264(
dts time.Duration, dts time.Duration,
pts time.Duration, pts time.Duration,
idrPresent bool, idrPresent bool,
enc []byte) error { enc []byte,
) error {
var af *astits.PacketAdaptationField var af *astits.PacketAdaptationField
if idrPresent { if idrPresent {
@ -135,7 +136,8 @@ func (t *muxerTSSegment) writeAAC(
pcr time.Duration, pcr time.Duration,
pts time.Duration, pts time.Duration,
enc []byte, enc []byte,
ausLen int) error { ausLen int,
) error {
af := &astits.PacketAdaptationField{ af := &astits.PacketAdaptationField{
RandomAccessIndicator: true, RandomAccessIndicator: true,
} }

Loading…
Cancel
Save