Update PeerConnectionSdpMethods::AddRemoteCandidate

...to use string_view for the mid and prefer .mid() over .name for
ContentInfo.

Bug: webrtc:42233761
Change-Id: Ia9bfe1d7454759ff87295939cda6a71e53cb6b98
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/374663
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#43781}
This commit is contained in:
Tommi 2025-01-17 16:00:53 +01:00 committed by WebRTC LUCI CQ
parent 3fef8b27db
commit 7a0bdb602c
5 changed files with 9 additions and 8 deletions

View File

@ -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<int>(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<cricket::Candidate> candidates = {candidate};
RTCError error =

View File

@ -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.

View File

@ -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;

View File

@ -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; }

View File

@ -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));