container/mts/pes/pes.go: simplified insertion of pts into pes []byte using comcast/gots InsertPTS func

This commit is contained in:
Saxon 2019-05-10 14:51:53 +09:30
parent 868d01527c
commit 542f017879
1 changed files with 6 additions and 9 deletions

View File

@ -26,6 +26,8 @@ LICENSE
package pes
import "github.com/Comcast/gots"
const MaxPesSize = 64 * 1 << 10
/*
@ -108,16 +110,11 @@ func (p *Packet) Bytes(buf []byte) []byte {
boolByte(p.ACIF)<<2 | boolByte(p.CRCF)<<1 | boolByte(p.EF)),
p.HeaderLength,
}...)
if p.PDI == byte(2) {
pts := 0x2100010001 | (p.PTS&0x1C0000000)<<3 | (p.PTS&0x3FFF8000)<<2 |
(p.PTS&0x7FFF)<<1
buf = append(buf, []byte{
byte((pts & 0xFF00000000) >> 32),
byte((pts & 0x00FF000000) >> 24),
byte((pts & 0x0000FF0000) >> 16),
byte((pts & 0x000000FF00) >> 8),
byte(pts & 0x00000000FF),
}...)
ptsIdx := len(buf)
buf = buf[:ptsIdx+5]
gots.InsertPTS(buf[ptsIdx:], p.PTS)
}
buf = append(buf, append(p.Stuff, p.Data...)...)
return buf