RTCIceCandidate* RTCIceCandidate::create(const RTCIceCandidateInit& candidateInit, ExceptionState& exceptionState) { if (!candidateInit.hasCandidate() || !candidateInit.candidate().length()) { exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::incorrectPropertyType("candidate", "is not a string, or is empty.")); return nullptr; } String sdpMid; if (candidateInit.hasSdpMid()) sdpMid = candidateInit.sdpMid(); unsigned short sdpMLineIndex = 0; if (candidateInit.hasSdpMLineIndex()) sdpMLineIndex = candidateInit.sdpMLineIndex(); return new RTCIceCandidate(WebRTCICECandidate(candidateInit.candidate(), sdpMid, sdpMLineIndex)); }
RTCIceCandidate* RTCIceCandidate::create(ExecutionContext* context, const RTCIceCandidateInit& candidateInit, ExceptionState& exceptionState) { if (!candidateInit.hasCandidate() || !candidateInit.candidate().length()) { exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::incorrectPropertyType("candidate", "is not a string, or is empty.")); return nullptr; } String sdpMid; if (candidateInit.hasSdpMid()) sdpMid = candidateInit.sdpMid(); // TODO(guidou): Change default value to -1. crbug.com/614958. unsigned short sdpMLineIndex = 0; if (candidateInit.hasSdpMLineIndex()) sdpMLineIndex = candidateInit.sdpMLineIndex(); else UseCounter::count(context, UseCounter::RTCIceCandidateDefaultSdpMLineIndex); return new RTCIceCandidate(WebRTCICECandidate(candidateInit.candidate(), sdpMid, sdpMLineIndex)); }