mirror of https://bitbucket.org/ausocean/av.git
revid: write timeouts for ringbuffer are just int to avoid overflow when converting duration to int on pi for the purpose of logging
This commit is contained in:
parent
ee1bea3f77
commit
8837dce389
|
@ -125,12 +125,12 @@ const (
|
|||
// MTS ring buffer defaults.
|
||||
defaultMTSRBSize = 1000
|
||||
defaultMTSRBElementSize = 100000
|
||||
defaultMTSRBWriteTimeout = 5 * time.Second
|
||||
defaultMTSRBWriteTimeout = 5
|
||||
|
||||
// RTMP ring buffer defaults.
|
||||
defaultRTMPRBSize = 1000
|
||||
defaultRTMPRBElementSize = 300000
|
||||
defaultRTMPRBWriteTimeout = 5 * time.Second
|
||||
defaultRTMPRBWriteTimeout = 5
|
||||
)
|
||||
|
||||
// Config provides parameters relevant to a revid instance. A new config must
|
||||
|
@ -258,12 +258,12 @@ type Config struct {
|
|||
// RTMP ring buffer parameters.
|
||||
RTMPRBSize int // The number of elements in the RTMP sender ringbuffer.
|
||||
RTMPRBElementSize int // The element size in bytes of the RTMP sender RingBuffer.
|
||||
RTMPRBWriteTimeout time.Duration
|
||||
RTMPRBWriteTimeout int // The ringbuffer write timeout in seconds.
|
||||
|
||||
// MTS ring buffer parameters.
|
||||
MTSRBSize int // The number of elements in the MTS sender ringbuffer.
|
||||
MTSRBElementSize int // The element size in bytes of the MTS sender RingBuffer.
|
||||
MTSRBWriteTimeout time.Duration
|
||||
MTSRBWriteTimeout int // The ringbuffer write timeout in seconds.
|
||||
}
|
||||
|
||||
// Validation errors.
|
||||
|
@ -462,7 +462,7 @@ func (c *Config) Validate() error {
|
|||
}
|
||||
|
||||
if c.RTMPRBWriteTimeout <= 0 {
|
||||
c.Logger.Log(logger.Info, pkg+"RTMPRBWriteTimeout bad or unset, defaulting", "RTMPRBWriteTimeout", int(defaultRTMPRBWriteTimeout))
|
||||
c.Logger.Log(logger.Info, pkg+"RTMPRBWriteTimeout bad or unset, defaulting", "RTMPRBWriteTimeout", defaultRTMPRBWriteTimeout)
|
||||
c.RTMPRBWriteTimeout = defaultRTMPRBWriteTimeout
|
||||
}
|
||||
|
||||
|
@ -477,7 +477,7 @@ func (c *Config) Validate() error {
|
|||
}
|
||||
|
||||
if c.MTSRBWriteTimeout <= 0 {
|
||||
c.Logger.Log(logger.Info, pkg+"MTSRBWriteTimeout bad or unset, defaulting", "MTSRBWriteTimeout", int(defaultMTSRBWriteTimeout))
|
||||
c.Logger.Log(logger.Info, pkg+"MTSRBWriteTimeout bad or unset, defaulting", "MTSRBWriteTimeout", defaultMTSRBWriteTimeout)
|
||||
c.MTSRBWriteTimeout = defaultMTSRBWriteTimeout
|
||||
}
|
||||
|
||||
|
|
|
@ -255,7 +255,7 @@ func (r *Revid) setupPipeline(mtsEnc func(dst io.WriteCloser, rate float64) (io.
|
|||
w = newMtsSender(
|
||||
newHttpSender(r.ns, r.config.Logger.Log),
|
||||
r.config.Logger.Log,
|
||||
ring.NewBuffer(r.config.MTSRBSize, r.config.MTSRBElementSize, r.config.MTSRBWriteTimeout),
|
||||
ring.NewBuffer(r.config.MTSRBSize, r.config.MTSRBElementSize, time.Duration(r.config.MTSRBWriteTimeout)*time.Second),
|
||||
r.config.ClipDuration,
|
||||
)
|
||||
mtsSenders = append(mtsSenders, w)
|
||||
|
@ -276,7 +276,7 @@ func (r *Revid) setupPipeline(mtsEnc func(dst io.WriteCloser, rate float64) (io.
|
|||
r.config.RTMPURL,
|
||||
rtmpConnectionTimeout,
|
||||
rtmpConnectionMaxTries,
|
||||
ring.NewBuffer(r.config.RTMPRBSize, r.config.RTMPRBElementSize, r.config.RTMPRBWriteTimeout),
|
||||
ring.NewBuffer(r.config.RTMPRBSize, r.config.RTMPRBElementSize, time.Duration(r.config.RTMPRBWriteTimeout)*time.Second),
|
||||
r.config.Logger.Log,
|
||||
)
|
||||
if err != nil {
|
||||
|
@ -596,7 +596,7 @@ func (r *Revid) Update(vars map[string]string) error {
|
|||
r.config.Logger.Log(logger.Warning, pkg+"invalid RTMPRBWriteTimeout var", "value", value)
|
||||
break
|
||||
}
|
||||
r.config.RTMPRBWriteTimeout = time.Duration(v) * time.Second
|
||||
r.config.RTMPRBWriteTimeout = v
|
||||
case "MTSRBSize":
|
||||
v, err := strconv.Atoi(value)
|
||||
if err != nil || v < 0 {
|
||||
|
@ -617,7 +617,7 @@ func (r *Revid) Update(vars map[string]string) error {
|
|||
r.config.Logger.Log(logger.Warning, pkg+"invalid MTSRBWriteTimeout var", "value", value)
|
||||
break
|
||||
}
|
||||
r.config.MTSRBWriteTimeout = time.Duration(v) * time.Second
|
||||
r.config.MTSRBWriteTimeout = v
|
||||
}
|
||||
}
|
||||
r.config.Logger.Log(logger.Info, pkg+"revid config changed", "config", fmt.Sprintf("%+v", r.config))
|
||||
|
|
Loading…
Reference in New Issue