mirror of https://bitbucket.org/ausocean/av.git
Merged in fix-encoder-timing (pull request #147)
stream/mts & stream/rtp: fixed timing calculations
This commit is contained in:
commit
725b40b114
|
@ -122,6 +122,7 @@ type Encoder struct {
|
|||
dst io.Writer
|
||||
|
||||
clock time.Duration
|
||||
lastTime time.Time
|
||||
frameInterval time.Duration
|
||||
ptsOffset time.Duration
|
||||
tsSpace [PacketSize]byte
|
||||
|
@ -247,7 +248,9 @@ func (e *Encoder) writePSI() error {
|
|||
|
||||
// tick advances the clock one frame interval.
|
||||
func (e *Encoder) tick() {
|
||||
e.clock += e.frameInterval
|
||||
now := time.Now()
|
||||
e.clock += now.Sub(e.lastTime)
|
||||
e.lastTime = now
|
||||
}
|
||||
|
||||
// pts retuns the current presentation timestamp.
|
||||
|
|
|
@ -51,6 +51,7 @@ type Encoder struct {
|
|||
seqNo uint16
|
||||
clock time.Duration
|
||||
frameInterval time.Duration
|
||||
lastTime time.Time
|
||||
fps int
|
||||
buffer []byte
|
||||
pktSpace [defPktSize]byte
|
||||
|
@ -120,7 +121,9 @@ func (e *Encoder) Encode(payload []byte) error {
|
|||
|
||||
// tick advances the clock one frame interval.
|
||||
func (e *Encoder) tick() {
|
||||
e.clock += e.frameInterval
|
||||
now := time.Now()
|
||||
e.clock += now.Sub(e.lastTime)
|
||||
e.lastTime = now
|
||||
}
|
||||
|
||||
// nxtTimestamp gets the next timestamp
|
||||
|
|
Loading…
Reference in New Issue