diff --git a/connections/implementation/mediums/webrtc.cc b/connections/implementation/mediums/webrtc.cc index d26646b8..a4ee822c 100644 --- a/connections/implementation/mediums/webrtc.cc +++ b/connections/implementation/mediums/webrtc.cc @@ -612,8 +612,7 @@ void WebRtc::ReceiveAnswer(const WebrtcPeerId& remote_peer_id, void WebRtc::ReceiveIceCandidates( const WebrtcPeerId& remote_peer_id, - std::vector> - ice_candidates) { + std::vector> ice_candidates) { const auto& entry = connection_flows_.find(remote_peer_id.GetId()); if (entry == connection_flows_.end()) { LOG(INFO) << "Unable to receive ice candidates. Failed to create a " @@ -704,8 +703,8 @@ std::unique_ptr WebRtc::CreateConnectionFlow( return ConnectionFlow::Create( {.local_ice_candidate_found_cb = - {[this, service_id, remote_peer_id]( - const webrtc::IceCandidateInterface* ice_candidate) { + {[this, service_id, + remote_peer_id](const webrtc::IceCandidate* ice_candidate) { // Note: We need to encode the ice candidate here, before we jump // off the thread. Otherwise, it gets destroyed and we can't read // it later. diff --git a/connections/implementation/mediums/webrtc.h b/connections/implementation/mediums/webrtc.h index 536956c3..de506702 100644 --- a/connections/implementation/mediums/webrtc.h +++ b/connections/implementation/mediums/webrtc.h @@ -195,8 +195,8 @@ class WebRtc { // Runs on |single_thread_executor_|. void ReceiveIceCandidates( const WebrtcPeerId& remote_peer_id, - std::vector> - ice_candidates) ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_); + std::vector> ice_candidates) + ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_); // Runs on |single_thread_executor_|. std::unique_ptr CreateConnectionFlow( diff --git a/connections/implementation/mediums/webrtc/connection_flow.cc b/connections/implementation/mediums/webrtc/connection_flow.cc index 665fb3d7..1d32ae17 100644 --- a/connections/implementation/mediums/webrtc/connection_flow.cc +++ b/connections/implementation/mediums/webrtc/connection_flow.cc @@ -302,8 +302,7 @@ bool ConnectionFlow::OnAnswerReceived(SessionDescriptionWrapper answer) { } bool ConnectionFlow::OnRemoteIceCandidatesReceived( - std::vector> - ice_candidates) { + std::vector> ice_candidates) { CHECK(!IsRunningOnSignalingThread()); // We can't call RunOnSignalingThread because C++ wants to copy ice_candidates // if we try. unique_ptr is not CopyConstructible and compilation fails. @@ -325,8 +324,7 @@ bool ConnectionFlow::OnRemoteIceCandidatesReceived( } void ConnectionFlow::AddIceCandidatesOnSignalingThread( - std::vector> - ice_candidates) { + std::vector> ice_candidates) { CHECK(IsRunningOnSignalingThread()); if (state_ == State::kEnded) { LOG(WARNING) << "You cannot add ice candidates to a disconnected session."; @@ -436,8 +434,7 @@ void ConnectionFlow::CreateSocketFromDataChannel( socket_wrapper_ = WebRtcSocketWrapper(std::move(socket)); } -void ConnectionFlow::OnIceCandidate( - const webrtc::IceCandidateInterface* candidate) { +void ConnectionFlow::OnIceCandidate(const webrtc::IceCandidate* candidate) { CHECK(IsRunningOnSignalingThread()); local_ice_candidate_listener_.local_ice_candidate_found_cb(candidate); } diff --git a/connections/implementation/mediums/webrtc/connection_flow.h b/connections/implementation/mediums/webrtc/connection_flow.h index c3d01d3b..e0986786 100644 --- a/connections/implementation/mediums/webrtc/connection_flow.h +++ b/connections/implementation/mediums/webrtc/connection_flow.h @@ -128,15 +128,15 @@ class ConnectionFlow : public webrtc::PeerConnectionObserver { // ice candidate to the peer connection if ready or cache it otherwise. // Can be called on any thread but never called on signaling thread. bool OnRemoteIceCandidatesReceived( - std::vector> - ice_candidates) ABSL_LOCKS_EXCLUDED(mutex_); + std::vector> ice_candidates) + ABSL_LOCKS_EXCLUDED(mutex_); // Close the peer connection and data channel if not connected. // Can be called on any thread but never called on signaling thread. bool CloseIfNotConnected() ABSL_LOCKS_EXCLUDED(mutex_); // webrtc::PeerConnectionObserver: // All methods called only on signaling thread. - void OnIceCandidate(const webrtc::IceCandidateInterface* candidate) override; + void OnIceCandidate(const webrtc::IceCandidate* candidate) override; void OnSignalingChange( webrtc::PeerConnectionInterface::SignalingState new_state) override; void OnDataChannel(webrtc::scoped_refptr @@ -165,8 +165,7 @@ class ConnectionFlow : public webrtc::PeerConnectionObserver { void CreateAnswerOnSignalingThread( Future success_future); void AddIceCandidatesOnSignalingThread( - std::vector> - ice_candidates); + std::vector> ice_candidates); // Invoked when the peer connection indicates that signaling is stable. void OnSignalingStable() ABSL_LOCKS_EXCLUDED(mutex_); @@ -225,7 +224,7 @@ class ConnectionFlow : public webrtc::PeerConnectionObserver { // connecting. WebRtcSocketWrapper socket_wrapper_; - std::vector> + std::vector> cached_remote_ice_candidates_; // This pointer is only for DCHECK() assertions. // It allows us to check if we are running on signaling thread even diff --git a/connections/implementation/mediums/webrtc/connection_flow_test.cc b/connections/implementation/mediums/webrtc/connection_flow_test.cc index dae9a003..6630b7f2 100644 --- a/connections/implementation/mediums/webrtc/connection_flow_test.cc +++ b/connections/implementation/mediums/webrtc/connection_flow_test.cc @@ -47,8 +47,8 @@ class ConnectionFlowTest : public ::testing::Test { ~ConnectionFlowTest() override { MediumEnvironment::Instance().Stop(); } }; -std::unique_ptr CopyCandidate( - const webrtc::IceCandidateInterface* candidate) { +std::unique_ptr CopyCandidate( + const webrtc::IceCandidate* candidate) { return webrtc::CreateIceCandidate(candidate->sdp_mid(), candidate->sdp_mline_index(), candidate->candidate()); @@ -68,8 +68,8 @@ TEST_F(ConnectionFlowTest, SuccessfulOfferAnswerFlow) { // Send Ice Candidates immediately when you retrieve them offerer = ConnectionFlow::Create( {.local_ice_candidate_found_cb = - [&answerer](const webrtc::IceCandidateInterface* candidate) { - std::vector> vec; + [&answerer](const webrtc::IceCandidate* candidate) { + std::vector> vec; vec.push_back(CopyCandidate(candidate)); // The callback might be alive while the objects in test are // destroyed. @@ -88,8 +88,8 @@ TEST_F(ConnectionFlowTest, SuccessfulOfferAnswerFlow) { ASSERT_NE(offerer, nullptr); answerer = ConnectionFlow::Create( {.local_ice_candidate_found_cb = - [&offerer](const webrtc::IceCandidateInterface* candidate) { - std::vector> vec; + [&offerer](const webrtc::IceCandidate* candidate) { + std::vector> vec; vec.push_back(CopyCandidate(candidate)); // The callback might be alive while the objects in test are // destroyed. @@ -267,8 +267,8 @@ TEST_F(ConnectionFlowTest, TerminateAnswerer) { // Send Ice Candidates immediately when you retrieve them offerer = ConnectionFlow::Create( {.local_ice_candidate_found_cb = - [&answerer](const webrtc::IceCandidateInterface* candidate) { - std::vector> vec; + [&answerer](const webrtc::IceCandidate* candidate) { + std::vector> vec; vec.push_back(CopyCandidate(candidate)); // The callback might be alive while the objects in test are // destroyed. @@ -287,8 +287,8 @@ TEST_F(ConnectionFlowTest, TerminateAnswerer) { ASSERT_NE(offerer, nullptr); answerer = ConnectionFlow::Create( {.local_ice_candidate_found_cb = - [&offerer](const webrtc::IceCandidateInterface* candidate) { - std::vector> vec; + [&offerer](const webrtc::IceCandidate* candidate) { + std::vector> vec; vec.push_back(CopyCandidate(candidate)); // The callback might be alive while the objects in test are // destroyed. @@ -357,8 +357,8 @@ TEST_F(ConnectionFlowTest, TerminateOfferer) { // Send Ice Candidates immediately when you retrieve them offerer = ConnectionFlow::Create( {.local_ice_candidate_found_cb = - [&answerer](const webrtc::IceCandidateInterface* candidate) { - std::vector> vec; + [&answerer](const webrtc::IceCandidate* candidate) { + std::vector> vec; vec.push_back(CopyCandidate(candidate)); // The callback might be alive while the objects in test are // destroyed. @@ -378,8 +378,8 @@ TEST_F(ConnectionFlowTest, TerminateOfferer) { ASSERT_NE(offerer, nullptr); answerer = ConnectionFlow::Create( {.local_ice_candidate_found_cb = - [&offerer](const webrtc::IceCandidateInterface* candidate) { - std::vector> vec; + [&offerer](const webrtc::IceCandidate* candidate) { + std::vector> vec; vec.push_back(CopyCandidate(candidate)); // The callback might be alive while the objects in test are // destroyed. diff --git a/connections/implementation/mediums/webrtc/local_ice_candidate_listener.h b/connections/implementation/mediums/webrtc/local_ice_candidate_listener.h index 40558c33..da71236f 100644 --- a/connections/implementation/mediums/webrtc/local_ice_candidate_listener.h +++ b/connections/implementation/mediums/webrtc/local_ice_candidate_listener.h @@ -18,6 +18,7 @@ #ifndef NO_WEBRTC #include "connections/listeners.h" +#include "webrtc/api/jsep.h" #include "webrtc/api/peer_connection_interface.h" namespace nearby { @@ -27,9 +28,9 @@ namespace mediums { // Callbacks from local ice candidate collection. struct LocalIceCandidateListener { // Called when a new local ice candidate has been found. - absl::AnyInvocable + absl::AnyInvocable local_ice_candidate_found_cb = - nearby::DefaultCallback(); + nearby::DefaultCallback(); }; } // namespace mediums diff --git a/connections/implementation/mediums/webrtc/signaling_frames.cc b/connections/implementation/mediums/webrtc/signaling_frames.cc index 63e80f0d..8991c60a 100644 --- a/connections/implementation/mediums/webrtc/signaling_frames.cc +++ b/connections/implementation/mediums/webrtc/signaling_frames.cc @@ -34,13 +34,12 @@ void SetSenderId(const WebrtcPeerId& sender_id, WebRtcSignalingFrame& frame) { frame.mutable_sender_id()->set_id(sender_id.GetId()); } -std::unique_ptr DecodeIceCandidate( +std::unique_ptr DecodeIceCandidate( location::nearby::mediums::IceCandidate ice_candidate_proto) { webrtc::SdpParseError error; - return std::unique_ptr( - webrtc::CreateIceCandidate(ice_candidate_proto.sdp_mid(), - ice_candidate_proto.sdp_m_line_index(), - ice_candidate_proto.sdp(), &error)); + return std::unique_ptr(webrtc::CreateIceCandidate( + ice_candidate_proto.sdp_mid(), ice_candidate_proto.sdp_m_line_index(), + ice_candidate_proto.sdp(), &error)); } } // namespace @@ -108,9 +107,9 @@ std::unique_ptr DecodeAnswer( frame.answer().session_description().description()); } -std::vector> DecodeIceCandidates( +std::vector> DecodeIceCandidates( const WebRtcSignalingFrame& frame) { - std::vector> ice_candidates; + std::vector> ice_candidates; for (const auto& candidate : frame.ice_candidates().ice_candidates()) { ice_candidates.push_back(DecodeIceCandidate(candidate)); } @@ -118,7 +117,7 @@ std::vector> DecodeIceCandidates( } location::nearby::mediums::IceCandidate EncodeIceCandidate( - const webrtc::IceCandidateInterface& ice_candidate) { + const webrtc::IceCandidate& ice_candidate) { std::string sdp; ice_candidate.ToString(&sdp); location::nearby::mediums::IceCandidate ice_candidate_proto; diff --git a/connections/implementation/mediums/webrtc/signaling_frames.h b/connections/implementation/mediums/webrtc/signaling_frames.h index 6a6c2890..6e13645d 100644 --- a/connections/implementation/mediums/webrtc/signaling_frames.h +++ b/connections/implementation/mediums/webrtc/signaling_frames.h @@ -40,14 +40,14 @@ ByteArray EncodeIceCandidates( const WebrtcPeerId& sender_id, const std::vector& ice_candidates); location::nearby::mediums::IceCandidate EncodeIceCandidate( - const webrtc::IceCandidateInterface& ice_candidate); + const webrtc::IceCandidate& ice_candidate); std::unique_ptr DecodeOffer( const location::nearby::mediums::WebRtcSignalingFrame& frame); std::unique_ptr DecodeAnswer( const location::nearby::mediums::WebRtcSignalingFrame& frame); -std::vector> DecodeIceCandidates( +std::vector> DecodeIceCandidates( const location::nearby::mediums::WebRtcSignalingFrame& frame); } // namespace webrtc_frames diff --git a/connections/implementation/mediums/webrtc/signaling_frames_test.cc b/connections/implementation/mediums/webrtc/signaling_frames_test.cc index 7e11b09a..de5f92bb 100644 --- a/connections/implementation/mediums/webrtc/signaling_frames_test.cc +++ b/connections/implementation/mediums/webrtc/signaling_frames_test.cc @@ -21,6 +21,7 @@ #include "gtest/gtest.h" #include "connections/implementation/mediums/webrtc_peer_id.h" #include "google/protobuf/text_format.h" +#include "webrtc/api/jsep.h" namespace nearby { namespace connections { @@ -149,7 +150,7 @@ TEST(SignalingFramesTest, EncodeValidIceCandidates) { WebrtcPeerId sender_id("abc"); webrtc::SdpParseError error; - std::vector> ice_candidates; + std::vector> ice_candidates; ice_candidates.emplace_back(webrtc::CreateIceCandidate( kIceSdpMid, kIceSdpMLineIndex, kIceCandidateSdp1, &error)); ice_candidates.emplace_back(webrtc::CreateIceCandidate( @@ -170,7 +171,7 @@ TEST(SignalingFramesTest, EncodeValidIceCandidates) { TEST(SignalingFramesTest, DecodeValidIceCandidates) { webrtc::SdpParseError error; - std::vector> ice_candidates; + std::vector> ice_candidates; ice_candidates.emplace_back(webrtc::CreateIceCandidate( kIceSdpMid, kIceSdpMLineIndex, kIceCandidateSdp1, &error)); ice_candidates.emplace_back(webrtc::CreateIceCandidate( @@ -178,8 +179,8 @@ TEST(SignalingFramesTest, DecodeValidIceCandidates) { WebRtcSignalingFrame frame; proto2::TextFormat::ParseFromString(kIceCandidatesProto, &frame); - std::vector> - decoded_candidates = DecodeIceCandidates(frame); + std::vector> decoded_candidates = + DecodeIceCandidates(frame); ASSERT_EQ(2u, decoded_candidates.size()); for (int i = 0; i < static_cast(decoded_candidates.size()); i++) { diff --git a/internal/platform/implementation/windows/webrtc_test.cc b/internal/platform/implementation/windows/webrtc_test.cc index d41f50db..708e0efc 100644 --- a/internal/platform/implementation/windows/webrtc_test.cc +++ b/internal/platform/implementation/windows/webrtc_test.cc @@ -19,10 +19,9 @@ #include #include "gtest/gtest.h" - #include "internal/platform/implementation/webrtc.h" -#include "webrtc/api/jsep.h" #include "webrtc/api/data_channel_interface.h" +#include "webrtc/api/jsep.h" #include "webrtc/api/peer_connection_interface.h" #include "webrtc/api/scoped_refptr.h" @@ -40,8 +39,7 @@ class MockPeerConnectionObserver : public webrtc::PeerConnectionObserver { void OnIceGatheringChange( webrtc::PeerConnectionInterface::IceGatheringState new_state) override {} - void OnIceCandidate(const webrtc::IceCandidateInterface* candidate) override { - } + void OnIceCandidate(const webrtc::IceCandidate* candidate) override {} }; location::nearby::connections::LocationHint GetCountryCodeLocationHint(