aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/rtcrtptransceiver/direction/index.html
blob: 09b0fba213881277bb1003e0c08c31c03368128e (plain)
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
---
title: RTCRtpTransceiver.direction
slug: Web/API/RTCRtpTransceiver/direction
translation_of: Web/API/RTCRtpTransceiver/direction
---
<div>{{APIRef("WebRTC")}}</div>

<p><span class="seoSummary">The {{domxref("RTCRtpTransceiver")}} property <code><strong>direction</strong></code> is a string which indicates the transceiver's preferred directionality.</span> Its value must be one of the strings defined by the {{domxref("RTCRtpTransceiverDirection")}} enumeration.</p>

<p>The transceiver's <em>current</em> direction is indicated by the {{domxref("RTCRtpTransceiver.currentDirection", "currentDirection")}} property.</p>

<h2 id="Syntax">Syntax</h2>

<pre class="syntaxbox notranslate">var <em>direction</em> = <em>RTCRtpTransceiver</em>.direction</pre>

<h3 id="Value">Value</h3>

<p>A {{domxref("DOMString")}} whose value is one of the strings which are a member of the <code>RTCRtpTransceiverDirection</code> enumerated type, indicating the transceiver's preferred direction. {{page("/en-US/docs/Web/API/RTCRtpTransceiverDirection", "Values")}}</p>

<h3 id="Exceptions">Exceptions</h3>

<p>When setting the value of <code>direction</code>, the following exceptions can occur:</p>

<dl>
 <dt><code>InvalidStateError</code></dt>
 <dd>Either the receiver's {{domxref("RTCPeerConnection")}} is closed or the {{domxref("RTCRtpReceiver")}} is stopped.</dd>
</dl>

<h2 id="Usage_notes">Usage notes</h2>

<h3 id="Setting_the_direction">Setting the direction</h3>

<p>When you change the value of <code>direction</code>, an <code>InvalidStateError</code> exception will occur if the connection is closed or the receiver is stopped.</p>

<p>If the new value of <code>direction</code> is in fact different from the existing value, renegotiation of the connection is required, so a {{event("negotiationneeded")}} event is sent to the {{domxref("RTCPeerConnection")}}.</p>

<h3 id="Effect_on_offers_and_answers">Effect on offers and answers</h3>

<p>The value of <code>direction</code> is used by {{domxref("RTCPeerConnection.createOffer()")}} or {{domxref("RTCPeerConnection.createAnswer()")}} in order to generate the SDP generated by each of those methods. The SDP contains an a-line which specifies the directionality. For example, if the <code>direction</code> is specified as <code>"sendrecv"</code>, the corresponding SDP a-line is:</p>

<pre class="notranslate">a=sendrecv</pre>

<h2 id="Specifications">Specifications</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{SpecName("WebRTC 1.0", "#dom-rtcrtptransceiver-direction", "RTCRtpTransceiver.direction")}}</td>
   <td>{{Spec2("WebRTC 1.0")}}</td>
   <td></td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<div>


<p>{{Compat("api.RTCRtpTransceiver.direction")}}</p>
</div>

<h2 id="See_also">See also</h2>

<ul>
 <li>{{domxref("RTCRtpTransceiver.currentDirection")}}</li>
</ul>