Browse Source

add amf0 strict array decode

pull/3189/head
pedro 2 years ago
parent
commit
95d23b23a1
  1. 17
      internal/protocols/rtmp/amf0/unmarshal.go

17
internal/protocols/rtmp/amf0/unmarshal.go

@ -183,6 +183,23 @@ func unmarshal(buf []byte) (interface{}, []byte, error) { @@ -183,6 +183,23 @@ func unmarshal(buf []byte) (interface{}, []byte, error) {
case markerNull:
return nil, buf, nil
case markerStrictArray:
if len(buf) < 4 {
return nil, nil, errBufferTooShort
}
keyLen := uint32(buf[0])<<24 | uint32(buf[1])<<16 | uint32(buf[2])<<8 | uint32(buf[3])
buf = buf[4:]
for i := 0; i < int(keyLen); i++ {
var buffData []byte
var err error
_, buffData, err = unmarshal(buf)
if err != nil {
return nil, nil, err
}
buf = buffData
}
return nil, buf, nil
default:
return nil, nil, fmt.Errorf("unsupported marker 0x%.2x", marker)
}

Loading…
Cancel
Save