Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 987875 of WebRTC API

  • Revision slug: Web/API/WebRTC_API
  • Revision title: WebRTC API
  • Revision id: 987875
  • Created:
  • Creator: jpmedley
  • Is current revision? No
  • Comment Add an interface definition.

Revision Content

{{WebRTCSidebar}}

WebRTC (Web Real-Time Communications) is a technology which enables Web applications and sites to capture and optionally stream audio and/or video media, as well as to exchange arbitrary data between browsers without requiring an intermediary. The set of standards that comprises WebRTC makes it possible to share data and perform teleconferencing peer-to-peer, without requiring that the user install plug-ins or any other third-party software.

WebRTC consists of several interrelated APIs and protocols which work together to achieve this. The documentation you'll find here will help you understand the fundamentals of WebRTC, how to set up and use both data and media connections, and more.

Interfaces

{{domxref("RTCPeerConnection")}}
Represents a WebRTC connection between the local computer and a remote peer. It is used to handle efficient streaming of data between the two peers.
{{domxref("RTCSessionDescription")}}
Represents the parameters of a session. EachRTCSessionDescription consists of a description type indicating which part of the offer/answer negotiation process it describes and of the SDP descriptor of the session.
{{domxref("RTCIceCandidate")}}
Represents a candidate internet connectivity establishment (ICE) server for establishing an {{domxref("RTCPeerConnection")}}.
{{domxref("RTCPeerConnectionIceEvent")}}
Represents events that occurs in relation to ICE candidates with the target, usually an {{domxref("RTCPeerConnection")}}. Only one event is of this type: {{event("icecandidate")}}.
{{domxref("RTCRtpSender")}}
Manages the encoding and transmission of data through a {{domxref("MediaStreamTrack")}} for an {{domxref("RTCPeerConnection")}}.
{{domxref("RTCRtpReceiver")}}
Manages the reception and decoding of data through a {{domxref("MediaStreamTrack")}} for an {{domxref("RTCPeerConnection")}}.
{{domxref("RTCTrackEvent")}}
Indicates that a new incoming {{domxref("MediaStreamTrack")}} was created and an associated {{domxref("RTCRtpReceiver")}} object was added to the {{domxref("RTCPeerConnection")}} object.
{{domxref("RTCCertificate")}}
Represents a certificate that an {{domxref("RTCPeerConnection")}} uses to authenticate.
{{domxref("RTCDataChannel")}}
Represents a bi-directional data channel between two peers of a connection.
{{domxref("RTCDataChannelEvent")}}
Represents events that occur while attaching a {{domxref("RTCDataChannel")}} to a {{domxref("RTCPeerConnection")}}. The only event sent with this interface is {{event("datachannel")}}.
{{domxref("RTCDTMFSender")}}
Manages the encoding and transmission of dual-tone multi-frequency (DTMF) signaling for an {{domxref("RTCPeerConnection")}}.
{{domxref("RTCDTMFToneChangeEvent")}}
TBD
{{domxref("RTCStatsReport")}}
TBD
{{domxref("RTCIdentityProviderRegistrar")}}
TBD
{{domxref("RTCIdentityProvider")}}
TBD
{{domxref("RTCIdentityAssertion")}}
Represents the identity of the a remote peer of the current connection. If no peer has yet been set and verified this interface returns null. Once set it can't be changed
{{domxref("RTCIdentityEvent")}}
Represents an identity assertion generated by an identity provider (idP). This is usually for an {{domxref("RTCPeerConnection")}}. The only event sent with this type is {{event("identityresult")}}.
{{domxref("RTCIdentityErrorEvent")}}
Represents an error associated with the identity provider (idP). This is usually for an {{domxref("RTCPeerConnection")}}. Two events are sent with this type: {{event("idpassertionerror")}} and {{event("idpvalidationerror")}}.

Guides

