namespace webrtc { namespace { // The sdpMLineIndex property is an unsigned short, a zero based index of the // m-line associated with the candidate. This function ensures we consistently // set the property to -1 for out-of-bounds values, to make candidate // comparisons more robust. int EnsureValidMLineIndex(int sdp_mline_index) { if (sdp_mline_index < 0 ||
sdp_mline_index > std::numeric_limits<uint16_t>::max()) return -1; return sdp_mline_index;
}
} // namespace
// static
std::unique_ptr<IceCandidate> IceCandidate::Create(absl::string_view mid, int sdp_mline_index,
absl::string_view sdp,
SdpParseError* absl_nullable
error /*= nullptr*/) {
RTCErrorOr<Candidate> c = Candidate::ParseCandidateString(sdp); if (!c.ok()) { if (error) {
error->line = sdp;
error->description = c.error().message();
} return nullptr;
} return std::make_unique<IceCandidate>(mid, sdp_mline_index, c.value());
}
IceCandidate::IceCandidate(absl::string_view sdp_mid, int sdp_mline_index, const Candidate& candidate)
: sdp_mid_(sdp_mid),
sdp_mline_index_(EnsureValidMLineIndex(sdp_mline_index)),
candidate_(candidate) { if (sdp_mid_.empty() && sdp_mline_index_ < 0) {
RTC_LOG(LS_ERROR) << "Neither mid nor index supplied for IceCandidate.";
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.