mirror of https://bitbucket.org/ausocean/av.git
Improving mpegts
This commit is contained in:
parent
2a3f058e77
commit
484f21e4d3
|
@ -126,8 +126,27 @@ func (p *MpegTsPacket) ToByteSlice() (output []byte) {
|
||||||
output[1] = boolToByte(p.TEI) << 7 | boolToByte(p.PUSI) << 6 |
|
output[1] = boolToByte(p.TEI) << 7 | boolToByte(p.PUSI) << 6 |
|
||||||
boolToByte(p.Priority) << 5 | byte((p.PID&0xFF00) >> 8)
|
boolToByte(p.Priority) << 5 | byte((p.PID&0xFF00) >> 8)
|
||||||
output[2] = byte(p.PID & 0x00FF)
|
output[2] = byte(p.PID & 0x00FF)
|
||||||
output[3] = p.TSC << 6 | (p.AFC << 4) | p.CC
|
output[3] = p.TSC << 6 | p.AFC << 4 | p.CC
|
||||||
output[4] = p.AFL
|
output[4] = p.AFL
|
||||||
output[5] =
|
output[5] = boolToByte(p.DI) << 7 | boolToByte(p.RAI) << 6 | boolToByte(p.ESPI) << 5 |
|
||||||
return
|
boolToByte(p.PCRF) << 4 | boolToByte(p.OPCRF) << 3 | boolToByte(p.SPF) << 2 |
|
||||||
|
boolToByte(TPDF) << 1 | boolToByte(AFEF)
|
||||||
|
currentIndex := 6
|
||||||
|
for ; p.PCRf && currentIndex < 12; currentIndex++ {
|
||||||
|
output[currentIndex] = p.PCR >> (22 - 2*currentIndex)
|
||||||
|
}
|
||||||
|
startIndex := currentIndex
|
||||||
|
for ; p.OPCRF && ( currentIndex < ( startIndex + 6 )); currentIndex++ {
|
||||||
|
output[currentIndex] = p.OPCR >> (10 - 2*(currentIndex-startIndex))
|
||||||
|
}
|
||||||
|
if p.SPF {
|
||||||
|
output[(currentIndex++)-1] = p.SC
|
||||||
|
}
|
||||||
|
if p.TPDF {
|
||||||
|
output[(currentIndex++)-1] = p.TPDL
|
||||||
|
copy(output[currentIndex:len(p.TPD)],p.TPD[:]]
|
||||||
|
currentIndex += len(p.TPD)
|
||||||
|
}
|
||||||
|
copy()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue