|
9 | 9 | // BSD 3-Clause "New" or "Revised" License, see included LICENSE.md file.
|
10 | 10 | //-----------------------------------------------------------------------------
|
11 | 11 |
|
| 12 | +using System.Collections.Generic; |
12 | 13 | using System.Diagnostics;
|
13 | 14 | using System.Linq;
|
14 | 15 | using System.Net;
|
@@ -1280,5 +1281,34 @@ public void AnnoucementMediaCheckTest()
|
1280 | 1281 | Assert.Equal("text/plain", sdp.Media.First().MessageMediaFormat.AcceptTypes[0]);
|
1281 | 1282 | Assert.Equal("text/x-msrp-heartbeat", sdp.Media.First().MessageMediaFormat.AcceptTypes[1]);
|
1282 | 1283 | }
|
| 1284 | + |
| 1285 | + /// <summary> |
| 1286 | + /// The media format negotiation rules specify that the first common format in the offer and answer |
| 1287 | + /// should be chiosen. This test checks that the media formats are maintained in the order they were added. |
| 1288 | + /// </summary> |
| 1289 | + [Fact] |
| 1290 | + public void Media_Formats_Order_Test() |
| 1291 | + { |
| 1292 | + logger.LogDebug("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name); |
| 1293 | + |
| 1294 | + var sdp = new SDP(); |
| 1295 | + |
| 1296 | + sdp.Media.Add(new SDPMediaAnnouncement() |
| 1297 | + { |
| 1298 | + Media = SDPMediaTypesEnum.audio, |
| 1299 | + MediaFormats = new Dictionary<int, SDPAudioVideoMediaFormat> |
| 1300 | + { |
| 1301 | + { 8, new SDPAudioVideoMediaFormat(SDPMediaTypesEnum.audio, 8, "PCMA", 8000) }, |
| 1302 | + { 0, new SDPAudioVideoMediaFormat(SDPMediaTypesEnum.audio, 0, "PCMU", 8000) }, |
| 1303 | + { 101, new SDPAudioVideoMediaFormat(SDPMediaTypesEnum.audio, 101, "telephone-event", 8000) } |
| 1304 | + } |
| 1305 | + }); |
| 1306 | + |
| 1307 | + logger.LogDebug(sdp.ToString()); |
| 1308 | + |
| 1309 | + var sdpParsed = SDP.ParseSDPDescription(sdp.ToString()); |
| 1310 | + |
| 1311 | + Assert.Equal(8, sdpParsed.Media.Where(x => x.Media == SDPMediaTypesEnum.audio).First().MediaFormats.First().Key); |
| 1312 | + } |
1283 | 1313 | }
|
1284 | 1314 | }
|
0 commit comments