Validate FlexFEC payload type range

This commit is contained in:
David Chen
2026-08-28 20:27:11 -07:00
parent 5764461ec3
commit d1e39735e2
2 changed files with 8 additions and 0 deletions
+4
View File
@@ -53,6 +53,10 @@ func isFlexFEC03MimeType(mimeType string) bool {
// validateFlexFECPayloadType ensures the configured flexfec payload type does
// not collide with any known codec payload type or its RTX (pt+1) slot.
func validateFlexFECPayloadType(payloadType uint8) error {
if payloadType > 127 {
return fmt.Errorf("flexfec payload type %d is outside the RTP payload type range 0-127", payloadType)
}
pt := webrtc.PayloadType(payloadType)
for _, codec := range protoCodecs.VideoCodecsParameters {
if pt == codec.PayloadType || pt == codec.PayloadType+1 {
+4
View File
@@ -78,6 +78,10 @@ a=ssrc:1111 cname:test
func TestFlexFECPayloadTypeValidation(t *testing.T) {
assert.NoError(t, validateFlexFECPayloadType(115))
// upper boundary of the 7-bit RTP payload type field
assert.NoError(t, validateFlexFECPayloadType(127))
assert.Error(t, validateFlexFECPayloadType(128))
assert.Error(t, validateFlexFECPayloadType(255))
// VP8 payload type
assert.Error(t, validateFlexFECPayloadType(96))
// RTX slot of VP8 (pt+1)