mirror of
https://github.com/livekit/livekit.git
synced 2026-09-16 06:22:36 +00:00
Validate FlexFEC payload type range
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user