@@ -20,7 +20,13 @@ defmodule ExWebRTC.PeerConnection.ConfigurationTest do
20
20
@ h264_codec % RTPCodecParameters {
21
21
payload_type: @ payload_type ,
22
22
mime_type: "video/H264" ,
23
- clock_rate: 90_000
23
+ clock_rate: 90_000 ,
24
+ sdp_fmtp_line: % FMTP {
25
+ pt: @ payload_type ,
26
+ level_asymmetry_allowed: true ,
27
+ packetization_mode: 1 ,
28
+ profile_level_id: 0x42E01F
29
+ }
24
30
}
25
31
26
32
@ vp8_codec % RTPCodecParameters {
@@ -35,6 +41,13 @@ defmodule ExWebRTC.PeerConnection.ConfigurationTest do
35
41
clock_rate: 90_000
36
42
}
37
43
44
+ @ av1_codec % RTPCodecParameters {
45
+ payload_type: @ payload_type ,
46
+ mime_type: "video/AV1" ,
47
+ clock_rate: 90_000 ,
48
+ sdp_fmtp_line: % FMTP { pt: @ payload_type , level_idx: 5 , profile: 0 , tier: 0 }
49
+ }
50
+
38
51
@ rtx % RTPCodecParameters {
39
52
payload_type: @ payload_type ,
40
53
mime_type: "video/rtx" ,
@@ -265,13 +278,19 @@ defmodule ExWebRTC.PeerConnection.ConfigurationTest do
265
278
audio_codecs: [ % { @ opus_codec | payload_type: 111 } ]
266
279
)
267
280
281
+ # opus should change its payload type as it is defined without fmtp, hence every fmtp from sdp is accepted
282
+ # h264 should have payload type 112 as this is the one that has the same fmtp
268
283
sdp =
269
284
"""
270
- m=audio 9 UDP/TLS/RTP/SAVPF 0
285
+ m=audio 9 UDP/TLS/RTP/SAVPF 115
271
286
a=rtpmap:115 opus/48000/2
272
- m=video 9 UDP/TLS/RTP/SAVPF 1
287
+ a=fmtp:111 minptime=10;maxaveragebitrate=96000;stereo=1;sprop-stereo=1;useinbandfec=1
288
+ m=video 9 UDP/TLS/RTP/SAVPF 100 111 112
273
289
a=rtpmap:100 VP8/90000
274
290
a=rtpmap:111 H264/90000
291
+ a=fmtp:111 profile-level-id=42e01f;packetization-mode=0;level-asymmetry-allowed=1
292
+ a=rtpmap:112 H264/90000
293
+ a=fmtp:112 profile-level-id=42e01f;packetization-mode=1;level-asymmetry-allowed=1
275
294
"""
276
295
|> ExSDP . parse! ( )
277
296
@@ -280,7 +299,7 @@ defmodule ExWebRTC.PeerConnection.ConfigurationTest do
280
299
assert % Configuration {
281
300
audio_codecs: [ % RTPCodecParameters { payload_type: 115 } ] ,
282
301
video_codecs: [
283
- % RTPCodecParameters { payload_type: 111 } ,
302
+ % RTPCodecParameters { payload_type: 112 } ,
284
303
% RTPCodecParameters { payload_type: 100 }
285
304
]
286
305
} = config
@@ -297,19 +316,27 @@ defmodule ExWebRTC.PeerConnection.ConfigurationTest do
297
316
% { @ rtx | payload_type: 111 , sdp_fmtp_line: % FMTP { pt: 111 , apt: 94 } } ,
298
317
% { @ vp8_codec | payload_type: 96 } ,
299
318
% { @ rtx | payload_type: 100 , sdp_fmtp_line: % FMTP { pt: 100 , apt: 96 } } ,
300
- % { @ vp9_codec | payload_type: 108 }
319
+ % { @ vp9_codec | payload_type: 108 } ,
320
+ % { @ av1_codec | payload_type: 102 } ,
321
+ % { @ rtx | payload_type: 113 , sdp_fmtp_line: % FMTP { pt: 113 , apt: 102 } }
301
322
]
302
323
)
303
324
304
- # h264 and its rtx both should change pt
325
+ # h264 and its rtx both should change pt (but to the second h264 from sdp as this is the one with matching fmtp)
305
326
# vp8 should stay as it is but its rtx should change pt as it conflicts with the new h264
306
327
# vp9 should just change pt
328
+ # av1 should stay as it is but its rtx should change pt as it conflicts with the second h264's rtx from sdp
307
329
sdp =
308
330
"""
309
- m=audio 9 UDP/TLS/RTP/SAVPF 0
331
+ m=audio 9 UDP/TLS/RTP/SAVPF 115
310
332
a=rtpmap:115 opus/48000/2
311
- m=video 9 UDP/TLS/RTP/SAVPF 1
333
+ m=video 9 UDP/TLS/RTP/SAVPF 112 113 100 101 96 110 111
334
+ a=rtpmap:112 H264/90000
335
+ a=fmtp:112 profile-level-id=42e01f;packetization-mode=0;level-asymmetry-allowed=1
336
+ a=rtpmap:113 rtx/90000
337
+ a=fmtp:113 apt=112
312
338
a=rtpmap:100 H264/90000
339
+ a=fmtp:100 profile-level-id=42e01f;packetization-mode=1;level-asymmetry-allowed=1
313
340
a=rtpmap:101 rtx/90000
314
341
a=fmtp:101 apt=100
315
342
a=rtpmap:96 VP8/90000
@@ -326,15 +353,25 @@ defmodule ExWebRTC.PeerConnection.ConfigurationTest do
326
353
video_codecs: video_codecs
327
354
} = config
328
355
329
- [ h264 , vp8 , vp9 ] = Enum . reject ( video_codecs , & String . ends_with? ( & 1 . mime_type , "/rtx" ) )
356
+ [ h264 , vp8 , vp9 , av1 ] = Enum . reject ( video_codecs , & String . ends_with? ( & 1 . mime_type , "/rtx" ) )
330
357
assert % { mime_type: "video/H264" , payload_type: 100 } = h264
331
358
assert % { mime_type: "video/VP8" , payload_type: 96 } = vp8
332
359
assert % { mime_type: "video/VP9" , payload_type: 110 } = vp9
360
+ assert % { mime_type: "video/AV1" , payload_type: 102 } = av1
361
+
362
+ [ h264_rtx , vp8_rtx , av1_rtx ] =
363
+ Enum . filter ( video_codecs , & String . ends_with? ( & 1 . mime_type , "/rtx" ) )
333
364
334
- [ h264_rtx , vp8_rtx ] = Enum . filter ( video_codecs , & String . ends_with? ( & 1 . mime_type , "/rtx" ) )
335
365
assert % { mime_type: "video/rtx" , payload_type: 101 , sdp_fmtp_line: % { apt: 100 } } = h264_rtx
336
- assert % { mime_type: "video/rtx" , payload_type: pt , sdp_fmtp_line: % { apt: 96 } } = vp8_rtx
337
- assert pt not in [ 100 , 101 , 96 , 110 ]
366
+
367
+ assert % { mime_type: "video/rtx" , payload_type: vp8_rtx_pt , sdp_fmtp_line: % { apt: 96 } } =
368
+ vp8_rtx
369
+
370
+ assert % { mime_type: "video/rtx" , payload_type: av1_rtx_pt , sdp_fmtp_line: % { apt: 102 } } =
371
+ av1_rtx
372
+
373
+ assert vp8_rtx_pt not in [ 100 , 101 , 112 , 113 , 96 , 110 , 111 ]
374
+ assert av1_rtx_pt not in [ 100 , 101 , 112 , 113 , 96 , 110 , 111 ]
338
375
end
339
376
340
377
test "does not update anything, when there are no common codecs" do
@@ -367,65 +404,6 @@ defmodule ExWebRTC.PeerConnection.ConfigurationTest do
367
404
String . ends_with? ( codec . mime_type , "/rtx" )
368
405
end )
369
406
end
370
-
371
- test "does not update codec payload type when FMTP does not match" do
372
- h264_codec = % RTPCodecParameters {
373
- payload_type: 98 ,
374
- mime_type: "video/H264" ,
375
- clock_rate: 90_000 ,
376
- sdp_fmtp_line: % FMTP {
377
- pt: 98 ,
378
- level_asymmetry_allowed: true ,
379
- packetization_mode: 1 ,
380
- profile_level_id: 0x42E01F
381
- }
382
- }
383
-
384
- og_config =
385
- Configuration . from_options! (
386
- controlling_process: self ( ) ,
387
- video_codecs: [ h264_codec ]
388
- )
389
-
390
- # packetization mode in fmtp differs
391
- sdp =
392
- """
393
- m=video 58712 UDP/TLS/RTP/SAVPF 127
394
- a=rtpmap:127 H264/90000
395
- a=rtcp-fb:127 nack
396
- a=rtcp-fb:127 nack pli
397
- a=fmtp:127 profile-level-id=42e01f;packetization-mode=0;level-asymmetry-allowed=1
398
- """
399
- |> ExSDP . parse! ( )
400
-
401
- assert Configuration . update ( og_config , sdp ) == og_config
402
- end
403
-
404
- test "updates codec payload type when there is no local FMTP" do
405
- og_config =
406
- Configuration . from_options! ( controlling_process: self ( ) , video_codecs: [ @ h264_codec ] )
407
-
408
- assert @ h264_codec . sdp_fmtp_line == nil
409
- assert @ h264_codec . payload_type != 96
410
-
411
- sdp =
412
- """
413
- m=video 58712 UDP/TLS/RTP/SAVPF 96
414
- a=rtpmap:96 H264/90000
415
- a=rtcp-fb:96 nack
416
- a=rtcp-fb:96 nack pli
417
- a=fmtp:96 profile-level-id=42e01f;packetization-mode=0;level-asymmetry-allowed=1
418
- """
419
- |> ExSDP . parse! ( )
420
-
421
- config = Configuration . update ( og_config , sdp )
422
-
423
- assert [ h264 , rtx ] = config . video_codecs
424
- assert h264 . payload_type == 96
425
- assert h264 . sdp_fmtp_line == nil
426
- assert rtx . payload_type != 96
427
- assert rtx . sdp_fmtp_line . apt == 96
428
- end
429
407
end
430
408
431
409
test "intersect_codecs/2" do
@@ -440,15 +418,20 @@ defmodule ExWebRTC.PeerConnection.ConfigurationTest do
440
418
441
419
sdp =
442
420
"""
443
- m=audio 9 UDP/TLS/RTP/SAVPF 0
421
+ m=audio 9 UDP/TLS/RTP/SAVPF 111
444
422
a=rtpmap:111 opus/48000/2
445
423
a=rtcp-fb:111 transport-cc
446
- m=video 9 UDP/TLS/RTP/SAVPF 1
424
+ m=video 9 UDP/TLS/RTP/SAVPF 112 115 120 121 113 117 119
447
425
a=rtpmap:112 H264/90000
448
- a=rtcp-fb:112 transport-cc
449
- a=rtcp-fb:112 nack pli
426
+ a=fmtp:112 profile-level-id=42e01f;packetization-mode=0;level-asymmetry-allowed=1
450
427
a=rtpmap:115 rtx/90000
451
428
a=fmtp:115 apt=112
429
+ a=rtpmap:120 H264/90000
430
+ a=fmtp:120 profile-level-id=42e01f;packetization-mode=1;level-asymmetry-allowed=1
431
+ a=rtcp-fb:120 transport-cc
432
+ a=rtcp-fb:120 nack pli
433
+ a=rtpmap:121 rtx/90000
434
+ a=fmtp:121 apt=120
452
435
a=rtpmap:113 VP8/90000
453
436
a=rtcp-fb:113 transport-cc
454
437
a=rtpmap:117 VP9/90000
@@ -477,15 +460,15 @@ defmodule ExWebRTC.PeerConnection.ConfigurationTest do
477
460
478
461
assert % RTPCodecParameters {
479
462
mime_type: "video/H264" ,
480
- payload_type: 112 ,
481
- rtcp_fbs: [ % RTCPFeedback { pt: 112 , feedback_type: :pli } ]
463
+ payload_type: 120 ,
464
+ rtcp_fbs: [ % RTCPFeedback { pt: 120 , feedback_type: :pli } ]
482
465
} = h264
483
466
484
467
assert % RTPCodecParameters {
485
468
mime_type: "video/rtx" ,
486
- payload_type: 115 ,
469
+ payload_type: 121 ,
487
470
rtcp_fbs: [ ] ,
488
- sdp_fmtp_line: % FMTP { pt: 115 , apt: 112 }
471
+ sdp_fmtp_line: % FMTP { pt: 121 , apt: 120 }
489
472
} = h264_rtx
490
473
end
491
474
@@ -507,6 +490,7 @@ defmodule ExWebRTC.PeerConnection.ConfigurationTest do
507
490
a=extmap:5 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01
508
491
a=extmap:10 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id
509
492
a=rtpmap:112 H264/90000
493
+ a=fmtp:112 profile-level-id=42e01f;packetization-mode=1;level-asymmetry-allowed=1
510
494
"""
511
495
|> ExSDP . parse! ( )
512
496
0 commit comments