WebRTC architecture overview
Beneath the APIs that developers use to create and use WebRTC connections lie a number of network protocols and connectivity standards. This brief overview covers these standards.
Lifetime of a WebRTC session
WebRTC lets you build peer-to-peer communication of arbitrary data, audio, or video—or any combination thereof—into a browser application. In this article, we'll look at the lifetime of a WebRTC session, from establishing the connection all the way through closing the connection when it's no longer needed.
WebRTC API overview
WebRTC consists of several interrelated APIs and protocols which work together to support the exchange of data and media between two or more peers. This article provides a brief overview of each of these APIs and what purpose it serves.
WebRTC basics
This article takes you through the creation of a cross-browser RTC App. By the end of it, you should have working peer-to-peer data channel and media channel.
WebRTC protocols
This article introduces the protocols on top of which the WebRTC API is built.
WebRTC connectivity
This article describes how the varous WebRTC-related protocols interact with one another in order to create a connection and transfer data and/or media among peers.

Tutorials

Improving compatibility using WebRTC adapter.js
The WebRTC organization provides on GitHub the WebRTC adapter to work around compatibility issues in different browsers' WebRTC implementations. The adapter is a JavaScript shim which lets your code to be written to the specification so that it will "just work" in all browsers with WebRTC support.
Taking still photos with WebRTC
This article shows how to use WebRTC to access the camera on a computer or mobile phone with WebRTC support and take a photo with it.
A simple RTCDataChannel sample
The {{domxref("RTCDataChannel")}} interface is a feature which lets you open a channel between two peers over which you may send and receive arbitrary data. The API is intentionally similar to the WebSocket API, so that the same programming model can be used for each.
Signaling and two-way video calling
Sample, we take the web socket chat system we've created in another example and add the ability to make video calls. The chat server is augmented to handle the WebRTC signaling.

Protocols

WebRTC-proper protocols

Specifications

Specification Status Comment
{{SpecName('WebRTC 1.0')}} {{Spec2('WebRTC 1.0')}} The initial definition of the API of WebRTC.
{{SpecName('Media Capture')}} {{Spec2('Media Capture')}} The initial definition of the object conveying the stream of media content.
{{SpecName('Media Capture DOM Elements')}} {{Spec2('Media Capture DOM Elements')}} The initial definition on how to obtain stream of content from DOM Elements

Revision Source

<p>{{WebRTCSidebar}}</p>

<p><span class="seoSummary"><strong>WebRTC</strong> (Web Real-Time Communications) is a technology which enables Web applications and sites to capture and optionally stream audio and/or video media, as well as to exchange arbitrary data between browsers without requiring an intermediary.</span> The set of standards that comprises WebRTC makes it possible to share data and perform teleconferencing peer-to-peer, without requiring that the user install plug-ins or any other third-party software.</p>

<p>WebRTC consists of several interrelated APIs and protocols which work together to achieve this. The documentation you'll find here will help you understand the fundamentals of WebRTC, how to set up and use both data and media connections, and more.</p>

<h2 id="Interfaces">Interfaces</h2>

