File: RTCPeerConnection-remote-track-properties.https.html

package info (click to toggle)
firefox 148.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,719,544 kB
  • sloc: cpp: 7,618,291; javascript: 6,701,749; ansic: 3,781,787; python: 1,418,389; xml: 638,647; asm: 438,962; java: 186,285; sh: 62,894; makefile: 19,011; objc: 13,092; perl: 12,763; yacc: 4,583; cs: 3,846; pascal: 3,448; lex: 1,720; ruby: 1,003; php: 436; lisp: 258; awk: 247; sql: 66; sed: 54; csh: 10; exp: 6
file content (72 lines) | stat: -rw-r--r-- 2,631 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
<!doctype html>
<meta charset=utf-8>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="RTCPeerConnection-helper.js"></script>
<script>
'use strict';

async function setupPeerConnectionAndWaitForTrack(t, localTrack, localStream) {
  const pc1 = createPeerConnectionWithCleanup(t);
  pc1.addTrack(localTrack, localStream);
  const pc2 = createPeerConnectionWithCleanup(t);

  const haveTrackEvent = waitUntilEvent(pc2, "track");
  await exchangeOfferAnswer(pc1, pc2);
  const trackEvent = await haveTrackEvent;
  return [ trackEvent.track, trackEvent.streams[0] ];
}

function testStreamId(localStream, remoteStream, kind)
{
  test(() => {
    assert_equals(localStream.id, remoteStream.id);
  }, "Stream id for " + kind);
}

function testTrackLabel(remoteTrack, kind)
{
  test(() => {
    assert_equals(remoteTrack.label, "remote " + kind);
  }, "Track label for " + kind);
}

promise_test(async t => {
  const [localTrack, localStream] = await createTrackAndStreamWithCleanup(t, "video");
  const [remoteTrack, remoteStream] = await setupPeerConnectionAndWaitForTrack(t, localTrack, localStream);

  testStreamId(localStream, remoteStream, "video");
  testTrackLabel(remoteTrack, "video");
}, 'Remote video track and stream');

promise_test(async t => {
  const [localTrack, localStream] = await createTrackAndStreamWithCleanup(t, "audio");
  const [remoteTrack, remoteStream] = await setupPeerConnectionAndWaitForTrack(t, localTrack, localStream);

  testStreamId(localStream, remoteStream, "audio");
  testTrackLabel(remoteTrack, "audio");
}, 'Remote audio track and stream');

promise_test(async t => {
  const [localTrack, localStream] = await createTrackAndStreamWithCleanup(t, "audio");
  const remoteTrackIds = new Set();
  for (let i = 0; i < 10; ++i) {
    const [remoteTrack, remoteStream] = await setupPeerConnectionAndWaitForTrack(t, localTrack, localStream);
    remoteTrackIds.add(remoteTrack.id);
  }

  assert_greater_than(remoteTrackIds.size, 1, "Remote tracks should have their own id");
}, 'Remote audio track ID is different on different PCs');

promise_test(async t => {
  const [localTrack, localStream] = await createTrackAndStreamWithCleanup(t, "video");
  const remoteTrackIds = new Set();
  for (let i = 0; i < 10; ++i) {
    const [remoteTrack, remoteStream] = await setupPeerConnectionAndWaitForTrack(t, localTrack, localStream);
    remoteTrackIds.add(remoteTrack.id);
  }

  assert_greater_than(remoteTrackIds.size, 1, "Remote tracks should have their own id");
}, 'Remote video track ID is different on different PCs');

</script>