mirror of https://bitbucket.org/ausocean/av.git
mts: PktSize to PacketSize
This commit is contained in:
parent
010abcfd0c
commit
46f5ffd6f2
|
@ -196,7 +196,7 @@ type Encoder struct {
|
|||
clock time.Duration
|
||||
frameInterval time.Duration
|
||||
ptsOffset time.Duration
|
||||
tsSpace [PktSize]byte
|
||||
tsSpace [PacketSize]byte
|
||||
pesSpace [pes.MaxPesSize]byte
|
||||
|
||||
psiCount int
|
||||
|
@ -269,7 +269,7 @@ func (e *Encoder) Encode(nalu []byte) error {
|
|||
}
|
||||
}
|
||||
e.psiCount--
|
||||
_, err := e.dst.Write(pkt.Bytes(e.tsSpace[:PktSize]))
|
||||
_, err := e.dst.Write(pkt.Bytes(e.tsSpace[:PacketSize]))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -291,7 +291,7 @@ func (e *Encoder) writePSI() error {
|
|||
AFC: hasPayload,
|
||||
Payload: patTable,
|
||||
}
|
||||
_, err := e.dst.Write(patPkt.Bytes(e.tsSpace[:PktSize]))
|
||||
_, err := e.dst.Write(patPkt.Bytes(e.tsSpace[:PacketSize]))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -314,7 +314,7 @@ func (e *Encoder) writePSI() error {
|
|||
AFC: hasPayload,
|
||||
Payload: pmtTable,
|
||||
}
|
||||
_, err = e.dst.Write(pmtPkt.Bytes(e.tsSpace[:PktSize]))
|
||||
_, err = e.dst.Write(pmtPkt.Bytes(e.tsSpace[:PacketSize]))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
PktSize = 188
|
||||
PacketSize = 188
|
||||
PayloadSize = 176
|
||||
)
|
||||
|
||||
|
@ -130,13 +130,13 @@ type Packet struct {
|
|||
// FindPMT will take a clip of mpegts and try to find a PMT table - if one
|
||||
// is found, then it is returned, otherwise nil and an error is returned.
|
||||
func FindPMT(d []byte) (p []byte, err error) {
|
||||
if len(d) < PktSize {
|
||||
if len(d) < PacketSize {
|
||||
return nil, errors.New("Mmpegts data not of valid length")
|
||||
}
|
||||
for i := 0; i < len(d); i += PktSize {
|
||||
for i := 0; i < len(d); i += PacketSize {
|
||||
pid := (uint16(d[i+1]&0x1f) << 8) | uint16(d[i+2])
|
||||
if pid == pmtPid {
|
||||
p = d[i+4 : i+PktSize]
|
||||
p = d[i+4 : i+PacketSize]
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -169,8 +169,8 @@ func asByte(b bool) byte {
|
|||
// ToByteSlice interprets the fields of the ts packet instance and outputs a
|
||||
// corresponding byte slice
|
||||
func (p *Packet) Bytes(buf []byte) []byte {
|
||||
if buf == nil || cap(buf) != PktSize {
|
||||
buf = make([]byte, 0, PktSize)
|
||||
if buf == nil || cap(buf) != PacketSize {
|
||||
buf = make([]byte, 0, PacketSize)
|
||||
}
|
||||
buf = buf[:0]
|
||||
stuffingLength := 182 - len(p.Payload) - len(p.TPD) - asInt(p.PCRF)*6 -
|
||||
|
|
Loading…
Reference in New Issue