mirror of https://bitbucket.org/ausocean/av.git
Merged in improve-defaulting (pull request #153)
Improve defaulting Approved-by: Alan Noble <anoble@gmail.com>
This commit is contained in:
commit
95eaf0fca7
|
@ -186,15 +186,18 @@ func (c *Config) Validate(r *Revid) error {
|
|||
c.Logger.Log(logger.Info, pkg+"defaulting frames per clip for rtmp out",
|
||||
"framesPerClip", defaultFramesPerClip)
|
||||
c.FramesPerClip = defaultFramesPerClip
|
||||
c.Packetization = Flv
|
||||
case NothingDefined:
|
||||
c.Logger.Log(logger.Warning, pkg+"no output defined, defaulting", "output",
|
||||
defaultOutput)
|
||||
c.Outputs[i] = defaultOutput
|
||||
c.Packetization = defaultPacketization
|
||||
fallthrough
|
||||
case Http, Rtp:
|
||||
c.Logger.Log(logger.Info, pkg+"defaulting frames per clip for http out",
|
||||
"framesPerClip", httpFramesPerClip)
|
||||
c.FramesPerClip = httpFramesPerClip
|
||||
c.Packetization = Mpegts
|
||||
default:
|
||||
return errors.New("bad output type defined in config")
|
||||
}
|
||||
|
|
|
@ -51,10 +51,12 @@ import (
|
|||
|
||||
// Ring buffer sizes and read/write timeouts.
|
||||
const (
|
||||
ringBufferSize = 1000
|
||||
ringBufferElementSize = 150000
|
||||
writeTimeout = 10 * time.Millisecond
|
||||
readTimeout = 10 * time.Millisecond
|
||||
mtsRbSize = 100
|
||||
mtsRbElementSize = 150000
|
||||
flvRbSize = 1000
|
||||
flvRbElementSize = 10000
|
||||
writeTimeout = 10 * time.Millisecond
|
||||
readTimeout = 10 * time.Millisecond
|
||||
)
|
||||
|
||||
// RTMP connection properties.
|
||||
|
@ -141,11 +143,6 @@ type packer struct {
|
|||
// are deemed to be successful, although a successful
|
||||
// write may include a dropped frame.
|
||||
func (p *packer) Write(frame []byte) (int, error) {
|
||||
if len(frame) > ringBufferElementSize {
|
||||
p.owner.config.Logger.Log(logger.Warning, pkg+"frame was too big", "frame size", len(frame))
|
||||
return len(frame), nil
|
||||
}
|
||||
|
||||
if len(p.owner.destination) != 0 {
|
||||
n, err := p.owner.buffer.Write(frame)
|
||||
if err != nil {
|
||||
|
@ -226,7 +223,14 @@ func (r *Revid) reset(config Config) error {
|
|||
}
|
||||
r.config = config
|
||||
|
||||
r.buffer = ring.NewBuffer(ringBufferSize, ringBufferElementSize, writeTimeout)
|
||||
// NB: currently we use two outputs that require the same packetization method
|
||||
// so we only need to check first output, but this may change later.
|
||||
switch r.config.Outputs[0] {
|
||||
case Rtmp, FfmpegRtmp:
|
||||
r.buffer = ring.NewBuffer(flvRbSize, flvRbElementSize, writeTimeout)
|
||||
case Http, Rtp:
|
||||
r.buffer = ring.NewBuffer(mtsRbSize, mtsRbElementSize, writeTimeout)
|
||||
}
|
||||
|
||||
r.destination = r.destination[:0]
|
||||
for _, typ := range r.config.Outputs {
|
||||
|
|
Loading…
Reference in New Issue