rtp: using 'size' instead of 'len'

This commit is contained in:
saxon 2019-01-02 10:32:48 +10:30
parent 037b511330
commit d5b6e91892
2 changed files with 9 additions and 9 deletions

View File

@ -53,7 +53,7 @@ type Encoder struct {
frameInterval time.Duration
fps int
buffer []byte
pktSpace [defPktLen]byte
pktSpace [defPktSize]byte
}
// NewEncoder returns a new Encoder type given an io.Writer - the destination
@ -94,7 +94,7 @@ func (e *Encoder) Encode(payload []byte) error {
Payload: payload,
Padding: no,
}
_, err := e.dst.Write(pkt.Bytes(e.pktSpace[:defPktLen]))
_, err := e.dst.Write(pkt.Bytes(e.pktSpace[:defPktSize]))
if err != nil {
return err
}

View File

@ -33,10 +33,10 @@ for rtp-h264 and rtp standards.
package rtp
const (
rtpVer = 2
headLen = 3 * 4
defPayloadLen = 7 * 188
defPktLen = headLen + defPayloadLen
rtpVer = 2
headSize = 3 * 4
defPayloadSize = 7 * 188
defPktSize = headSize + defPayloadSize
)
// Pkt provides fields consistent with RFC3550 definition of an rtp packet
@ -57,10 +57,10 @@ type Pkt struct {
// Bytes provides a byte slice of the packet
func (p *Pkt) Bytes(buf []byte) []byte {
if buf == nil || len(buf) != defPktLen {
buf = make([]byte, headLen, defPktLen)
if buf == nil || len(buf) != defPktSize {
buf = make([]byte, headSize, defPktSize)
}
buf = buf[:headLen]
buf = buf[:headSize]
if p.V == 0 {
p.V = rtpVer
}