RTCIceCandidate

A interface RTCIceCandidate—parte da WebRTC API—representa a configuração de um candidato a estabelecimento de conexão de internet (ICE). Que pode ser usado para estabelecer uma RTCPeerConnection.

An ICE candidate describes the protocols and routing needed for WebRTC to be able to communicate with a remote device. When starting a WebRTC peer connection, typically a number of candidates are proposed by each end of the connection, until they mutually agree upon one which describes the connection they decide will be best. WebRTC then uses that candidate's details to initiate the connection.

For details on how the ICE process works, see Lifetime of a WebRTC session. The article WebRTC connectivity provides additional useful details.

Construtor

RTCIceCandidate()
Cria um objeto RTCIceCandidate para representar um único ICE candidate, Configurado opcionalmente, baseado em um objeto baseado no dicionario RTCIceCandidateInit.
Note: For backward compatibility, the constructor also accepts as input a string containing the value of the candidate property instead of a RTCIceCandidateInit object, since the candidate includes all of the information that RTCIceCandidateInit does and more.

Propriedades

candidate Somente leitura
A DOMString representing the transport address for the candidate that can be used for connectivity checks. The format of this address is a candidate-attribute as defined in RFC 5245. This string is empty ("") if the RTCIceCandidate is an "end of candidates" indicator.
component Somente leitura
A DOMString which indicates whether the candidate is an RTP or an RTCP candidate; its value is either "rtp" or "rtcp", and is derived from the  "component-id" field in the candidate a-line string. The permitted values are listed in the RTCIceComponent enumerated type.
foundation Somente leitura
Returns a DOMString containing a unique identifier that is the same for any candidates of the same type, share the same base (the address from which the ICE agent sent the candidate), and come from the same STUN server. This is used to help optimize ICE performance while prioritizing and correlating candidates that appear on multiple RTCIceTransport objects.
ip Somente leitura
Uma DOMString contendo o endereço de IP do candidato.
port Somente leitura
Um valor inteiro indicando o número da porta do candidato.
priority Somente leitura
Um valor long indicando a prioridade do candidato.
protocol Somente leitura
Uma string indicando se o protocolo do candidato é "tcp" or "udp". A string é uma das contidas no tipo enumerável RTCIceProtocol.
relatedAddress Somente leitura
Se um candidato é derivado de outro candidato, relatedAddress é uma DOMString contendo o endereço de IP desse Host. Para candidatos Host, esse valor é null.
relatedPort Somente leitura
For a candidate that is derived from another, such as a relay or reflexive candidate, the relatedPort is a number indicating the port number of the candidate from which this candidate is derived. For host candidates, the relatedPort property is null.
sdpMid Somente leitura
A DOMString specifying the candidate's media stream identification tag which uniquely identifies the media stream within the component with which the candidate is associated, or null if no such association exists.
sdpMLineIndex Somente leitura
If not null, sdpMLineIndex indicates the zero-based index number of the media description (as defined in RFC 4566) in the SDP with which the candidate is associated.
tcpType Somente leitura
se o protocolo for "tcp"tcpType representa o tipo do candidato TCP. se não, tcpType é null.
type Somente leitura
Uma DOMString indicando o tipo do candidato como uma das strings do tipo enumerável RTCIceCandidateType.
usernameFragment Somente leitura
Uma DOMString contendo um fragmento de username gerado aleatóriamente ("ice-ufrag") que ICE usa para integridade de mensagem junto de uma senha gerada aleatóriamente ("ice-pwd"). Você pode usar essa string para verificar gerações do ICE generation; Cada geração do mesmo processo ICE vai usar o mesmousernameFragment, mesmo após ICE restarts.

Métodos

toJSON()
Dada a configuração atual do RTCIceCandidate, toJSON()retorna uma DOMString contendo uma representação JSON dessa configuração na forma de um objeto RTCIceCandidateInit.

Exmeplos

Para exemplos, veja Signaling and video calling, que demonstra o processo inteiro.

Especificações

Especificação Status Comentário
WebRTC 1.0: Real-time Communication Between Browsers
The definition of 'RTCIceCandidate' in that specification.
Candidata a Recomendação Definição inicial.