<dl>
 <dt>{{domxref("RTCPeerConnection")}}</dt>
 <dd>Represents a WebRTC connection between the local computer and a remote peer. It is used to handle efficient streaming of data between the two peers.</dd>
 <dt>{{domxref("RTCSessionDescription")}}</dt>
 <dd>Represents the parameters of a session. Each<code>RTCSessionDescription</code>&nbsp;consists of a description&nbsp;<a href="https://developer.mozilla.org/en-US/docs/Web/API/RTCSessionDescription/type" title="The property RTCSessionDescription.type is an enum of type RTCSdpType describing the description's type."><code>type</code></a>&nbsp;indicating which part of the offer/answer negotiation process it describes and of the&nbsp;<a href="https://developer.mozilla.org/en-US/docs/Glossary/SDP" title="SDP: SDP (Session Description Protocol) is the standard describing a peer-to-peer connection. SDP contains the codec, source address, and timing information of audio and video.">SDP</a>&nbsp;descriptor of the session.</dd>
 <dt>{{domxref("RTCIceCandidate")}}</dt>
 <dd>Represents a candidate internet connectivity establishment (ICE) server for establishing an&nbsp;{{domxref("RTCPeerConnection")}}.</dd>
 <dt>{{domxref("RTCPeerConnectionIceEvent")}}</dt>
 <dd>Represents events that occurs in relation to ICE candidates with the target, usually an {{domxref("RTCPeerConnection")}}. Only one event is of this type: {{event("icecandidate")}}.</dd>
 <dt>{{domxref("RTCRtpSender")}}</dt>
 <dd>Manages the encoding and transmission of data through a&nbsp;{{domxref("MediaStreamTrack")}} for an&nbsp;{{domxref("RTCPeerConnection")}}.</dd>
 <dt>{{domxref("RTCRtpReceiver")}}</dt>
 <dd>Manages the reception and decoding of data through a&nbsp;{{domxref("MediaStreamTrack")}} for an&nbsp;{{domxref("RTCPeerConnection")}}.</dd>
 <dt>{{domxref("RTCTrackEvent")}}</dt>
 <dd>Indicates that a new incoming&nbsp;{{domxref("MediaStreamTrack")}} was created and an associated&nbsp;{{domxref("RTCRtpReceiver")}} object was added to the&nbsp;{{domxref("RTCPeerConnection")}} object.</dd>
 <dt>{{domxref("RTCCertificate")}}</dt>
 <dd>Represents a certificate that an&nbsp;{{domxref("RTCPeerConnection")}} uses to authenticate.</dd>
 <dt>{{domxref("RTCDataChannel")}}</dt>
 <dd>Represents a bi-directional data channel between two peers of a connection.</dd>
 <dt>{{domxref("RTCDataChannelEvent")}}</dt>
 <dd>Represents events that occur&nbsp;while attaching a {{domxref("RTCDataChannel")}} to a {{domxref("RTCPeerConnection")}}. The only event sent with this interface is {{event("datachannel")}}.</dd>
 <dt>{{domxref("RTCDTMFSender")}}</dt>
 <dd>Manages the encoding and transmission of dual-tone multi-frequency (DTMF) signaling&nbsp;for an&nbsp;{{domxref("RTCPeerConnection")}}.</dd>
 <dt>{{domxref("RTCDTMFToneChangeEvent")}}</dt>
 <dd>TBD</dd>
 <dt>{{domxref("RTCStatsReport")}}</dt>
 <dd>TBD</dd>
 <dt>{{domxref("RTCIdentityProviderRegistrar")}}</dt>
 <dd>TBD</dd>
 <dt>{{domxref("RTCIdentityProvider")}}</dt>
 <dd>TBD</dd>
 <dt>{{domxref("RTCIdentityAssertion")}}</dt>
 <dd>R<span style="line-height:1.5">epresents the identity of the a remote peer of the current connection. If no peer has yet been set and verified this interface returns </span><code style="font-style: normal; font-weight: normal; line-height: 1.5;">null</code><span style="line-height:1.5">. Once set it can't be changed</span></dd>
 <dt>{{domxref("RTCIdentityEvent")}}</dt>
 <dd>Represents an identity assertion&nbsp;generated by an identity provider (idP). This is usually for an {{domxref("RTCPeerConnection")}}.&nbsp;The only event sent with this type is {{event("identityresult")}}.</dd>
 <dt>{{domxref("RTCIdentityErrorEvent")}}</dt>
 <dd>Represents an error associated with the identity provider (idP). This is usually for an&nbsp;{{domxref("RTCPeerConnection")}}.&nbsp;Two events are sent with this type: {{event("idpassertionerror")}} and {{event("idpvalidationerror")}}.</dd>
</dl>

<h2 id="Guides">Guides</h2>

