Browse Source

add amf0 long string decode

pull/3189/head
pedro 2 years ago
parent
commit
31f83019d4
  1. 12
      internal/protocols/rtmp/amf0/unmarshal.go

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

@ -200,6 +200,18 @@ func unmarshal(buf []byte) (interface{}, []byte, error) { @@ -200,6 +200,18 @@ func unmarshal(buf []byte) (interface{}, []byte, error) {
}
return nil, buf, nil
case markerLongString:
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:]
if len(buf) < int(keyLen) {
return nil, nil, errBufferTooShort
}
return string(buf[:keyLen]), buf[keyLen:], nil
default:
return nil, nil, fmt.Errorf("unsupported marker 0x%.2x", marker)
}

Loading…
Cancel
Save