vidforward: use consistent revid construction function

This commit is contained in:
Saxon Nelson-Milton 2023-03-12 19:40:26 +10:30
parent a4754e5ead
commit c82d7a8e55
2 changed files with 14 additions and 25 deletions

View File

@ -39,10 +39,8 @@ import (
"time" "time"
"bitbucket.org/ausocean/av/cmd/vidforward/global" "bitbucket.org/ausocean/av/cmd/vidforward/global"
"bitbucket.org/ausocean/av/codec/codecutil"
"bitbucket.org/ausocean/av/container/mts" "bitbucket.org/ausocean/av/container/mts"
"bitbucket.org/ausocean/av/revid" "bitbucket.org/ausocean/av/revid"
"bitbucket.org/ausocean/av/revid/config"
"bitbucket.org/ausocean/utils/logging" "bitbucket.org/ausocean/utils/logging"
"gopkg.in/natefinch/lumberjack.v2" "gopkg.in/natefinch/lumberjack.v2"
) )
@ -281,22 +279,8 @@ func (m *broadcastManager) createOrUpdate(broadcast Broadcast) error {
m.mu.Lock() m.mu.Lock()
defer m.mu.Unlock() 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 var err error
broadcast.rv, err = revid.New(cfg, nil) broadcast.rv, err = newRevid(m.log, broadcast.urls)
if err != nil { if err != nil {
return fmt.Errorf("could not initialise revid: %w", err) return fmt.Errorf("could not initialise revid: %w", err)
} }

View File

@ -38,15 +38,20 @@ import (
var loggingLevel = logging.Info var loggingLevel = logging.Info
func newRevid(log logging.Logger, urls []string) (*revid.Revid, error) { func newRevid(log logging.Logger, urls []string) (*revid.Revid, error) {
return revid.New( var outputs []uint8
config.Config{ for _ = range urls {
outputs = append(outputs, config.OutputRTMP)
}
cfg := config.Config{
Logger: log, Logger: log,
Input: config.InputManual, Input: config.InputManual,
InputCodec: codecutil.H264_AU, InputCodec: codecutil.H264_AU,
Outputs: []uint8{config.OutputRTMP}, Outputs: outputs,
RTMPURL: urls, RTMPURL: urls,
LogLevel: loggingLevel, LogLevel: logging.Debug,
}, nil) }
return revid.New(
cfg, nil)
} }
// writeError logs an error and writes to w in JSON format. // writeError logs an error and writes to w in JSON format.