| Soares Chen | 172fe9d | 2017-07-18 09:30:18 | [diff] [blame] | 1 | <!doctype html> |
| 2 | <meta charset=utf-8> |
| 3 | <title>RTCRtpReceiver.prototype.getParameters</title> |
| 4 | <script src="/resources/testharness.js"></script> |
| 5 | <script src="/resources/testharnessreport.js"></script> |
| 6 | <script src="dictionary-helper.js"></script> |
| 7 | <script src="RTCRtpParameters-helper.js"></script> |
| 8 | <script> |
| 9 | 'use strict'; |
| 10 | |
| 11 | // Test is based on the following editor draft: |
| 12 | // https://w3c.github.io/webrtc-pc/archives/20170605/webrtc.html |
| 13 | |
| 14 | // The following helper functions are called from RTCRtpParameters-helper.js: |
| 15 | // validateReceiverRtpParameters |
| 16 | |
| 17 | /* |
| 18 | Validates the RTCRtpParameters returned from RTCRtpReceiver.prototype.getParameters |
| 19 | |
| 20 | 5.3. RTCRtpReceiver Interface |
| 21 | getParameters |
| 22 | When getParameters is called, the RTCRtpParameters dictionary is constructed |
| 23 | as follows: |
| 24 | |
| Soares Chen | 172fe9d | 2017-07-18 09:30:18 | [diff] [blame] | 25 | - The headerExtensions sequence is populated based on the header extensions that |
| 26 | the receiver is currently prepared to receive. |
| 27 | |
| 28 | - The codecs sequence is populated based on the codecs that the receiver is currently |
| 29 | prepared to receive. |
| 30 | |
| 31 | - rtcp.reducedSize is set to true if the receiver is currently prepared to receive |
| 32 | reduced-size RTCP packets, and false otherwise. rtcp.cname is left undefined. |
| Florent Castelli | 4f34fd4 | 2020-04-01 21:31:49 | [diff] [blame^] | 33 | */ |
| Florent Castelli | 5dd605c | 2018-12-11 14:39:55 | [diff] [blame] | 34 | promise_test(async t => { |
| Soares Chen | 172fe9d | 2017-07-18 09:30:18 | [diff] [blame] | 35 | const pc = new RTCPeerConnection(); |
| Florent Castelli | 5dd605c | 2018-12-11 14:39:55 | [diff] [blame] | 36 | t.add_cleanup(() => pc.close()); |
| 37 | pc.addTransceiver('audio'); |
| 38 | const callee = await doOfferAnswerExchange(t, pc); |
| 39 | const param = callee.getReceivers()[0].getParameters(); |
| Soares Chen | 172fe9d | 2017-07-18 09:30:18 | [diff] [blame] | 40 | validateReceiverRtpParameters(param); |
| Florent Castelli | 5dd605c | 2018-12-11 14:39:55 | [diff] [blame] | 41 | |
| 42 | assert_greater_than(param.headerExtensions.length, 0); |
| 43 | assert_greater_than(param.codecs.length, 0); |
| 44 | assert_equals(param.encodings.length, 1); |
| 45 | }, 'getParameters() with audio receiver'); |
| 46 | |
| 47 | promise_test(async t => { |
| 48 | const pc = new RTCPeerConnection(); |
| 49 | t.add_cleanup(() => pc.close()); |
| 50 | pc.addTransceiver('video'); |
| 51 | const callee = await doOfferAnswerExchange(t, pc); |
| 52 | const param = callee.getReceivers()[0].getParameters(); |
| 53 | validateReceiverRtpParameters(param); |
| 54 | |
| 55 | assert_greater_than(param.headerExtensions.length, 0); |
| 56 | assert_greater_than(param.codecs.length, 0); |
| 57 | assert_equals(param.encodings.length, 1); |
| 58 | }, 'getParameters() with video receiver'); |
| 59 | |
| 60 | promise_test(async t => { |
| 61 | const pc = new RTCPeerConnection(); |
| 62 | t.add_cleanup(() => pc.close()); |
| 63 | pc.addTransceiver('video', { |
| 64 | sendEncodings: [ |
| 65 | { rid: "rid1" }, |
| 66 | { rid: "rid2" } |
| 67 | ] |
| 68 | }); |
| 69 | const callee = await doOfferAnswerExchange(t, pc); |
| 70 | const param = callee.getReceivers()[0].getParameters(); |
| 71 | validateReceiverRtpParameters(param); |
| 72 | |
| 73 | assert_greater_than(param.headerExtensions.length, 0); |
| 74 | assert_greater_than(param.codecs.length, 0); |
| 75 | assert_equals(param.encodings.length, 2, 'layer count must match'); |
| 76 | assert_equals(param.encodings[0].rid, "rid1", |
| 77 | 'simulcast rids must match'); |
| 78 | assert_equals(param.encodings[1].rid, "rid2", |
| 79 | 'simulcast rids must match'); |
| 80 | }, 'getParameters() with simulcast video receiver'); |
| Soares Chen | 172fe9d | 2017-07-18 09:30:18 | [diff] [blame] | 81 | </script> |