File: RTCRtpTransceiver-setDirection.html

package info (click to toggle)
thunderbird 1%3A60.9.0-1~deb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,339,492 kB
  • sloc: cpp: 5,457,040; ansic: 2,360,385; python: 596,167; asm: 340,963; java: 326,296; xml: 258,830; sh: 84,445; makefile: 23,705; perl: 17,317; objc: 3,768; yacc: 1,766; ada: 1,681; lex: 1,364; pascal: 1,264; cs: 879; exp: 527; php: 436; lisp: 258; ruby: 153; awk: 152; sed: 53; csh: 27
file content (94 lines) | stat: -rw-r--r-- 3,257 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
<!doctype html>
<meta charset=utf-8>
<title>RTCRtpTransceiver.prototype.setDirection</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="RTCPeerConnection-helper.js"></script>
<script>
  'use strict';

  // Test is based on the following editor draft:
  // https://rawgit.com/w3c/webrtc-pc/cc8d80f455b86c8041d63bceb8b457f45c72aa89/webrtc.html

  // The following helper functions are called from RTCPeerConnection-helper.js:
  // generateAnswer

  /*
    5.4.  RTCRtpTransceiver Interface
      interface RTCRtpTransceiver {
        readonly attribute RTCRtpTransceiverDirection  direction;
        readonly attribute RTCRtpTransceiverDirection? currentDirection;
        void setDirection(RTCRtpTransceiverDirection direction);
        ...
      };
   */

   /*
    5.4.  setDirection
      4.  Set transceiver's [[Direction]] slot to newDirection.
   */
  test(t => {
    const pc = new RTCPeerConnection();
    const transceiver = pc.addTransceiver('audio');
    assert_equals(transceiver.direction, 'sendrecv');
    assert_equals(transceiver.currentDirection, null);

    transceiver.setDirection('recvonly');
    assert_equals(transceiver.direction, 'recvonly');
    assert_equals(transceiver.currentDirection, null,
      'Expect transceiver.currentDirection to not change');

  }, 'setDirection should change transceiver.direction');

   /*
    5.4.  setDirection
      3.  If newDirection is equal to transceiver's [[Direction]] slot, abort
          these steps.
   */
  test(t => {
    const pc = new RTCPeerConnection();
    const transceiver = pc.addTransceiver('audio', { direction: 'sendonly' });
    assert_equals(transceiver.direction, 'sendonly');
    transceiver.setDirection('sendonly');
    assert_equals(transceiver.direction, 'sendonly');

  }, 'setDirection with same direction should have no effect');

  promise_test(t => {
    const pc = new RTCPeerConnection();
    const transceiver = pc.addTransceiver('audio', { direction: 'recvonly' });
    assert_equals(transceiver.direction, 'recvonly');
    assert_equals(transceiver.currentDirection, null);

    return pc.createOffer()
    .then(offer =>
      pc.setLocalDescription(offer)
      .then(() => generateAnswer(offer)))
    .then(answer => pc.setRemoteDescription(answer))
    .then(() => {
      assert_equals(transceiver.currentDirection, 'recvonly');
      transceiver.setDirection('sendrecv');
      assert_equals(transceiver.direction, 'sendrecv');
      assert_equals(transceiver.currentDirection, 'recvonly');
    });
  }, 'setDirection should change transceiver.direction independent of transceiver.currentDirection');

  /*
    TODO
        Calls to setDirection() do not take effect immediately. Instead, future calls
        to createOffer and createAnswer mark the corresponding media description as
        sendrecv, sendonly, recvonly or inactive as defined in [JSEP] (section 5.2.2.
        and section 5.3.2.).

    Tested in RTCPeerConnection-onnegotiationneeded.html
      5.4.  setDirection
        6.  Update the negotiation-needed flag for connection.

    Coverage Report
      Tested        6
      Not Tested    1
      Untestable    0
      Total         7
   */

</script>