mirror of https://bitbucket.org/ausocean/av.git
rtp: simplified addition of padding to rtp packet
This commit is contained in:
parent
f4d44e0c79
commit
6f1515cc46
|
@ -45,7 +45,7 @@ type Pkt struct {
|
||||||
TS uint32 // Timestamp
|
TS uint32 // Timestamp
|
||||||
SSRC uint32 // Synchronisation source identifier
|
SSRC uint32 // Synchronisation source identifier
|
||||||
Payload []byte // H264 Payload data
|
Payload []byte // H264 Payload data
|
||||||
Padding int // No of bytes of padding
|
Padding byte // No of bytes of padding
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Pkt) Bytes() []byte {
|
func (p *Pkt) Bytes() []byte {
|
||||||
|
@ -72,7 +72,7 @@ func (p *Pkt) Bytes() []byte {
|
||||||
}
|
}
|
||||||
|
|
||||||
const headSize = 3 * 4 // bytes
|
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[0] = p.V<<6 | p.P<<5 | p.CC
|
||||||
buf[1] = p.M<<7 | p.PT
|
buf[1] = p.M<<7 | p.PT
|
||||||
|
@ -89,7 +89,8 @@ func (p *Pkt) Bytes() []byte {
|
||||||
|
|
||||||
buf = append(buf, p.Payload...)
|
buf = append(buf, p.Payload...)
|
||||||
if p.Padding != 0 {
|
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
|
return buf
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue