Merged in gardening/timeconsts (pull request #25)

revid: use time.Duration for durations

Approved-by: Alan Noble <anoble@gmail.com>
This commit is contained in:
kortschak 2018-06-08 03:58:11 +00:00 committed by Alan Noble
commit d457256931
1 changed files with 8 additions and 9 deletions

View File

@ -52,16 +52,16 @@ import (
// Misc constants
const (
clipDuration = 1 // s
mp2tPacketSize = 188 // MPEG-TS packet size
mp2tMaxPackets = 2016 * clipDuration // # first multiple of 7 and 8 greater than 2000
clipDuration = 1 * time.Second
mp2tPacketSize = 188 // MPEG-TS packet size
mp2tMaxPackets = int(clipDuration * 2016 / time.Second) // # first multiple of 7 and 8 greater than 2000
ringBufferSize = 500
ringBufferElementSize = 150000
writeTimeout = 10 * time.Millisecond
readTimeout = 10 * time.Millisecond
httpTimeOut = 5 // s
httpTimeout = 5 * time.Second
packetsPerFrame = 7
bitrateTime = 60 // s
bitrateTime = 1 * time.Minute
mjpegParserInChanLen = 100000
ffmpegPath = "/usr/local/bin/ffmpeg"
rtmpConnectionTimout = 10
@ -72,7 +72,7 @@ const (
clipSizeThreshold = 11
rtmpConnectionMaxTries = 5
raspividNoOfTries = 3
sendingWaitTime = time.Duration(5) * time.Millisecond
sendingWaitTime = 5 * time.Millisecond
)
// Log Types
@ -446,7 +446,7 @@ func (r *revid) outputClips() {
// Log some information regarding bitrate and ring buffer size if it's time
now = time.Now()
deltaTime := now.Sub(prevTime)
if deltaTime > time.Duration(bitrateTime)*time.Second {
if deltaTime > bitrateTime {
r.currentBitrate = int64(float64(bytes*8) / float64(deltaTime/1e9))
r.Log(Debug, fmt.Sprintf("Bitrate: %v bits/s\n", r.currentBitrate))
r.Log(Debug, fmt.Sprintf("Ring buffer size: %v\n", r.ringBuffer.Len()))
@ -470,8 +470,7 @@ func (r *revid) sendClipToHTTP(clip *ring.Chunk) error {
defer r.sendMutex.Unlock()
r.sendMutex.Lock()
timeout := time.Duration(httpTimeOut * time.Second)
client := http.Client{Timeout: timeout}
client := http.Client{Timeout: httpTimeout}
url := r.config.HttpAddress + strconv.Itoa(clip.Len())
// FIXME(kortschak): This is necessary because Post takes