@@ -93,57 +93,107 @@ func TestGetPayloadTypeForVP8(t *testing.T) {
93
93
94
94
func TestGetCodecForPayloadType (t * testing.T ) {
95
95
for _ , test := range []struct {
96
+ name string
97
+ SD SessionDescription
96
98
PayloadType uint8
97
99
Expected Codec
98
100
}{
99
101
{
100
- PayloadType : 120 ,
101
- Expected : Codec {
102
+ "vp8" ,
103
+ getTestSessionDescription (),
104
+ 120 ,
105
+ Codec {
102
106
PayloadType : 120 ,
103
107
Name : "VP8" ,
104
108
ClockRate : 90000 ,
105
109
Fmtp : "max-fs=12288;max-fr=60" ,
106
110
},
107
111
},
108
112
{
109
- PayloadType : 121 ,
110
- Expected : Codec {
113
+ "vp9" ,
114
+ getTestSessionDescription (),
115
+ 121 ,
116
+ Codec {
111
117
PayloadType : 121 ,
112
118
Name : "VP9" ,
113
119
ClockRate : 90000 ,
114
120
Fmtp : "max-fs=12288;max-fr=60" ,
115
121
},
116
122
},
117
123
{
118
- PayloadType : 126 ,
119
- Expected : Codec {
124
+ "h264 126" ,
125
+ getTestSessionDescription (),
126
+ 126 ,
127
+ Codec {
120
128
PayloadType : 126 ,
121
129
Name : "H264" ,
122
130
ClockRate : 90000 ,
123
131
Fmtp : "profile-level-id=42e01f;level-asymmetry-allowed=1;packetization-mode=1" ,
124
132
},
125
133
},
126
134
{
127
- PayloadType : 97 ,
128
- Expected : Codec {
135
+ "h264 97" ,
136
+ getTestSessionDescription (),
137
+ 97 ,
138
+ Codec {
129
139
PayloadType : 97 ,
130
140
Name : "H264" ,
131
141
ClockRate : 90000 ,
132
142
Fmtp : "profile-level-id=42e01f;level-asymmetry-allowed=1" ,
133
143
RTCPFeedback : []string {"ccm fir" , "nack" , "nack pli" },
134
144
},
135
145
},
146
+ {
147
+ "pcmu without rtpmap" ,
148
+ SessionDescription {
149
+ MediaDescriptions : []* MediaDescription {
150
+ {
151
+ MediaName : MediaName {
152
+ Media : "audio" ,
153
+ Protos : []string {"RTP" , "AVP" },
154
+ Formats : []string {"0" , "8" },
155
+ },
156
+ },
157
+ },
158
+ },
159
+ 0 ,
160
+ Codec {
161
+ PayloadType : 0 ,
162
+ Name : "PCMU" ,
163
+ ClockRate : 8000 ,
164
+ },
165
+ },
166
+ {
167
+ "pcma without rtpmap" ,
168
+ SessionDescription {
169
+ MediaDescriptions : []* MediaDescription {
170
+ {
171
+ MediaName : MediaName {
172
+ Media : "audio" ,
173
+ Protos : []string {"RTP" , "AVP" },
174
+ Formats : []string {"0" , "8" },
175
+ },
176
+ },
177
+ },
178
+ },
179
+ 8 ,
180
+ Codec {
181
+ PayloadType : 8 ,
182
+ Name : "PCMA" ,
183
+ ClockRate : 8000 ,
184
+ },
185
+ },
136
186
} {
137
- sd := getTestSessionDescription ()
187
+ t .Run (test .name , func (t * testing.T ) {
188
+ actual , err := test .SD .GetCodecForPayloadType (test .PayloadType )
189
+ if got , want := err , error (nil ); ! errors .Is (got , want ) {
190
+ t .Fatalf ("GetCodecForPayloadType(): err=%v, want=%v" , got , want )
191
+ }
138
192
139
- actual , err := sd .GetCodecForPayloadType (test .PayloadType )
140
- if got , want := err , error (nil ); ! errors .Is (got , want ) {
141
- t .Fatalf ("GetCodecForPayloadType(): err=%v, want=%v" , got , want )
142
- }
143
-
144
- if ! reflect .DeepEqual (actual , test .Expected ) {
145
- t .Errorf ("error:\n \n EXPECTED:\n %v\n ACTUAL:\n %v" , test .Expected , actual )
146
- }
193
+ if ! reflect .DeepEqual (actual , test .Expected ) {
194
+ t .Errorf ("error:\n \n EXPECTED:\n %v\n ACTUAL:\n %v" , test .Expected , actual )
195
+ }
196
+ })
147
197
}
148
198
}
149
199
0 commit comments