diff --git a/pc/peer_connection.cc b/pc/peer_connection.cc index 5f2d7bdea8..9b39356cbc 100644 --- a/pc/peer_connection.cc +++ b/pc/peer_connection.cc @@ -2587,7 +2587,7 @@ bool PeerConnection::GetLocalCandidateMediaIndex( bool content_found = false; const ContentInfos& contents = local_description()->description()->contents(); for (size_t index = 0; index < contents.size(); ++index) { - if (contents[index].name == content_name) { + if (contents[index].mid() == content_name) { *sdp_mline_index = static_cast(index); content_found = true; break; @@ -2669,7 +2669,7 @@ bool PeerConnection::ValidateBundleSettings( citer != contents.end(); ++citer) { const cricket::ContentInfo* content = (&*citer); RTC_DCHECK(content != NULL); - auto it = bundle_groups_by_mid.find(content->name); + auto it = bundle_groups_by_mid.find(content->mid()); if (it != bundle_groups_by_mid.end() && !(content->rejected || content->bundle_only) && content->type == MediaProtocolType::kRtp) { @@ -2747,7 +2747,7 @@ void PeerConnection::NoteUsageEvent(UsageEvent event) { } // Asynchronously adds remote candidates on the network thread. -void PeerConnection::AddRemoteCandidate(const std::string& mid, +void PeerConnection::AddRemoteCandidate(absl::string_view mid, const cricket::Candidate& candidate) { RTC_DCHECK_RUN_ON(signaling_thread()); @@ -2763,7 +2763,8 @@ void PeerConnection::AddRemoteCandidate(const std::string& mid, new_candidate.set_underlying_type_for_vpn(rtc::ADAPTER_TYPE_UNKNOWN); network_thread()->PostTask(SafeTask( - network_thread_safety_, [this, mid = mid, candidate = new_candidate] { + network_thread_safety_, + [this, mid = std::string(mid), candidate = new_candidate] { RTC_DCHECK_RUN_ON(network_thread()); std::vector candidates = {candidate}; RTCError error = diff --git a/pc/peer_connection.h b/pc/peer_connection.h index f091ae0474..49732f0ac8 100644 --- a/pc/peer_connection.h +++ b/pc/peer_connection.h @@ -376,7 +376,7 @@ class PeerConnection : public PeerConnectionInternal, void NoteUsageEvent(UsageEvent event) override; // Asynchronously adds a remote candidate on the network thread. - void AddRemoteCandidate(const std::string& mid, + void AddRemoteCandidate(absl::string_view mid, const cricket::Candidate& candidate) override; // Report the UMA metric BundleUsage for the given remote description. diff --git a/pc/peer_connection_internal.h b/pc/peer_connection_internal.h index f3c470726b..54f69b94bf 100644 --- a/pc/peer_connection_internal.h +++ b/pc/peer_connection_internal.h @@ -109,7 +109,7 @@ class PeerConnectionSdpMethods { int max_message_size) = 0; // Asynchronously adds a remote candidate on the network thread. - virtual void AddRemoteCandidate(const std::string& mid, + virtual void AddRemoteCandidate(absl::string_view mid, const cricket::Candidate& candidate) = 0; virtual Call* call_ptr() = 0; diff --git a/pc/test/fake_peer_connection_base.h b/pc/test/fake_peer_connection_base.h index 640f741997..f81d104bb9 100644 --- a/pc/test/fake_peer_connection_base.h +++ b/pc/test/fake_peer_connection_base.h @@ -355,7 +355,7 @@ class FakePeerConnectionBase : public PeerConnectionInternal { int remote_port, int max_message_size) override {} - void AddRemoteCandidate(const std::string& mid, + void AddRemoteCandidate(absl::string_view mid, const cricket::Candidate& candidate) override {} Call* call_ptr() override { return nullptr; } diff --git a/pc/test/mock_peer_connection_internal.h b/pc/test/mock_peer_connection_internal.h index 09a11dc68a..db891be748 100644 --- a/pc/test/mock_peer_connection_internal.h +++ b/pc/test/mock_peer_connection_internal.h @@ -270,7 +270,7 @@ class MockPeerConnectionInternal : public PeerConnectionInternal { MOCK_METHOD(void, StartSctpTransport, (int, int, int), (override)); MOCK_METHOD(void, AddRemoteCandidate, - (const std::string&, const cricket::Candidate&), + (absl::string_view, const cricket::Candidate&), (override)); MOCK_METHOD(Call*, call_ptr, (), (override)); MOCK_METHOD(bool, SrtpRequired, (), (const, override));