switch to time.Duration
This commit is contained in:
parent
97f2cceb2c
commit
5815ff6efa
11
demuxer.go
11
demuxer.go
@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"time"
|
||||
"github.com/nareix/av"
|
||||
"github.com/nareix/av/pktqueue"
|
||||
"github.com/nareix/codec/aacparser"
|
||||
@ -41,9 +42,9 @@ func (self *Demuxer) Streams() (streams []av.CodecData, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (self *Demuxer) CurrentTime() (time float32) {
|
||||
func (self *Demuxer) CurrentTime() (tm time.Duration) {
|
||||
if self.pktque != nil {
|
||||
time = self.pktque.CurrentTime()
|
||||
tm = self.pktque.CurrentTime()
|
||||
}
|
||||
return
|
||||
}
|
||||
@ -158,11 +159,11 @@ func (self *Stream) payloadEnd() (err error) {
|
||||
IsKeyFrame: self.tshdr.RandomAccessIndicator,
|
||||
Data: payload,
|
||||
}
|
||||
time := float32(dts) / float32(PTS_HZ)
|
||||
tm := time.Duration(dts)*time.Second / time.Duration(PTS_HZ)
|
||||
if pts != dts {
|
||||
pkt.CompositionTime = float32(pts-dts) / float32(PTS_HZ)
|
||||
pkt.CompositionTime = time.Duration(pts-dts)*time.Second / time.Duration(PTS_HZ)
|
||||
}
|
||||
self.demuxer.pktque.WriteTimePacket(self.idx, time, pkt)
|
||||
self.demuxer.pktque.WriteTimePacket(self.idx, tm, pkt)
|
||||
self.demuxer.gotpkt = true
|
||||
|
||||
if self.CodecData == nil {
|
||||
|
11
stream.go
11
stream.go
@ -1,6 +1,7 @@
|
||||
package ts
|
||||
|
||||
import (
|
||||
"time"
|
||||
"bytes"
|
||||
"github.com/nareix/av"
|
||||
)
|
||||
@ -25,13 +26,13 @@ type Stream struct {
|
||||
|
||||
idx int
|
||||
pkt av.Packet
|
||||
time float32
|
||||
time time.Duration
|
||||
}
|
||||
|
||||
func timeToPesTs(time float32) uint64 {
|
||||
return uint64(time*PTS_HZ) + PTS_HZ
|
||||
func timeToPesTs(tm time.Duration) uint64 {
|
||||
return uint64(tm*PTS_HZ/time.Second) + PTS_HZ
|
||||
}
|
||||
|
||||
func timeToPCR(time float32) uint64 {
|
||||
return uint64(time*PCR_HZ) + PCR_HZ
|
||||
func timeToPCR(tm time.Duration) uint64 {
|
||||
return uint64(tm*PCR_HZ/time.Second) + PCR_HZ
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user