The RTCIceCandidate
()
constructor creates and returns a new RTCIceCandidate
object, which can be configured to represent a single ICE candidate.
Syntax
candidate = new RTCIceCandidate([candidateInfo]);
Parameters
candidateInfo
Optional- An optional
RTCIceCandidateInit
object providing information about the candidate; if this is provided, the candidate is initialized configured to represent the described candidate.
Return value
A newly-created RTCIceCandidate
object, optionally configured based on the specified object based on the RTCIceCandidateInit
dictionary.
If candidateInfo
is provided, the new RTCIceCandidate
is initialized as follows:
- Each member of the
RTCIceCandidateInit
object is initialized to the value of the property by the same name fromRTCIceCandidateInit
. This includes thecandidate
,sdpMid
,sdpMLineIndex
, andusernameFragment
properties. - The
candidate
string (which is SDP text) is parsed; each property found is stored in the corresponding field in theRTCIceCandidate
. If any of the fields is invalid, parsing of the string silently aborts without throwing an exception. The default value ofcandidate
is the empty string, which indicates that the candidate is an "end-of-candidates" message. - The following fields are initialized to
null
if they are not included in theRTCIceCandidate.candidate
property:foundation
,component
,priority
,ip
,protocol
,port
,type
,tcpType
,relatedAddress
, andrelatedPort
.
Note: Parsing of the candidate
string is performed using the candidate-attribute grammar from the WebRTC Specification.
Exceptions
TypeError
- The specified
RTCIceCandidateInit
has values ofnull
in both thesdpMid
andsdpMLineIndex
properties.
Usage notes
This constructor does not do complete validation of the specified candidateInfo
object or string.
Specifications
Specification | Status | Comment |
---|---|---|
WebRTC 1.0: Real-time Communication Between Browsers The definition of 'RTCIceCandidate()' in that specification. |
Candidate Recommendation | Initial definition. |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
RTCIceCandidate() constructor | Chrome Full support Yes | Edge Full support ≤18 | Firefox
Full support
22
| IE No support No | Opera Full support Yes | Safari ? | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android
Full support
Yes
| Opera Android Full support Yes | Safari iOS ? | Samsung Internet Android Full support Yes |
Legend
- Full support
- Full support
- No support
- No support
- Compatibility unknown
- Compatibility unknown
- See implementation notes.
- See implementation notes.