revid: audio input meta addition moved to Revid.setupPipeline()

This commit is contained in:
Saxon 2019-11-09 22:49:04 +10:30
parent 79ddea32c0
commit fa5585271e
2 changed files with 12 additions and 16 deletions

View File

@ -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 {

View File

@ -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
}