mirror of https://bitbucket.org/ausocean/av.git
Merge branch 'master' into move-audio-netsender
This commit is contained in:
commit
cf4d89c3f8
|
@ -369,7 +369,7 @@ func capAdd16(a, b int16) int16 {
|
||||||
// EncBytes will return the number of adpcm bytes that will be generated when encoding the given amount of pcm bytes (n).
|
// EncBytes will return the number of adpcm bytes that will be generated when encoding the given amount of pcm bytes (n).
|
||||||
func EncBytes(n int) int {
|
func EncBytes(n int) int {
|
||||||
// For 'n' pcm bytes, 1 sample is left uncompressed, the rest is compressed by a factor of 4
|
// For 'n' pcm bytes, 1 sample is left uncompressed, the rest is compressed by a factor of 4
|
||||||
// and a start index and padding-flag byte are added.
|
// and a chunk length (4B), start index (1B) and padding-flag (1B) are added.
|
||||||
// Also if there are an even number of samples, there will be half a byte of padding added to the last byte.
|
// Also if there are an even number of samples, there will be half a byte of padding added to the last byte.
|
||||||
if n%bytesPerEnc == 0 {
|
if n%bytesPerEnc == 0 {
|
||||||
return (n-byteDepth)/compFact + headSize + 1
|
return (n-byteDepth)/compFact + headSize + 1
|
||||||
|
|
|
@ -44,7 +44,7 @@ import (
|
||||||
const (
|
const (
|
||||||
H264ID = 27
|
H264ID = 27
|
||||||
H265ID = 36
|
H265ID = 36
|
||||||
audioStreamID = 0xc0 // First audio stream ID.
|
audioStreamID = 0xc0 // ADPCM audio stream ID.
|
||||||
)
|
)
|
||||||
|
|
||||||
// Constants used to communicate which media codec will be packetized.
|
// Constants used to communicate which media codec will be packetized.
|
||||||
|
@ -150,10 +150,12 @@ type Encoder struct {
|
||||||
func NewEncoder(dst io.WriteCloser, rate float64, mediaType int) *Encoder {
|
func NewEncoder(dst io.WriteCloser, rate float64, mediaType int) *Encoder {
|
||||||
var mPid int
|
var mPid int
|
||||||
var sid byte
|
var sid byte
|
||||||
|
nbp := true
|
||||||
switch mediaType {
|
switch mediaType {
|
||||||
case EncodeAudio:
|
case EncodeAudio:
|
||||||
mPid = AudioPid
|
mPid = AudioPid
|
||||||
sid = audioStreamID
|
sid = audioStreamID
|
||||||
|
nbp = false
|
||||||
case EncodeH265:
|
case EncodeH265:
|
||||||
mPid = VideoPid
|
mPid = VideoPid
|
||||||
sid = H265ID
|
sid = H265ID
|
||||||
|
@ -168,7 +170,7 @@ func NewEncoder(dst io.WriteCloser, rate float64, mediaType int) *Encoder {
|
||||||
Pil: 0,
|
Pil: 0,
|
||||||
Essd: &psi.ESSD{
|
Essd: &psi.ESSD{
|
||||||
St: byte(sid),
|
St: byte(sid),
|
||||||
Epid: 0x0100,
|
Epid: uint16(mPid),
|
||||||
Esil: 0x00,
|
Esil: 0x00,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -180,7 +182,7 @@ func NewEncoder(dst io.WriteCloser, rate float64, mediaType int) *Encoder {
|
||||||
writePeriod: time.Duration(float64(time.Second) / rate),
|
writePeriod: time.Duration(float64(time.Second) / rate),
|
||||||
ptsOffset: ptsOffset,
|
ptsOffset: ptsOffset,
|
||||||
|
|
||||||
nalBasedPSI: true,
|
nalBasedPSI: nbp,
|
||||||
|
|
||||||
pktCount: 8,
|
pktCount: 8,
|
||||||
|
|
||||||
|
|
4
go.mod
4
go.mod
|
@ -3,8 +3,8 @@ module bitbucket.org/ausocean/av
|
||||||
go 1.12
|
go 1.12
|
||||||
|
|
||||||
require (
|
require (
|
||||||
bitbucket.org/ausocean/iot v1.2.6
|
bitbucket.org/ausocean/iot v1.2.7
|
||||||
bitbucket.org/ausocean/utils v1.2.8
|
bitbucket.org/ausocean/utils v1.2.9
|
||||||
github.com/BurntSushi/toml v0.3.1 // indirect
|
github.com/BurntSushi/toml v0.3.1 // indirect
|
||||||
github.com/Comcast/gots v0.0.0-20190305015453-8d56e473f0f7
|
github.com/Comcast/gots v0.0.0-20190305015453-8d56e473f0f7
|
||||||
github.com/go-audio/audio v0.0.0-20181013203223-7b2a6ca21480
|
github.com/go-audio/audio v0.0.0-20181013203223-7b2a6ca21480
|
||||||
|
|
4
go.sum
4
go.sum
|
@ -2,10 +2,14 @@ bitbucket.org/ausocean/av v0.0.0-20190416003121-6ee286e98874/go.mod h1:DxZEprrNN
|
||||||
bitbucket.org/ausocean/iot v1.2.4/go.mod h1:5HVLgPHccW2PxS7WDUQO6sKWMgk3Vfze/7d5bHs8EWU=
|
bitbucket.org/ausocean/iot v1.2.4/go.mod h1:5HVLgPHccW2PxS7WDUQO6sKWMgk3Vfze/7d5bHs8EWU=
|
||||||
bitbucket.org/ausocean/iot v1.2.6 h1:KAAY1KZDbyOpoKajT1dM8BawupHiW9hUOelseSV1Ptc=
|
bitbucket.org/ausocean/iot v1.2.6 h1:KAAY1KZDbyOpoKajT1dM8BawupHiW9hUOelseSV1Ptc=
|
||||||
bitbucket.org/ausocean/iot v1.2.6/go.mod h1:71AYHh8yGZ8XyzDBskwIWMF+8E8ORagXpXE24wlhoE0=
|
bitbucket.org/ausocean/iot v1.2.6/go.mod h1:71AYHh8yGZ8XyzDBskwIWMF+8E8ORagXpXE24wlhoE0=
|
||||||
|
bitbucket.org/ausocean/iot v1.2.7 h1:dZgrmVtuXnzHgybDthn0bYgAJms9euTONXBsqsx9g5M=
|
||||||
|
bitbucket.org/ausocean/iot v1.2.7/go.mod h1:aAWgPo2f8sD2OPmxae1E5/iD9+tKY/iW4pcQMQXUvHM=
|
||||||
bitbucket.org/ausocean/utils v0.0.0-20190408050157-66d3b4d4041e/go.mod h1:uXzX9z3PLemyURTMWRhVI8uLhPX4uuvaaO85v2hcob8=
|
bitbucket.org/ausocean/utils v0.0.0-20190408050157-66d3b4d4041e/go.mod h1:uXzX9z3PLemyURTMWRhVI8uLhPX4uuvaaO85v2hcob8=
|
||||||
bitbucket.org/ausocean/utils v1.2.6/go.mod h1:uXzX9z3PLemyURTMWRhVI8uLhPX4uuvaaO85v2hcob8=
|
bitbucket.org/ausocean/utils v1.2.6/go.mod h1:uXzX9z3PLemyURTMWRhVI8uLhPX4uuvaaO85v2hcob8=
|
||||||
bitbucket.org/ausocean/utils v1.2.8 h1:hyxAIqYBqjqCguG+6A/kKyrAihyeUt2LziZg6CH0gLU=
|
bitbucket.org/ausocean/utils v1.2.8 h1:hyxAIqYBqjqCguG+6A/kKyrAihyeUt2LziZg6CH0gLU=
|
||||||
bitbucket.org/ausocean/utils v1.2.8/go.mod h1:uXzX9z3PLemyURTMWRhVI8uLhPX4uuvaaO85v2hcob8=
|
bitbucket.org/ausocean/utils v1.2.8/go.mod h1:uXzX9z3PLemyURTMWRhVI8uLhPX4uuvaaO85v2hcob8=
|
||||||
|
bitbucket.org/ausocean/utils v1.2.9 h1:g45C6KCNvCLOGFv+ZnmDbQOOdnwpIsvzuNOD141CTVI=
|
||||||
|
bitbucket.org/ausocean/utils v1.2.9/go.mod h1:uXzX9z3PLemyURTMWRhVI8uLhPX4uuvaaO85v2hcob8=
|
||||||
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
|
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
|
||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
github.com/Comcast/gots v0.0.0-20190305015453-8d56e473f0f7 h1:LdOc9B9Bj6LEsKiXShkLA3/kpxXb6LJpH+ekU2krbzw=
|
github.com/Comcast/gots v0.0.0-20190305015453-8d56e473f0f7 h1:LdOc9B9Bj6LEsKiXShkLA3/kpxXb6LJpH+ekU2krbzw=
|
||||||
|
|
|
@ -119,10 +119,11 @@ type Revid struct {
|
||||||
// an error if construction of the new instance was not successful.
|
// an error if construction of the new instance was not successful.
|
||||||
func New(c Config, ns *netsender.Sender) (*Revid, error) {
|
func New(c Config, ns *netsender.Sender) (*Revid, error) {
|
||||||
r := Revid{ns: ns, err: make(chan error)}
|
r := Revid{ns: ns, err: make(chan error)}
|
||||||
err := r.reset(c)
|
err := r.setConfig(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, fmt.Errorf("could not set config, failed with error: %v",err)
|
||||||
}
|
}
|
||||||
|
r.config.Logger.SetLevel(c.LogLevel)
|
||||||
go r.handleErrors()
|
go r.handleErrors()
|
||||||
return &r, nil
|
return &r, nil
|
||||||
}
|
}
|
||||||
|
@ -317,12 +318,17 @@ func (r *Revid) Start() error {
|
||||||
}
|
}
|
||||||
r.config.Logger.Log(logger.Info, pkg+"starting Revid")
|
r.config.Logger.Log(logger.Info, pkg+"starting Revid")
|
||||||
r.isRunning = true
|
r.isRunning = true
|
||||||
var err error
|
err := r.reset(r.config)
|
||||||
|
if err != nil {
|
||||||
|
r.Stop()
|
||||||
|
return err
|
||||||
|
}
|
||||||
r.closeInput, err = r.setupInput()
|
r.closeInput, err = r.setupInput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
r.Stop()
|
r.Stop()
|
||||||
}
|
|
||||||
return err
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stop closes down the pipeline. This closes encoders and sender output routines,
|
// Stop closes down the pipeline. This closes encoders and sender output routines,
|
||||||
|
@ -543,7 +549,7 @@ func (r *Revid) Update(vars map[string]string) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
r.config.Logger.Log(logger.Info, pkg+"revid config changed", "config", fmt.Sprintf("%+v", r.config))
|
r.config.Logger.Log(logger.Info, pkg+"revid config changed", "config", fmt.Sprintf("%+v", r.config))
|
||||||
return r.reset(r.config)
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// startRaspivid sets up things for input from raspivid i.e. starts
|
// startRaspivid sets up things for input from raspivid i.e. starts
|
||||||
|
|
Loading…
Reference in New Issue