Compatibilidade de Browser

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
RTCIceCandidateChrome Full support YesEdge Full support YesFirefox Full support 22IE No support NoOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes
RTCIceCandidate()Chrome Full support YesEdge Full support YesFirefox Full support 22
Notes
Full support 22
Notes
Notes Before Firefox 68, the constructor's options parameter was required.
IE No support NoOpera Full support YesSafari ? WebView Android Full support YesChrome Android Full support YesFirefox Android Full support Yes
Notes
Full support Yes
Notes
Notes Before Firefox 68, the constructor's options parameter was required.
Opera Android Full support YesSafari iOS ? Samsung Internet Android Full support Yes
addressChrome Full support 74Edge ? Firefox ? IE No support NoOpera ? Safari ? WebView Android Full support 74Chrome Android Full support 74Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android ?
candidateChrome Full support 23Edge Full support 15Firefox Full support 22IE No support NoOpera Full support 15Safari Full support YesWebView Android Full support YesChrome Android Full support 25Firefox Android Full support YesOpera Android Full support 14Safari iOS Full support YesSamsung Internet Android Full support 1.5
componentChrome Full support 74Edge ? Firefox No support NoIE No support NoOpera ? Safari ? WebView Android Full support 74Chrome Android Full support 74Firefox Android No support NoOpera Android ? Safari iOS ? Samsung Internet Android ?
foundationChrome Full support 74Edge Full support YesFirefox No support NoIE No support NoOpera No support NoSafari ? WebView Android Full support 74Chrome Android Full support 74Firefox Android ? Opera Android No support NoSafari iOS ? Samsung Internet Android Full support Yes
ipChrome No support NoEdge Full support YesFirefox No support NoIE No support NoOpera No support NoSafari ? WebView Android No support NoChrome Android No support NoFirefox Android No support NoOpera Android No support NoSafari iOS ? Samsung Internet Android Full support Yes
portChrome Full support 74Edge Full support YesFirefox No support NoIE No support NoOpera No support NoSafari ? WebView Android Full support 74Chrome Android Full support 74Firefox Android No support NoOpera Android No support NoSafari iOS ? Samsung Internet Android Full support Yes
priorityChrome Full support 74Edge Full support YesFirefox No support NoIE No support NoOpera No support NoSafari ? WebView Android Full support 74Chrome Android Full support 74Firefox Android No support NoOpera Android No support NoSafari iOS ? Samsung Internet Android Full support Yes
protocolChrome Full support 74Edge Full support YesFirefox No support NoIE No support NoOpera No support NoSafari ? WebView Android Full support 74Chrome Android Full support 74Firefox Android No support NoOpera Android No support NoSafari iOS ? Samsung Internet Android Full support Yes
relatedAddressChrome Full support 74Edge Full support YesFirefox No support NoIE No support NoOpera No support NoSafari ? WebView Android Full support 74Chrome Android Full support 74Firefox Android No support NoOpera Android No support NoSafari iOS ? Samsung Internet Android Full support Yes
relatedPortChrome Full support 74Edge Full support YesFirefox No support NoIE No support NoOpera No support NoSafari ? WebView Android Full support 74Chrome Android Full support 74Firefox Android No support NoOpera Android No support NoSafari iOS ? Samsung Internet Android Full support Yes
sdpMidChrome Full support 23Edge Full support 15Firefox Full support 22IE No support NoOpera Full support 15Safari Full support YesWebView Android Full support YesChrome Android Full support 25Firefox Android Full support YesOpera Android Full support 14Safari iOS Full support YesSamsung Internet Android Full support 1.5
sdpMLineIndexChrome Full support 23Edge Full support 15Firefox Full support 22IE No support NoOpera Full support 15Safari Full support YesWebView Android Full support YesChrome Android Full support 25Firefox Android Full support YesOpera Android Full support 14Safari iOS Full support YesSamsung Internet Android Full support 1.5
tcpTypeChrome Full support 74Edge Full support YesFirefox No support NoIE No support NoOpera No support NoSafari ? WebView Android Full support 74Chrome Android Full support 74Firefox Android No support NoOpera Android No support NoSafari iOS ? Samsung Internet Android Full support Yes
toJSONChrome Full support 45Edge Full support 15Firefox Full support 27IE No support NoOpera Full support 32Safari Full support YesWebView Android Full support 45Chrome Android Full support 45Firefox Android Full support 27Opera Android Full support 32Safari iOS Full support YesSamsung Internet Android Full support 5.0
typeChrome Full support 74Edge Full support YesFirefox No support NoIE No support NoOpera No support NoSafari ? WebView Android Full support 74Chrome Android Full support 74Firefox Android No support NoOpera Android No support NoSafari iOS ? Samsung Internet Android Full support Yes
usernameFragmentChrome Full support 74Edge ? Firefox Full support 67IE No support NoOpera ? Safari ? WebView Android Full support 74Chrome Android Full support 74Firefox Android Full support 67Opera Android ? Safari iOS ? Samsung Internet Android ?

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
See implementation notes.
See implementation notes.