mts: removed usage of word len, and removed empty import

This commit is contained in:
saxon 2019-01-02 10:26:34 +10:30
parent 52b8f7bf54
commit 692f5772a1
4 changed files with 7 additions and 9 deletions

View File

@ -146,9 +146,9 @@ func FindPMT(d []byte) (p []byte, err error) {
// FillPayload takes a channel and fills the packets Payload field until the
// channel is empty or we've the packet reaches capacity
func (p *Packet) FillPayload(data []byte) int {
currentPktSizegth := 6 + asInt(p.PCRF)*6 + asInt(p.OPCRF)*6 +
currentPktLen := 6 + asInt(p.PCRF)*6 + asInt(p.OPCRF)*6 +
asInt(p.SPF)*1 + asInt(p.TPDF)*1 + len(p.TPD)
p.Payload = make([]byte, PayloadSize-currentPktSizegth)
p.Payload = make([]byte, PayloadSize-currentPktLen)
return copy(p.Payload, data)
}

View File

@ -26,9 +26,7 @@ LICENSE
package pes
import ()
const MaxPesLen = 10000
const MaxPesSize = 10000
/*
The below data struct encapsulates the fields of an PES packet. Below is
@ -95,8 +93,8 @@ type Packet struct {
}
func (p *Packet) Bytes(buf []byte) []byte {
if buf == nil || cap(buf) != MaxPesLen {
buf = make([]byte, 0, MaxPesLen)
if buf == nil || cap(buf) != MaxPesSize {
buf = make([]byte, 0, MaxPesSize)
}
buf = buf[:0]
buf = append(buf, []byte{

View File

@ -147,7 +147,7 @@ func updateCrc(out []byte) []byte {
// addPadding adds an appropriate amount of padding to a pat or pmt table for
// addition to an mpegts packet
func addPadding(d []byte) []byte {
for len(d) < PktLen {
for len(d) < PktSize {
d = append(d, 0xff)
}
return d

View File

@ -32,7 +32,7 @@ import (
// Misc consts
const (
PktLen = 184
PktSize = 184
)
// Lengths of section definitions