idnits 2.17.1 draft-ietf-rtcweb-jsep-08.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- == There are 44 instances of lines with non-RFC6890-compliant IPv4 addresses in the document. If these are example addresses, they should be changed. == There are 20 instances of lines with private range IPv4 addresses in the document. If these are generic example addresses, they should be changed to use any of the ranges defined in RFC 6890 (or successor): 192.0.2.x, 198.51.100.x or 203.0.113.x. -- The document has examples using IPv4 documentation addresses according to RFC6890, but does not use any IPv6 documentation addresses. Maybe there should be IPv6 examples, too? Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (October 27, 2014) is 3468 days in the past. Is this intentional? Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) == Missing Reference: 'RFC1918' is mentioned on line 680, but not defined == Missing Reference: 'RFC4787' is mentioned on line 683, but not defined == Unused Reference: 'RFC5124' is defined on line 2741, but no explicit reference was found in the text == Outdated reference: A later version (-17) exists of draft-ietf-mmusic-msid-01 == Outdated reference: A later version (-26) exists of draft-ietf-mmusic-sctp-sdp-04 == Outdated reference: A later version (-54) exists of draft-ietf-mmusic-sdp-bundle-negotiation-04 == Outdated reference: A later version (-19) exists of draft-ietf-mmusic-sdp-mux-attributes-01 == Outdated reference: A later version (-02) exists of draft-ietf-mmusic-trickle-ice-00 == Outdated reference: A later version (-11) exists of draft-ietf-rtcweb-audio-02 == Outdated reference: A later version (-09) exists of draft-ietf-rtcweb-data-protocol-04 == Outdated reference: A later version (-26) exists of draft-ietf-rtcweb-rtp-usage-09 == Outdated reference: A later version (-12) exists of draft-ietf-rtcweb-security-06 == Outdated reference: A later version (-20) exists of draft-ietf-rtcweb-security-arch-09 -- No information found for draft-nandakumar-mmusic-proto-iana-registration - is the name correct? -- Possible downref: Normative reference to a draft: ref. 'I-D.nandakumar-mmusic-proto-iana-registration' ** Obsolete normative reference: RFC 4566 (Obsoleted by RFC 8866) ** Obsolete normative reference: RFC 4572 (Obsoleted by RFC 8122) ** Obsolete normative reference: RFC 5245 (Obsoleted by RFC 8445, RFC 8839) ** Obsolete normative reference: RFC 5285 (Obsoleted by RFC 8285) == Outdated reference: A later version (-08) exists of draft-nandakumar-rtcweb-sdp-02 Summary: 4 errors (**), 0 flaws (~~), 17 warnings (==), 4 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Network Working Group J. Uberti 3 Internet-Draft Google 4 Intended status: Standards Track C. Jennings 5 Expires: April 30, 2015 Cisco 6 E. Rescorla, Ed. 7 Mozilla 8 October 27, 2014 10 Javascript Session Establishment Protocol 11 draft-ietf-rtcweb-jsep-08 13 Abstract 15 This document describes the mechanisms for allowing a Javascript 16 application to control the signaling plane of a multimedia session 17 via the interface specified in the W3C RTCPeerConnection API, and 18 discusses how this relates to existing signaling protocols. 20 Status of This Memo 22 This Internet-Draft is submitted in full conformance with the 23 provisions of BCP 78 and BCP 79. 25 Internet-Drafts are working documents of the Internet Engineering 26 Task Force (IETF). Note that other groups may also distribute 27 working documents as Internet-Drafts. The list of current Internet- 28 Drafts is at http://datatracker.ietf.org/drafts/current/. 30 Internet-Drafts are draft documents valid for a maximum of six months 31 and may be updated, replaced, or obsoleted by other documents at any 32 time. It is inappropriate to use Internet-Drafts as reference 33 material or to cite them other than as "work in progress." 35 This Internet-Draft will expire on April 30, 2015. 37 Copyright Notice 39 Copyright (c) 2014 IETF Trust and the persons identified as the 40 document authors. All rights reserved. 42 This document is subject to BCP 78 and the IETF Trust's Legal 43 Provisions Relating to IETF Documents 44 (http://trustee.ietf.org/license-info) in effect on the date of 45 publication of this document. Please review these documents 46 carefully, as they describe your rights and restrictions with respect 47 to this document. Code Components extracted from this document must 48 include Simplified BSD License text as described in Section 4.e of 49 the Trust Legal Provisions and are provided without warranty as 50 described in the Simplified BSD License. 52 Table of Contents 54 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3 55 1.1. General Design of JSEP . . . . . . . . . . . . . . . . . 3 56 1.2. Other Approaches Considered . . . . . . . . . . . . . . . 5 57 2. Terminology . . . . . . . . . . . . . . . . . . . . . . . . . 6 58 3. Semantics and Syntax . . . . . . . . . . . . . . . . . . . . 6 59 3.1. Signaling Model . . . . . . . . . . . . . . . . . . . . . 6 60 3.2. Session Descriptions and State Machine . . . . . . . . . 6 61 3.3. Session Description Format . . . . . . . . . . . . . . . 10 62 3.4. ICE . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 63 3.4.1. ICE Gathering Overview . . . . . . . . . . . . . . . 10 64 3.4.2. ICE Candidate Trickling . . . . . . . . . . . . . . . 11 65 3.4.2.1. ICE Candidate Format . . . . . . . . . . . . . . 11 66 3.4.3. ICE Candidate Policy . . . . . . . . . . . . . . . . 12 67 3.4.4. ICE Candidate Pool . . . . . . . . . . . . . . . . . 13 68 3.5. Interactions With Forking . . . . . . . . . . . . . . . . 13 69 3.5.1. Sequential Forking . . . . . . . . . . . . . . . . . 14 70 3.5.2. Parallel Forking . . . . . . . . . . . . . . . . . . 14 71 4. Interface . . . . . . . . . . . . . . . . . . . . . . . . . . 15 72 4.1. Methods . . . . . . . . . . . . . . . . . . . . . . . . . 15 73 4.1.1. Constructor . . . . . . . . . . . . . . . . . . . . . 15 74 4.1.2. createOffer . . . . . . . . . . . . . . . . . . . . . 17 75 4.1.3. createAnswer . . . . . . . . . . . . . . . . . . . . 18 76 4.1.4. SessionDescriptionType . . . . . . . . . . . . . . . 19 77 4.1.4.1. Use of Provisional Answers . . . . . . . . . . . 20 78 4.1.4.2. Rollback . . . . . . . . . . . . . . . . . . . . 20 79 4.1.5. setLocalDescription . . . . . . . . . . . . . . . . . 21 80 4.1.6. setRemoteDescription . . . . . . . . . . . . . . . . 21 81 4.1.7. localDescription . . . . . . . . . . . . . . . . . . 22 82 4.1.8. remoteDescription . . . . . . . . . . . . . . . . . . 22 83 4.1.9. canTrickle . . . . . . . . . . . . . . . . . . . . . 22 84 4.1.10. setConfiguration . . . . . . . . . . . . . . . . . . 23 85 4.1.11. addIceCandidate . . . . . . . . . . . . . . . . . . . 24 86 5. SDP Interaction Procedures . . . . . . . . . . . . . . . . . 24 87 5.1. Requirements Overview . . . . . . . . . . . . . . . . . . 24 88 5.1.1. Implementation Requirements . . . . . . . . . . . . . 24 89 5.1.2. Usage Requirements . . . . . . . . . . . . . . . . . 26 90 5.1.3. Profile Names and Interoperability . . . . . . . . . 26 91 5.2. Constructing an Offer . . . . . . . . . . . . . . . . . . 27 92 5.2.1. Initial Offers . . . . . . . . . . . . . . . . . . . 27 93 5.2.2. Subsequent Offers . . . . . . . . . . . . . . . . . . 32 94 5.2.3. Options Handling . . . . . . . . . . . . . . . . . . 35 95 5.2.3.1. OfferToReceiveAudio . . . . . . . . . . . . . . . 35 96 5.2.3.2. OfferToReceiveVideo . . . . . . . . . . . . . . . 35 97 5.2.3.3. IceRestart . . . . . . . . . . . . . . . . . . . 36 98 5.2.3.4. VoiceActivityDetection . . . . . . . . . . . . . 36 99 5.3. Generating an Answer . . . . . . . . . . . . . . . . . . 36 100 5.3.1. Initial Answers . . . . . . . . . . . . . . . . . . . 36 101 5.3.2. Subsequent Answers . . . . . . . . . . . . . . . . . 40 102 5.3.3. Options Handling . . . . . . . . . . . . . . . . . . 41 103 5.3.3.1. VoiceActivityDetection . . . . . . . . . . . . . 41 104 5.4. Parsing an Offer . . . . . . . . . . . . . . . . . . . . 41 105 5.5. Parsing an Answer . . . . . . . . . . . . . . . . . . . . 41 106 5.6. Applying a Local Description . . . . . . . . . . . . . . 41 107 5.7. Applying a Remote Description . . . . . . . . . . . . . . 41 108 6. Configurable SDP Parameters . . . . . . . . . . . . . . . . . 41 109 7. Examples . . . . . . . . . . . . . . . . . . . . . . . . . . 42 110 7.1. Simple Example . . . . . . . . . . . . . . . . . . . . . 43 111 7.2. Normal Examples . . . . . . . . . . . . . . . . . . . . . 47 112 8. Security Considerations . . . . . . . . . . . . . . . . . . . 58 113 9. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 58 114 10. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 58 115 11. References . . . . . . . . . . . . . . . . . . . . . . . . . 59 116 11.1. Normative References . . . . . . . . . . . . . . . . . . 59 117 11.2. Informative References . . . . . . . . . . . . . . . . . 61 118 Appendix A. Change log . . . . . . . . . . . . . . . . . . . . . 62 119 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 65 121 1. Introduction 123 This document describes how the W3C WEBRTC RTCPeerConnection 124 interface[W3C.WD-webrtc-20140617] is used to control the setup, 125 management and teardown of a multimedia session. 127 1.1. General Design of JSEP 129 The thinking behind WebRTC call setup has been to fully specify and 130 control the media plane, but to leave the signaling plane up to the 131 application as much as possible. The rationale is that different 132 applications may prefer to use different protocols, such as the 133 existing SIP or Jingle call signaling protocols, or something custom 134 to the particular application, perhaps for a novel use case. In this 135 approach, the key information that needs to be exchanged is the 136 multimedia session description, which specifies the necessary 137 transport and media configuration information necessary to establish 138 the media plane. 140 With these considerations in mind, this document describes the 141 Javascript Session Establishment Protocol (JSEP) that allows for full 142 control of the signaling state machine from Javascript. JSEP removes 143 the browser almost entirely from the core signaling flow, which is 144 instead handled by the Javascript making use of two interfaces: (1) 145 passing in local and remote session descriptions and (2) interacting 146 with the ICE state machine. 148 In this document, the use of JSEP is described as if it always occurs 149 between two browsers. Note though in many cases it will actually be 150 between a browser and some kind of server, such as a gateway or MCU. 151 This distinction is invisible to the browser; it just follows the 152 instructions it is given via the API. 154 JSEP's handling of session descriptions is simple and 155 straightforward. Whenever an offer/answer exchange is needed, the 156 initiating side creates an offer by calling a createOffer() API. The 157 application optionally modifies that offer, and then uses it to set 158 up its local config via the setLocalDescription() API. The offer is 159 then sent off to the remote side over its preferred signaling 160 mechanism (e.g., WebSockets); upon receipt of that offer, the remote 161 party installs it using the setRemoteDescription() API. 163 To complete the offer/answer exchange, the remote party uses the 164 createAnswer() API to generate an appropriate answer, applies it 165 using the setLocalDescription() API, and sends the answer back to the 166 initiator over the signaling channel. When the initiator gets that 167 answer, it installs it using the setRemoteDescription() API, and 168 initial setup is complete. This process can be repeated for 169 additional offer/answer exchanges. 171 Regarding ICE [RFC5245], JSEP decouples the ICE state machine from 172 the overall signaling state machine, as the ICE state machine must 173 remain in the browser, because only the browser has the necessary 174 knowledge of candidates and other transport info. Performing this 175 separation also provides additional flexibility; in protocols that 176 decouple session descriptions from transport, such as Jingle, the 177 session description can be sent immediately and the transport 178 information can be sent when available. In protocols that don't, 179 such as SIP, the information can be used in the aggregated form. 180 Sending transport information separately can allow for faster ICE and 181 DTLS startup, since ICE checks can start as soon as any transport 182 information is available rather than waiting for all of it. 184 Through its abstraction of signaling, the JSEP approach does require 185 the application to be aware of the signaling process. While the 186 application does not need to understand the contents of session 187 descriptions to set up a call, the application must call the right 188 APIs at the right times, convert the session descriptions and ICE 189 information into the defined messages of its chosen signaling 190 protocol, and perform the reverse conversion on the messages it 191 receives from the other side. 193 One way to mitigate this is to provide a Javascript library that 194 hides this complexity from the developer; said library would 195 implement a given signaling protocol along with its state machine and 196 serialization code, presenting a higher level call-oriented interface 197 to the application developer. For example, libraries exist to adapt 198 the JSEP API into an API suitable for a SIP or XMPP. Thus, JSEP 199 provides greater control for the experienced developer without 200 forcing any additional complexity on the novice developer. 202 1.2. Other Approaches Considered 204 One approach that was considered instead of JSEP was to include a 205 lightweight signaling protocol. Instead of providing session 206 descriptions to the API, the API would produce and consume messages 207 from this protocol. While providing a more high-level API, this put 208 more control of signaling within the browser, forcing the browser to 209 have to understand and handle concepts like signaling glare. In 210 addition, it prevented the application from driving the state machine 211 to a desired state, as is needed in the page reload case. 213 A second approach that was considered but not chosen was to decouple 214 the management of the media control objects from session 215 descriptions, instead offering APIs that would control each component 216 directly. This was rejected based on a feeling that requiring 217 exposure of this level of complexity to the application programmer 218 would not be beneficial; it would result in an API where even a 219 simple example would require a significant amount of code to 220 orchestrate all the needed interactions, as well as creating a large 221 API surface that needed to be agreed upon and documented. In 222 addition, these API points could be called in any order, resulting in 223 a more complex set of interactions with the media subsystem than the 224 JSEP approach, which specifies how session descriptions are to be 225 evaluated and applied. 227 One variation on JSEP that was considered was to keep the basic 228 session description-oriented API, but to move the mechanism for 229 generating offers and answers out of the browser. Instead of 230 providing createOffer/createAnswer methods within the browser, this 231 approach would instead expose a getCapabilities API which would 232 provide the application with the information it needed in order to 233 generate its own session descriptions. This increases the amount of 234 work that the application needs to do; it needs to know how to 235 generate session descriptions from capabilities, and especially how 236 to generate the correct answer from an arbitrary offer and the 237 supported capabilities. While this could certainly be addressed by 238 using a library like the one mentioned above, it basically forces the 239 use of said library even for a simple example. Providing 240 createOffer/createAnswer avoids this problem, but still allows 241 applications to generate their own offers/answers (to a large extent) 242 if they choose, using the description generated by createOffer as an 243 indication of the browser's capabilities. 245 2. Terminology 247 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 248 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 249 document are to be interpreted as described in [RFC2119]. 251 3. Semantics and Syntax 253 3.1. Signaling Model 255 JSEP does not specify a particular signaling model or state machine, 256 other than the generic need to exchange SDP media descriptions in the 257 fashion described by [RFC3264] (offer/answer) in order for both sides 258 of the session to know how to conduct the session. JSEP provides 259 mechanisms to create offers and answers, as well as to apply them to 260 a session. However, the browser is totally decoupled from the actual 261 mechanism by which these offers and answers are communicated to the 262 remote side, including addressing, retransmission, forking, and glare 263 handling. These issues are left entirely up to the application; the 264 application has complete control over which offers and answers get 265 handed to the browser, and when. 267 +-----------+ +-----------+ 268 | Web App |<--- App-Specific Signaling -->| Web App | 269 +-----------+ +-----------+ 270 ^ ^ 271 | SDP | SDP 272 V V 273 +-----------+ +-----------+ 274 | Browser |<----------- Media ------------>| Browser | 275 +-----------+ +-----------+ 277 Figure 1: JSEP Signaling Model 279 3.2. Session Descriptions and State Machine 281 In order to establish the media plane, the user agent needs specific 282 parameters to indicate what to transmit to the remote side, as well 283 as how to handle the media that is received. These parameters are 284 determined by the exchange of session descriptions in offers and 285 answers, and there are certain details to this process that must be 286 handled in the JSEP APIs. 288 Whether a session description applies to the local side or the remote 289 side affects the meaning of that description. For example, the list 290 of codecs sent to a remote party indicates what the local side is 291 willing to receive, which, when intersected with the set of codecs 292 the remote side supports, specifies what the remote side should send. 293 However, not all parameters follow this rule; for example, the DTLS- 294 SRTP parameters [RFC5763] sent to a remote party indicate what 295 certificate the local side will use in DTLS setup, and thereby what 296 the remote party should expect to receive; the remote party will have 297 to accept these parameters, with no option to choose different 298 values. 300 In addition, various RFCs put different conditions on the format of 301 offers versus answers. For example, a offer may propose an arbitrary 302 number of media streams (i.e. m= sections), but an answer must 303 contain the exact same number as the offer. 305 Lastly, while the exact media parameters are only known only after an 306 offer and an answer have been exchanged, it is possible for the 307 offerer to receive media after they have sent an offer and before 308 they have received an answer. To properly process incoming media in 309 this case, the offerer's media handler must be aware of the details 310 of the offer before the answer arrives. 312 Therefore, in order to handle session descriptions properly, the user 313 agent needs: 315 1. To know if a session description pertains to the local or remote 316 side. 318 2. To know if a session description is an offer or an answer. 320 3. To allow the offer to be specified independently of the answer. 322 JSEP addresses this by adding both setLocalDescription and 323 setRemoteDescription methods and having session description objects 324 contain a type field indicating the type of session description being 325 supplied. This satisfies the requirements listed above for both the 326 offerer, who first calls setLocalDescription(sdp [offer]) and then 327 later setRemoteDescription(sdp [answer]), as well as for the 328 answerer, who first calls setRemoteDescription(sdp [offer]) and then 329 later setLocalDescription(sdp [answer]). 331 JSEP also allows for an answer to be treated as provisional by the 332 application. Provisional answers provide a way for an answerer to 333 communicate initial session parameters back to the offerer, in order 334 to allow the session to begin, while allowing a final answer to be 335 specified later. This concept of a final answer is important to the 336 offer/answer model; when such an answer is received, any extra 337 resources allocated by the caller can be released, now that the exact 338 session configuration is known. These "resources" can include things 339 like extra ICE components, TURN candidates, or video decoders. 340 Provisional answers, on the other hand, do no such deallocation 341 results; as a result, multiple dissimilar provisional answers can be 342 received and applied during call setup. 344 In [RFC3264], the constraint at the signaling level is that only one 345 offer can be outstanding for a given session, but at the media stack 346 level, a new offer can be generated at any point. For example, when 347 using SIP for signaling, if one offer is sent, then cancelled using a 348 SIP CANCEL, another offer can be generated even though no answer was 349 received for the first offer. To support this, the JSEP media layer 350 can provide an offer via the createOffer() method whenever the 351 Javascript application needs one for the signaling. The answerer can 352 send back zero or more provisional answers, and finally end the 353 offer-answer exchange by sending a final answer. The state machine 354 for this is as follows: 356 setRemote(OFFER) setLocal(PRANSWER) 357 /-----\ /-----\ 358 | | | | 359 v | v | 360 +---------------+ | +---------------+ | 361 | |----/ | |----/ 362 | | setLocal(PRANSWER) | | 363 | Remote-Offer |------------------- >| Local-Pranswer| 364 | | | | 365 | | | | 366 +---------------+ +---------------+ 367 ^ | | 368 | | setLocal(ANSWER) | 369 setRemote(OFFER) | | 370 | V setLocal(ANSWER) | 371 +---------------+ | 372 | | | 373 | |<---------------------------+ 374 | Stable | 375 | |<---------------------------+ 376 | | | 377 +---------------+ setRemote(ANSWER) | 378 ^ | | 379 | | setLocal(OFFER) | 380 setRemote(ANSWER) | | 381 | V | 382 +---------------+ +---------------+ 383 | | | | 384 | | setRemote(PRANSWER) | | 385 | Local-Offer |------------------- >|Remote-Pranswer| 386 | | | | 387 | |----\ | |----\ 388 +---------------+ | +---------------+ | 389 ^ | ^ | 390 | | | | 391 \-----/ \-----/ 392 setLocal(OFFER) setRemote(PRANSWER) 394 Figure 2: JSEP State Machine 396 Aside from these state transitions there is no other difference 397 between the handling of provisional ("pranswer") and final ("answer") 398 answers. 400 3.3. Session Description Format 402 In the WebRTC specification, session descriptions are formatted as 403 SDP messages. While this format is not optimal for manipulation from 404 Javascript, it is widely accepted, and frequently updated with new 405 features. Any alternate encoding of session descriptions would have 406 to keep pace with the changes to SDP, at least until the time that 407 this new encoding eclipsed SDP in popularity. As a result, JSEP 408 currently uses SDP as the internal representation for its session 409 descriptions. 411 However, to simplify Javascript processing, and provide for future 412 flexibility, the SDP syntax is encapsulated within a 413 SessionDescription object, which can be constructed from SDP, and be 414 serialized out to SDP. If future specifications agree on a JSON 415 format for session descriptions, we could easily enable this object 416 to generate and consume that JSON. 418 Other methods may be added to SessionDescription in the future to 419 simplify handling of SessionDescriptions from Javascript. In the 420 meantime, Javascript libraries can be used to perform these 421 manipulations. 423 Note that most applications should be able to treat the 424 SessionDescriptions produced and consumed by these various API calls 425 as opaque blobs; that is, the application will not need to read or 426 change them. The W3C WebRTC API specification will provide 427 appropriate APIs to allow the application to control various session 428 parameters, which will provide the necessary information to the 429 browser about what sort of SessionDescription to produce. 431 3.4. ICE 433 3.4.1. ICE Gathering Overview 435 JSEP gathers ICE candidates as needed by the application. Collection 436 of ICE candidates is referred to as a gathering phase, and this is 437 triggered either by the addition of a new or recycled m= line to the 438 local session description, or new ICE credentials in the description, 439 indicating an ICE restart. Use of new ICE credentials can be 440 triggered explicitly by the application, or implicitly by the browser 441 in response to changes in the ICE configuration. 443 When a new gathering phase starts, the ICE Agent will notify the 444 application that gathering is occurring through a callback. Then, 445 when each new ICE candidate becomes available, the ICE Agent will 446 supply it to the application via an additional callback; these 447 candidates will also automatically be added to the local session 448 description. Finally, when all candidates have been gathered, a 449 callback will be dispatched to signal that the gathering process is 450 complete. 452 Note that gathering phases only gather the candidates needed by 453 new/recycled/restarting m= lines; other m= lines continue to use 454 their existing candidates. 456 3.4.2. ICE Candidate Trickling 458 Candidate trickling is a technique through which a caller may 459 incrementally provide candidates to the callee after the initial 460 offer has been dispatched; the semantics of "Trickle ICE" are defined 461 in [I-D.ietf-mmusic-trickle-ice]. This process allows the callee to 462 begin acting upon the call and setting up the ICE (and perhaps DTLS) 463 connections immediately, without having to wait for the caller to 464 gather all possible candidates. This results in faster media setup 465 in cases where gathering is not performed prior to initiating the 466 call. 468 JSEP supports optional candidate trickling by providing APIs, as 469 described above, that provide control and feedback on the ICE 470 candidate gathering process. Applications that support candidate 471 trickling can send the initial offer immediately and send individual 472 candidates when they get the notified of a new candidate; 473 applications that do not support this feature can simply wait for the 474 indication that gathering is complete, and then create and send their 475 offer, with all the candidates, at this time. 477 Upon receipt of trickled candidates, the receiving application will 478 supply them to its ICE Agent. This triggers the ICE Agent to start 479 using the new remote candidates for connectivity checks. 481 3.4.2.1. ICE Candidate Format 483 As with session descriptions, the syntax of the IceCandidate object 484 provides some abstraction, but can be easily converted to and from 485 the SDP candidate lines. 487 The candidate lines are the only SDP information that is contained 488 within IceCandidate, as they represent the only information needed 489 that is not present in the initial offer (i.e., for trickle 490 candidates). This information is carried with the same syntax as the 491 "candidate-attribute" field defined for ICE. For example: 493 candidate:1 1 UDP 1694498815 192.0.2.33 10000 typ host 494 The IceCandidate object also contains fields to indicate which m= 495 line it should be associated with. The m= line can be identified in 496 one of two ways; either by a m= line index, or a MID. The m= line 497 index is a zero-based index, with index N referring to the N+1th m= 498 line in the SDP sent by the entity which sent the IceCandidate. The 499 MID uses the "media stream identification" attribute, as defined in 500 [RFC5888], Section 4, to identify the m= line. JSEP implementations 501 creating an ICE Candidate object MUST populate both of these fields. 502 Implementations receiving an ICE Candidate object MUST use the MID if 503 present, or the m= line index, if not (as it could have come from a 504 non-JSEP endpoint). 506 3.4.3. ICE Candidate Policy 508 Typically, when gathering ICE candidates, the browser will gather all 509 possible forms of initial candidates - host, server reflexive, and 510 relay. However, in certain cases, applications may want to have more 511 specific control over the gathering process, due to privacy or 512 related concerns. For example, one may want to suppress the use of 513 host candidates, to avoid exposing information about the local 514 network, or go as far as only using relay candidates, to leak as 515 little location information as possible (note that these choices come 516 with corresponding operational costs). To accomplish this, the 517 browser MUST allow the application to restrict which ICE candidates 518 are used in a session. In addition, administrators may also wish to 519 control the set of ICE candidates, and so the browser SHOULD also 520 allow control via local policy, with the most restrictive policy 521 prevailing. 523 There may also be cases where the application wants to change which 524 types of candidates are used while the session is active. A prime 525 example is where a callee may initially want to use only relay 526 candidates, to avoid leaking location information to an arbitrary 527 caller, but then change to use all candidates (for lower operational 528 cost) once the user has indicated they want to take the call. For 529 this scenario, the browser MUST allow the candidate policy to be 530 changed in mid-session, subject to the aforementioned interactions 531 with local policy. 533 To administer the ICE candidate policy, the browser will determine 534 the current setting at the start of each gathering phase. Then, 535 during the gathering phase, the browser MUST NOT expose candidates 536 disallowed by the current policy to the application, use them as the 537 source of connectivity checks, or indirectly expose them via other 538 fields, such as the raddr/rport attributes for other ICE candidates. 539 Later, if a different policy is specified by the application, the 540 application can apply it by kicking off a new gathering phase via an 541 ICE restart. 543 3.4.4. ICE Candidate Pool 545 JSEP applications typically inform the browser to begin ICE gathering 546 via the information supplied to setLocalDescription, as this is where 547 the app specifies the number of media streams, and thereby ICE 548 components, for which to gather candidates. However, to accelerate 549 cases where the application knows the number of ICE components to use 550 ahead of time, it may ask the browser to gather a pool of potential 551 ICE candidates to help ensure rapid media setup. 553 When setLocalDescription is eventually called, and the browser goes 554 to gather the needed ICE candidates, it SHOULD start by checking if 555 any candidates are available in the pool. If there are candidates in 556 the pool, they SHOULD be handed to the application immediately via 557 the ICE candidate callback. If the pool becomes depleted, either 558 because a larger-than-expected number of ICE components is used, or 559 because the pool has not had enough time to gather candidates, the 560 remaining candidates are gathered as usual. 562 One example of where this concept is useful is an application that 563 expects an incoming call at some point in the future, and wants to 564 minimize the time it takes to establish connectivity, to avoid 565 clipping of initial media. By pre-gathering candidates into the 566 pool, it can exchange and start sending connectivity checks from 567 these candidates almost immediately upon receipt of a call. Note 568 though that by holding on to these pre-gathered candidates, which 569 will be kept alive as long as they may be needed, the application 570 will consume resources on the STUN/TURN servers it is using. 572 3.5. Interactions With Forking 574 Some call signaling systems allow various types of forking where an 575 SDP Offer may be provided to more than one device. For example, SIP 576 [RFC3261] defines both a "Parallel Search" and "Sequential Search". 577 Although these are primarily signaling level issues that are outside 578 the scope of JSEP, they do have some impact on the configuration of 579 the media plane that is relevant. When forking happens at the 580 signaling layer, the Javascript application responsible for the 581 signaling needs to make the decisions about what media should be sent 582 or received at any point of time, as well as which remote endpoint it 583 should communicate with; JSEP is used to make sure the media engine 584 can make the RTP and media perform as required by the application. 585 The basic operations that the applications can have the media engine 586 do are: 588 o Start exchanging media with a given remote peer, but keep all the 589 resources reserved in the offer. 591 o Start exchanging media with a given remote peer, and free any 592 resources in the offer that are not being used. 594 3.5.1. Sequential Forking 596 Sequential forking involves a call being dispatched to multiple 597 remote callees, where each callee can accept the call, but only one 598 active session ever exists at a time; no mixing of received media is 599 performed. 601 JSEP handles sequential forking well, allowing the application to 602 easily control the policy for selecting the desired remote endpoint. 603 When an answer arrives from one of the callees, the application can 604 choose to apply it either as a provisional answer, leaving open the 605 possibility of using a different answer in the future, or apply it as 606 a final answer, ending the setup flow. 608 In a "first-one-wins" situation, the first answer will be applied as 609 a final answer, and the application will reject any subsequent 610 answers. In SIP parlance, this would be ACK + BYE. 612 In a "last-one-wins" situation, all answers would be applied as 613 provisional answers, and any previous call leg will be terminated. 614 At some point, the application will end the setup process, perhaps 615 with a timer; at this point, the application could reapply the 616 existing remote description as a final answer. 618 3.5.2. Parallel Forking 620 Parallel forking involves a call being dispatched to multiple remote 621 callees, where each callee can accept the call, and multiple 622 simultaneous active signaling sessions can be established as a 623 result. If multiple callees send media at the same time, the 624 possibilities for handling this are described in Section 3.1 of 625 [RFC3960]. Most SIP devices today only support exchanging media with 626 a single device at a time, and do not try to mix multiple early media 627 audio sources, as that could result in a confusing situation. For 628 example, consider having a European ringback tone mixed together with 629 the North American ringback tone - the resulting sound would not be 630 like either tone, and would confuse the user. If the signaling 631 application wishes to only exchange media with one of the remote 632 endpoints at a time, then from a media engine point of view, this is 633 exactly like the sequential forking case. 635 In the parallel forking case where the Javascript application wishes 636 to simultaneously exchange media with multiple peers, the flow is 637 slightly more complex, but the Javascript application can follow the 638 strategy that [RFC3960] describes using UPDATE. The UPDATE approach 639 allows the signaling to set up a separate media flow for each peer 640 that it wishes to exchange media with. In JSEP, this offer used in 641 the UPDATE would be formed by simply creating a new PeerConnection 642 and making sure that the same local media streams have been added 643 into this new PeerConnection. Then the new PeerConnection object 644 would produce a SDP offer that could be used by the signaling to 645 perform the UPDATE strategy discussed in [RFC3960]. 647 As a result of sharing the media streams, the application will end up 648 with N parallel PeerConnection sessions, each with a local and remote 649 description and their own local and remote addresses. The media flow 650 from these sessions can be managed by specifying SDP direction 651 attributes in the descriptions, or the application can choose to play 652 out the media from all sessions mixed together. Of course, if the 653 application wants to only keep a single session, it can simply 654 terminate the sessions that it no longer needs. 656 4. Interface 658 This section details the basic operations that must be present to 659 implement JSEP functionality. The actual API exposed in the W3C API 660 may have somewhat different syntax, but should map easily to these 661 concepts. 663 4.1. Methods 665 4.1.1. Constructor 667 The PeerConnection constructor allows the application to specify 668 global parameters for the media session, such as the STUN/TURN 669 servers and credentials to use when gathering candidates, as well as 670 the initial ICE candidate policy and pool size, and also the BUNDLE 671 policy to use. 673 If an ICE candidate policy is specified, it functions as described in 674 Section 3.4.3, causing the browser to only surface the permitted 675 candidates to the application, and only use those candidates for 676 connectivity checks. The set of available policies is as follows: 678 all: All candidates will be gathered and used. 680 public: Candidates with private IP addresses [RFC1918] will be 681 filtered out. This prevents exposure of internal network details, 682 at the cost of requiring relay usage even for intranet calls, if 683 the NAT does not allow hairpinning as described in [RFC4787], 684 section 6. 686 relay: All candidates except relay candidates will be filtered out. 687 This obfuscates the location information that might be ascertained 688 by the remote peer from the received candidates. Depending on how 689 the application deploys its relay servers, this could obfuscate 690 location to a metro or possibly even global level. 692 Although it can be overridden by local policy, the default ICE 693 candidate policy MUST be set to allow all candidates, as this 694 minimizes use of application STUN/TURN server resources. 696 If a size is specified for the ICE candidate pool, this indicates the 697 number of ICE components to pre-gather candidates for. Because pre- 698 gathering results in utilizing STUN/TURN server resources for 699 potentially long periods of time, this must only occur upon 700 application request, and therefore the default candidate pool size 701 MUST be zero. 703 Lastly, the application can specify its preferred policy regarding 704 use of BUNDLE, the multiplexing mechanism defined in 705 [I-D.ietf-mmusic-sdp-bundle-negotiation]. By specifying a policy 706 from the list below, the application can control how aggressively it 707 will try to BUNDLE media streams together. The set of available 708 policies is as follows: 710 balanced: The application will BUNDLE all media streams of the same 711 type together. That is, if there are multiple audio and multiple 712 video MediaStreamTracks attached to a PeerConnection, all but the 713 first audio and video tracks will be marked as bundle-only, and 714 candidates will only be gathered for N media streams, where N is 715 the number of distinct media types. When talking to a non-BUNDLE- 716 aware endpoint, only the non-bundle-only streams will be 717 negotiated. This policy balances desire to multiplex with the 718 need to ensure basic audio and video still works in legacy cases. 719 Data channels will be in a separate bundle group. 721 max-compat: The application will offer BUNDLE, but mark none of its 722 streams as bundle-only. This policy will allow all streams to be 723 received by non-BUNDLE-aware endpoints, but require separate 724 candidates to be gathered for each media stream. 726 max-bundle: The application will BUNDLE all of its media streams, 727 including data channels, on a single transport. All streams other 728 than the first will be marked as bundle-only. This policy aims to 729 minimize candidate gathering and maximize multiplexing, at the 730 cost of less compatibility with legacy endpoints. 732 max-bundle-and-rtcp-mux: Similar to max-bundle, but RTCP candidates 733 are not gathered. This policy reduces the candidates that must be 734 gathered to the absolute minimum, but will not be compatible with 735 legacy endpoints that do not support RTCP mux. 737 As it provides the best tradeoff between performance and 738 compatibility with legacy endpoints, the default BUNDLE policy MUST 739 be set to "balanced". 741 4.1.2. createOffer 743 The createOffer method generates a blob of SDP that contains a 744 [RFC3264] offer with the supported configurations for the session, 745 including descriptions of the local MediaStreams attached to this 746 PeerConnection, the codec/RTP/RTCP options supported by this 747 implementation, and any candidates that have been gathered by the ICE 748 Agent. An options parameter may be supplied to provide additional 749 control over the generated offer. This options parameter should 750 allow for the following manipulations to be performed: 752 o To indicate support for a media type even if no MediaStreamTracks 753 of that type have been added to the session (e.g., an audio call 754 that wants to receive video.) 756 o To trigger an ICE restart, for the purpose of reestablishing 757 connectivity. 759 In the initial offer, the generated SDP will contain all desired 760 functionality for the session (functionality that is supported but 761 not desired by default may be omitted); for each SDP line, the 762 generation of the SDP will follow the process defined for generating 763 an initial offer from the document that specifies the given SDP line. 764 The exact handling of initial offer generation is detailed in 765 Section 5.2.1 below. 767 In the event createOffer is called after the session is established, 768 createOffer will generate an offer to modify the current session 769 based on any changes that have been made to the session, e.g. adding 770 or removing MediaStreams, or requesting an ICE restart. For each 771 existing stream, the generation of each SDP line must follow the 772 process defined for generating an updated offer from the RFC that 773 specifies the given SDP line. For each new stream, the generation of 774 the SDP must follow the process of generating an initial offer, as 775 mentioned above. If no changes have been made, or for SDP lines that 776 are unaffected by the requested changes, the offer will only contain 777 the parameters negotiated by the last offer-answer exchange. The 778 exact handling of subsequent offer generation is detailed in 779 Section 5.2.2. below. 781 Session descriptions generated by createOffer must be immediately 782 usable by setLocalDescription; if a system has limited resources 783 (e.g. a finite number of decoders), createOffer should return an 784 offer that reflects the current state of the system, so that 785 setLocalDescription will succeed when it attempts to acquire those 786 resources. Because this method may need to inspect the system state 787 to determine the currently available resources, it may be implemented 788 as an async operation. 790 Calling this method may do things such as generate new ICE 791 credentials, but does not result in candidate gathering, or cause 792 media to start or stop flowing. 794 4.1.3. createAnswer 796 The createAnswer method generates a blob of SDP that contains a 797 [RFC3264] SDP answer with the supported configuration for the session 798 that is compatible with the parameters supplied in the most recent 799 call to setRemoteDescription, which MUST have been called prior to 800 calling createAnswer. Like createOffer, the returned blob contains 801 descriptions of the local MediaStreams attached to this 802 PeerConnection, the codec/RTP/RTCP options negotiated for this 803 session, and any candidates that have been gathered by the ICE Agent. 804 An options parameter may be supplied to provide additional control 805 over the generated answer. 807 As an answer, the generated SDP will contain a specific configuration 808 that specifies how the media plane should be established; for each 809 SDP line, the generation of the SDP must follow the process defined 810 for generating an answer from the document that specifies the given 811 SDP line. The exact handling of answer generation is detailed in 812 Section 5.3. below. 814 Session descriptions generated by createAnswer must be immediately 815 usable by setLocalDescription; like createOffer, the returned 816 description should reflect the current state of the system. Because 817 this method may need to inspect the system state to determine the 818 currently available resources, it may need to be implemented as an 819 async operation. 821 Calling this method may do things such as generate new ICE 822 credentials, but does not trigger candidate gathering or change media 823 state. 825 4.1.4. SessionDescriptionType 827 Session description objects (RTCSessionDescription) may be of type 828 "offer", "pranswer", or "answer". These types provide information as 829 to how the description parameter should be parsed, and how the media 830 state should be changed. 832 "offer" indicates that a description should be parsed as an offer; 833 said description may include many possible media configurations. A 834 description used as an "offer" may be applied anytime the 835 PeerConnection is in a stable state, or as an update to a previously 836 supplied but unanswered "offer". 838 "pranswer" indicates that a description should be parsed as an 839 answer, but not a final answer, and so should not result in the 840 freeing of allocated resources. It may result in the start of media 841 transmission, if the answer does not specify an inactive media 842 direction. A description used as a "pranswer" may be applied as a 843 response to an "offer", or an update to a previously sent "pranswer". 845 "answer" indicates that a description should be parsed as an answer, 846 the offer-answer exchange should be considered complete, and any 847 resources (decoders, candidates) that are no longer needed can be 848 released. A description used as an "answer" may be applied as a 849 response to a "offer", or an update to a previously sent "pranswer". 851 The only difference between a provisional and final answer is that 852 the final answer results in the freeing of any unused resources that 853 were allocated as a result of the offer. As such, the application 854 can use some discretion on whether an answer should be applied as 855 provisional or final, and can change the type of the session 856 description as needed. For example, in a serial forking scenario, an 857 application may receive multiple "final" answers, one from each 858 remote endpoint. The application could choose to accept the initial 859 answers as provisional answers, and only apply an answer as final 860 when it receives one that meets its criteria (e.g. a live user 861 instead of voicemail). 863 "rollback" is a special session description type implying that the 864 state machine should be rolled back to the previous state, as 865 described in Section 4.1.4.2. The contents MUST be empty. 867 4.1.4.1. Use of Provisional Answers 869 Most web applications will not need to create answers using the 870 "pranswer" type. While it is good practice to send an immediate 871 response to an "offer", in order to warm up the session transport and 872 prevent media clipping, the preferred handling for a web application 873 would be to create and send an "inactive" final answer immediately 874 after receiving the offer. Later, when the called user actually 875 accepts the call, the application can create a new "sendrecv" offer 876 to update the previous offer/answer pair and start the media flow. 877 While this could also be done with an inactive "pranswer", followed 878 by a sendrecv "answer", the initial "pranswer" leaves the offer- 879 answer exchange open, which means that neither side can send an 880 updated offer during this time. 882 As an example, consider a typical web application that will set up a 883 data channel, an audio channel, and a video channel. When an 884 endpoint receives an offer with these channels, it could send an 885 answer accepting the data channel for two-way data, and accepting the 886 audio and video tracks as inactive or receive-only. It could then 887 ask the user to accept the call, acquire the local media streams, and 888 send a new offer to the remote side moving the audio and video to be 889 two-way media. By the time the human has accepted the call and 890 triggered the new offer, it is likely that the ICE and DTLS 891 handshaking for all the channels will already have finished. 893 Of course, some applications may not be able to perform this double 894 offer-answer exchange, particularly ones that are attempting to 895 gateway to legacy signaling protocols. In these cases, "pranswer" 896 can still provide the application with a mechanism to warm up the 897 transport. 899 4.1.4.2. Rollback 901 In certain situations it may be desirable to "undo" a change made to 902 setLocalDescription or setRemoteDescription. Consider a case where a 903 call is ongoing, and one side wants to change some of the session 904 parameters; that side generates an updated offer and then calls 905 setLocalDescription. However, the remote side, either before or 906 after setRemoteDescription, decides it does not want to accept the 907 new parameters, and sends a reject message back to the offerer. Now, 908 the offerer, and possibly the answerer as well, need to return to a 909 stable state and the previous local/remote description. To support 910 this, we introduce the concept of "rollback". 912 A rollback discards any proposed changes to the session, returning 913 the state machine to the stable state, and setting the modified local 914 and/or remote description back to their previous values. Any 915 resources or candidates that were allocated by the abandoned local 916 description are discarded; any media that is received will be 917 processed according to the previous local and remote descriptions. 918 Rollback can only be used to cancel proposed changes; there is no 919 support for rolling back from a stable state to a previous stable 920 state. Note that this implies that once the answerer has performed 921 setLocalDescription with his answer, this cannot be rolled back. 923 A rollback is performed by supplying a session description of type 924 "rollback" with empty contents to either setLocalDescription or 925 setRemoteDescription, depending on which was most recently used (i.e. 926 if the new offer was supplied to setLocalDescription, the rollback 927 should be done using setLocalDescription as well). 929 4.1.5. setLocalDescription 931 The setLocalDescription method instructs the PeerConnection to apply 932 the supplied SDP blob as its local configuration. The type field 933 indicates whether the blob should be processed as an offer, 934 provisional answer, or final answer; offers and answers are checked 935 differently, using the various rules that exist for each SDP line. 937 This API changes the local media state; among other things, it sets 938 up local resources for receiving and decoding media. In order to 939 successfully handle scenarios where the application wants to offer to 940 change from one media format to a different, incompatible format, the 941 PeerConnection must be able to simultaneously support use of both the 942 old and new local descriptions (e.g. support codecs that exist in 943 both descriptions) until a final answer is received, at which point 944 the PeerConnection can fully adopt the new local description, or roll 945 back to the old description if the remote side denied the change. 947 This API indirectly controls the candidate gathering process. When a 948 local description is supplied, and the number of transports currently 949 in use does not match the number of transports needed by the local 950 description, the PeerConnection will create transports as needed and 951 begin gathering candidates for them. 953 If setRemoteDescription was previous called with an offer, and 954 setLocalDescription is called with an answer (provisional or final), 955 and the media directions are compatible, and media are available to 956 send, this will result in the starting of media transmission. 958 4.1.6. setRemoteDescription 960 The setRemoteDescription method instructs the PeerConnection to apply 961 the supplied SDP blob as the desired remote configuration. As in 962 setLocalDescription, the type field of the indicates how the blob 963 should be processed. 965 This API changes the local media state; among other things, it sets 966 up local resources for sending and encoding media. 968 If setLocalDescription was previously called with an offer, and 969 setRemoteDescription is called with an answer (provisional or final), 970 and the media directions are compatible, and media are available to 971 send, this will result in the starting of media transmission. 973 4.1.7. localDescription 975 The localDescription method returns a copy of the current local 976 configuration, i.e. what was most recently passed to 977 setLocalDescription, plus any local candidates that have been 978 generated by the ICE Agent. 980 [[OPEN ISSUE: Do we need to expose accessors for both the current and 981 proposed local description? https://github.com/rtcweb-wg/jsep/ 982 issues/16]] 984 A null object will be returned if the local description has not yet 985 been established, or if the PeerConnection has been closed. 987 4.1.8. remoteDescription 989 The remoteDescription method returns a copy of the current remote 990 configuration, i.e. what was most recently passed to 991 setRemoteDescription, plus any remote candidates that have been 992 supplied via processIceMessage. 994 [[OPEN ISSUE: Do we need to expose accessors for both the current and 995 proposed remote description? https://github.com/rtcweb-wg/jsep/ 996 issues/16]] 998 A null object will be returned if the remote description has not yet 999 been established, or if the PeerConnection has been closed. 1001 4.1.9. canTrickle 1003 [[TODO: Revise if the W3C API uses different stuff here.]] The 1004 canTrickle property indicates whether the remote side supports 1005 receiving trickled candidates. There are three potential values: 1007 null: No SDP has been received from the other side, so it is not 1008 known if it can handle trickle. This is the initial value before 1009 setRemoteDescription() is called. 1011 true: SDP has been received from the other side indicating that it 1012 can support trickle. 1014 false: SDP has been received from the other side indicating that it 1015 cannot support trickle. 1017 As described in Section 3.4.2, JSEP implementations always provide 1018 candidates to the application individually, consistent with what is 1019 needed for Trickle ICE. However, applications can use the canTrickle 1020 property to determine whether they can actually do Trickle ICE, i.e. 1021 safely send an initial offer or answer followed later by candidates 1022 as they are gathered. As "true" is the only value that definitively 1023 indicates remote Trickle ICE support, an application which compares 1024 canTrickle against "true" will by default attempt Half Trickle on 1025 initial offers and Full Trickle on subsequent interactions with a 1026 Trickle ICE-compatible agent. 1028 4.1.10. setConfiguration 1030 The setConfiguration method allows the global configuration of the 1031 PeerConnection, which was initially set by constructor parameters, to 1032 be changed during the session. The effects of this method call 1033 depend on when it is invoked, and differ depending on which specific 1034 parameters are changed: 1036 o Any changes to the STUN/TURN servers to use affect the next 1037 gathering phase. If gathering has already occurred, this will 1038 cause the next call to createOffer to generate new ICE 1039 credentials, for the purpose of forcing an ICE restart and kicking 1040 off a new gathering phase, in which the new servers will be used. 1041 If the ICE candidate pool has a nonzero size, any existing 1042 candidates will be discarded, and new candidates will be gathered 1043 from the new servers. 1045 o Any changes to the ICE candidate policy also affect the next 1046 gathering phase, in similar fashion to the server changes 1047 described above. Note though that changes to the policy have no 1048 effect on the candidate pool, because pooled candidates are not 1049 surfaced to the application until a gathering phase occurs, and so 1050 any necessary filtering can still be done on any pooled 1051 candidates. 1053 o Any changes to the ICE candidate pool size take effect 1054 immediately; if increased, additional candidates are pre-gathered; 1055 if decreased, the now-superfluous candidates are discarded. 1057 o Any changes to the BUNDLE policy take effect immediately, i.e. 1058 any future tracks added to the PeerConnection will have their 1059 bundle-only state marked accordingly. 1061 This call may result in a change to the state of the ICE Agent, and 1062 may result in a change to media state if it results in connectivity 1063 being established. 1065 4.1.11. addIceCandidate 1067 The addIceCandidate method provides a remote candidate to the ICE 1068 Agent, which, if parsed successfully, will be added to the remote 1069 description according to the rules defined for Trickle ICE. 1070 Connectivity checks will be sent to the new candidate. 1072 This call will result in a change to the state of the ICE Agent, and 1073 may result in a change to media state if it results in connectivity 1074 being established. 1076 5. SDP Interaction Procedures 1078 This section describes the specific procedures to be followed when 1079 creating and parsing SDP objects. 1081 5.1. Requirements Overview 1083 JSEP implementations must comply with the specifications listed below 1084 that govern the creation and processing of offers and answers. 1086 The first set of specifications is the "mandatory-to-implement" set. 1087 All implementations must support these behaviors, but may not use all 1088 of them if the remote side, which may not be a JSEP endpoint, does 1089 not support them. 1091 The second set of specifications is the "mandatory-to-use" set. The 1092 local JSEP endpoint and any remote endpoint must indicate support for 1093 these specifications in their session descriptions. 1095 5.1.1. Implementation Requirements 1097 This list of mandatory-to-implement specifications is derived from 1098 the requirements outlined in [I-D.ietf-rtcweb-rtp-usage]. 1100 R-1 [RFC4566] is the base SDP specification and MUST be 1101 implemented. 1103 R-2 [RFC5764] MUST be supported for signaling the UDP/TLS/RTP/SAVPF 1104 [RFC5764] and TCP/TLS/RTP/SAVPF 1105 [I-D.nandakumar-mmusic-proto-iana-registration] RTP profiles. 1107 R-3 [RFC5245] MUST be implemented for signaling the ICE credentials 1108 and candidate lines corresponding to each media stream. The 1109 ICE implementation MUST be a Full implementation, not a Lite 1110 implementation. 1112 R-4 [RFC5763] MUST be implemented to signal DTLS certificate 1113 fingerprints. 1115 R-5 [RFC4568] MUST NOT be implemented to signal SDES SRTP keying 1116 information. 1118 R-6 The [RFC5888] grouping framework MUST be implemented for 1119 signaling grouping information, and MUST be used to identify m= 1120 lines via the a=mid attribute. 1122 R-7 [I-D.ietf-mmusic-msid] MUST be supported, in order to signal 1123 associations between RTP objects and W3C MediaStreams and 1124 MediaStreamTracks in a standard way. 1126 R-8 The bundle mechanism in 1127 [I-D.ietf-mmusic-sdp-bundle-negotiation] MUST be supported to 1128 signal the ability to multiplex RTP streams on a single UDP 1129 port, in order to avoid excessive use of port number resources. 1131 R-9 The SDP attributes of "sendonly", "recvonly", "inactive", and 1132 "sendrecv" from [RFC4566] MUST be implemented to signal 1133 information about media direction. 1135 R-10 [RFC5576] MUST be implemented to signal RTP SSRC values. 1137 R-11 [RFC4585] MUST be implemented to signal RTCP based feedback. 1139 R-12 [RFC5761] MUST be implemented to signal multiplexing of RTP and 1140 RTCP. 1142 R-13 [RFC5506] MUST be implemented to signal reduced-size RTCP 1143 messages. 1145 R-14 [RFC3556] with bandwidth modifiers MAY be supported for 1146 specifying RTCP bandwidth as a fraction of the media bandwidth, 1147 RTCP fraction allocated to the senders and setting maximum 1148 media bit-rate boundaries. 1150 As required by [RFC4566], Section 5.13, JSEP implementations MUST 1151 ignore unknown attribute (a=) lines. 1153 5.1.2. Usage Requirements 1155 All session descriptions handled by JSEP endpoints, both local and 1156 remote, MUST indicate support for the following specifications. If 1157 any of these are absent, this omission MUST be treated as an error. 1159 R-1 ICE, as specified in [RFC5245], MUST be used. Note that the 1160 remote endpoint may use a Lite implementation; implementations 1161 MUST properly handle remote endpoints which do ICE-Lite. 1163 R-2 DTLS-SRTP, as specified in [RFC5763], MUST be used. 1165 5.1.3. Profile Names and Interoperability 1167 For media m= sections, JSEP endpoints MUST support both the "UDP/TLS/ 1168 RTP/SAVPF" and "TCP/TLS/RTP/SAVPF" profiles and MUST indicate one of 1169 these two profiles for each media m= line they produce in an offer. 1170 For data m= sections, JSEP endpoints must support both the "UDP/TLS/ 1171 SCTP" and "TCP/TLS/SCTP" profiles and MUST indicate one of these two 1172 profiles for each data m= line they produce in an offer. Because ICE 1173 can select either TCP or UDP transport depending on network 1174 conditions, both advertisements are consistent with ICE eventually 1175 selecting either either UDP or TCP. 1177 Unfortunately, in an attempt at compatibility, some endpoints 1178 generate other profile strings even when they mean to support one of 1179 these profiles. For instance, an endpoint might generate "RTP/AVP" 1180 but supply "a=fingerprint" and "a=rtcp-fb" attributes, indicating its 1181 willingness to support "(UDP,TCP)/TLS/RTP/SAVPF". In order to 1182 simplify compatibility with such endpoints, JSEP endpoints MUST 1183 follow the following rules when processing the media m= sections in 1184 an offer: 1186 o The profile in any "m=" line in any answer MUST exactly match the 1187 profile provided in the offer. 1189 o Any profile matching the following patterns MUST be accepted: 1190 "RTP/[S]AVP[F]" and "(UDP/TCP)/TLS/RTP/SAVP[F]" 1192 o Because DTLS-SRTP is REQUIRED, the choice of SAVP or AVP has no 1193 effect; support for DTLS-SRTP is determined by the presence of the 1194 "a=fingerprint" attribute. Note that lack of an "a=fingerprint" 1195 attribute will lead to negotiation failure. 1197 o The use of AVPF or AVP simply controls the timing rules used for 1198 RTCP feedback. If AVPF is provided, or an "a=rtcp-fb" attribute 1199 is present, assume AVPF timing, i.e. a default value of "trr- 1200 int=0". Otherwise, assume that AVPF is being used in an AVP 1201 compatible mode and use AVP timing, i.e., "trr-int=4". 1203 o For data m= sections, JSEP endpoints MUST support receiving the 1204 "UDP/ TLS/SCTP", "TCP/TLS/SCTP", or "DTLS/SCTP" (for backwards 1205 compatibility) profiles. 1207 Note that re-offers by JSEP endpoints MUST use the correct profile 1208 strings even if the initial offer/answer exchange used an (incorrect) 1209 older profile string. 1211 5.2. Constructing an Offer 1213 When createOffer is called, a new SDP description must be created 1214 that includes the functionality specified in 1215 [I-D.ietf-rtcweb-rtp-usage]. The exact details of this process are 1216 explained below. 1218 5.2.1. Initial Offers 1220 When createOffer is called for the first time, the result is known as 1221 the initial offer. 1223 The first step in generating an initial offer is to generate session- 1224 level attributes, as specified in [RFC4566], Section 5. 1225 Specifically: 1227 o The first SDP line MUST be "v=0", as specified in [RFC4566], 1228 Section 5.1 1230 o The second SDP line MUST be an "o=" line, as specified in 1231 [RFC4566], Section 5.2. The value of the field SHOULD 1232 be "-". The value of the field SHOULD be a 1233 cryptographically random number. To ensure uniqueness, this 1234 number SHOULD be at least 64 bits long. The value of the field SHOULD be zero. The value of the 1236 tuple SHOULD be set to a non- 1237 meaningful address, such as IN IP4 0.0.0.0, to prevent leaking the 1238 local address in this field. As mentioned in [RFC4566], the 1239 entire o= line needs to be unique, but selecting a random number 1240 for is sufficient to accomplish this. 1242 o The third SDP line MUST be a "s=" line, as specified in [RFC4566], 1243 Section 5.3; to match the "o=" line, a single dash SHOULD be used 1244 as the session name, e.g. "s=-". Note that this differs from the 1245 advice in [RFC4566] which proposes a single space, but as both 1246 "o=" and "s=" are meaningless, having the same meaningless value 1247 seems clearer. 1249 o Session Information ("i="), URI ("u="), Email Address ("e="), 1250 Phone Number ("p="), Bandwidth ("b="), Repeat Times ("r="), and 1251 Time Zones ("z=") lines are not useful in this context and SHOULD 1252 NOT be included. 1254 o Encryption Keys ("k=") lines do not provide sufficient security 1255 and MUST NOT be included. 1257 o A "t=" line MUST be added, as specified in [RFC4566], Section 5.9; 1258 both and SHOULD be set to zero, e.g. "t=0 1259 0". 1261 o An "a=msid-semantic:WMS" line MUST be added, as specified in 1262 [I-D.ietf-mmusic-msid], Section 4. 1264 The next step is to generate m= sections, as specified in [RFC4566] 1265 Section 5.14, for each MediaStreamTrack that has been added to the 1266 PeerConnection via the addStream method. (Note that this method 1267 takes a MediaStream, which can contain multiple MediaStreamTracks, 1268 and therefore multiple m= sections can be generated even if addStream 1269 is only called once.) m=sections MUST be sorted first by the order in 1270 which the MediaStreams were added to the PeerConnection, and then by 1271 the alphabetical ordering of the media type for the MediaStreamTrack. 1272 For example, if a MediaStream containing both an audio and a video 1273 MediaStreamTrack is added to a PeerConnection, the resultant m=audio 1274 section will precede the m=video section. If a second MediaStream 1275 containing an audio MediaStreamTrack was added, it would follow the 1276 m=video section. 1278 Each m= section, provided it is not being bundled into another m= 1279 section, MUST generate a unique set of ICE credentials and gather its 1280 own unique set of ICE candidates. Otherwise, it MUST use the same 1281 ICE credentials and candidates as the m= section into which it is 1282 being bundled. Note that this means that for offers, any m= sections 1283 which are not bundle-only MUST have unique ICE credentials and 1284 candidates, since it is possible that the answerer will accept them 1285 without bundling them. 1287 For DTLS, all m= sections MUST use the certificate for the identity 1288 that has been specified for the PeerConnection; as a result, they 1289 MUST all have the same [RFC4572] fingerprint value, or this value 1290 MUST be a session-level attribute. 1292 Each m= section should be generated as specified in [RFC4566], 1293 Section 5.14. For the m= line itself, the following rules MUST be 1294 followed: 1296 o The port value is set to the port of the default ICE candidate for 1297 this m= section, but given that no candidates have yet been 1298 gathered, the "dummy" port value of 9 (Discard) MUST be used, as 1299 indicated in [I-D.ietf-mmusic-trickle-ice], Section 5.1. 1301 o To properly indicate use of DTLS, the field MUST be set to 1302 "UDP/TLS/RTP/SAVPF", as specified in [RFC5764], Section 8, if the 1303 default candidate uses UDP transport, or "TCP/TLS/RTP/SAVPF", as 1304 specified in[I-D.nandakumar-mmusic-proto-iana-registration] if the 1305 default candidate uses TCP transport. 1307 The m= line MUST be followed immediately by a "c=" line, as specified 1308 in [RFC4566], Section 5.7. Again, as no candidates have yet been 1309 gathered, the "c=" line must contain the "dummy" value "IN IP6 ::", 1310 as defined in [I-D.ietf-mmusic-trickle-ice], Section 5.1. 1312 Each m= section MUST include the following attribute lines: 1314 o An "a=mid" line, as specified in [RFC5888], Section 4. When 1315 generating mid values, it is RECOMMENDED that the values be 3 1316 bytes or less, to allow them to efficiently fit into the RTP 1317 header extension defined in 1318 [I-D.ietf-mmusic-sdp-bundle-negotiation], Section 11. 1320 o An "a=rtcp" line, as specified in [RFC3605], Section 2.1, 1321 containing the dummy value "9 IN IP6 ::", because no candidates 1322 have yet been gathered. 1324 o An "a=msid" line, as specified in [I-D.ietf-mmusic-msid], 1325 Section 2. 1327 o An "a=sendrecv" line, as specified in [RFC3264], Section 5.1. 1329 o For each supported codec, "a=rtpmap" and "a=fmtp" lines, as 1330 specified in [RFC4566], Section 6. For audio, the codecs 1331 specified in [I-D.ietf-rtcweb-audio], Section 3, MUST be be 1332 supported. 1334 o If this m= section is for media with configurable frame sizes, 1335 e.g. audio, an "a=maxptime" line, indicating the smallest of the 1336 maximum supported frame sizes out of all codecs included above, as 1337 specified in [RFC4566], Section 6. 1339 o For each primary codec where RTP retransmission should be used, a 1340 corresponding "a=rtpmap" line indicating "rtx" with the clock rate 1341 of the primary codec and an "a=fmtp" line that references the 1342 payload type of the primary codec, as specified in [RFC4588], 1343 Section 8.1. 1345 o For each supported FEC mechanism, a corresponding "a=rtpmap" line 1346 indicating the desired FEC codec. 1348 o "a=ice-ufrag" and "a=ice-passwd" lines, as specified in [RFC5245], 1349 Section 15.4. 1351 o An "a=ice-options" line, with the "trickle" option, as specified 1352 in [I-D.ietf-mmusic-trickle-ice], Section 4. 1354 o An "a=fingerprint" line, as specified in [RFC4572], Section 5; the 1355 algorithm used for the fingerprint MUST match that used in the 1356 certificate signature. 1358 o An "a=setup" line, as specified in [RFC4145], Section 4, and 1359 clarified for use in DTLS-SRTP scenarios in [RFC5763], Section 5. 1360 The role value in the offer MUST be "actpass". 1362 o An "a=rtcp-mux" line, as specified in [RFC5761], Section 5.1.1. 1364 o An "a=rtcp-rsize" line, as specified in [RFC5506], Section 5. 1366 o For each supported RTP header extension, an "a=extmap" line, as 1367 specified in [RFC5285], Section 5. The list of header extensions 1368 that SHOULD/MUST be supported is specified in 1369 [I-D.ietf-rtcweb-rtp-usage], Section 5.2. [TODO: ensure that 1370 urn:ietf:params:rtp-hdrext:sdes:mid appears either there or here] 1371 Any header extensions that require encryption MUST be specified as 1372 indicated in [RFC6904], Section 4. 1374 o For each supported RTCP feedback mechanism, an "a=rtcp-fb" 1375 mechanism, as specified in [RFC4585], Section 4.2. The list of 1376 RTCP feedback mechanisms that SHOULD/MUST be supported is 1377 specified in [I-D.ietf-rtcweb-rtp-usage], Section 5.1. 1379 o An "a=ssrc" line, as specified in [RFC5576], Section 4.1, 1380 indicating the SSRC to be used for sending media, along with the 1381 mandatory "cname" source attribute, as specified in Section 6.1, 1382 indicating the CNAME for the source. The CNAME must be generated 1383 in accordance with [RFC7022]. [OPEN ISSUE: How are CNAMEs 1384 specified for MSTs? Are they randomly generated for each 1385 MediaStream? If so, can two MediaStreams be synced? See: 1386 https://github.com/rtcweb-wg/jsep/issues/4] 1388 o If RTX is supported for this media type, another "a=ssrc" line 1389 with the RTX SSRC, and an "a=ssrc-group" line, as specified in 1390 [RFC5576], section 4.2, with semantics set to "FID" and including 1391 the primary and RTX SSRCs. 1393 o If FEC is supported for this media type, another "a=ssrc" line 1394 with the FEC SSRC, and an "a=ssrc-group" line, as specified in 1395 [RFC5576], section 4.2, with semantics set to "FEC" and including 1396 the primary and FEC SSRCs. 1398 o [OPEN ISSUE: Handling of a=imageattr] 1400 o If the BUNDLE policy for this PeerConnection is set to "max- 1401 bundle", and this is not the first m= section, or the BUNDLE 1402 policy is set to "balanced", and this is not the first m= section 1403 for this media type, an "a=bundle-only" line. 1405 Lastly, if a data channel has been created, a m= section MUST be 1406 generated for data. The field MUST be set to "application" 1407 and the field MUST be set to "UDP/TLS/SCTP" if the default 1408 candidate uses UDP transport, or "TCP/TLS/SCTP" if the default 1409 candidate uses TCP transport [I-D.ietf-mmusic-sctp-sdp]. The "fmt" 1410 value MUST be set to the SCTP port number, as specified in 1411 Section 4.1. [TODO: update this to use a=sctp-port, as indicated in 1412 the latest data channel docs] 1414 Within the data m= section, the "a=mid", "a=ice-ufrag", "a=ice- 1415 passwd", "a=ice-options", "a=candidate", "a=fingerprint", and 1416 "a=setup" lines MUST be included as mentioned above, along with an 1417 "a=sctpmap" line referencing the SCTP port number and specifying the 1418 application protocol indicated in [I-D.ietf-rtcweb-data-protocol]. 1419 [OPEN ISSUE: the -01 of this document is missing this information.] 1421 Once all m= sections have been generated, a session-level "a=group" 1422 attribute MUST be added as specified in [RFC5888]. This attribute 1423 MUST have semantics "BUNDLE", and MUST include the mid identifiers of 1424 each m= section. The effect of this is that the browser offers all 1425 m= sections as one BUNDLE group. However, whether the m= sections 1426 are bundle-only or not depends on the BUNDLE policy. 1428 Attributes which SDP permits to either be at the session level or the 1429 media level SHOULD generally be at the media level even if they are 1430 identical. This promotes readability, especially if one of a set of 1431 initially identical attributes is subsequently changed. 1433 Attributes other than the ones specified above MAY be included, 1434 except for the following attributes which are specifically 1435 incompatible with the requirements of [I-D.ietf-rtcweb-rtp-usage], 1436 and MUST NOT be included: 1438 o "a=crypto" 1440 o "a=key-mgmt" 1442 o "a=ice-lite" 1444 Note that when BUNDLE is used, any additional attributes that are 1445 added MUST follow the advice in [I-D.ietf-mmusic-sdp-mux-attributes] 1446 on how those attributes interact with BUNDLE. 1448 Note that these requirements are in some cases stricter than those of 1449 SDP. Implementations MUST be prepared to accept compliant SDP even 1450 if it would not conform to the requirements for generating SDP in 1451 this specification. 1453 5.2.2. Subsequent Offers 1455 When createOffer is called a second (or later) time, or is called 1456 after a local description has already been installed, the processing 1457 is somewhat different than for an initial offer. 1459 If the initial offer was not applied using setLocalDescription, 1460 meaning the PeerConnection is still in the "stable" state, the steps 1461 for generating an initial offer should be followed, subject to the 1462 following restriction: 1464 o The fields of the "o=" line MUST stay the same except for the 1465 field, which MUST increment if the session 1466 description changes in any way, including the addition of ICE 1467 candidates. 1469 If the initial offer was applied using setLocalDescription, but an 1470 answer from the remote side has not yet been applied, meaning the 1471 PeerConnection is still in the "local-offer" state, an offer is 1472 generated by following the steps in the "stable" state above, along 1473 with these exceptions: 1475 o The "s=" and "t=" lines MUST stay the same. 1477 o Each "m=" and c=" line MUST be filled in with the port and address 1478 of the default candidate for the m= section, as described in 1479 [RFC5245], Section 4.3. Each "a=rtcp" attribute line MUST also be 1480 filled in with the port and address of the appropriate default 1481 candidate, either the default RTP or RTCP candidate, depending on 1482 whether RTCP multiplexing is currently active or not. Note that 1483 if RTCP multiplexing is being offered, but not yet active, the 1484 default RTCP candidate MUST be used, as indicated in [RFC5761], 1485 section 5.1.3. In each case, if no candidates of the desired type 1486 have yet been gathered, dummy values MUST be used, as described 1487 above. [TODO: update profile UDP/TCP per default candidate] 1489 o Each "a=mid" line MUST stay the same. 1491 o Each "a=ice-ufrag" and "a=ice-pwd" line MUST stay the same, unless 1492 the ICE configuration has changed (either changes to the supported 1493 STUN/TURN servers, or the ICE candidate policy), or the 1494 "IceRestart" option (Section 5.2.3.3 was specified. 1496 o Within each m= section, for each candidate that has been gathered 1497 during the most recent gathering phase (see Section 3.4.1), an 1498 "a=candidate" line MUST be added, as specified in [RFC5245], 1499 Section 4.3., paragraph 3. If candidate gathering for the section 1500 has completed, an "a=end-of-candidates" attribute MUST be added, 1501 as described in [I-D.ietf-mmusic-trickle-ice], Section 9.3. 1503 o For MediaStreamTracks that are still present, the "a=msid", 1504 "a=ssrc", and "a=ssrc-group" lines MUST stay the same. 1506 o If any MediaStreamTracks have been removed, either through the 1507 removeStream method or by removing them from an added MediaStream, 1508 their m= sections MUST be marked as recvonly by changing the value 1509 of the [RFC3264] directional attribute to "a=recvonly". The 1510 "a=msid", "a=ssrc", and "a=ssrc-group" lines MUST be removed from 1511 the associated m= sections. 1513 o If any MediaStreamTracks have been added, and there exist m= 1514 sections of the appropriate media type with no associated 1515 MediaStreamTracks (i.e. as described in the preceding paragraph), 1516 those m= sections MUST be recycled by adding the new 1517 MediaStreamTrack to the m= section. This is done by adding the 1518 necessary "a=msid", "a=ssrc", and "a=ssrc-group" lines to the 1519 recycled m= section, and removing the "a=recvonly" attribute. 1521 If the initial offer was applied using setLocalDescription, and an 1522 answer from the remote side has been applied using 1523 setRemoteDescription, meaning the PeerConnection is in the "remote- 1524 pranswer" or "stable" states, an offer is generated based on the 1525 negotiated session descriptions by following the steps mentioned for 1526 the "local-offer" state above, along with these exceptions: [OPEN 1527 ISSUE: should this be permitted in the remote-pranswer state?] 1529 o If a m= section exists in the current local description, but does 1530 not have an associated local MediaStreamTrack (possibly because 1531 said MediaStreamTrack was removed since the last exchange), a m= 1532 section MUST still be generated in the new offer, as indicated in 1533 [RFC3264], Section 8. The disposition of this section will depend 1534 on the state of the remote MediaStreamTrack associated with this 1535 m= section. If one exists, and it is still in the "live" state, 1536 the new m= section MUST be marked as "a=recvonly", with no 1537 "a=msid" or related attributes present. If no remote 1538 MediaStreamTrack exists, or it is in the "ended" state, the m= 1539 section MUST be marked as rejected, by setting the port to zero, 1540 as indicated in [RFC3264], Section 8.2. 1542 o If any MediaStreamTracks have been added, and there exist recvonly 1543 m= sections of the appropriate media type with no associated 1544 MediaStreamTracks, or rejected m= sections of any media type, 1545 those m= sections MUST be recycled, and a local MediaStreamTrack 1546 associated with these recycled m= sections until all such existing 1547 m= sections have been used. This includes any recvonly or 1548 rejected m= sections created by the preceding paragraph. 1550 In addition, for each non-recycled, non-rejected m= section in the 1551 new offer, the following adjustments are made based on the contents 1552 of the corresponding m= section in the current remote description: 1554 o The m= line and corresponding "a=rtpmap" and "a=fmtp" lines MUST 1555 only include codecs present in the remote description. 1557 o The RTP header extensions MUST only include those that are present 1558 in the remote description. 1560 o The RTCP feedback extensions MUST only include those that are 1561 present in the remote description. 1563 o The "a=rtcp-mux" line MUST only be added if present in the remote 1564 description. 1566 o The "a=rtcp-rsize" line MUST only be added if present in the 1567 remote description. 1569 The "a=group:BUNDLE" attribute MUST include the mid identifiers 1570 specified in the BUNDLE group in the most recent answer, minus any m= 1571 sections that have been marked as rejected, plus any newly added or 1572 re-enabled m= sections. In other words, the BUNDLE attribute must 1573 contain all m= sections that were previously bundled, as long as they 1574 are still alive, as well as any new m= sections. 1576 5.2.3. Options Handling 1578 The createOffer method takes as a parameter an RTCOfferOptions 1579 object. Special processing is performed when generating a SDP 1580 description if the following constraints are present. 1582 5.2.3.1. OfferToReceiveAudio 1584 If the "OfferToReceiveAudio" option is specified, with an integer 1585 value of N, and M audio MediaStreamTracks have been added to the 1586 PeerConnection, the offer MUST include N non-rejected m= sections 1587 with media type "audio", even if N is greater than M. This allows 1588 the offerer to receive audio, including multiple independent streams, 1589 even when not sending it; accordingly, the directional attribute on 1590 the N-M audio m= sections without associated MediaStreamTracks MUST 1591 be set to recvonly. 1593 If N is set to a value less than M, the offer MUST mark the m= 1594 sections associated with the M-N most recently added (since the last 1595 setLocalDescription) MediaStreamTracks as sendonly. This allows the 1596 offerer to indicate that it does not want to receive audio on some or 1597 all of its newly created streams. For m= sections that have 1598 previously been negotiated, this setting has no effect. [TODO: refer 1599 to RTCRtpSender in the future] 1601 For backwards compatibility with pre-standard versions of this 1602 specification, a value of "true" is interpreted as equivalent to N=1, 1603 and "false" as N=0. 1605 5.2.3.2. OfferToReceiveVideo 1607 If the "OfferToReceiveVideo" option is specified, with an integer 1608 value of N, and M video MediaStreamTracks have been added to the 1609 PeerConnection, the offer MUST include N non-rejected m= sections 1610 with media type "video", even if N is greater than M. This allows 1611 the offerer to receive video, including multiple independent streams, 1612 even when not sending it; accordingly, the directional attribute on 1613 the N-M video m= sections without associated MediaStreamTracks MUST 1614 be set to recvonly. 1616 If N is set to a value less than M, the offer MUST mark the m= 1617 sections associated with the M-N most recently added (since the last 1618 setLocalDescription) MediaStreamTracks as sendonly. This allows the 1619 offerer to indicate that it does not want to receive video on some or 1620 all of its newly created streams. For m= sections that have 1621 previously been negotiated, this setting has no effect. [TODO: refer 1622 to RTCRtpSender in the future] 1623 For backwards compatibility with pre-standard versions of this 1624 specification, a value of "true" is interpreted as equivalent to N=1, 1625 and "false" as N=0. 1627 5.2.3.3. IceRestart 1629 If the "IceRestart" option is specified, with a value of "true", the 1630 offer MUST indicate an ICE restart by generating new ICE ufrag and 1631 pwd attributes, as specified in [RFC5245], Section 9.1.1.1. If this 1632 option is specified on an initial offer, it has no effect (since a 1633 new ICE ufrag and pwd are already generated). Similarly, if the ICE 1634 configuration has changed, this option has no effect, since new ufrag 1635 and pwd attributes will be generated automatically. This option is 1636 primarily useful for reestablishing connectivity in cases where 1637 failures are detected by the application. 1639 5.2.3.4. VoiceActivityDetection 1641 If the "VoiceActivityDetection" option is specified, with a value of 1642 "true", the offer MUST indicate support for silence suppression in 1643 the audio it receives by including comfort noise ("CN") codecs for 1644 each offered audio codec, as specified in [RFC3389], Section 5.1, 1645 except for codecs that have their own internal silence suppression 1646 support. For codecs that have their own internal silence suppression 1647 support, the appropriate fmtp parameters for that codec MUST be 1648 specified to indicate that silence suppression for received audio is 1649 desired. For example, when using the Opus codec, the "usedtx=1" 1650 parameter would be specified in the offer. This option allows the 1651 endpoint to significantly reduce the amount of audio bandwidth it 1652 receives, at the cost of some fidelity, depending on the quality of 1653 the remote VAD algorithm. 1655 5.3. Generating an Answer 1657 When createAnswer is called, a new SDP description must be created 1658 that is compatible with the supplied remote description as well as 1659 the requirements specified in [I-D.ietf-rtcweb-rtp-usage]. The exact 1660 details of this process are explained below. 1662 5.3.1. Initial Answers 1664 When createAnswer is called for the first time after a remote 1665 description has been provided, the result is known as the initial 1666 answer. If no remote description has been installed, an answer 1667 cannot be generated, and an error MUST be returned. 1669 Note that the remote description SDP may not have been created by a 1670 JSEP endpoint and may not conform to all the requirements listed in 1671 Section 5.2. For many cases, this is not a problem. However, if any 1672 mandatory SDP attributes are missing, or functionality listed as 1673 mandatory-to-use above is not present, this MUST be treated as an 1674 error, and MUST cause the affected m= sections to be marked as 1675 rejected. 1677 The first step in generating an initial answer is to generate 1678 session-level attributes. The process here is identical to that 1679 indicated in the Initial Offers section above. 1681 The next step is to generate m= sections for each m= section that is 1682 present in the remote offer, as specified in [RFC3264], Section 6. 1683 For the purposes of this discussion, any session-level attributes in 1684 the offer that are also valid as media-level attributes SHALL be 1685 considered to be present in each m= section. 1687 The next step is to go through each offered m= section. If there is 1688 a local MediaStreamTrack of the same type which has been added to the 1689 PeerConnection via addStream and not yet associated with a m= 1690 section, and the specific m= section is either sendrecv or recvonly, 1691 the MediaStreamTrack will be associated with the m= section at this 1692 time. MediaStreamTracks are assigned to m= sections using the 1693 canonical order described in Section 5.2.1. If there are more m= 1694 sections of a certain type than MediaStreamTracks, some m= sections 1695 will not have an associated MediaStreamTrack. If there are more 1696 MediaStreamTracks of a certain type than compatible m= sections, only 1697 the first N MediaStreamTracks will be able to be associated in the 1698 constructed answer. The remainder will need to be associated in a 1699 subsequent offer. 1701 For each offered m= section, if the associated remote 1702 MediaStreamTrack has been stopped, and is therefore in state "ended", 1703 and no local MediaStreamTrack has been associated, the corresponding 1704 m= section in the answer MUST be marked as rejected by setting the 1705 port in the m= line to zero, as indicated in [RFC3264], Section 6., 1706 and further processing for this m= section can be skipped. 1708 Provided that is not the case, each m= section in the answer should 1709 then be generated as specified in [RFC3264], Section 6.1. For the m= 1710 line itself, the following rules must be followed: 1712 o The port value would normally be set to the port of the default 1713 ICE candidate for this m= section, but given that no candidates 1714 have yet been gathered, the "dummy" port value of 9 (Discard) MUST 1715 be used, as indicated in [I-D.ietf-mmusic-trickle-ice], 1716 Section 5.1. 1718 o The field MUST be set to exactly match the field 1719 for the corresponding m= line in the offer. 1721 The m= line MUST be followed immediately by a "c=" line, as specified 1722 in [RFC4566], Section 5.7. Again, as no candidates have yet been 1723 gathered, the "c=" line must contain the "dummy" value "IN IP6 ::", 1724 as defined in [I-D.ietf-mmusic-trickle-ice], Section 5.1. 1726 If the offer supports BUNDLE, all m= sections to be BUNDLEd must use 1727 the same ICE credentials and candidates; all m= sections not being 1728 BUNDLEd must use unique ICE credentials and candidates. Each m= 1729 section MUST include the following: 1731 o If present in the offer, an "a=mid" line, as specified in 1732 [RFC5888], Section 9.1. The "mid" value MUST match that specified 1733 in the offer. 1735 o An "a=rtcp" line, as specified in [RFC3605], Section 2.1, 1736 containing the dummy value "9 IN IP6 ::", because no candidates 1737 have yet been gathered. 1739 o If a local MediaStreamTrack has been associated, an "a=msid" line, 1740 as specified in [I-D.ietf-mmusic-msid], Section 2. 1742 o Depending on the directionality of the offer, the disposition of 1743 any associated remote MediaStreamTrack, and the presence of an 1744 associated local MediaStreamTrack, the appropriate directionality 1745 attribute, as specified in [RFC3264], Section 6.1. If the offer 1746 was sendrecv, and the remote MediaStreamTrack is still "live", and 1747 there is a local MediaStreamTrack that has been associated, the 1748 directionality MUST be set as sendrecv. If the offer was 1749 sendonly, and the remote MediaStreamTrack is still "live", the 1750 directionality MUST be set as recvonly. If the offer was 1751 recvonly, and a local MediaStreamTrack has been associated, the 1752 directionality MUST be set as sendonly. If the offer was 1753 inactive, the directionality MUST be set as inactive. 1755 o For each supported codec that is present in the offer, "a=rtpmap" 1756 and "a=fmtp" lines, as specified in [RFC4566], Section 6, and 1757 [RFC3264], Section 6.1. For audio, the codecs specified in 1758 [I-D.ietf-rtcweb-audio], Section 3, MUST be supported. Note that 1759 for simplicity, the answerer MAY use different payload types for 1760 codecs than the offerer, as it is not prohibited by Section 6.1. 1762 o If this m= section is for media with configurable frame sizes, 1763 e.g. audio, an "a=maxptime" line, indicating the smallest of the 1764 maximum supported frame sizes out of all codecs included above, as 1765 specified in [RFC4566], Section 6. 1767 o If "rtx" is present in the offer, for each primary codec where RTP 1768 retransmission should be used, a corresponding "a=rtpmap" line 1769 indicating "rtx" with the clock rate of the primary codec and an 1770 "a=fmtp" line that references the payload type of the primary 1771 codec, as specified in [RFC4588], Section 8.1. 1773 o For each supported FEC mechanism that is present in the offer, a 1774 corresponding "a=rtpmap" line indicating the desired FEC codec. 1776 o "a=ice-ufrag" and "a=ice-passwd" lines, as specified in [RFC5245], 1777 Section 15.4. 1779 o If the "trickle" ICE option is present in the offer, an "a=ice- 1780 options" line, with the "trickle" option, as specified in 1781 [I-D.ietf-mmusic-trickle-ice], Section 4. 1783 o An "a=fingerprint" line, as specified in [RFC4572], Section 5; the 1784 algorithm used for the fingerprint MUST match that used in the 1785 certificate signature. 1787 o An "a=setup" line, as specified in [RFC4145], Section 4, and 1788 clarified for use in DTLS-SRTP scenarios in [RFC5763], Section 5. 1789 The role value in the answer MUST be "active" or "passive"; the 1790 "active" role is RECOMMENDED. 1792 o If present in the offer, an "a=rtcp-mux" line, as specified in 1793 [RFC5761], Section 5.1.1. 1795 o If present in the offer, an "a=rtcp-rsize" line, as specified in 1796 [RFC5506], Section 5. 1798 o For each supported RTP header extension that is present in the 1799 offer, an "a=extmap" line, as specified in [RFC5285], Section 5. 1800 The list of header extensions that SHOULD/MUST be supported is 1801 specified in [I-D.ietf-rtcweb-rtp-usage], Section 5.2. [TODO: 1802 Ensure this contains MID header] Any header extensions that 1803 require encryption MUST be specified as indicated in [RFC6904], 1804 Section 4. 1806 o For each supported RTCP feedback mechanism that is present in the 1807 offer, an "a=rtcp-fb" mechanism, as specified in [RFC4585], 1808 Section 4.2. The list of RTCP feedback mechanisms that SHOULD/ 1809 MUST be supported is specified in [I-D.ietf-rtcweb-rtp-usage], 1810 Section 5.1. 1812 o If a local MediaStreamTrack has been associated, an "a=ssrc" line, 1813 as specified in [RFC5576], Section 4.1, indicating the SSRC to be 1814 used for sending media. 1816 o If a local MediaStreamTrack has been associated, and RTX has been 1817 negotiated for this m= section, another "a=ssrc" line with the RTX 1818 SSRC, and an "a=ssrc-group" line, as specified in [RFC5576], 1819 section 4.2, with semantics set to "FID" and including the primary 1820 and RTX SSRCs. 1822 o If a local MediaStreamTrack has been associated, and FEC has been 1823 negotiated for this m= section, another "a=ssrc" line with the FEC 1824 SSRC, and an "a=ssrc-group" line, as specified in [RFC5576], 1825 section 4.2, with semantics set to "FEC" and including the primary 1826 and FEC SSRCs. 1828 o [OPEN ISSUE: Handling of a=imageattr] 1830 If a data channel m= section has been offered, a m= section MUST also 1831 be generated for data. The field MUST be set to 1832 "application" and the field MUST be set to exactly match the 1833 field in the offer; the "fmt" value MUST be set to the SCTP port 1834 number, as specified in Section 4.1. [TODO: update this to use 1835 a=sctp-port, as indicated in the latest data channel docs] 1837 Within the data m= section, the "a=mid", "a=ice-ufrag", "a=ice- 1838 passwd", "a=ice-options", "a=candidate", "a=fingerprint", and 1839 "a=setup" lines MUST be included as mentioned above, along with an 1840 "a=sctpmap" line referencing the SCTP port number and specifying the 1841 application protocol indicated in [I-D.ietf-rtcweb-data-protocol]. 1842 [OPEN ISSUE: the -01 of this document is missing this information.] 1844 If "a=group" attributes with semantics of "BUNDLE" are offered, 1845 corresponding session-level "a=group" attributes MUST be added as 1846 specified in [RFC5888]. These attributes MUST have semantics 1847 "BUNDLE", and MUST include the all mid identifiers from the offered 1848 BUNDLE groups that have not been rejected. Note that regardless of 1849 the presence of "a=bundle-only" in the offer, no m= sections in the 1850 answer should have an "a=bundle-only" line. 1852 Attributes that are common between all m= sections MAY be moved to 1853 session-level, if explicitly defined to be valid at session-level. 1855 The attributes prohibited in the creation of offers are also 1856 prohibited in the creation of answers. 1858 5.3.2. Subsequent Answers 1859 5.3.3. Options Handling 1861 The createOffer method takes as a parameter an RTCAnswerOptions 1862 object. Special processing is performed when generating a SDP 1863 description if the following constraints are present. 1865 5.3.3.1. VoiceActivityDetection 1867 Handling of the "VoiceActivityDetection" option in answers is the 1868 same as is indicated for offers in Section 5.2.3.4. 1870 5.4. Parsing an Offer 1872 5.5. Parsing an Answer 1874 5.6. Applying a Local Description 1876 5.7. Applying a Remote Description 1878 6. Configurable SDP Parameters 1880 It is possible to change elements in the SDP returned from 1881 createOffer before passing it to setLocalDescription. When an 1882 implementation receives modified SDP it MUST either: 1884 o Accept the changes and adjust its behavior to match the SDP. 1886 o Reject the changes and return an error via the error callback. 1888 Changes MUST NOT be silently ignored. 1890 The following elements of the SDP media description MUST NOT be 1891 changed between the createOffer and the setLocalDescription, since 1892 they reflect transport attributes that are solely under browser 1893 control, and the browser MUST NOT honor an attempt to change them: 1895 o The number, type and port number of m= lines. 1897 o The generated ICE credentials (a=ice-ufrag and a=ice-pwd). 1899 o The set of ICE candidates and their parameters (a=candidate). 1901 The following modifications, if done by the browser to a description 1902 between createOffer/createAnswer and the setLocalDescription, MUST be 1903 honored by the browser: 1905 o Remove or reorder codecs (m=) 1906 The following parameters may be controlled by constraints passed into 1907 createOffer/createAnswer. As an open issue, these changes may also 1908 be be performed by manipulating the SDP returned from createOffer/ 1909 createAnswer, as indicated above, as long as the capabilities of the 1910 endpoint are not exceeded (e.g. asking for a resolution greater than 1911 what the endpoint can encode): 1913 o [[OPEN ISSUE: This is a placeholder for other modifications, which 1914 we may continue adding as use cases appear.]] 1916 Implementations MAY choose to either honor or reject any elements not 1917 listed in the above two categories, but must do so explicitly as 1918 described at the beginning of this section. Note that future 1919 standards may add new SDP elements to the list of elements which must 1920 be accepted or rejected, but due to version skew, applications must 1921 be prepared for implementations to accept changes which must be 1922 rejected and vice versa. 1924 The application can also modify the SDP to reduce the capabilities in 1925 the offer it sends to the far side or the offer that it installs from 1926 the far side in any way the application sees fit, as long as it is a 1927 valid SDP offer and specifies a subset of what was in the original 1928 offer. This is safe because the answer is not permitted to expand 1929 capabilities and therefore will just respond to what is actually in 1930 the offer. 1932 As always, the application is solely responsible for what it sends to 1933 the other party, and all incoming SDP will be processed by the 1934 browser to the extent of its capabilities. It is an error to assume 1935 that all SDP is well-formed; however, one should be able to assume 1936 that any implementation of this specification will be able to 1937 process, as a remote offer or answer, unmodified SDP coming from any 1938 other implementation of this specification. 1940 7. Examples 1942 Note that this example section shows several SDP fragments. To 1943 format in 72 columns, some of the lines in SDP have been split into 1944 multiple lines, where leading whitespace indicates that a line is a 1945 continuation of the previous line. In addition, some blank lines 1946 have been added to improve readability but are not valid in SDP. 1948 More examples of SDP for WebRTC call flows can be found in 1949 [I-D.nandakumar-rtcweb-sdp]. 1951 7.1. Simple Example 1953 This section shows a very simple example that sets up a minimal audio 1954 / video call between two browsers and does not use trickle ICE. The 1955 example in the following section provides a more realistic example of 1956 what would happen in a normal browser to browser connection. 1958 The flow shows Alice's browser initiating the session to Bob's 1959 browser. The messages from Alice's JS to Bob's JS are assumed to 1960 flow over some signaling protocol via a web server. The JS on both 1961 Alice's side and Bob's side waits for all candidates before sending 1962 the offer or answer, so the offers and answers are complete. Trickle 1963 ICE is not used. Both Alice and Bob are using the default policy of 1964 balanced. 1966 // set up local media state 1967 AliceJS->AliceUA: create new PeerConnection 1968 AliceJS->AliceUA: addStream with stream containing audio and video 1969 AliceJS->AliceUA: createOffer to get offer 1970 AliceJS->AliceUA: setLocalDescription with offer 1971 AliceUA->AliceJS: multiple onicecandidate callbacks with candidates 1973 // wait for ICE gathering to complete 1974 AliceUA->AliceJS: onicecandidate callback with null candidate 1975 AliceJS->AliceUA: get |offer-A1| from value of localDescription 1977 // |offer-A1| is sent over signaling protocol to Bob 1978 AliceJS->WebServer: signaling with |offer-A1| 1979 WebServer->BobJS: signaling with |offer-A1| 1981 // |offer-A1| arrives at Bob 1982 BobJS->BobUA: create a PeerConnection 1983 BobJS->BobUA: setRemoteDescription with |offer-A1| 1984 BobUA->BobJS: onaddstream callback with remoteStream 1986 // Bob accepts call 1987 BobJS->BobUA: addStream with local media 1988 BobJS->BobUA: createAnswer 1989 BobJS->BobUA: setLocalDescription with answer 1990 BobUA->BobJS: multiple onicecandidate callbacks with candidates 1992 // wait for ICE gathering to complete 1993 BobUA->BobJS: onicecandidate callback with null candidate 1994 BobJS->BobUA: get |answer-A1| from value of localDescription 1996 // |answer-A1| is sent over signaling protocol to Alice 1997 BobJS->WebServer: signaling with |answer-A1| 1998 WebServer->AliceJS: signaling with |answer-A1| 2000 // |answer-A1| arrives at Alice 2001 AliceJS->AliceUA: setRemoteDescription with |answer-A1| 2002 AliceUA->AliceJS: onaddstream callback with remoteStream 2004 // media flows 2005 BobUA->AliceUA: media sent from Bob to Alice 2006 AliceUA->BobUA: media sent from Alice to Bob 2008 The SDP for |offer-A1| looks like: 2010 v=0 2011 o=- 4962303333179871722 1 IN IP4 0.0.0.0 2012 s=- 2013 t=0 0 2014 a=msid-semantic:WMS 2015 a=group:BUNDLE a1 v1 2016 m=audio 56500 UDP/TLS/RTP/SAVPF 96 0 8 97 98 2017 c=IN IP4 192.0.2.1 2018 a=mid:a1 2019 a=rtcp:56501 IN IP4 192.0.2.1 2020 a=msid:47017fee-b6c1-4162-929c-a25110252400 2021 f83006c5-a0ff-4e0a-9ed9-d3e6747be7d9 2022 a=sendrecv 2023 a=rtpmap:96 opus/48000/2 2024 a=rtpmap:0 PCMU/8000 2025 a=rtpmap:8 PCMA/8000 2026 a=rtpmap:97 telephone-event/8000 2027 a=rtpmap:98 telephone-event/48000 2028 a=maxptime:120 2029 a=ice-ufrag:ETEn1v9DoTMB9J4r 2030 a=ice-pwd:OtSK0WpNtpUjkY4+86js7ZQl 2031 a=ice-options:trickle 2032 a=fingerprint:sha-256 2033 19:E2:1C:3B:4B:9F:81:E6:B8:5C:F4:A5:A8:D8:73:04 2034 :BB:05:2F:70:9F:04:A9:0E:05:E9:26:33:E8:70:88:A2 2035 a=setup:actpass 2036 a=rtcp-mux 2037 a=rtcp-rsize 2038 a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level 2039 a=extmap:2 urn:ietf:params:rtp-hdrext:sdes:mid 2040 a=ssrc:1732846380 cname:EocUG1f0fcg/yvY7 2041 a=candidate:3348148302 1 udp 2113937151 192.0.2.1 56500 2042 typ host 2043 a=candidate:3348148302 2 udp 2113937151 192.0.2.1 56501 2044 typ host 2045 a=end-of-candidates 2047 m=video 56502 UDP/TLS/RTP/SAVPF 100 101 2048 c=IN IP4 192.0.2.1 2049 a=rtcp:56503 IN IP4 192.0.2.1 2050 a=mid:v1 2051 a=msid:61317484-2ed4-49d7-9eb7-1414322a7aae 2052 f30bdb4a-5db8-49b5-bcdc-e0c9a23172e0 2053 a=sendrecv 2054 a=rtpmap:100 VP8/90000 2055 a=rtpmap:101 rtx/90000 2056 a=fmtp:101 apt=100 2057 a=ice-ufrag:BGKkWnG5GmiUpdIV 2058 a=ice-pwd:mqyWsAjvtKwTGnvhPztQ9mIf 2059 a=ice-options:trickle 2060 a=fingerprint:sha-256 2061 19:E2:1C:3B:4B:9F:81:E6:B8:5C:F4:A5:A8:D8:73:04 2063 :BB:05:2F:70:9F:04:A9:0E:05:E9:26:33:E8:70:88:A2 2064 a=setup:actpass 2065 a=rtcp-mux 2066 a=rtcp-rsize 2067 a=extmap:3 urn:ietf:params:rtp-hdrext:sdes:mid 2068 a=rtcp-fb:100 ccm fir 2069 a=rtcp-fb:100 nack 2070 a=rtcp-fb:100 nack pli 2071 a=ssrc:1366781083 cname:EocUG1f0fcg/yvY7 2072 a=ssrc:1366781084 cname:EocUG1f0fcg/yvY7 2073 a=ssrc-group:FID 1366781083 1366781084 2074 a=candidate:3348148302 1 udp 2113937151 192.0.2.1 56502 2075 typ host 2076 a=candidate:3348148302 2 udp 2113937151 192.0.2.1 56503 2077 typ host 2078 a=end-of-candidates 2080 The SDP for |answer-A1| looks like: 2082 v=0 2083 o=- 6729291447651054566 1 IN IP4 0.0.0.0 2084 s=- 2085 t=0 0 2086 a=msid-semantic:WMS 2087 m=audio 20000 UDP/TLS/RTP/SAVPF 96 0 8 97 98 2088 c=IN IP4 192.0.2.2 2089 a=mid:a1 2090 a=rtcp:20000 IN IP4 192.0.2.2 2091 a=msid:PI39StLS8W7ZbQl1sJsWUXkr3Zf12fJUvzQ1 2092 PI39StLS8W7ZbQl1sJsWUXkr3Zf12fJUvzQ1a0 2093 a=sendrecv 2094 a=rtpmap:96 opus/48000/2 2095 a=rtpmap:0 PCMU/8000 2096 a=rtpmap:8 PCMA/8000 2097 a=rtpmap:97 telephone-event/8000 2098 a=rtpmap:98 telephone-event/48000 2099 a=maxptime:120 2100 a=ice-ufrag:6sFvz2gdLkEwjZEr 2101 a=ice-pwd:cOTZKZNVlO9RSGsEGM63JXT2 2102 a=fingerprint:sha-256 6B:8B:F0:65:5F:78:E2:51:3B:AC:6F:F3:3F:46:1B:35 2103 :DC:B8:5F:64:1A:24:C2:43:F0:A1:58:D0:A1:2C:19:08 2104 a=setup:active 2105 a=rtcp-mux 2106 a=rtcp-rsize 2107 a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level 2108 a=ssrc:3429951804 cname:Q/NWs1ao1HmN4Xa5 2109 a=candidate:2299743422 1 udp 2113937151 192.0.2.2 20000 2110 typ host 2112 a=end-of-candidates 2114 m=video 20001 UDP/TLS/RTP/SAVPF 100 101 2115 c=IN IP4 192.0.2.2 2116 a=rtcp 20001 IN IP4 192.0.2.2 2117 a=mid:v1 2118 a=msid:PI39StLS8W7ZbQl1sJsWUXkr3Zf12fJUvzQ1 2119 PI39StLS8W7ZbQl1sJsWUXkr3Zf12fJUvzQ1v0 2120 a=sendrecv 2121 a=rtpmap:100 VP8/90000 2122 a=rtpmap:101 rtx/90000 2123 a=fmtp:101 apt=100 2124 a=ice-ufrag:6sFvz2gdLkEwjZEr 2125 a=ice-pwd:cOTZKZNVlO9RSGsEGM63JXT2 2126 a=fingerprint:sha-256 6B:8B:F0:65:5F:78:E2:51:3B:AC:6F:F3:3F:46:1B:35 2127 :DC:B8:5F:64:1A:24:C2:43:F0:A1:58:D0:A1:2C:19:08 2128 a=setup:active 2129 a=rtcp-mux 2130 a=rtcp-rsize 2131 a=rtcp-fb:100 ccm fir 2132 a=rtcp-fb:100 nack 2133 a=rtcp-fb:100 nack pli 2134 a=ssrc:3229706345 cname:Q/NWs1ao1HmN4Xa5 2135 a=ssrc:3229706346 cname:Q/NWs1ao1HmN4Xa5 2136 a=ssrc-group:FID 3229706345 3229706346 2137 a=candidate:2299743422 1 udp 2113937151 192.0.2.2 20001 2138 typ host 2139 a=end-of-candidates 2141 7.2. Normal Examples 2143 This section shows a typical example of a session between two 2144 browsers setting up an audio channel and a data channel. Trickle ICE 2145 is used in full trickle mode with a policy of max-bundle-and-rtcp-mux 2146 and a single TURN server. Later, two video flows, one for the 2147 presenter and one for screen sharing, are added to the session. This 2148 example shows Alice's browser initiating the session to Bob's 2149 browser. The messages from Alice's JS to Bob's JS are assumed to 2150 flow over some signaling protocol via a web server. 2152 // set up local media state 2153 AliceJS->AliceUA: create new PeerConnection 2154 AliceJS->AliceUA: addStream that contains audio track 2155 AliceJS->AliceUA: createDataChannel to get data channel 2156 AliceJS->AliceUA: createOffer to get |offer-B1| 2157 AliceJS->AliceUA: setLocalDescription with |offer-B1| 2159 // |offer-B1| is sent over signaling protocol to Bob 2160 AliceJS->WebServer: signaling with |offer-B1| 2161 WebServer->BobJS: signaling with |offer-B1| 2163 // |offer-B1| arrives at Bob 2164 BobJS->BobUA: create a PeerConnection 2165 BobJS->BobUA: setRemoteDescription with |offer-B1| 2166 BobUA->BobJS: onaddstream with audio track from Alice 2168 // candidates are sent to Bob 2169 AliceUA->AliceJS: onicecandidate callback with |candidate-B1| (host) 2170 AliceJS->WebServer: signaling with |candidate-B1| 2171 AliceUA->AliceJS: onicecandidate callback with |candidate-B2| (srflx) 2172 AliceJS->WebServer: signaling with |candidate-B2| 2173 AliceUA->AliceJS: onicecandidate callback with |candidate-B3| (relay) 2174 AliceJS->WebServer: signaling with |candidate-B3| 2176 WebServer->BobJS: signaling with |candidate-B1| 2177 BobJS->BobUA: addIceCandidate with |candidate-B1| 2178 WebServer->BobJS: signaling with |candidate-B2| 2179 BobJS->BobUA: addIceCandidate with |candidate-B2| 2180 WebServer->BobJS: signaling with |candidate-B3| 2181 BobJS->BobUA: addIceCandidate with |candidate-B3| 2183 // Bob accepts call 2184 BobJS->BobUA: addStream with local audio stream 2185 BobJS->BobUA: createDataChannel to get data channel 2186 BobJS->BobUA: createAnswer to get |answer-B1| 2187 BobJS->BobUA: setLocalDescription with |answer-B1| 2189 // |answer-B1| is sent to Alice 2190 BobJS->WebServer: signaling with |answer-B1| 2191 WebServer->AliceJS: signaling with |answer-B1| 2192 AliceJS->AliceUA: setRemoteDescription with |answer-B1| 2193 AliceUA->AliceJS: onaddstream callback with audio track from Bob 2195 // candidates are sent to Alice 2196 BobUA->BobJS: onicecandidate callback with |candidate-B4| (host) 2197 BobJS->WebServer: signaling with |candidate-B4| 2198 BobUA->BobJS: onicecandidate callback with |candidate-B5| (srflx) 2199 BobJS->WebServer: signaling with |candidate-B5| 2200 BobUA->BobJS: onicecandidate callback with |candidate-B6| (relay) 2201 BobJS->WebServer: signaling with |candidate-B6| 2203 WebServer->AliceJS: signaling with |candidate-B4| 2204 AliceJS->AliceUA: addIceCandidate with |candidate-B4| 2205 WebServer->AliceJS: signaling with |candidate-B5| 2206 AliceJS->AliceUA: addIceCandidate with |candidate-B5| 2207 WebServer->AliceJS: signaling with |candidate-B6| 2208 AliceJS->AliceUA: addIceCandidate with |candidate-B6| 2210 // data channel opens 2211 BobUA->BobJS: ondatachannel callback 2212 AliceUA->AliceJS: ondatachannel callback 2213 BobUA->BobJS: onopen 2214 AliceUA->AliceJS: onopen 2216 // media is flowing between browsers 2217 BobUA->AliceUA: audio+data sent from Bob to Alice 2218 AliceUA->BobUA: audio+data sent from Alice to Bob 2220 // some time later Bob adds two video streams 2221 // note, no candidates exchanged, because of BUNDLE 2222 BobJS->BobUA: addStream with first video stream 2223 BobJS->BobUA: addStream with second video stream 2224 BobJS->BobUA: createOffer to get |offer-B2| 2225 BobJS->BobUA: setLocalDescription with |offer-B2| 2227 // |offer-B2| is sent to Alice 2228 BobJS->WebServer: signaling with |offer-B2| 2229 WebServer->AliceJS: signaling with |offer-B2| 2230 AliceJS->AliceUA: setRemoteDescription with |offer-B2| 2231 AliceUA->AliceJS: onaddstream callback with first video stream 2232 AliceUA->AliceJS: onaddstream callback with second video stream 2233 AliceJS->AliceUA: createAnswer to get |answer-B2| 2234 AliceJS->AliceUA: setLocalDescription with |answer-B2| 2236 // |answer-B2| is sent over signaling protocol to Bob 2237 AliceJS->WebServer: signaling with |answer-B2| 2238 WebServer->BobJS: signaling with |answer-B2| 2239 BobJS->BobUA: setRemoteDescription with |answer-B2| 2241 // media is flowing between browsers 2242 BobUA->AliceUA: audio+video+data sent from Bob to Alice 2243 AliceUA->BobUA: audio+video+data sent from Alice to Bob 2245 The SDP for |offer-B1| looks like: 2247 v=0 2248 o=- 4962303333179871723 1 IN IP4 0.0.0.0 2249 s=- 2250 t=0 0 2251 a=msid-semantic:WMS 2252 a=group:BUNDLE a1 d1 2253 m=audio 9 UDP/TLS/RTP/SAVPF 96 0 8 97 98 2254 c=IN IP6 :: 2255 a=rtcp:9 IN IP6 :: 2256 a=mid:a1 2257 a=msid:57017fee-b6c1-4162-929c-a25110252400 2258 e83006c5-a0ff-4e0a-9ed9-d3e6747be7d9 2259 a=sendrecv 2260 a=rtpmap:96 opus/48000/2 2261 a=rtpmap:0 PCMU/8000 2262 a=rtpmap:8 PCMA/8000 2263 a=rtpmap:97 telephone-event/8000 2264 a=rtpmap:98 telephone-event/48000 2265 a=maxptime:120 2266 a=ice-ufrag:ATEn1v9DoTMB9J4r 2267 a=ice-pwd:AtSK0WpNtpUjkY4+86js7ZQl 2268 a=ice-options:trickle 2269 a=fingerprint:sha-256 2270 19:E2:1C:3B:4B:9F:81:E6:B8:5C:F4:A5:A8:D8:73:04 2271 :BB:05:2F:70:9F:04:A9:0E:05:E9:26:33:E8:70:88:A2 2272 a=setup:actpass 2273 a=rtcp-mux 2274 a=rtcp-rsize 2275 a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level 2276 a=extmap:2 urn:ietf:params:rtp-hdrext:sdes:mid 2277 a=ssrc:1732846380 cname:FocUG1f0fcg/yvY7 2279 m=application 9 UDP/TLS/SCTP webrtc-datachannel 2280 c=IN IP6 :: 2281 a=mid:d1 2282 a=fmtp:webrtc-datachannel max-message-size=65536 2283 a=sctp-port 5000 2284 a=ice-ufrag:ATEn1v9DoTMB9J4r 2285 a=ice-pwd:AtSK0WpNtpUjkY4+86js7ZQl 2286 a=ice-options:trickle 2287 a=fingerprint:sha-256 19:E2:1C:3B:4B:9F:81:E6:B8:5C:F4:A5:A8:D8:73:04 2288 :BB:05:2F:70:9F:04:A9:0E:05:E9:26:33:E8:70:88:A2 2289 a=setup:actpass 2291 The SDP for |candidate-B1| looks like: 2293 candidate:109270923 1 udp 2122194687 192.168.1.2 51556 typ host 2294 The SDP for |candidate-B2| looks like: 2296 candidate:4036177503 1 udp 1685987071 11.22.33.44 52546 typ srflx 2297 raddr 192.168.1.2 rport 51556 2299 The SDP for |candidate-B3| looks like: 2301 candidate:3671762466 1 udp 41819903 22.33.44.55 61405 typ relay 2302 raddr 11.22.33.44 rport 52546 2304 The SDP for |answer-B1| looks like: 2306 v=0 2307 o=- 7729291447651054566 1 IN IP4 0.0.0.0 2308 s=- 2309 t=0 0 2310 a=msid-semantic:WMS 2311 a=group:BUNDLE a1 d1 2312 m=audio 9 UDP/TLS/RTP/SAVPF 96 0 8 97 98 2313 c=IN IP6 :: 2314 a=rtcp:9 IN IP6 :: 2315 a=mid:a1 2316 a=msid:QI39StLS8W7ZbQl1sJsWUXkr3Zf12fJUvzQ1 2317 QI39StLS8W7ZbQl1sJsWUXkr3Zf12fJUvzQ1a0 2318 a=sendrecv 2319 a=rtpmap:96 opus/48000/2 2320 a=rtpmap:0 PCMU/8000 2321 a=rtpmap:8 PCMA/8000 2322 a=rtpmap:97 telephone-event/8000 2323 a=rtpmap:98 telephone-event/48000 2324 a=maxptime:120 2325 a=ice-ufrag:7sFvz2gdLkEwjZEr 2326 a=ice-pwd:dOTZKZNVlO9RSGsEGM63JXT2 2327 a=ice-options:trickle 2328 a=fingerprint:sha-256 6B:8B:F0:65:5F:78:E2:51:3B:AC:6F:F3:3F:46:1B:35 2329 :DC:B8:5F:64:1A:24:C2:43:F0:A1:58:D0:A1:2C:19:08 2330 a=setup:active 2331 a=rtcp-mux 2332 a=rtcp-rsize 2333 a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level 2334 a=extmap:2 urn:ietf:params:rtp-hdrext:sdes:mid 2335 a=ssrc:4429951804 cname:Q/NWs1ao1HmN4Xa5 2337 m=application 9 UDP/TLS/SCTP webrtc-datachannel 2338 c=IN IP6 :: 2339 a=mid:d1 2340 a=fmtp:webrtc-datachannel max-message-size=65536 2341 a=sctp-port 5000 2342 a=ice-ufrag:7sFvz2gdLkEwjZEr 2343 a=ice-pwd:dOTZKZNVlO9RSGsEGM63JXT2 2344 a=ice-options:trickle 2345 a=fingerprint:sha-256 6B:8B:F0:65:5F:78:E2:51:3B:AC:6F:F3:3F:46:1B:35 2346 :DC:B8:5F:64:1A:24:C2:43:F0:A1:58:D0:A1:2C:19:08 2347 a=setup:active 2349 The SDP for |candidate-B4| looks like: 2351 candidate:109270924 1 udp 2122194687 192.168.2.3 61665 typ host 2353 The SDP for |candidate-B5| looks like: 2355 candidate:4036177504 1 udp 1685987071 55.66.77.88 64532 typ srflx 2356 raddr 192.168.2.3 rport 61665 2358 The SDP for |candidate-B6| looks like: 2360 candidate:3671762467 1 udp 41819903 66.77.88.99 50416 typ relay 2361 raddr 55.66.77.88 rport 64532 2363 The SDP for |offer-B2| looks like: (note the increment of the version 2364 number in the o= line, and the c= and a=rtcp lines, which indicate 2365 the local candidate that was selected) 2367 v=0 2368 o=- 7729291447651054566 2 IN IP4 0.0.0.0 2369 s=- 2370 t=0 0 2371 a=msid-semantic:WMS 2372 a=group:BUNDLE a1 d1 v1 v2 2373 m=audio 64532 UDP/TLS/RTP/SAVPF 96 0 8 97 98 2374 c=IN IP4 55.66.77.88 2375 a=rtcp:64532 IN IP4 55.66.77.88 2376 a=mid:a1 2377 a=msid:QI39StLS8W7ZbQl1sJsWUXkr3Zf12fJUvzQ1 2378 QI39StLS8W7ZbQl1sJsWUXkr3Zf12fJUvzQ1a0 2379 a=sendrecv 2380 a=rtpmap:96 opus/48000/2 2381 a=rtpmap:0 PCMU/8000 2382 a=rtpmap:8 PCMA/8000 2383 a=rtpmap:97 telephone-event/8000 2384 a=rtpmap:98 telephone-event/48000 2385 a=maxptime:120 2386 a=ice-ufrag:7sFvz2gdLkEwjZEr 2387 a=ice-pwd:dOTZKZNVlO9RSGsEGM63JXT2 2388 a=ice-options:trickle 2389 a=fingerprint:sha-256 6B:8B:F0:65:5F:78:E2:51:3B:AC:6F:F3:3F:46:1B:35 2390 :DC:B8:5F:64:1A:24:C2:43:F0:A1:58:D0:A1:2C:19:08 2391 a=setup:actpass 2392 a=rtcp-mux 2393 a=rtcp-rsize 2394 a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level 2395 a=extmap:2 urn:ietf:params:rtp-hdrext:sdes:mid 2396 a=ssrc:4429951804 cname:Q/NWs1ao1HmN4Xa5 2397 a=candidate:109270924 1 udp 2122194687 192.168.2.3 61665 typ host 2398 a=candidate:4036177504 1 udp 1685987071 55.66.77.88 64532 typ srflx 2399 raddr 192.168.2.3 rport 61665 2400 a=candidate:3671762467 1 udp 41819903 66.77.88.99 50416 typ relay 2401 raddr 55.66.77.88 rport 64532 2402 a=end-of-candidates 2403 m=application 64532 UDP/TLS/SCTP webrtc-datachannel 2404 c=IN IP4 55.66.77.88 2405 a=mid:d1 2406 a=fmtp:webrtc-datachannel max-message-size=65536 2407 a=sctp-port 5000 2408 a=ice-ufrag:7sFvz2gdLkEwjZEr 2409 a=ice-pwd:dOTZKZNVlO9RSGsEGM63JXT2 2410 a=ice-options:trickle 2411 a=fingerprint:sha-256 6B:8B:F0:65:5F:78:E2:51:3B:AC:6F:F3:3F:46:1B:35 2412 :DC:B8:5F:64:1A:24:C2:43:F0:A1:58:D0:A1:2C:19:08 2413 a=setup:actpass 2414 a=candidate:109270924 1 udp 2122194687 192.168.2.3 61665 typ host 2415 a=candidate:4036177504 1 udp 1685987071 55.66.77.88 64532 typ srflx 2416 raddr 192.168.2.3 rport 61665 2417 a=candidate:3671762467 1 udp 41819903 66.77.88.99 50416 typ relay 2418 raddr 55.66.77.88 rport 64532 2419 a=end-of-candidates 2421 m=video 64532 UDP/TLS/RTP/SAVPF 100 101 2422 c=IN IP4 55.66.77.88 2423 a=rtcp:64532 IN IP4 55.66.77.88 2424 a=mid:v1 2425 a=msid:61317484-2ed4-49d7-9eb7-1414322a7aae 2426 f30bdb4a-5db8-49b5-bcdc-e0c9a23172e0 2427 a=sendrecv 2428 a=rtpmap:100 VP8/90000 2429 a=rtpmap:101 rtx/90000 2430 a=fmtp:101 apt=100 2431 a=ice-ufrag:7sFvz2gdLkEwjZEr 2432 a=ice-pwd:dOTZKZNVlO9RSGsEGM63JXT2 2433 a=ice-options:trickle 2434 a=fingerprint:sha-256 2435 19:E2:1C:3B:4B:9F:81:E6:B8:5C:F4:A5:A8:D8:73:04 2436 :BB:05:2F:70:9F:04:A9:0E:05:E9:26:33:E8:70:88:A2 2437 a=setup:actpass 2438 a=rtcp-mux 2439 a=rtcp-rsize 2440 a=extmap:2 urn:ietf:params:rtp-hdrext:sdes:mid 2441 a=rtcp-fb:100 ccm fir 2442 a=rtcp-fb:100 nack 2443 a=rtcp-fb:100 nack pli 2444 a=ssrc:1366781083 cname:Q/NWs1ao1HmN4Xa5 2445 a=ssrc:1366781084 cname:Q/NWs1ao1HmN4Xa5 2446 a=ssrc-group:FID 1366781083 1366781084 2447 a=candidate:109270924 1 udp 2122194687 192.168.2.3 61665 typ host 2448 a=candidate:4036177504 1 udp 1685987071 55.66.77.88 64532 typ srflx 2449 raddr 192.168.2.3 rport 61665 2450 a=candidate:3671762467 1 udp 41819903 66.77.88.99 50416 typ relay 2451 raddr 55.66.77.88 rport 64532 2452 a=end-of-candidates 2454 m=video 64532 UDP/TLS/RTP/SAVPF 100 101 2455 c=IN IP4 55.66.77.88 2456 a=rtcp:64532 IN IP4 55.66.77.88 2457 a=mid:v1 2458 a=msid:71317484-2ed4-49d7-9eb7-1414322a7aae 2459 f30bdb4a-5db8-49b5-bcdc-e0c9a23172e0 2460 a=sendrecv 2461 a=rtpmap:100 VP8/90000 2462 a=rtpmap:101 rtx/90000 2463 a=fmtp:101 apt=100 2464 a=ice-ufrag:7sFvz2gdLkEwjZEr 2465 a=ice-pwd:dOTZKZNVlO9RSGsEGM63JXT2 2466 a=ice-options:trickle 2467 a=fingerprint:sha-256 2468 19:E2:1C:3B:4B:9F:81:E6:B8:5C:F4:A5:A8:D8:73:04 2469 :BB:05:2F:70:9F:04:A9:0E:05:E9:26:33:E8:70:88:A2 2470 a=setup:actpass 2471 a=rtcp-mux 2472 a=rtcp-rsize 2473 a=extmap:2 urn:ietf:params:rtp-hdrext:sdes:mid 2474 a=rtcp-fb:100 ccm fir 2475 a=rtcp-fb:100 nack 2476 a=rtcp-fb:100 nack pli 2477 a=ssrc:2366781083 cname:Q/NWs1ao1HmN4Xa5 2478 a=ssrc:2366781084 cname:Q/NWs1ao1HmN4Xa5 2479 a=ssrc-group:FID 2366781083 2366781084 2480 a=candidate:109270924 1 udp 2122194687 192.168.2.3 61665 typ host 2481 a=candidate:4036177504 1 udp 1685987071 55.66.77.88 64532 typ srflx 2482 raddr 192.168.2.3 rport 61665 2483 a=candidate:3671762467 1 udp 41819903 66.77.88.99 50416 typ relay 2484 raddr 55.66.77.88 rport 64532 2485 a=end-of-candidates 2487 The SDP for |answer-B2| looks like: (note the use of setup:passive to 2488 maintain the existing DTLS roles, and the use of a=recvonly to 2489 indicate that the video streams are one-way) 2491 v=0 2492 o=- 4962303333179871723 2 IN IP4 0.0.0.0 2493 s=- 2494 t=0 0 2495 a=msid-semantic:WMS 2496 a=group:BUNDLE a1 d1 v1 v2 2497 m=audio 52546 UDP/TLS/RTP/SAVPF 96 0 8 97 98 2498 c=IN IP4 11.22.33.44 2499 a=rtcp:52546 IN IP4 11.22.33.44 2500 a=mid:a1 2501 a=msid:57017fee-b6c1-4162-929c-a25110252400 2502 e83006c5-a0ff-4e0a-9ed9-d3e6747be7d9 2503 a=sendrecv 2504 a=rtpmap:96 opus/48000/2 2505 a=rtpmap:0 PCMU/8000 2506 a=rtpmap:8 PCMA/8000 2507 a=rtpmap:97 telephone-event/8000 2508 a=rtpmap:98 telephone-event/48000 2509 a=maxptime:120 2510 a=ice-ufrag:ATEn1v9DoTMB9J4r 2511 a=ice-pwd:AtSK0WpNtpUjkY4+86js7ZQl 2512 a=ice-options:trickle 2513 a=fingerprint:sha-256 2514 19:E2:1C:3B:4B:9F:81:E6:B8:5C:F4:A5:A8:D8:73:04 2515 :BB:05:2F:70:9F:04:A9:0E:05:E9:26:33:E8:70:88:A2 2516 a=setup:actpass 2517 a=rtcp-mux 2518 a=rtcp-rsize 2519 a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level 2520 a=extmap:2 urn:ietf:params:rtp-hdrext:sdes:mid 2521 a=ssrc:1732846380 cname:FocUG1f0fcg/yvY7 2522 a=candidate:109270923 1 udp 2122194687 192.168.1.2 51556 typ host 2523 a=candidate:4036177503 1 udp 1685987071 11.22.33.44 52546 typ srflx 2524 raddr 192.168.1.2 rport 51556 2525 a=candidate:3671762466 1 udp 41819903 22.33.44.55 61405 typ relay 2526 raddr 11.22.33.44 rport 52546 2527 a=end-of-candidates 2529 m=application 52546 UDP/TLS/SCTP webrtc-datachannel 2530 c=IN IP4 11.22.33.44 2531 a=mid:d1 2532 a=fmtp:webrtc-datachannel max-message-size=65536 2533 a=sctp-port 5000 2534 a=ice-ufrag:ATEn1v9DoTMB9J4r 2535 a=ice-pwd:AtSK0WpNtpUjkY4+86js7ZQl 2536 a=ice-options:trickle 2537 a=fingerprint:sha-256 19:E2:1C:3B:4B:9F:81:E6:B8:5C:F4:A5:A8:D8:73:04 2538 :BB:05:2F:70:9F:04:A9:0E:05:E9:26:33:E8:70:88:A2 2539 a=setup:actpass 2540 a=candidate:109270923 1 udp 2122194687 192.168.1.2 51556 typ host 2541 a=candidate:4036177503 1 udp 1685987071 11.22.33.44 52546 typ srflx 2542 raddr 192.168.1.2 rport 51556 2543 a=candidate:3671762466 1 udp 41819903 22.33.44.55 61405 typ relay 2544 raddr 11.22.33.44 rport 52546 2545 a=end-of-candidates 2546 m=video 52546 UDP/TLS/RTP/SAVPF 100 101 2547 c=IN IP4 11.22.33.44 2548 a=rtcp:52546 IN IP4 11.22.33.44 2549 a=mid:v1 2550 a=recvonly 2551 a=rtpmap:100 VP8/90000 2552 a=rtpmap:101 rtx/90000 2553 a=fmtp:101 apt=100 2554 a=ice-ufrag:ATEn1v9DoTMB9J4r 2555 a=ice-pwd:AtSK0WpNtpUjkY4+86js7ZQl 2556 a=ice-options:trickle 2557 a=fingerprint:sha-256 2558 19:E2:1C:3B:4B:9F:81:E6:B8:5C:F4:A5:A8:D8:73:04 2559 :BB:05:2F:70:9F:04:A9:0E:05:E9:26:33:E8:70:88:A2 2560 a=setup:passive 2561 a=rtcp-mux 2562 a=rtcp-rsize 2563 a=extmap:2 urn:ietf:params:rtp-hdrext:sdes:mid 2564 a=rtcp-fb:100 ccm fir 2565 a=rtcp-fb:100 nack 2566 a=rtcp-fb:100 nack pli 2567 a=candidate:109270923 1 udp 2122194687 192.168.1.2 51556 typ host 2568 a=candidate:4036177503 1 udp 1685987071 11.22.33.44 52546 typ srflx 2569 raddr 192.168.1.2 rport 51556 2570 a=candidate:3671762466 1 udp 41819903 22.33.44.55 61405 typ relay 2571 raddr 11.22.33.44 rport 52546 2572 a=end-of-candidates 2574 m=video 52546 UDP/TLS/RTP/SAVPF 100 101 2575 c=IN IP4 11.22.33.44 2576 a=rtcp:52546 IN IP4 11.22.33.44 2577 a=mid:v2 2578 a=recvonly 2579 a=rtpmap:100 VP8/90000 2580 a=rtpmap:101 rtx/90000 2581 a=fmtp:101 apt=100 2582 a=ice-ufrag:ATEn1v9DoTMB9J4r 2583 a=ice-pwd:AtSK0WpNtpUjkY4+86js7ZQl 2584 a=ice-options:trickle 2585 a=fingerprint:sha-256 2586 19:E2:1C:3B:4B:9F:81:E6:B8:5C:F4:A5:A8:D8:73:04 2587 :BB:05:2F:70:9F:04:A9:0E:05:E9:26:33:E8:70:88:A2 2588 a=setup:passive 2589 a=rtcp-mux 2590 a=rtcp-rsize 2591 a=extmap:2 urn:ietf:params:rtp-hdrext:sdes:mid 2592 a=rtcp-fb:100 ccm fir 2593 a=rtcp-fb:100 nack 2594 a=rtcp-fb:100 nack pli 2595 a=candidate:109270923 1 udp 2122194687 192.168.1.2 51556 typ host 2596 a=candidate:4036177503 1 udp 1685987071 11.22.33.44 52546 typ srflx 2597 raddr 192.168.1.2 rport 51556 2598 a=candidate:3671762466 1 udp 41819903 22.33.44.55 61405 typ relay 2599 raddr 11.22.33.44 rport 52546 2600 a=end-of-candidates 2602 8. Security Considerations 2604 The IETF has published separate documents 2605 [I-D.ietf-rtcweb-security-arch] [I-D.ietf-rtcweb-security] describing 2606 the security architecture for WebRTC as a whole. The remainder of 2607 this section describes security considerations for this document. 2609 While formally the JSEP interface is an API, it is better to think of 2610 it is an Internet protocol, with the JS being untrustworthy from the 2611 perspective of the browser. Thus, the threat model of [RFC3552] 2612 applies. In particular, JS can call the API in any order and with 2613 any inputs, including malicious ones. This is particularly relevant 2614 when we consider the SDP which is passed to setLocalDescription(). 2615 While correct API usage requires that the application pass in SDP 2616 which was derived from createOffer() or createAnswer() (perhaps 2617 suitably modified as described in Section 6, there is no guarantee 2618 that applications do so. The browser MUST be prepared for the JS to 2619 pass in bogus data instead. 2621 Conversely, the application programmer MUST recognize that the JS 2622 does not have complete control of browser behavior. One case that 2623 bears particular mention is that editing ICE candidates out of the 2624 SDP or suppressing trickled candidates does not have the expected 2625 behavior: implementations will still perform checks from those 2626 candidates even if they are not sent to the other side. Thus, for 2627 instance, it is not possible to prevent the remote peer from learning 2628 your public IP address by removing server reflexive candidates. 2629 Applications which wish to conceal their public IP address should 2630 instead configure the ICE agent to use only relay candidates. 2632 9. IANA Considerations 2634 This document requires no actions from IANA. 2636 10. Acknowledgements 2638 Significant text incorporated in the draft as well and review was 2639 provided by Harald Alvestrand and Suhas Nandakumar. Dan Burnett, 2640 Neil Stratford, Eric Rescorla, Anant Narayanan, Andrew Hutton, 2641 Richard Ejzak, Adam Bergkvist and Matthew Kaufman all provided 2642 valuable feedback on this proposal. 2644 11. References 2646 11.1. Normative References 2648 [I-D.ietf-mmusic-msid] 2649 Alvestrand, H., "Cross Session Stream Identification in 2650 the Session Description Protocol", draft-ietf-mmusic- 2651 msid-01 (work in progress), August 2013. 2653 [I-D.ietf-mmusic-sctp-sdp] 2654 Loreto, S. and G. Camarillo, "Stream Control Transmission 2655 Protocol (SCTP)-Based Media Transport in the Session 2656 Description Protocol (SDP)", draft-ietf-mmusic-sctp-sdp-04 2657 (work in progress), June 2013. 2659 [I-D.ietf-mmusic-sdp-bundle-negotiation] 2660 Holmberg, C., Alvestrand, H., and C. Jennings, 2661 "Multiplexing Negotiation Using Session Description 2662 Protocol (SDP) Port Numbers", draft-ietf-mmusic-sdp- 2663 bundle-negotiation-04 (work in progress), June 2013. 2665 [I-D.ietf-mmusic-sdp-mux-attributes] 2666 Nandakumar, S., "A Framework for SDP Attributes when 2667 Multiplexing", draft-ietf-mmusic-sdp-mux-attributes-01 2668 (work in progress), February 2014. 2670 [I-D.ietf-mmusic-trickle-ice] 2671 Ivov, E., Rescorla, E., and J. Uberti, "Trickle ICE: 2672 Incremental Provisioning of Candidates for the Interactive 2673 Connectivity Establishment (ICE) Protocol", draft-ietf- 2674 mmusic-trickle-ice-00 (work in progress), March 2013. 2676 [I-D.ietf-rtcweb-audio] 2677 Valin, J. and C. Bran, "WebRTC Audio Codec and Processing 2678 Requirements", draft-ietf-rtcweb-audio-02 (work in 2679 progress), August 2013. 2681 [I-D.ietf-rtcweb-data-protocol] 2682 Jesup, R., Loreto, S., and M. Tuexen, "WebRTC Data Channel 2683 Protocol", draft-ietf-rtcweb-data-protocol-04 (work in 2684 progress), February 2013. 2686 [I-D.ietf-rtcweb-rtp-usage] 2687 Perkins, C., Westerlund, M., and J. Ott, "Web Real-Time 2688 Communication (WebRTC): Media Transport and Use of RTP", 2689 draft-ietf-rtcweb-rtp-usage-09 (work in progress), 2690 September 2013. 2692 [I-D.ietf-rtcweb-security] 2693 Rescorla, E., "Security Considerations for WebRTC", draft- 2694 ietf-rtcweb-security-06 (work in progress), January 2014. 2696 [I-D.ietf-rtcweb-security-arch] 2697 Rescorla, E., "WebRTC Security Architecture", draft-ietf- 2698 rtcweb-security-arch-09 (work in progress), February 2014. 2700 [I-D.nandakumar-mmusic-proto-iana-registration] 2701 Nandakumar, S., "IANA registration of SDP 'proto' 2702 attribute for transporting RTP Media over TCP under 2703 various RTP profiles.", September 2014. 2705 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 2706 Requirement Levels", BCP 14, RFC 2119, March 1997. 2708 [RFC3261] Rosenberg, J., Schulzrinne, H., Camarillo, G., Johnston, 2709 A., Peterson, J., Sparks, R., Handley, M., and E. 2710 Schooler, "SIP: Session Initiation Protocol", RFC 3261, 2711 June 2002. 2713 [RFC3264] Rosenberg, J. and H. Schulzrinne, "An Offer/Answer Model 2714 with Session Description Protocol (SDP)", RFC 3264, June 2715 2002. 2717 [RFC3552] Rescorla, E. and B. Korver, "Guidelines for Writing RFC 2718 Text on Security Considerations", BCP 72, RFC 3552, July 2719 2003. 2721 [RFC3605] Huitema, C., "Real Time Control Protocol (RTCP) attribute 2722 in Session Description Protocol (SDP)", RFC 3605, October 2723 2003. 2725 [RFC4145] Yon, D. and G. Camarillo, "TCP-Based Media Transport in 2726 the Session Description Protocol (SDP)", RFC 4145, 2727 September 2005. 2729 [RFC4566] Handley, M., Jacobson, V., and C. Perkins, "SDP: Session 2730 Description Protocol", RFC 4566, July 2006. 2732 [RFC4572] Lennox, J., "Connection-Oriented Media Transport over the 2733 Transport Layer Security (TLS) Protocol in the Session 2734 Description Protocol (SDP)", RFC 4572, July 2006. 2736 [RFC4585] Ott, J., Wenger, S., Sato, N., Burmeister, C., and J. Rey, 2737 "Extended RTP Profile for Real-time Transport Control 2738 Protocol (RTCP)-Based Feedback (RTP/AVPF)", RFC 4585, July 2739 2006. 2741 [RFC5124] Ott, J. and E. Carrara, "Extended Secure RTP Profile for 2742 Real-time Transport Control Protocol (RTCP)-Based Feedback 2743 (RTP/SAVPF)", RFC 5124, February 2008. 2745 [RFC5245] Rosenberg, J., "Interactive Connectivity Establishment 2746 (ICE): A Protocol for Network Address Translator (NAT) 2747 Traversal for Offer/Answer Protocols", RFC 5245, April 2748 2010. 2750 [RFC5285] Singer, D. and H. Desineni, "A General Mechanism for RTP 2751 Header Extensions", RFC 5285, July 2008. 2753 [RFC5761] Perkins, C. and M. Westerlund, "Multiplexing RTP Data and 2754 Control Packets on a Single Port", RFC 5761, April 2010. 2756 [RFC5888] Camarillo, G. and H. Schulzrinne, "The Session Description 2757 Protocol (SDP) Grouping Framework", RFC 5888, June 2010. 2759 [RFC6904] Lennox, J., "Encryption of Header Extensions in the Secure 2760 Real-time Transport Protocol (SRTP)", RFC 6904, April 2761 2013. 2763 [RFC7022] Begen, A., Perkins, C., Wing, D., and E. Rescorla, 2764 "Guidelines for Choosing RTP Control Protocol (RTCP) 2765 Canonical Names (CNAMEs)", RFC 7022, September 2013. 2767 11.2. Informative References 2769 [I-D.nandakumar-rtcweb-sdp] 2770 Nandakumar, S. and C. Jennings, "SDP for the WebRTC", 2771 draft-nandakumar-rtcweb-sdp-02 (work in progress), July 2772 2013. 2774 [RFC3389] Zopf, R., "Real-time Transport Protocol (RTP) Payload for 2775 Comfort Noise (CN)", RFC 3389, September 2002. 2777 [RFC3556] Casner, S., "Session Description Protocol (SDP) Bandwidth 2778 Modifiers for RTP Control Protocol (RTCP) Bandwidth", RFC 2779 3556, July 2003. 2781 [RFC3960] Camarillo, G. and H. Schulzrinne, "Early Media and Ringing 2782 Tone Generation in the Session Initiation Protocol (SIP)", 2783 RFC 3960, December 2004. 2785 [RFC4568] Andreasen, F., Baugher, M., and D. Wing, "Session 2786 Description Protocol (SDP) Security Descriptions for Media 2787 Streams", RFC 4568, July 2006. 2789 [RFC4588] Rey, J., Leon, D., Miyazaki, A., Varsa, V., and R. 2790 Hakenberg, "RTP Retransmission Payload Format", RFC 4588, 2791 July 2006. 2793 [RFC5506] Johansson, I. and M. Westerlund, "Support for Reduced-Size 2794 Real-Time Transport Control Protocol (RTCP): Opportunities 2795 and Consequences", RFC 5506, April 2009. 2797 [RFC5576] Lennox, J., Ott, J., and T. Schierl, "Source-Specific 2798 Media Attributes in the Session Description Protocol 2799 (SDP)", RFC 5576, June 2009. 2801 [RFC5763] Fischl, J., Tschofenig, H., and E. Rescorla, "Framework 2802 for Establishing a Secure Real-time Transport Protocol 2803 (SRTP) Security Context Using Datagram Transport Layer 2804 Security (DTLS)", RFC 5763, May 2010. 2806 [RFC5764] McGrew, D. and E. Rescorla, "Datagram Transport Layer 2807 Security (DTLS) Extension to Establish Keys for the Secure 2808 Real-time Transport Protocol (SRTP)", RFC 5764, May 2010. 2810 [W3C.WD-webrtc-20140617] 2811 Bergkvist, A., Burnett, D., Narayanan, A., and C. 2812 Jennings, "WebRTC 1.0: Real-time Communication Between 2813 Browsers", World Wide Web Consortium WD WD-webrtc- 2814 20140617, June 2014, 2815 . 2817 Appendix A. Change log 2819 Note: This section will be removed by RFC Editor before publication. 2821 Changes in draft-08: 2823 o Added new example section and removed old examples in appendix. 2825 o Fixed field handling. 2827 o Added text describing a=rtcp attribute. 2829 o Reworked handling of OfferToReceiveAudio and OfferToReceiveVideo 2830 per discussion at IETF 90. 2832 o Reworked trickle ICE handling and its impact on m= and c= lines 2833 per discussion at interim. 2835 o Added max-bundle-and-rtcp-mux policy. 2837 o Added description of maxptime handling. 2839 o Updated ICE candidate pool default to 0. 2841 o Resolved open issues around AppID/receiver-ID. 2843 o Reworked and expanded how changes to the ICE configuration are 2844 handled. 2846 o Some reference updates. 2848 o Editorial clarification. 2850 Changes in draft-07: 2852 o Expanded discussion of VAD and Opus DTX. 2854 o Added a security considerations section. 2856 o Rewrote the section on modifying SDP to require implementations to 2857 clearly indicate whether any given modification is allowed. 2859 o Clarified impact of IceRestart on CreateOffer in local-offer 2860 state. 2862 o Guidance on whether attributes should be defined at the media 2863 level or the session level. 2865 o Renamed "default" bundle policy to "balanced". 2867 o Removed default ICE candidate pool size and clarify how it works. 2869 o Defined a canonical order for assignment of MSTs to m= lines. 2871 o Removed discussion of rehydration. 2873 o Added Eric Rescorla as a draft editor. 2875 o Cleaned up references. 2877 o Editorial cleanup 2879 Changes in draft-06: 2881 o Reworked handling of m= line recycling. 2883 o Added handling of BUNDLE and bundle-only. 2885 o Clarified handling of rollback. 2887 o Added text describing the ICE Candidate Pool and its behavior. 2889 o Allowed OfferToReceiveX to create multiple recvonly m= sections. 2891 Changes in draft-05: 2893 o Fixed several issues identified in the createOffer/Answer sections 2894 during document review. 2896 o Updated references. 2898 Changes in draft-04: 2900 o Filled in sections on createOffer and createAnswer. 2902 o Added SDP examples. 2904 o Fixed references. 2906 Changes in draft-03: 2908 o Added text describing relationship to W3C specification 2910 Changes in draft-02: 2912 o Converted from nroff 2914 o Removed comparisons to old approaches abandoned by the working 2915 group 2917 o Removed stuff that has moved to W3C specification 2919 o Align SDP handling with W3C draft 2921 o Clarified section on forking. 2923 Changes in draft-01: 2925 o Added diagrams for architecture and state machine. 2927 o Added sections on forking and rehydration. 2929 o Clarified meaning of "pranswer" and "answer". 2931 o Reworked how ICE restarts and media directions are controlled. 2933 o Added list of parameters that can be changed in a description. 2935 o Updated suggested API and examples to match latest thinking. 2937 o Suggested API and examples have been moved to an appendix. 2939 Changes in draft -00: 2941 o Migrated from draft-uberti-rtcweb-jsep-02. 2943 Authors' Addresses 2945 Justin Uberti 2946 Google 2947 747 6th Ave S 2948 Kirkland, WA 98033 2949 USA 2951 Email: justin@uberti.name 2953 Cullen Jennings 2954 Cisco 2955 170 West Tasman Drive 2956 San Jose, CA 95134 2957 USA 2959 Email: fluffy@iii.ca 2961 Eric Rescorla (editor) 2962 Mozilla 2963 331 Evelyn Ave 2964 Mountain View, CA 94041 2965 USA 2967 Email: ekr@rtfm.com