@@ -127,11 +127,11 @@ func TestSDPMediaAnswer(t *testing.T) {
127
127
name : "default" ,
128
128
offer : sdp.MediaDescription {
129
129
MediaName : sdp.MediaName {
130
- Formats : []string {"0 " , "9 " , "8" , "101" },
130
+ Formats : []string {"9 " , "0 " , "8" , "101" },
131
131
},
132
132
Attributes : []sdp.Attribute {
133
- {Key : "rtpmap" , Value : "0 PCMU/8000" },
134
133
{Key : "rtpmap" , Value : "9 G722/8000" },
134
+ {Key : "rtpmap" , Value : "0 PCMU/8000" },
135
135
{Key : "rtpmap" , Value : "101 telephone-event/8000" },
136
136
},
137
137
},
@@ -145,11 +145,11 @@ func TestSDPMediaAnswer(t *testing.T) {
145
145
name : "lowercase" ,
146
146
offer : sdp.MediaDescription {
147
147
MediaName : sdp.MediaName {
148
- Formats : []string {"0 " , "9 " , "101" },
148
+ Formats : []string {"9 " , "0 " , "101" },
149
149
},
150
150
Attributes : []sdp.Attribute {
151
- {Key : "rtpmap" , Value : "0 pcmu/8000" },
152
151
{Key : "rtpmap" , Value : "9 g722/8000" },
152
+ {Key : "rtpmap" , Value : "0 pcmu/8000" },
153
153
{Key : "rtpmap" , Value : "101 telephone-event/8000" },
154
154
},
155
155
},
@@ -163,11 +163,11 @@ func TestSDPMediaAnswer(t *testing.T) {
163
163
name : "no dtmf" ,
164
164
offer : sdp.MediaDescription {
165
165
MediaName : sdp.MediaName {
166
- Formats : []string {"0 " , "9 " },
166
+ Formats : []string {"9 " , "0 " },
167
167
},
168
168
Attributes : []sdp.Attribute {
169
- {Key : "rtpmap" , Value : "0 PCMU/8000" },
170
169
{Key : "rtpmap" , Value : "9 G722/8000" },
170
+ {Key : "rtpmap" , Value : "0 PCMU/8000" },
171
171
},
172
172
},
173
173
exp : & AudioConfig {
@@ -179,11 +179,11 @@ func TestSDPMediaAnswer(t *testing.T) {
179
179
name : "custom dtmf" ,
180
180
offer : sdp.MediaDescription {
181
181
MediaName : sdp.MediaName {
182
- Formats : []string {"0 " , "9 " , "103" },
182
+ Formats : []string {"9 " , "0 " , "103" },
183
183
},
184
184
Attributes : []sdp.Attribute {
185
- {Key : "rtpmap" , Value : "0 PCMU/8000" },
186
185
{Key : "rtpmap" , Value : "9 G722/8000" },
186
+ {Key : "rtpmap" , Value : "0 PCMU/8000" },
187
187
{Key : "rtpmap" , Value : "103 telephone-event/8000" },
188
188
},
189
189
},
@@ -270,13 +270,45 @@ func TestSDPMediaAnswer(t *testing.T) {
270
270
DTMFType : 101 ,
271
271
},
272
272
},
273
+ {
274
+ name : "changed order" ,
275
+ offer : sdp.MediaDescription {
276
+ MediaName : sdp.MediaName {
277
+ Formats : []string {"0" , "9" },
278
+ },
279
+ Attributes : []sdp.Attribute {
280
+ {Key : "rtpmap" , Value : "0 PCMU/8000" },
281
+ {Key : "rtpmap" , Value : "9 G722/8000" },
282
+ },
283
+ },
284
+ exp : & AudioConfig {
285
+ Codec : getCodec (g711 .ULawSDPName ),
286
+ Type : 0 ,
287
+ },
288
+ },
289
+ {
290
+ name : "changed order g711" ,
291
+ offer : sdp.MediaDescription {
292
+ MediaName : sdp.MediaName {
293
+ Formats : []string {"8" , "0" },
294
+ },
295
+ Attributes : []sdp.Attribute {
296
+ {Key : "rtpmap" , Value : "8 PCMA/8000" },
297
+ {Key : "rtpmap" , Value : "0 PCMU/8000" },
298
+ },
299
+ },
300
+ exp : & AudioConfig {
301
+ Codec : getCodec (g711 .ALawSDPName ),
302
+ Type : 8 ,
303
+ },
304
+ },
273
305
}
274
306
for _ , c := range cases {
275
307
c := c
276
308
t .Run (c .name , func (t * testing.T ) {
277
309
m , err := ParseMedia (& c .offer )
278
310
require .NoError (t , err )
279
- got , err := SelectAudio (* m )
311
+ got , err := SelectAudio (* m , true )
280
312
if c .exp == nil {
281
313
require .Error (t , err )
282
314
return
0 commit comments