File: RTCRtpReceiver-getSynchronizationSources.https.html

package info (click to toggle)
firefox-esr 68.10.0esr-1~deb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 3,143,932 kB
  • sloc: cpp: 5,227,879; javascript: 4,315,531; ansic: 2,467,042; python: 794,975; java: 349,993; asm: 232,034; xml: 228,320; sh: 82,008; lisp: 41,202; makefile: 22,347; perl: 15,555; objc: 5,277; cs: 4,725; yacc: 1,778; ada: 1,681; pascal: 1,673; lex: 1,417; exp: 527; php: 436; ruby: 225; awk: 162; sed: 53; csh: 44
file content (96 lines) | stat: -rw-r--r-- 4,190 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<!doctype html>
<meta charset=utf-8>
<!-- This file contains two tests that wait for 10 seconds each. -->
<meta name="timeout" content="long">
<title>RTCRtpReceiver.prototype.getSynchronizationSources</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="RTCPeerConnection-helper.js"></script>
<script>
'use strict';

async function initiateSingleTrackCallAndReturnReceiver(t, kind) {
  const pc1 = new RTCPeerConnection();
  t.add_cleanup(() => pc1.close());
  const pc2 = new RTCPeerConnection();
  t.add_cleanup(() => pc2.close());

  const stream = await navigator.mediaDevices.getUserMedia({[kind]:true});
  const [track] = stream.getTracks();
  t.add_cleanup(() => track.stop());
  pc1.addTrack(track, stream);

  exchangeIceCandidates(pc1, pc2);
  const trackEvent = await exchangeOfferAndListenToOntrack(t, pc1, pc2);
  await exchangeAnswer(pc1, pc2);
  return trackEvent.receiver;
}

for (const kind of ['audio', 'video']) {
  promise_test(async t => {
    const receiver = await initiateSingleTrackCallAndReturnReceiver(t, kind);
    await listenForSSRCs(t, receiver);
  }, '[' + kind + '] getSynchronizationSources() eventually returns a ' +
     'non-empty list');

  promise_test(async t => {
    const startTime = performance.now();
    const receiver = await initiateSingleTrackCallAndReturnReceiver(t, kind);
    const [ssrc] = await listenForSSRCs(t, receiver);
    assert_equals(typeof ssrc.timestamp, 'number');
    assert_true(ssrc.timestamp >= startTime);
  }, '[' + kind + '] RTCRtpSynchronizationSource.timestamp is a number');

  promise_test(async t => {
    const receiver = await initiateSingleTrackCallAndReturnReceiver(t, kind);
    // Wait for packets to start flowing.
    await listenForSSRCs(t, receiver);
    // Wait for 10 seconds.
    await new Promise(resolve => t.step_timeout(resolve, 10000));
    let earliestTimestamp = undefined;
    let latestTimestamp = undefined;
    for (const ssrc of await listenForSSRCs(t, receiver)) {
      if (earliestTimestamp == undefined || earliestTimestamp > ssrc.timestamp)
        earliestTimestamp = ssrc.timestamp;
      if (latestTimestamp == undefined || latestTimestamp < ssrc.timestamp)
        latestTimestamp = ssrc.timestamp;
    }
    assert_true(latestTimestamp - earliestTimestamp <= 10000);
  }, '[' + kind + '] getSynchronizationSources() does not contain SSRCs ' +
     'older than 10 seconds');

  promise_test(async t => {
    const startTime = performance.timeOrigin + performance.now();
    const receiver = await initiateSingleTrackCallAndReturnReceiver(t, kind);
    const [ssrc] = await listenForSSRCs(t, receiver);
    const endTime = performance.timeOrigin + performance.now();
    assert_true(startTime <= ssrc.timestamp && ssrc.timestamp <= endTime);
  }, '[' + kind + '] RTCRtpSynchronizationSource.timestamp is comparable to ' +
     'performance.timeOrigin + performance.now()');

  promise_test(async t => {
    const receiver = await initiateSingleTrackCallAndReturnReceiver(t, kind);
    const [ssrc] = await listenForSSRCs(t, receiver);
    assert_equals(typeof ssrc.source, 'number');
  }, '[' + kind + '] RTCRtpSynchronizationSource.source is a number');
}

promise_test(async t => {
  const receiver = await initiateSingleTrackCallAndReturnReceiver(t, 'audio');
  const [ssrc] = await listenForSSRCs(t, receiver);
  assert_equals(typeof ssrc.audioLevel, 'number');
  assert_greater_than_equal(ssrc.audioLevel, 0);
  assert_less_than_equal(ssrc.audioLevel, 1);
}, '[audio-only] RTCRtpSynchronizationSource.audioLevel is a number [0, 1]');

// This test only passes if the implementation is sending the RFC 6464 extension
// header and the "vad" extension attribute is not "off", otherwise
// voiceActivityFlag is absent. TODO: Consider moving this test to an
// optional-to-implement subfolder?
promise_test(async t => {
  const receiver = await initiateSingleTrackCallAndReturnReceiver(t, 'audio');
  const [ssrc] = await listenForSSRCs(t, receiver);
  assert_equals(typeof ssrc.voiceActivityFlag, 'boolean');
}, '[audio-only] RTCRtpSynchronizationSource.voiceActivityFlag is a boolean');

</script>