From c82d7a8e5558beb87603cafce672dad92f075164 Mon Sep 17 00:00:00 2001 From: Saxon Nelson-Milton Date: Sun, 12 Mar 2023 19:40:26 +1030 Subject: [PATCH] vidforward: use consistent revid construction function --- cmd/vidforward/main.go | 18 +----------------- cmd/vidforward/utils.go | 21 +++++++++++++-------- 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/cmd/vidforward/main.go b/cmd/vidforward/main.go index 7375fb0c..20aff8b1 100644 --- a/cmd/vidforward/main.go +++ b/cmd/vidforward/main.go @@ -39,10 +39,8 @@ import ( "time" "bitbucket.org/ausocean/av/cmd/vidforward/global" - "bitbucket.org/ausocean/av/codec/codecutil" "bitbucket.org/ausocean/av/container/mts" "bitbucket.org/ausocean/av/revid" - "bitbucket.org/ausocean/av/revid/config" "bitbucket.org/ausocean/utils/logging" "gopkg.in/natefinch/lumberjack.v2" ) @@ -281,22 +279,8 @@ func (m *broadcastManager) createOrUpdate(broadcast Broadcast) error { m.mu.Lock() defer m.mu.Unlock() - var outputs []uint8 - for _ = range broadcast.urls { - outputs = append(outputs, config.OutputRTMP) - } - - cfg := config.Config{ - Logger: m.log, - Input: config.InputManual, - InputCodec: codecutil.H264_AU, - Outputs: outputs, - RTMPURL: broadcast.urls, - LogLevel: logging.Debug, - } - var err error - broadcast.rv, err = revid.New(cfg, nil) + broadcast.rv, err = newRevid(m.log, broadcast.urls) if err != nil { return fmt.Errorf("could not initialise revid: %w", err) } diff --git a/cmd/vidforward/utils.go b/cmd/vidforward/utils.go index 4b5887f2..2d19a1b1 100644 --- a/cmd/vidforward/utils.go +++ b/cmd/vidforward/utils.go @@ -38,15 +38,20 @@ import ( var loggingLevel = logging.Info func newRevid(log logging.Logger, urls []string) (*revid.Revid, error) { + var outputs []uint8 + for _ = range urls { + outputs = append(outputs, config.OutputRTMP) + } + cfg := config.Config{ + Logger: log, + Input: config.InputManual, + InputCodec: codecutil.H264_AU, + Outputs: outputs, + RTMPURL: urls, + LogLevel: logging.Debug, + } return revid.New( - config.Config{ - Logger: log, - Input: config.InputManual, - InputCodec: codecutil.H264_AU, - Outputs: []uint8{config.OutputRTMP}, - RTMPURL: urls, - LogLevel: loggingLevel, - }, nil) + cfg, nil) } // writeError logs an error and writes to w in JSON format.