joy4/mp4/stream.go
nareix 92528599ba Add 'mp4/' from commit 'bd71ca9823ec91410ccdf4d2ed783ba44b8a14d7'
git-subtree-dir: mp4
git-subtree-mainline: 8bb2ec1a5cdf4acae1ca4dfa09dd876b850bea24
git-subtree-split: bd71ca9823ec91410ccdf4d2ed783ba44b8a14d7
2016-07-01 21:31:47 +08:00

60 lines
1.1 KiB
Go

package mp4
import (
"github.com/nareix/av"
"github.com/nareix/mp4/atom"
"time"
"io"
)
type Stream struct {
av.CodecData
trackAtom *atom.Track
r io.ReadSeeker
idx int
lasttime time.Duration
timeScale int64
duration int64
muxer *Muxer
sample *atom.SampleTable
sampleIndex int
sampleOffsetInChunk int64
syncSampleIndex int
dts int64
sttsEntryIndex int
sampleIndexInSttsEntry int
cttsEntryIndex int
sampleIndexInCttsEntry int
chunkGroupIndex int
chunkIndex int
sampleIndexInChunk int
sttsEntry *atom.TimeToSampleEntry
cttsEntry *atom.CompositionOffsetEntry
}
func timeToTs(tm time.Duration, timeScale int64) int64 {
return int64(tm*time.Duration(timeScale) / time.Second)
}
func tsToTime(ts int64, timeScale int64) time.Duration {
return time.Duration(ts)*time.Second / time.Duration(timeScale)
}
func (self *Stream) timeToTs(tm time.Duration) int64 {
return int64(tm*time.Duration(self.timeScale) / time.Second)
}
func (self *Stream) tsToTime(ts int64) time.Duration {
return time.Duration(ts)*time.Second / time.Duration(self.timeScale)
}