@@ -127,11 +127,11 @@ func TestSDPMediaAnswer(t *testing.T) {
127127 name : "default" ,
128128 offer : sdp.MediaDescription {
129129 MediaName : sdp.MediaName {
130- Formats : []string {"0 " , "9 " , "8" , "101" },
130+ Formats : []string {"9 " , "0 " , "8" , "101" },
131131 },
132132 Attributes : []sdp.Attribute {
133- {Key : "rtpmap" , Value : "0 PCMU/8000" },
134133 {Key : "rtpmap" , Value : "9 G722/8000" },
134+ {Key : "rtpmap" , Value : "0 PCMU/8000" },
135135 {Key : "rtpmap" , Value : "101 telephone-event/8000" },
136136 },
137137 },
@@ -145,11 +145,11 @@ func TestSDPMediaAnswer(t *testing.T) {
145145 name : "lowercase" ,
146146 offer : sdp.MediaDescription {
147147 MediaName : sdp.MediaName {
148- Formats : []string {"0 " , "9 " , "101" },
148+ Formats : []string {"9 " , "0 " , "101" },
149149 },
150150 Attributes : []sdp.Attribute {
151- {Key : "rtpmap" , Value : "0 pcmu/8000" },
152151 {Key : "rtpmap" , Value : "9 g722/8000" },
152+ {Key : "rtpmap" , Value : "0 pcmu/8000" },
153153 {Key : "rtpmap" , Value : "101 telephone-event/8000" },
154154 },
155155 },
@@ -163,11 +163,11 @@ func TestSDPMediaAnswer(t *testing.T) {
163163 name : "no dtmf" ,
164164 offer : sdp.MediaDescription {
165165 MediaName : sdp.MediaName {
166- Formats : []string {"0 " , "9 " },
166+ Formats : []string {"9 " , "0 " },
167167 },
168168 Attributes : []sdp.Attribute {
169- {Key : "rtpmap" , Value : "0 PCMU/8000" },
170169 {Key : "rtpmap" , Value : "9 G722/8000" },
170+ {Key : "rtpmap" , Value : "0 PCMU/8000" },
171171 },
172172 },
173173 exp : & AudioConfig {
@@ -179,11 +179,11 @@ func TestSDPMediaAnswer(t *testing.T) {
179179 name : "custom dtmf" ,
180180 offer : sdp.MediaDescription {
181181 MediaName : sdp.MediaName {
182- Formats : []string {"0 " , "9 " , "103" },
182+ Formats : []string {"9 " , "0 " , "103" },
183183 },
184184 Attributes : []sdp.Attribute {
185- {Key : "rtpmap" , Value : "0 PCMU/8000" },
186185 {Key : "rtpmap" , Value : "9 G722/8000" },
186+ {Key : "rtpmap" , Value : "0 PCMU/8000" },
187187 {Key : "rtpmap" , Value : "103 telephone-event/8000" },
188188 },
189189 },
@@ -270,13 +270,45 @@ func TestSDPMediaAnswer(t *testing.T) {
270270 DTMFType : 101 ,
271271 },
272272 },
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+ },
273305 }
274306 for _ , c := range cases {
275307 c := c
276308 t .Run (c .name , func (t * testing.T ) {
277309 m , err := ParseMedia (& c .offer )
278310 require .NoError (t , err )
279- got , err := SelectAudio (* m )
311+ got , err := SelectAudio (* m , true )
280312 if c .exp == nil {
281313 require .Error (t , err )
282314 return
0 commit comments