This article needs a technical review. How you can help.
This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for usage 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 specification changes.
The createAnswer()
method of the RTCPeerConnection
interface is used by the recipient of an offer to create an answer to return to the peer which initiated the offer. This is part of the two-part offer/answer negotiation of a WebRTC peer connection.
Syntax
aPromise = RTCPeerConnection.createAnswer([options]); RTCPeerConnection.createAnswer(successCallback, failureCallback);
Parameters
options
Optional- An
RTCAnswerOptions
dictionary providing options for the answer.
RTCAnswerOptions dictionary
The RTCAnswerOptions
dictionary is used to customize the answer.
voiceActivityDetection
Optional- Some codecs and hardware are able to detect when audio begins and ends by watching for "silence" (or relatively low sound levels) to occur. This reduces network bandwidth used for audio by only sending audio data when there's actually something to broadcast. However, in some cases, this is unwanted. For example, in the case of music or other non-voice transmission, this can cause loss of important low-volume sounds. Also, emergency calls should never cut audio when quiet. This option defaults to
true
(voice activity detection enabled).
Deprecated parameters
successCallback
- An
RTCSessionDescriptionCallback
which accepts as an input anRTCSessionDescription
representing the SDP answer to then be sent to the other peer. failureCallback
- An
RTCPeerConnectionErrorCallback
which receives aDOMException
specifying the cause of the failure. This may be any of the exceptions listed under Exceptions.
Exceptions
NotReadableError
- The identity provider wasn't able to provide an identity assertion.
OperationError
- Generation of the SDP failed for some reason; this is a general failure catch-all exception.
Return value
A Promise
which when fulfilled returns a RTCSessionDescription
representing the answer which is to be delivered to the other peer
Specifications
Specification | Status | Comment |
---|---|---|
WebRTC 1.0: Real-time Communication Between Browser The definition of 'createOffer()' in that specification. |
Working Draft | Initial definition. |
Browser compatibility
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | No support [1] | 22 (22) [2] | ? | ? | ? |
Feature | Android | Android Webview | Firefox Mobile (Gecko) | Firefox OS | IE Mobile | Opera Mobile | Safari Mobile | Chrome for Android |
---|---|---|---|---|---|---|---|---|
Basic support | No support | No support [1] | 22.0 (22) [2] | ? | ? | ? | ? | No support [1] |
[1] A callback-based version of this method was deprecated in Chrome 49.
[2] The callback-based version of this method was deprecated in Firefox 37.