@@ -961,3 +961,158 @@ a=ssrc:4281768245 msid:6ff05509-be96-4ef1-a74f-425e14720983 16d5d7fe-d076-4718-9
961
961
assert .Len (t , mediaEngine .negotiatedVideoCodecs , 2 )
962
962
})
963
963
}
964
+
965
+ func TestAutoConfigRTXCodecs (t * testing.T ) {
966
+ for _ , test := range []struct {
967
+ Original []RTPCodecParameters
968
+ ExpectedResult []RTPCodecParameters
969
+ ExpectedError error
970
+ }{
971
+ {
972
+ // no video codec
973
+ Original : []RTPCodecParameters {
974
+ {
975
+ PayloadType : 1 ,
976
+ RTPCodecCapability : RTPCodecCapability {
977
+ MimeType : MimeTypeFlexFEC03 ,
978
+ ClockRate : 90000 ,
979
+ Channels : 0 ,
980
+ SDPFmtpLine : "repair-window=10000000" ,
981
+ RTCPFeedback : nil ,
982
+ },
983
+ },
984
+ },
985
+ ExpectedResult : []RTPCodecParameters {
986
+ {
987
+ PayloadType : 1 ,
988
+ RTPCodecCapability : RTPCodecCapability {
989
+ MimeType : MimeTypeFlexFEC03 ,
990
+ ClockRate : 90000 ,
991
+ Channels : 0 ,
992
+ SDPFmtpLine : "repair-window=10000000" ,
993
+ RTCPFeedback : nil ,
994
+ },
995
+ },
996
+ },
997
+ ExpectedError : nil ,
998
+ },
999
+ {
1000
+ // one video codec with no nack rtcp feedback
1001
+ Original : []RTPCodecParameters {
1002
+ {
1003
+ PayloadType : 1 ,
1004
+ RTPCodecCapability : RTPCodecCapability {
1005
+ MimeType : MimeTypeH265 ,
1006
+ ClockRate : 90000 ,
1007
+ Channels : 0 ,
1008
+ SDPFmtpLine : "" ,
1009
+ RTCPFeedback : nil ,
1010
+ },
1011
+ },
1012
+ },
1013
+ ExpectedResult : []RTPCodecParameters {
1014
+ {
1015
+ PayloadType : 1 ,
1016
+ RTPCodecCapability : RTPCodecCapability {
1017
+ MimeType : MimeTypeH265 ,
1018
+ ClockRate : 90000 ,
1019
+ Channels : 0 ,
1020
+ SDPFmtpLine : "" ,
1021
+ RTCPFeedback : nil ,
1022
+ },
1023
+ },
1024
+ },
1025
+ ExpectedError : nil ,
1026
+ },
1027
+ {
1028
+ // one video codec with nack and pli rtcp feedback
1029
+ Original : []RTPCodecParameters {
1030
+ {
1031
+ PayloadType : 1 ,
1032
+ RTPCodecCapability : RTPCodecCapability {
1033
+ MimeType : MimeTypeH265 ,
1034
+ ClockRate : 90000 ,
1035
+ Channels : 0 ,
1036
+ SDPFmtpLine : "" ,
1037
+ RTCPFeedback : []RTCPFeedback {
1038
+ {Type : "nack" , Parameter : "" },
1039
+ {Type : "nack" , Parameter : "pli" },
1040
+ },
1041
+ },
1042
+ },
1043
+ },
1044
+ ExpectedResult : []RTPCodecParameters {
1045
+ {
1046
+ PayloadType : 1 ,
1047
+ RTPCodecCapability : RTPCodecCapability {
1048
+ MimeType : MimeTypeH265 ,
1049
+ ClockRate : 90000 ,
1050
+ Channels : 0 ,
1051
+ SDPFmtpLine : "" ,
1052
+ RTCPFeedback : []RTCPFeedback {
1053
+ {Type : "nack" , Parameter : "" },
1054
+ {Type : "nack" , Parameter : "pli" },
1055
+ },
1056
+ },
1057
+ },
1058
+ {
1059
+ PayloadType : 2 ,
1060
+ RTPCodecCapability : RTPCodecCapability {
1061
+ MimeType : MimeTypeRTX ,
1062
+ ClockRate : 90000 ,
1063
+ Channels : 0 ,
1064
+ SDPFmtpLine : "apt=1" ,
1065
+ RTCPFeedback : nil ,
1066
+ },
1067
+ },
1068
+ },
1069
+ ExpectedError : nil ,
1070
+ },
1071
+ {
1072
+ // multiple video codec, expect error because of PayloadType collision
1073
+ Original : []RTPCodecParameters {
1074
+ {
1075
+ PayloadType : 1 ,
1076
+ RTPCodecCapability : RTPCodecCapability {
1077
+ MimeType : MimeTypeH265 ,
1078
+ ClockRate : 90000 ,
1079
+ Channels : 0 ,
1080
+ SDPFmtpLine : "" ,
1081
+ RTCPFeedback : []RTCPFeedback {
1082
+ {Type : "nack" , Parameter : "" },
1083
+ {Type : "nack" , Parameter : "pli" },
1084
+ },
1085
+ },
1086
+ },
1087
+ {
1088
+ PayloadType : 2 ,
1089
+ RTPCodecCapability : RTPCodecCapability {
1090
+ MimeType : MimeTypeVP8 ,
1091
+ ClockRate : 90000 ,
1092
+ Channels : 0 ,
1093
+ SDPFmtpLine : "" ,
1094
+ RTCPFeedback : []RTCPFeedback {
1095
+ {Type : "nack" , Parameter : "" },
1096
+ {Type : "nack" , Parameter : "pli" },
1097
+ },
1098
+ },
1099
+ },
1100
+ },
1101
+ ExpectedResult : nil ,
1102
+ ExpectedError : ErrCodecAlreadyRegistered ,
1103
+ },
1104
+ } {
1105
+ m := & MediaEngine {
1106
+ videoCodecs : test .Original ,
1107
+ }
1108
+ err := m .autoConfigRTXCodecs ()
1109
+ assert .Equal (t , err , test .ExpectedError )
1110
+ if err == nil {
1111
+ for i := range m .videoCodecs {
1112
+ // ignore for following assert
1113
+ m .videoCodecs [i ].statsID = ""
1114
+ }
1115
+ assert .Equal (t , m .videoCodecs , test .ExpectedResult )
1116
+ }
1117
+ }
1118
+ }
0 commit comments