RTCPeerConnection.setRemoteDescription()

by 1 contributor:

This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for the proper prefixes to use in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the spec changes.

The RTCPeerConnection.setRemoteDescription() method changes the remote description associated with the connection. The description defines the properties of the connection like its codec. The connection is affected by this change and must be able to support both old and new descriptions. The method takes three parameters, a RTCSessionDescription object to set, and two callbacks, one called if the change of description succeeds, another called if it failed.

The method returns instantaneously without waiting for the actual setting to be done: in case of success, the successCallback will be called; in case of failure, the errorCallback will be called.

This connection offer would usually come from data sent by a match making server. Implementors should call this to set the remote description, and then generate an answer to send back to the remote computer.

Syntax

pc.setRemoteDescription(sessionDescription, successCallback, errorCallback);

There is no return value for this method.

Parameters

sessionDescription
Is a DOMString is the description of the parameters to be applied to the remote session.
successCallback
Is a Function without parameter which will be called when the description has been successfully set. At this point, one can send the offer to a remote server that can forward it to a remote client
errorCallback
Is a RTCPeerConnectionErrorCallback which will be called if the description can't be set. It takes the following parameter:
  • errorInformation which is a DOMString describing the reason why the description has not been set.

Example

var pc = new PeerConnection();
pc.setRemoteDescription( new RTCSessionDescription( offer ), function() {
   pc.createAnswer( function( answer ) {
     pc.setLocalDescription( answer, function() {
       // send the answer to the remote connection
    })
  })
});

Specifications

Specification Status Comment
WebRTC 1.0: Real-time Communication Between Browser
The definition of 'RTCPeerConnection.setRemoteDescription()' in that specification.
Working Draft Initial specification.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) [1] (Yes) [1] Not supported (Yes) ?
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support ? ? ? Not supported ? ?

[1] Though this property is not prefixed, the interface it belongs to is.

See also

Document Tags and Contributors

Contributors to this page: teoli
Last updated by: teoli,