diff --git a/stream/rtp/rtp.go b/stream/rtp/rtp.go index b9234b0f..fa62d9fb 100644 --- a/stream/rtp/rtp.go +++ b/stream/rtp/rtp.go @@ -45,7 +45,7 @@ type Pkt struct { TS uint32 // Timestamp SSRC uint32 // Synchronisation source identifier Payload []byte // H264 Payload data - Padding int // No of bytes of padding + Padding byte // No of bytes of padding } func (p *Pkt) Bytes() []byte { @@ -72,7 +72,7 @@ func (p *Pkt) Bytes() []byte { } const headSize = 3 * 4 // bytes - buf := make([]byte, headSize, headSize+len(p.Payload)+p.Padding) + buf := make([]byte, headSize, headSize+len(p.Payload)+int(p.Padding)) buf[0] = p.V<<6 | p.P<<5 | p.CC buf[1] = p.M<<7 | p.PT @@ -89,7 +89,8 @@ func (p *Pkt) Bytes() []byte { buf = append(buf, p.Payload...) if p.Padding != 0 { - buf = append(buf, append(make([]byte, p.Padding-1, p.Padding), byte(p.Padding))...) + buf = buf[:cap(buf)] + buf[len(buf)-1] = byte(p.Padding) } return buf }