mirror of https://bitbucket.org/ausocean/av.git
Merged in build-on-windows (pull request #285)
Make audio platform specific. Approved-by: Trek Hopton <trek.hopton@gmail.com> Approved-by: Saxon Milton <saxon.milton@gmail.com> Approved-by: Alan Noble <anoble@gmail.com>
This commit is contained in:
commit
47e621ad1f
|
@ -0,0 +1,62 @@
|
||||||
|
/*
|
||||||
|
NAME
|
||||||
|
audio_linux.go
|
||||||
|
|
||||||
|
AUTHORS
|
||||||
|
Alan Noble <alan@ausocean.org>
|
||||||
|
|
||||||
|
LICENSE
|
||||||
|
revid is Copyright (C) 2019 the Australian Ocean Lab (AusOcean)
|
||||||
|
|
||||||
|
It is free software: you can redistribute it and/or modify them
|
||||||
|
under the terms of the GNU General Public License as published by the
|
||||||
|
Free Software Foundation, either version 3 of the License, or (at your
|
||||||
|
option) any later version.
|
||||||
|
|
||||||
|
It is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
in gpl.txt. If not, see http://www.gnu.org/licenses.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package revid
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"bitbucket.org/ausocean/av/codec/codecutil"
|
||||||
|
"bitbucket.org/ausocean/av/codec/pcm"
|
||||||
|
"bitbucket.org/ausocean/av/container/mts"
|
||||||
|
"bitbucket.org/ausocean/av/device/alsa"
|
||||||
|
"bitbucket.org/ausocean/utils/logger"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (r *Revid) setupAudio() error {
|
||||||
|
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.input = alsa.New(r.cfg.Logger)
|
||||||
|
|
||||||
|
l, err := codecutil.NewByteLexer(pcm.DataSize(r.cfg.SampleRate, r.cfg.Channels, r.cfg.BitDepth, r.cfg.RecPeriod, r.cfg.InputCodec))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
r.lexTo = l.Lex
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
NAME
|
||||||
|
audio_windows.go
|
||||||
|
|
||||||
|
AUTHORS
|
||||||
|
Alan Noble <alan@ausocean.org>
|
||||||
|
|
||||||
|
LICENSE
|
||||||
|
revid is Copyright (C) 2019 the Australian Ocean Lab (AusOcean)
|
||||||
|
|
||||||
|
It is free software: you can redistribute it and/or modify them
|
||||||
|
under the terms of the GNU General Public License as published by the
|
||||||
|
Free Software Foundation, either version 3 of the License, or (at your
|
||||||
|
option) any later version.
|
||||||
|
|
||||||
|
It is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
in gpl.txt. If not, see http://www.gnu.org/licenses.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package revid
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (r *Revid) setupAudio() error {
|
||||||
|
return errors.New("audio not implemented on Windows")
|
||||||
|
}
|
|
@ -42,11 +42,9 @@ import (
|
||||||
"bitbucket.org/ausocean/av/codec/h264"
|
"bitbucket.org/ausocean/av/codec/h264"
|
||||||
"bitbucket.org/ausocean/av/codec/h265"
|
"bitbucket.org/ausocean/av/codec/h265"
|
||||||
"bitbucket.org/ausocean/av/codec/mjpeg"
|
"bitbucket.org/ausocean/av/codec/mjpeg"
|
||||||
"bitbucket.org/ausocean/av/codec/pcm"
|
|
||||||
"bitbucket.org/ausocean/av/container/flv"
|
"bitbucket.org/ausocean/av/container/flv"
|
||||||
"bitbucket.org/ausocean/av/container/mts"
|
"bitbucket.org/ausocean/av/container/mts"
|
||||||
"bitbucket.org/ausocean/av/device"
|
"bitbucket.org/ausocean/av/device"
|
||||||
"bitbucket.org/ausocean/av/device/alsa"
|
|
||||||
"bitbucket.org/ausocean/av/device/file"
|
"bitbucket.org/ausocean/av/device/file"
|
||||||
"bitbucket.org/ausocean/av/device/geovision"
|
"bitbucket.org/ausocean/av/device/geovision"
|
||||||
"bitbucket.org/ausocean/av/device/raspivid"
|
"bitbucket.org/ausocean/av/device/raspivid"
|
||||||
|
@ -349,28 +347,10 @@ func (r *Revid) setupPipeline(mtsEnc func(dst io.WriteCloser, rate float64) (io.
|
||||||
}
|
}
|
||||||
|
|
||||||
case config.InputAudio:
|
case config.InputAudio:
|
||||||
mts.Meta.Add("sampleRate", strconv.Itoa(r.cfg.SampleRate))
|
err := r.setupAudio()
|
||||||
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.input = alsa.New(r.cfg.Logger)
|
|
||||||
|
|
||||||
l, err := codecutil.NewByteLexer(pcm.DataSize(r.cfg.SampleRate, r.cfg.Channels, r.cfg.BitDepth, r.cfg.RecPeriod, r.cfg.InputCodec))
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
r.lexTo = l.Lex
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configure the input device. We know that defaults are set, so no need to
|
// Configure the input device. We know that defaults are set, so no need to
|
||||||
|
|
Loading…
Reference in New Issue