From d8bbc7858622b6d9c278469aab701ca0b609cddf Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 15 May 2024 05:35:49 +0200 Subject: Merging upstream version 126.0. Signed-off-by: Daniel Baumann --- .../libwebrtc/pc/jsep_session_description.cc | 36 ++++------------------ 1 file changed, 6 insertions(+), 30 deletions(-) (limited to 'third_party/libwebrtc/pc/jsep_session_description.cc') diff --git a/third_party/libwebrtc/pc/jsep_session_description.cc b/third_party/libwebrtc/pc/jsep_session_description.cc index 885c1eb310..7fae4459ec 100644 --- a/third_party/libwebrtc/pc/jsep_session_description.cc +++ b/third_party/libwebrtc/pc/jsep_session_description.cc @@ -26,37 +26,15 @@ #include "rtc_base/net_helper.h" #include "rtc_base/socket_address.h" +using cricket::Candidate; using cricket::SessionDescription; namespace webrtc { namespace { -// RFC 5245 -// It is RECOMMENDED that default candidates be chosen based on the -// likelihood of those candidates to work with the peer that is being -// contacted. It is RECOMMENDED that relayed > reflexive > host. -constexpr int kPreferenceUnknown = 0; -constexpr int kPreferenceHost = 1; -constexpr int kPreferenceReflexive = 2; -constexpr int kPreferenceRelayed = 3; - constexpr char kDummyAddress[] = "0.0.0.0"; constexpr int kDummyPort = 9; -int GetCandidatePreferenceFromType(const std::string& type) { - int preference = kPreferenceUnknown; - if (type == cricket::LOCAL_PORT_TYPE) { - preference = kPreferenceHost; - } else if (type == cricket::STUN_PORT_TYPE) { - preference = kPreferenceReflexive; - } else if (type == cricket::RELAY_PORT_TYPE) { - preference = kPreferenceRelayed; - } else { - preference = kPreferenceUnknown; - } - return preference; -} - // Update the connection address for the MediaContentDescription based on the // candidates. void UpdateConnectionAddress( @@ -65,7 +43,7 @@ void UpdateConnectionAddress( int port = kDummyPort; std::string ip = kDummyAddress; std::string hostname; - int current_preference = kPreferenceUnknown; + int current_preference = 0; // Start with lowest preference. int current_family = AF_UNSPEC; for (size_t i = 0; i < candidate_collection.count(); ++i) { const IceCandidateInterface* jsep_candidate = candidate_collection.at(i); @@ -77,8 +55,7 @@ void UpdateConnectionAddress( if (jsep_candidate->candidate().protocol() != cricket::UDP_PROTOCOL_NAME) { continue; } - const int preference = - GetCandidatePreferenceFromType(jsep_candidate->candidate().type()); + const int preference = jsep_candidate->candidate().type_preference(); const int family = jsep_candidate->candidate().address().ipaddr().family(); // See if this candidate is more preferable then the current one if it's the // same family. Or if the current family is IPv4 already so we could safely @@ -253,7 +230,7 @@ bool JsepSessionDescription::AddCandidate( return false; } - cricket::Candidate updated_candidate = candidate->candidate(); + Candidate updated_candidate = candidate->candidate(); if (updated_candidate.username().empty()) { updated_candidate.set_username(transport_info->description.ice_ufrag); } @@ -278,7 +255,7 @@ bool JsepSessionDescription::AddCandidate( } size_t JsepSessionDescription::RemoveCandidates( - const std::vector& candidates) { + const std::vector& candidates) { size_t num_removed = 0; for (auto& candidate : candidates) { int mediasection_index = GetMediasectionIndex(candidate); @@ -352,8 +329,7 @@ bool JsepSessionDescription::GetMediasectionIndex( return true; } -int JsepSessionDescription::GetMediasectionIndex( - const cricket::Candidate& candidate) { +int JsepSessionDescription::GetMediasectionIndex(const Candidate& candidate) { // Find the description with a matching transport name of the candidate. const std::string& transport_name = candidate.transport_name(); for (size_t i = 0; i < description_->contents().size(); ++i) { -- cgit v1.2.3