stream/mts/encoder.go: no need to have a now field to capture current time - this can be local to encode function

This commit is contained in:
saxon 2019-01-24 14:39:14 +10:30
parent 42c9fb1d09
commit 31b9ec07e9
1 changed files with 3 additions and 4 deletions

View File

@ -201,7 +201,6 @@ type Encoder struct {
continuity map[int]byte
now time.Time
psiLastTime time.Time
}
@ -234,13 +233,13 @@ const (
// generate handles the incoming data and generates equivalent mpegts packets -
// sending them to the output channel.
func (e *Encoder) Encode(nalu []byte) error {
e.now = time.Now()
if e.now.Sub(e.psiLastTime) > psiInterval {
now := time.Now()
if now.Sub(e.psiLastTime) > psiInterval {
err := e.writePSI()
if err != nil {
return err
}
e.psiLastTime = e.now
e.psiLastTime = now
}
// Prepare PES data.