From fa5585271e86851f7eae9f075feb016e55099e7e Mon Sep 17 00:00:00 2001 From: Saxon Date: Sat, 9 Nov 2019 22:49:04 +1030 Subject: [PATCH] revid: audio input meta addition moved to Revid.setupPipeline() --- revid/audio_linux.go | 16 ---------------- revid/revid.go | 12 ++++++++++++ 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/revid/audio_linux.go b/revid/audio_linux.go index ad3a3e5d..76d30a9f 100644 --- a/revid/audio_linux.go +++ b/revid/audio_linux.go @@ -19,12 +19,8 @@ LICENSE package revid import ( - "fmt" - "strconv" "time" - "bitbucket.org/ausocean/av/codec/codecutil" - "bitbucket.org/ausocean/av/container/mts" "bitbucket.org/ausocean/av/input/audio" "bitbucket.org/ausocean/utils/logger" ) @@ -40,18 +36,6 @@ func (r *Revid) startAudioDevice() (func() error, error) { BitDepth: r.cfg.BitDepth, Codec: r.cfg.InputCodec, } - mts.Meta.Add("sampleRate", strconv.Itoa(r.cfg.SampleRate)) - mts.Meta.Add("channels", strconv.Itoa(r.cfg.Channels)) - mts.Meta.Add("period", fmt.Sprintf("%.6f", r.cfg.RecPeriod)) - mts.Meta.Add("bitDepth", strconv.Itoa(r.cfg.BitDepth)) - switch r.cfg.InputCodec { - case codecutil.PCM: - mts.Meta.Add("codec", "pcm") - case codecutil.ADPCM: - mts.Meta.Add("codec", "adpcm") - default: - r.cfg.Logger.Log(logger.Fatal, pkg+"no audio codec set in config") - } ai, err := audio.NewDevice(ac, r.cfg.Logger) if err != nil { diff --git a/revid/revid.go b/revid/revid.go index 1f7c213f..f9c48478 100644 --- a/revid/revid.go +++ b/revid/revid.go @@ -337,6 +337,18 @@ func (r *Revid) setupPipeline(mtsEnc func(dst io.WriteCloser, rate float64) (io. panic("not implemented") } case config.InputAudio: + mts.Meta.Add("sampleRate", strconv.Itoa(r.cfg.SampleRate)) + mts.Meta.Add("channels", strconv.Itoa(r.cfg.Channels)) + mts.Meta.Add("period", fmt.Sprintf("%.6f", r.cfg.RecPeriod)) + mts.Meta.Add("bitDepth", strconv.Itoa(r.cfg.BitDepth)) + switch r.cfg.InputCodec { + case codecutil.PCM: + mts.Meta.Add("codec", "pcm") + case codecutil.ADPCM: + mts.Meta.Add("codec", "adpcm") + default: + r.cfg.Logger.Log(logger.Fatal, pkg+"no audio codec set in config") + } r.setupInput = r.startAudioDevice r.lexTo = codecutil.NewByteLexer(&r.cfg.ChunkSize).Lex }