mirror of https://bitbucket.org/ausocean/av.git
revid: clean up vars for use in calculation of time between writes to packer
This commit is contained in:
parent
b46e267983
commit
8878063dc8
|
@ -125,9 +125,6 @@ type Revid struct {
|
|||
isRunning bool
|
||||
}
|
||||
|
||||
var now = time.Now()
|
||||
var prevTime = now
|
||||
|
||||
// packer takes data segments and packs them into clips
|
||||
// of the number frames specified in the owners config.
|
||||
type packer struct {
|
||||
|
@ -136,6 +133,10 @@ type packer struct {
|
|||
packetCount uint
|
||||
}
|
||||
|
||||
// lastTime is used in the packer's Write method to determine how much time has
|
||||
// passed since last write to packer
|
||||
var lastTime time.Time
|
||||
|
||||
// Write implements the io.Writer interface.
|
||||
//
|
||||
// Unless the ring buffer returns an error, all writes
|
||||
|
@ -156,11 +157,11 @@ func (p *packer) Write(frame []byte) (int, error) {
|
|||
return n, err
|
||||
}
|
||||
p.packetCount++
|
||||
now = time.Now()
|
||||
if (p.owner.config.Output1 != Rtmp && now.Sub(prevTime) > clipDuration && p.packetCount%7 == 0) || p.owner.config.Output1 == Rtmp {
|
||||
now := time.Now()
|
||||
if (p.owner.config.Output1 != Rtmp && now.Sub(lastTime) > clipDuration && p.packetCount%7 == 0) || p.owner.config.Output1 == Rtmp {
|
||||
p.owner.buffer.Flush()
|
||||
p.packetCount = 0
|
||||
prevTime = now
|
||||
lastTime = now
|
||||
}
|
||||
return len(frame), nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue