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 // FillPayload takes a channel and fills the packets Payload field until the
// channel is empty or we've the packet reaches capacity // channel is empty or we've the packet reaches capacity
func (p *Packet) FillPayload(data []byte) int { 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) 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) return copy(p.Payload, data)
} }

View File

@ -26,9 +26,7 @@ LICENSE
package pes package pes
import () const MaxPesSize = 10000
const MaxPesLen = 10000
/* /*
The below data struct encapsulates the fields of an PES packet. Below is 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 { func (p *Packet) Bytes(buf []byte) []byte {
if buf == nil || cap(buf) != MaxPesLen { if buf == nil || cap(buf) != MaxPesSize {
buf = make([]byte, 0, MaxPesLen) buf = make([]byte, 0, MaxPesSize)
} }
buf = buf[:0] buf = buf[:0]
buf = append(buf, []byte{ 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 // addPadding adds an appropriate amount of padding to a pat or pmt table for
// addition to an mpegts packet // addition to an mpegts packet
func addPadding(d []byte) []byte { func addPadding(d []byte) []byte {
for len(d) < PktLen { for len(d) < PktSize {
d = append(d, 0xff) d = append(d, 0xff)
} }
return d return d

View File

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