mirror of https://bitbucket.org/ausocean/av.git
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:
parent
42c9fb1d09
commit
31b9ec07e9
|
@ -201,7 +201,6 @@ type Encoder struct {
|
||||||
|
|
||||||
continuity map[int]byte
|
continuity map[int]byte
|
||||||
|
|
||||||
now time.Time
|
|
||||||
psiLastTime time.Time
|
psiLastTime time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,13 +233,13 @@ const (
|
||||||
// generate handles the incoming data and generates equivalent mpegts packets -
|
// generate handles the incoming data and generates equivalent mpegts packets -
|
||||||
// sending them to the output channel.
|
// sending them to the output channel.
|
||||||
func (e *Encoder) Encode(nalu []byte) error {
|
func (e *Encoder) Encode(nalu []byte) error {
|
||||||
e.now = time.Now()
|
now := time.Now()
|
||||||
if e.now.Sub(e.psiLastTime) > psiInterval {
|
if now.Sub(e.psiLastTime) > psiInterval {
|
||||||
err := e.writePSI()
|
err := e.writePSI()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
e.psiLastTime = e.now
|
e.psiLastTime = now
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepare PES data.
|
// Prepare PES data.
|
||||||
|
|
Loading…
Reference in New Issue