mirror of https://bitbucket.org/ausocean/av.git
protocol/rtp: removed Len field from ExtensionHeader struct as we can gather from len(ExtensionHeader.Header)
This commit is contained in:
parent
95a9e4a2ef
commit
efa0d38aad
|
@ -64,7 +64,6 @@ type Pkt struct {
|
||||||
// ExtensionHeader header provides fields for an RTP packet extension header.
|
// ExtensionHeader header provides fields for an RTP packet extension header.
|
||||||
type ExtensionHeader struct {
|
type ExtensionHeader struct {
|
||||||
ID uint16
|
ID uint16
|
||||||
Len uint16
|
|
||||||
Header [][4]byte
|
Header [][4]byte
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,10 +72,7 @@ func (p *Pkt) Bytes(buf []byte) []byte {
|
||||||
// Calculate the required length for the RTP packet.
|
// Calculate the required length for the RTP packet.
|
||||||
headerExtensionLen := 0
|
headerExtensionLen := 0
|
||||||
if p.X {
|
if p.X {
|
||||||
if p.Extension.Len != uint16(len(p.Extension.Header)) {
|
headerExtensionLen = int(4 + 4*len(p.Extension.Header))
|
||||||
panic("bad rtp packet extension length field")
|
|
||||||
}
|
|
||||||
headerExtensionLen = int(4 + 4*p.Extension.Len)
|
|
||||||
}
|
}
|
||||||
requiredPktLen := defaultHeadSize + uint8(4*p.CC) + uint8(headerExtensionLen) + uint8(len(p.Payload)) + uint8(len(p.Padding))
|
requiredPktLen := defaultHeadSize + uint8(4*p.CC) + uint8(headerExtensionLen) + uint8(len(p.Payload)) + uint8(len(p.Padding))
|
||||||
|
|
||||||
|
@ -110,12 +106,12 @@ func (p *Pkt) Bytes(buf []byte) []byte {
|
||||||
if p.X {
|
if p.X {
|
||||||
binary.BigEndian.PutUint16(buf[idx:idx+2], p.Extension.ID)
|
binary.BigEndian.PutUint16(buf[idx:idx+2], p.Extension.ID)
|
||||||
idx += 2
|
idx += 2
|
||||||
binary.BigEndian.PutUint16(buf[idx:idx+2], p.Extension.Len)
|
binary.BigEndian.PutUint16(buf[idx:idx+2], uint16(len(p.Extension.Header)))
|
||||||
idx += 2
|
idx += 2
|
||||||
for i := 0; i < int(p.Extension.Len); i++ {
|
for i := 0; i < len(p.Extension.Header); i++ {
|
||||||
copy(buf[idx+i*4:], p.Extension.Header[i][:])
|
copy(buf[idx+i*4:], p.Extension.Header[i][:])
|
||||||
}
|
}
|
||||||
idx += int(p.Extension.Len * 4)
|
idx += len(p.Extension.Header) * 4
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there is payload, add to the buffer.
|
// If there is payload, add to the buffer.
|
||||||
|
|
|
@ -156,8 +156,7 @@ var rtpTests = []struct {
|
||||||
{0x05, 0x06, 0x07, 0x08},
|
{0x05, 0x06, 0x07, 0x08},
|
||||||
},
|
},
|
||||||
Extension: ExtensionHeader{
|
Extension: ExtensionHeader{
|
||||||
ID: 15,
|
ID: 15,
|
||||||
Len: 2,
|
|
||||||
Header: [][4]byte{
|
Header: [][4]byte{
|
||||||
{0x01, 0x02, 0x03, 0x04},
|
{0x01, 0x02, 0x03, 0x04},
|
||||||
{0x05, 0x06, 0x07, 0x08},
|
{0x05, 0x06, 0x07, 0x08},
|
||||||
|
|
Loading…
Reference in New Issue