<dl>
 <dt><a href="https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/Architecture">WebRTC architecture overview</a></dt>
 <dd>Beneath the APIs that developers use to create and use WebRTC connections lie a number of network protocols and connectivity standards. This brief overview covers these standards.</dd>
 <dt><a href="https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/Session_lifetime">Lifetime of a WebRTC session</a></dt>
 <dd>WebRTC lets you build peer-to-peer communication of arbitrary data, audio, or video—or any combination thereof—into a browser application. In this article, we'll look at the lifetime of a WebRTC session, from establishing the connection all the way through closing the connection when it's no longer needed.</dd>
 <dt><a href="https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/Overview">WebRTC API overview</a></dt>
 <dd>WebRTC consists of several interrelated APIs and protocols which work together to support the exchange of data and media between two or more peers. This article provides a brief overview of each of these APIs and what purpose it serves.</dd>
 <dt><a href="/en-US/docs/Web/API/WebRTC_API/WebRTC_basics">WebRTC basics</a></dt>
 <dd>This article takes you through the creation of a cross-browser RTC App. By the end of it, you should have working peer-to-peer data channel and media channel.</dd>
 <dt><a href="https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/Protocols">WebRTC protocols</a></dt>
 <dd>This article introduces the protocols on top of which the WebRTC API is built.</dd>
 <dt><a href="https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/Connectivity">WebRTC connectivity</a></dt>
 <dd>This article describes how the varous WebRTC-related protocols interact with one another in order to create a connection and transfer data and/or media among peers.</dd>
</dl>

<h2 id="Tutorials">Tutorials</h2>

<dl>
 <dt><a href="https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/adapter.js">Improving compatibility using WebRTC adapter.js</a></dt>
 <dd>The WebRTC organization <a href="https://github.com/webrtc/adapter/">provides on GitHub the WebRTC adapter</a> to work around compatibility issues in different browsers' WebRTC implementations. The adapter is a JavaScript shim which lets your code to be written to the specification so that it will "just work" in all browsers with WebRTC support.</dd>
 <dt><a href="https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/Taking_still_photos">Taking still photos with WebRTC</a></dt>
 <dd>This article shows how to use WebRTC to access the camera on a computer or mobile phone with WebRTC support and take a photo with it.</dd>
 <dt><a href="https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/Simple_RTCDataChannel_sample">A simple RTCDataChannel sample</a></dt>
 <dd>The {{domxref("RTCDataChannel")}} interface is a feature which lets you open a channel between two peers over which you may send and receive arbitrary data. The API is intentionally similar to the <a href="https://developer.mozilla.org/en-US/docs/Web/API/WebSocket_API">WebSocket API</a>, so that the same programming model can be used for each.</dd>
 <dt><a href="/en-US/docs/Web/API/WebRTC_API/Signaling_and_video_calling">Signaling and two-way video calling</a></dt>
 <dd>Sample, we take the web socket chat system we've created in another example and add the ability to make video calls. The chat server is augmented to handle the WebRTC signaling.</dd>
</dl>

<h2 class="Related_Topics" id="Related_Topics" name="Related_Topics">Resources</h2>

<h3 id="Protocols">Protocols</h3>

<h4 id="WebRTC-proper_protocols">WebRTC-proper protocols</h4>

<ul>
 <li><a href="https://datatracker.ietf.org/doc/draft-ietf-rtcweb-alpn/"><cite>Application Layer Protocol Negotiation for Web Real-Time Communications</cite></a></li>
 <li><a href="https://datatracker.ietf.org/doc/draft-ietf-rtcweb-audio/"><cite>WebRTC Audio Codec and Processing Requirements</cite></a></li>
 <li><a href="https://datatracker.ietf.org/doc/draft-ietf-rtcweb-data-channel/"><cite>RTCWeb Data Channels</cite></a></li>
 <li><a href="https://datatracker.ietf.org/doc/draft-ietf-rtcweb-data-protocol/"><cite>RTCWeb Data Channel Protocol</cite></a></li>
 <li><a href="https://datatracker.ietf.org/doc/draft-ietf-rtcweb-rtp-usage/"><cite>Web Real-Time Communication (WebRTC): Media Transport and Use of RTP</cite></a></li>
 <li><a href="https://datatracker.ietf.org/doc/draft-ietf-rtcweb-security-arch/"><cite>WebRTC Security Architecture</cite></a></li>
 <li><a href="https://datatracker.ietf.org/doc/draft-ietf-rtcweb-transports/"><cite>Transports for RTCWEB</cite></a></li>
