Fix panic on AVCCToCodec #1652

This commit is contained in:
Alex X
2025-05-22 15:52:10 +03:00
parent 7107508286
commit ae8145f266
2 changed files with 16 additions and 5 deletions
+9 -5
View File
@@ -82,7 +82,15 @@ func AVCCToCodec(avcc []byte) *core.Codec {
buf := bytes.NewBufferString("packetization-mode=1")
for {
n := len(avcc)
if n < 4 {
break
}
size := 4 + int(binary.BigEndian.Uint32(avcc))
if n < size {
break
}
switch NALUType(avcc) {
case NALUTypeSPS:
@@ -95,11 +103,7 @@ func AVCCToCodec(avcc []byte) *core.Codec {
buf.WriteString(base64.StdEncoding.EncodeToString(avcc[4:size]))
}
if size < len(avcc) {
avcc = avcc[size:]
} else {
break
}
avcc = avcc[size:]
}
return &core.Codec{