@@ -575,21 +575,71 @@ func TestMediaEngineHeaderExtensionDirection(t *testing.T) {
575
575
576
576
// If a user attempts to register a codec twice we should just discard duplicate calls.
577
577
func TestMediaEngineDoubleRegister (t * testing.T ) {
578
- mediaEngine := MediaEngine {}
578
+ t .Run ("Same Codec" , func (t * testing.T ) {
579
+ mediaEngine := MediaEngine {}
579
580
580
- assert .NoError (t , mediaEngine .RegisterCodec (
581
- RTPCodecParameters {
582
- RTPCodecCapability : RTPCodecCapability {MimeTypeOpus , 48000 , 0 , "" , nil },
583
- PayloadType : 111 ,
584
- }, RTPCodecTypeAudio ))
581
+ assert .NoError (t , mediaEngine .RegisterCodec (
582
+ RTPCodecParameters {
583
+ RTPCodecCapability : RTPCodecCapability {MimeTypeOpus , 48000 , 0 , "" , nil },
584
+ PayloadType : 111 ,
585
+ }, RTPCodecTypeAudio ))
585
586
586
- assert .NoError (t , mediaEngine .RegisterCodec (
587
- RTPCodecParameters {
588
- RTPCodecCapability : RTPCodecCapability {MimeTypeOpus , 48000 , 0 , "" , nil },
589
- PayloadType : 111 ,
590
- }, RTPCodecTypeAudio ))
587
+ assert .NoError (t , mediaEngine .RegisterCodec (
588
+ RTPCodecParameters {
589
+ RTPCodecCapability : RTPCodecCapability {MimeTypeOpus , 48000 , 0 , "" , nil },
590
+ PayloadType : 111 ,
591
+ }, RTPCodecTypeAudio ))
591
592
592
- assert .Equal (t , len (mediaEngine .audioCodecs ), 1 )
593
+ assert .Equal (t , len (mediaEngine .audioCodecs ), 1 )
594
+ })
595
+
596
+ t .Run ("Case Insensitive Audio Codec" , func (t * testing.T ) {
597
+ mediaEngine := MediaEngine {}
598
+
599
+ assert .NoError (t , mediaEngine .RegisterCodec (
600
+ RTPCodecParameters {
601
+ RTPCodecCapability : RTPCodecCapability {"audio/OPUS" , 48000 , 0 , "" , nil },
602
+ PayloadType : 111 ,
603
+ }, RTPCodecTypeAudio ))
604
+
605
+ assert .NoError (t , mediaEngine .RegisterCodec (
606
+ RTPCodecParameters {
607
+ RTPCodecCapability : RTPCodecCapability {"audio/opus" , 48000 , 0 , "" , nil },
608
+ PayloadType : 111 ,
609
+ }, RTPCodecTypeAudio ))
610
+
611
+ assert .Equal (t , len (mediaEngine .audioCodecs ), 1 )
612
+ })
613
+
614
+ t .Run ("Case Insensitive Video Codec" , func (t * testing.T ) {
615
+ mediaEngine := MediaEngine {}
616
+
617
+ assert .NoError (t , mediaEngine .RegisterCodec (
618
+ RTPCodecParameters {
619
+ RTPCodecCapability : RTPCodecCapability {strings .ToUpper (MimeTypeRTX ), 90000 , 0 , "" , nil },
620
+ PayloadType : 98 ,
621
+ }, RTPCodecTypeVideo ))
622
+ assert .NoError (t , mediaEngine .RegisterCodec (
623
+ RTPCodecParameters {
624
+ RTPCodecCapability : RTPCodecCapability {MimeTypeRTX , 90000 , 0 , "" , nil },
625
+ PayloadType : 98 ,
626
+ }, RTPCodecTypeVideo ))
627
+ assert .NoError (t , mediaEngine .RegisterCodec (
628
+ RTPCodecParameters {
629
+ RTPCodecCapability : RTPCodecCapability {strings .ToUpper (MimeTypeFlexFEC ), 90000 , 0 , "" , nil },
630
+ PayloadType : 100 ,
631
+ }, RTPCodecTypeVideo ))
632
+ assert .NoError (t , mediaEngine .RegisterCodec (
633
+ RTPCodecParameters {
634
+ RTPCodecCapability : RTPCodecCapability {MimeTypeFlexFEC , 90000 , 0 , "" , nil },
635
+ PayloadType : 100 ,
636
+ }, RTPCodecTypeVideo ))
637
+ assert .Equal (t , len (mediaEngine .videoCodecs ), 2 )
638
+ isRTX := mediaEngine .isRTXEnabled (RTPCodecTypeVideo , []RTPTransceiverDirection {RTPTransceiverDirectionRecvonly })
639
+ assert .True (t , isRTX )
640
+ isFEC := mediaEngine .isFECEnabled (RTPCodecTypeVideo , []RTPTransceiverDirection {RTPTransceiverDirectionRecvonly })
641
+ assert .True (t , isFEC )
642
+ })
593
643
}
594
644
595
645
// If a user attempts to register a codec with same payload but with different
0 commit comments