</ul>

<h4 id="Related_supporting_protocols">Related supporting protocols</h4>

<ul>
 <li><a href="https://tools.ietf.org/html/rfc5245">Interactive Connectivity Establishment (ICE): A Protocol for Network Address Translator (NAT) Traversal for Offer/Answer Protocol</a></li>
 <li><a href="https://tools.ietf.org/html/rfc5389"><cite>Session Traversal Utilities for NAT (STUN)</cite></a></li>
 <li><a href="https://tools.ietf.org/html/rfc7064"><cite>URI Scheme for the Session Traversal Utilities for NAT (STUN) Protocol</cite></a></li>
 <li><a href="https://tools.ietf.org/html/rfc7065"><cite>Traversal Using Relays around NAT (TURN) Uniform Resource Identifiers</cite></a></li>
 <li><a href="https://tools.ietf.org/html/rfc3264"><cite>An Offer/Answer Model with Session Description Protocol (SDP)</cite></a></li>
 <li><a href="https://datatracker.ietf.org/doc/draft-ietf-tram-turn-third-party-authz/"><cite>Session Traversal Utilities for NAT (STUN) Extension for Third Party Authorization</cite></a></li>
</ul>

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

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('WebRTC 1.0')}}</td>
   <td>{{Spec2('WebRTC 1.0')}}</td>
   <td>The initial definition of the API of WebRTC.</td>
  </tr>
  <tr>
   <td>{{SpecName('Media Capture')}}</td>
   <td>{{Spec2('Media Capture')}}</td>
   <td>The initial definition of the object conveying the stream of media content.</td>
  </tr>
  <tr>
   <td>{{SpecName('Media Capture DOM Elements')}}</td>
   <td>{{Spec2('Media Capture DOM Elements')}}</td>
   <td>The initial definition on how to obtain stream of content from DOM Elements</td>
  </tr>
 </tbody>
</table>

<p class="Related_Topics" name="Related_Topics">In additions to these specifications defining the API needed to use WebRTC, there are several protocols, listed under <a href="#Protocols">resources</a>.</p>

<h2 class="Related_Topics" id="Related_Topics" name="Related_Topics">See also</h2>

<ul>
 <li>{{domxref("MediaDevices")}}</li>
 <li>{{domxref("MediaStreamEvent")}}</li>
 <li>{{domxref("MediaStreamConstraints")}}</li>
 <li>{{domxref("MediaStreamTrack")}}</li>
 <li>{{domxref("MessageEvent")}}</li>
 <li>{{domxref("MediaStream")}}</li>
 <li><a href="https://hacks.mozilla.org/2015/06/firefox-multistream-and-renegotiation-for-jitsi-videobridge/">Firefox multistream and renegotiation for Jitsi Videobridge</a></li>
 <li><a href="https://hacks.mozilla.org/2015/04/peering-through-the-webrtc-fog-with-socketpeer/">Peering Through the WebRTC Fog with SocketPeer</a></li>
 <li><a href="https://hacks.mozilla.org/2014/04/inside-the-party-bus-building-a-web-app-with-multiple-live-video-streams-interactive-graphics/">Inside the Party Bus: Building a Web App with Multiple Live Video Streams + Interactive Graphics</a></li>
</ul>
Revert to this revision