web api interface
RTCIceCandidateStats
The RTCIceCandidateStats dictionary of the WebRTC API is used to report statistics related to an RTCIceCandidate.
The statistics can be obtained by iterating the RTCStatsReport returned by getStats() until you find a report with the type of local-candidate.
Instance properties
addressOptional- : A string containing the address of the candidate. This value may be an IPv4 address, an IPv6 address, or a fully-qualified domain name. This property was previously named
ipand only accepted IP addresses. Corresponds toaddress.
- : A string containing the address of the candidate. This value may be an IPv4 address, an IPv6 address, or a fully-qualified domain name. This property was previously named
candidateType- : A string matching one of the values in
RTCIceCandidate.type, indicating what kind of candidate the object provides statistics for.
- : A string matching one of the values in
deleted- : A boolean indicating whether or not the candidate has been deleted or released.
foundationOptional Experimental- : A string that uniquely identifies the candidate across multiple transports.
Corresponds to
foundation.
- : A string that uniquely identifies the candidate across multiple transports.
Corresponds to
portOptional- : The network port number used by the candidate.
Corresponds to
port.
- : The network port number used by the candidate.
Corresponds to
priorityOptional- : The candidate’s priority.
Corresponds to
priority.
- : The candidate’s priority.
Corresponds to
protocolOptional- : A string specifying the protocol (
tcporudp) used to transmit data on theport. Corresponds toprotocol.
- : A string specifying the protocol (
relayProtocoltransportId- : A string uniquely identifying the transport object that was inspected in order to obtain the
RTCTransportStatsassociated with the candidate corresponding to these statistics.
- : A string uniquely identifying the transport object that was inspected in order to obtain the
urlOptional- : A string specifying the URL of the ICE server from which the described candidate was obtained. This property is only available for local candidates.
usernameFragmentOptional Experimental- : A string containing the ICE username fragment (“ice-ufrag”).
Corresponds to
usernameFragment.
- : A string containing the ICE username fragment (“ice-ufrag”).
Corresponds to
Common instance properties
The following properties are common to all WebRTC statistics objects.
id- : A string that uniquely identifies the object that is being monitored to produce this set of statistics.
timestamp- : A
DOMHighResTimeStampobject indicating the time at which the sample was taken for this statistics object.
- : A
type- : A string with the value
"local-candidate", indicating the type of statistics that the object contains.
- : A string with the value
Examples
Given a variable myPeerConnection, which is an instance of RTCPeerConnection, the code below uses await to wait for the statistics report, and then iterates it using RTCStatsReport.forEach().
It then filters the dictionaries for just those reports that have the type of local-candidate and logs the result.
const stats = await myPeerConnection.getStats();
stats.forEach((report) => {
if (report.type === "local-candidate") {
// Log the ICE candidate information
console.log(report);
}
});
Specifications
SpecificationsStandards references are available on the canonical MDN page.
Browser compatibility
Browser compatibilityCompatibility data is available on the canonical MDN page.