mirror of https://bitbucket.org/ausocean/av.git
updating remote
This commit is contained in:
parent
563539ad34
commit
309de69964
|
@ -77,6 +77,8 @@ func (p* H264Parser)Parse() {
|
|||
aByte = <-p.InputByteChan
|
||||
outputBuffer = append(outputBuffer, aByte)
|
||||
if nalType := aByte & 0x1F; nalType == 1 || nalType == 5 {
|
||||
if firstRunThrough {
|
||||
spsPpsSei = append(spsPpsSei,
|
||||
searchingForEnd = true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -144,7 +144,10 @@ func (p *MpegTsPacket) FillPayload(channel chan byte){
|
|||
func (p *MpegTsPacket) ToByteSlice() (output []byte, err error) {
|
||||
stuffingLength := 182-len(p.Payload)-len(p.TPD)-int(tools.BoolToByte(p.PCRF))*6-
|
||||
int(tools.BoolToByte(p.OPCRF))*6 - int(tools.BoolToByte(p.SPF))
|
||||
stuffing := make([]byte,stuffingLength)
|
||||
var stuffing []byte
|
||||
if stuffingLength > 0 {
|
||||
stuffing = make([]byte,stuffingLength)
|
||||
}
|
||||
for i := range stuffing {
|
||||
stuffing[i] = 0xFF
|
||||
}
|
||||
|
@ -162,7 +165,7 @@ func (p *MpegTsPacket) ToByteSlice() (output []byte, err error) {
|
|||
output = append(output, []byte{
|
||||
byte(afl), (tools.BoolToByte(p.DI)<<7 | tools.BoolToByte(p.RAI)<<6 | tools.BoolToByte(p.ESPI)<<5 |
|
||||
tools.BoolToByte(p.PCRF)<<4 | tools.BoolToByte(p.OPCRF)<<3 | tools.BoolToByte(p.SPF)<<2 |
|
||||
tools.BoolToByte(p.TPDF)<<1 | tools.BoolToByte(p.AFEF))
|
||||
tools.BoolToByte(p.TPDF)<<1 | tools.BoolToByte(p.AFEF)),
|
||||
}...)
|
||||
for i := 40; p.PCRF && i >= 0; i-=8 {
|
||||
output = append(output, byte((p.PCR<<15)>>uint(i)))
|
||||
|
@ -176,8 +179,8 @@ func (p *MpegTsPacket) ToByteSlice() (output []byte, err error) {
|
|||
if p.TPDF {
|
||||
output = append(output, append([]byte{p.TPDL}, p.TPD...)...)
|
||||
}
|
||||
output = append(output, p.EXT)
|
||||
output = append(output, p.stuffing)
|
||||
output = append(output, p.Ext...)
|
||||
output = append(output, stuffing...)
|
||||
}
|
||||
output = append(output, p.Payload...)
|
||||
|
||||
|
|
|
@ -38,11 +38,11 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
sdtTable = []byte{0, 66, 240, 65, 0, 1, 193, 0, 0, 255, 1, 255, 0, 1, 252, 128, 48, 72, 46, 1, 6, 70, 70, 109, 112, 101, 103, 37, 115, 116, 114, 101, 97, 109, 101, 100, 32, 98, 121, 32, 116, 104, 101, 32, 71, 101, 111, 86, 105, 115, 105, 111, 110, 32, 82, 116, 115, 112, 32, 83, 101, 114, 118, 101, 114, 99, 176, 214, 195, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,}
|
||||
SdtTable = []byte{0, 66, 240, 65, 0, 1, 193, 0, 0, 255, 1, 255, 0, 1, 252, 128, 48, 72, 46, 1, 6, 70, 70, 109, 112, 101, 103, 37, 115, 116, 114, 101, 97, 109, 101, 100, 32, 98, 121, 32, 116, 104, 101, 32, 71, 101, 111, 86, 105, 115, 105, 111, 110, 32, 82, 116, 115, 112, 32, 83, 101, 114, 118, 101, 114, 99, 176, 214, 195, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,}
|
||||
|
||||
patTable = []byte{0, 0, 176, 13, 0, 1, 193, 0, 0, 0, 1, 240, 0, 42, 177, 4, 178, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,}
|
||||
PatTable = []byte{0, 0, 176, 13, 0, 1, 193, 0, 0, 0, 1, 240, 0, 42, 177, 4, 178, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,}
|
||||
|
||||
pmtTable = []byte{0, 2, 176, 18, 0, 1, 193, 0, 0, 0xE1, 0x00, 0xF0, 0, 0x1B, 0xE1, 0, 0xF0, 0, 0x15, 0xBD, 0x4D, 0x56, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,}
|
||||
PmtTable = []byte{0, 2, 176, 18, 0, 1, 193, 0, 0, 0xE1, 0x00, 0xF0, 0, 0x1B, 0xE1, 0, 0xF0, 0, 0x15, 0xBD, 0x4D, 0x56, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,}
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -102,6 +102,7 @@ func NewTsGenerator(fps uint) (g *tsGenerator) {
|
|||
g.currentPtsTime = .7
|
||||
g.pesPktChan = make(chan []byte, 1000)
|
||||
g.payloadByteChan = make(chan byte, 100000)
|
||||
g.ccMap = make(map[int]int, 4)
|
||||
g.ccMap[SdtPid] = 0
|
||||
g.ccMap[PatPid] = 0
|
||||
g.ccMap[PmtPid] = 0
|
||||
|
@ -224,7 +225,7 @@ func (g *tsGenerator) Generate() {
|
|||
PUSI: pusi,
|
||||
PID: VideoPid,
|
||||
RAI: pusi,
|
||||
CC: g.getCC(VideoPid),
|
||||
CC: byte(g.getCC(VideoPid)),
|
||||
AFC: byte(3),
|
||||
PCRF: pusi,
|
||||
}
|
||||
|
@ -236,9 +237,9 @@ func (g *tsGenerator) Generate() {
|
|||
sdtPkt := mpegts.MpegTsPacket{
|
||||
PUSI: pusi,
|
||||
PID: SdtPid,
|
||||
CC: g.getCC(SdtPid),
|
||||
CC: byte(g.getCC(SdtPid)),
|
||||
AFC: 1,
|
||||
Payload: SdtTable
|
||||
Payload: SdtTable,
|
||||
}
|
||||
g.tsChan <- &sdtPkt
|
||||
|
||||
|
@ -246,9 +247,9 @@ func (g *tsGenerator) Generate() {
|
|||
patPkt := mpegts.MpegTsPacket{
|
||||
PUSI: pusi,
|
||||
PID: PatPid,
|
||||
CC: g.getCC(PatPid),
|
||||
CC: byte(g.getCC(PatPid)),
|
||||
AFC: 1,
|
||||
Payload: PatTable
|
||||
Payload: PatTable,
|
||||
}
|
||||
g.tsChan <- &patPkt
|
||||
|
||||
|
@ -256,9 +257,9 @@ func (g *tsGenerator) Generate() {
|
|||
pmtPkt := mpegts.MpegTsPacket{
|
||||
PUSI: pusi,
|
||||
PID: PmtPid,
|
||||
CC: g.getCC(PmtPid)
|
||||
CC: byte(g.getCC(PmtPid)),
|
||||
AFC: 1,
|
||||
Payload: PmtTable
|
||||
Payload: PmtTable,
|
||||
}
|
||||
g.tsChan <- &pmtPkt
|
||||
pkt.PCR = g.genPcr()
|
||||
|
@ -271,9 +272,10 @@ func (g *tsGenerator) Generate() {
|
|||
}
|
||||
}
|
||||
|
||||
func (g *tsGenerator) getCC(int pid){
|
||||
func (g *tsGenerator) getCC(pid int) int {
|
||||
temp := g.ccMap[pid]
|
||||
if g.ccMap[pid]++; g.ccMap[pid] > 15 {
|
||||
g.ccMap[pid] = 0
|
||||
}
|
||||
return g.ccMap[pid]
|
||||
return temp
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue