diff --git a/connections/implementation/mediums/webrtc/BUILD b/connections/implementation/mediums/webrtc/BUILD index 26c8f243..23dfffce 100644 --- a/connections/implementation/mediums/webrtc/BUILD +++ b/connections/implementation/mediums/webrtc/BUILD @@ -38,6 +38,7 @@ cc_library( hdrs = ["connection_flow.h"], deps = [ ":webrtc", + ":webrtc_medium", ":webrtc_socket_impl", "//connections/implementation/mediums:webrtc_socket", "//internal/platform:base", @@ -87,6 +88,19 @@ cc_library( ], ) +cc_library( + name = "webrtc_medium", + hdrs = ["webrtc.h"], + deps = [ + "//internal/platform:base", + "//internal/platform/implementation:comm", + "//internal/platform/implementation:platform", + # "//third_party/webrtc/files/stable/webrtc/api:libjingle_peerconnection_api", + "//third_party/webrtc/files/stable/webrtc/rtc_base:network_constants", + "@com_google_absl//absl/strings:string_view", + ], +) + cc_library( name = "webrtc_impl", srcs = ["webrtc_impl.cc"], @@ -98,6 +112,7 @@ cc_library( ":connection_flow", ":signaling_frames", ":webrtc", + ":webrtc_medium", "//connections/implementation/mediums:webrtc", "//connections/implementation/mediums:webrtc_peer_id", "//connections/implementation/mediums:webrtc_socket", @@ -117,6 +132,18 @@ cc_library( ], ) +cc_library( + name = "fake_webrtc", + testonly = True, + srcs = ["fake_webrtc.cc"], + hdrs = ["fake_webrtc.h"], + deps = [ + ":webrtc_medium", + "//internal/platform:cancellation_flag", + "@com_google_absl//absl/strings:string_view", + ], +) + cc_test( name = "webrtc_test", timeout = "short", @@ -132,22 +159,24 @@ cc_test( ], deps = [ ":connection_flow", + ":fake_webrtc", ":signaling_frames", ":webrtc", ":webrtc_impl", + ":webrtc_medium", ":webrtc_socket_impl", + "//connections/implementation/mediums:webrtc", "//connections/implementation/mediums:webrtc_peer_id", "//connections/implementation/mediums:webrtc_socket", "//internal/platform:base", "//internal/platform:cancellation_flag", - "//internal/platform:comm", "//internal/platform:test_util", "//internal/platform:types", "//internal/platform/implementation:platform_impl", - "//internal/test", # "//third_party/webrtc/files/stable/webrtc/api:data_channel_interface", # "//third_party/webrtc/files/stable/webrtc/api:jsep", # "//third_party/webrtc/files/stable/webrtc/api:scoped_refptr", + "//third_party/webrtc/files/stable/webrtc/rtc_base:network_constants", "//third_party/webrtc/files/stable/webrtc/rtc_base:refcount", "@com_github_protobuf_matchers//protobuf-matchers", "@com_google_absl//absl/strings:string_view", diff --git a/connections/implementation/mediums/webrtc/connection_flow.cc b/connections/implementation/mediums/webrtc/connection_flow.cc index 02f31b20..d8a2578d 100644 --- a/connections/implementation/mediums/webrtc/connection_flow.cc +++ b/connections/implementation/mediums/webrtc/connection_flow.cc @@ -24,13 +24,13 @@ #include "connections/implementation/mediums/webrtc/data_channel_listener.h" #include "connections/implementation/mediums/webrtc/local_ice_candidate_listener.h" #include "connections/implementation/mediums/webrtc/session_description_wrapper.h" +#include "connections/implementation/mediums/webrtc/webrtc.h" #include "connections/implementation/mediums/webrtc/webrtc_socket_impl.h" #include "internal/platform/exception.h" #include "internal/platform/future.h" #include "internal/platform/logging.h" #include "internal/platform/mutex_lock.h" #include "internal/platform/runnable.h" -#include "internal/platform/webrtc.h" #include "webrtc/api/data_channel_interface.h" #include "webrtc/api/jsep.h" #include "webrtc/api/peer_connection_interface.h" diff --git a/connections/implementation/mediums/webrtc/connection_flow.h b/connections/implementation/mediums/webrtc/connection_flow.h index b83cfe0b..01c808c1 100644 --- a/connections/implementation/mediums/webrtc/connection_flow.h +++ b/connections/implementation/mediums/webrtc/connection_flow.h @@ -24,13 +24,13 @@ #include "connections/implementation/mediums/webrtc/data_channel_listener.h" #include "connections/implementation/mediums/webrtc/local_ice_candidate_listener.h" #include "connections/implementation/mediums/webrtc/session_description_wrapper.h" +#include "connections/implementation/mediums/webrtc/webrtc.h" #include "connections/implementation/mediums/webrtc_socket.h" #include "internal/platform/count_down_latch.h" #include "internal/platform/future.h" #include "internal/platform/listeners.h" #include "internal/platform/mutex.h" #include "internal/platform/runnable.h" -#include "internal/platform/webrtc.h" #include "webrtc/api/data_channel_interface.h" #include "webrtc/api/jsep.h" #include "webrtc/api/peer_connection_interface.h" diff --git a/connections/implementation/mediums/webrtc/connection_flow_test.cc b/connections/implementation/mediums/webrtc/connection_flow_test.cc index e08aa5ae..0145fb47 100644 --- a/connections/implementation/mediums/webrtc/connection_flow_test.cc +++ b/connections/implementation/mediums/webrtc/connection_flow_test.cc @@ -24,15 +24,16 @@ #include "connections/implementation/mediums/webrtc/data_channel_listener.h" #include "connections/implementation/mediums/webrtc/local_ice_candidate_listener.h" #include "connections/implementation/mediums/webrtc/session_description_wrapper.h" +#include "connections/implementation/mediums/webrtc/webrtc.h" #include "connections/implementation/mediums/webrtc_socket.h" #include "internal/platform/byte_array.h" #include "internal/platform/count_down_latch.h" #include "internal/platform/exception.h" #include "internal/platform/future.h" #include "internal/platform/medium_environment.h" -#include "internal/platform/webrtc.h" #include "webrtc/api/jsep.h" #include "webrtc/api/scoped_refptr.h" +#include "webrtc/rtc_base/network_constants.h" namespace nearby { namespace connections { diff --git a/internal/test/fake_webrtc.cc b/connections/implementation/mediums/webrtc/fake_webrtc.cc similarity index 78% rename from internal/test/fake_webrtc.cc rename to connections/implementation/mediums/webrtc/fake_webrtc.cc index e3850c86..6f829d94 100644 --- a/internal/test/fake_webrtc.cc +++ b/connections/implementation/mediums/webrtc/fake_webrtc.cc @@ -12,11 +12,15 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "internal/test/fake_webrtc.h" +#include "connections/implementation/mediums/webrtc/fake_webrtc.h" #include -namespace nearby { +#include "absl/strings/string_view.h" +#include "connections/implementation/mediums/webrtc/webrtc.h" +#include "internal/platform/cancellation_flag.h" + +namespace nearby::connections::mediums { FakeWebRtcMedium::FakeWebRtcMedium(CancellationFlag* flag) : WebRtcMedium(), flag_(flag) {} @@ -34,4 +38,4 @@ FakeWebRtcMedium::GetSignalingMessenger( return WebRtcMedium::GetSignalingMessenger(self_id, location_hint); } -} // namespace nearby +} // namespace nearby::connections::mediums diff --git a/internal/test/fake_webrtc.h b/connections/implementation/mediums/webrtc/fake_webrtc.h similarity index 78% rename from internal/test/fake_webrtc.h rename to connections/implementation/mediums/webrtc/fake_webrtc.h index b1f54c5c..65f9e3f5 100644 --- a/internal/test/fake_webrtc.h +++ b/connections/implementation/mediums/webrtc/fake_webrtc.h @@ -12,14 +12,16 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef THIRD_PARTY_NEARBY_INTERNAL_TEST_FAKE_WEBRTC_H_ -#define THIRD_PARTY_NEARBY_INTERNAL_TEST_FAKE_WEBRTC_H_ +#ifndef CORE_INTERNAL_MEDIUMS_WEBRTC_FAKE_WEBRTC_H_ +#define CORE_INTERNAL_MEDIUMS_WEBRTC_FAKE_WEBRTC_H_ #include -#include "internal/platform/webrtc.h" +#include "absl/strings/string_view.h" +#include "connections/implementation/mediums/webrtc/webrtc.h" +#include "internal/platform/cancellation_flag.h" -namespace nearby { +namespace nearby::connections::mediums { class FakeWebRtcMedium : public WebRtcMedium { public: @@ -48,6 +50,6 @@ class FakeWebRtcMedium : public WebRtcMedium { bool cancel_during_get_signaling_messenger_ = false; }; -} // namespace nearby +} // namespace nearby::connections::mediums -#endif // THIRD_PARTY_NEARBY_INTERNAL_TEST_FAKE_WEBRTC_H_ +#endif // CORE_INTERNAL_MEDIUMS_WEBRTC_FAKE_WEBRTC_H_ diff --git a/internal/platform/webrtc.h b/connections/implementation/mediums/webrtc/webrtc.h similarity index 89% rename from internal/platform/webrtc.h rename to connections/implementation/mediums/webrtc/webrtc.h index 1eef3d26..adccaa55 100644 --- a/internal/platform/webrtc.h +++ b/connections/implementation/mediums/webrtc/webrtc.h @@ -12,10 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef PLATFORM_PUBLIC_WEBRTC_H_ -#define PLATFORM_PUBLIC_WEBRTC_H_ - -#ifndef NO_WEBRTC +#ifndef CORE_INTERNAL_MEDIUMS_WEBRTC_WEBRTC_H_ +#define CORE_INTERNAL_MEDIUMS_WEBRTC_WEBRTC_H_ #include #include @@ -28,8 +26,9 @@ #include "internal/platform/implementation/platform.h" #include "internal/platform/implementation/webrtc.h" #include "webrtc/api/peer_connection_interface.h" +#include "webrtc/rtc_base/network_constants.h" -namespace nearby { +namespace nearby::connections::mediums { class WebRtcSignalingMessenger { public: @@ -67,11 +66,9 @@ class WebRtcSignalingMessenger { class WebRtcMedium { public: - using PeerConnectionCallback = api::WebRtcMedium::PeerConnectionCallback; - WebRtcMedium() : impl_(api::ImplementationPlatform::CreateWebRtcMedium()) {} virtual ~WebRtcMedium() = default; - WebRtcMedium(WebRtcMedium&&) = delete; + WebRtcMedium(WebRtcMedium&&) = default; WebRtcMedium& operator=(WebRtcMedium&&) = delete; // Gets the default two-letter country code associated with current locale. @@ -84,8 +81,9 @@ class WebRtcMedium { // Creates and returns a new webrtc::PeerConnectionInterface object via // |callback|. - void CreatePeerConnection(webrtc::PeerConnectionObserver* observer, - PeerConnectionCallback callback) { + void CreatePeerConnection( + webrtc::PeerConnectionObserver* observer, + api::WebRtcMedium::PeerConnectionCallback callback) { if (FeatureFlags::GetInstance() .GetFlags() .support_web_rtc_non_cellular_medium && non_cellular_) { @@ -112,8 +110,6 @@ class WebRtcMedium { bool non_cellular_ = false; }; -} // namespace nearby +} // namespace nearby::connections::mediums -#endif - -#endif // PLATFORM_PUBLIC_WEBRTC_H_ +#endif // CORE_INTERNAL_MEDIUMS_WEBRTC_WEBRTC_H_ diff --git a/connections/implementation/mediums/webrtc/webrtc_impl.cc b/connections/implementation/mediums/webrtc/webrtc_impl.cc index 85202f7c..b7487bf7 100644 --- a/connections/implementation/mediums/webrtc/webrtc_impl.cc +++ b/connections/implementation/mediums/webrtc/webrtc_impl.cc @@ -26,6 +26,7 @@ #include "connections/implementation/mediums/webrtc/connection_flow.h" #include "connections/implementation/mediums/webrtc/session_description_wrapper.h" #include "connections/implementation/mediums/webrtc/signaling_frames.h" +#include "connections/implementation/mediums/webrtc/webrtc.h" #include "connections/implementation/mediums/webrtc_peer_id.h" #include "connections/implementation/mediums/webrtc_socket.h" #include "internal/platform/byte_array.h" @@ -39,7 +40,6 @@ #include "internal/platform/logging.h" #include "internal/platform/mutex_lock.h" #include "internal/platform/runnable.h" -#include "internal/platform/webrtc.h" #include "webrtc/api/jsep.h" #include "webrtc/rtc_base/network_constants.h" diff --git a/connections/implementation/mediums/webrtc/webrtc_impl.h b/connections/implementation/mediums/webrtc/webrtc_impl.h index 349581bd..b4ec12fb 100644 --- a/connections/implementation/mediums/webrtc/webrtc_impl.h +++ b/connections/implementation/mediums/webrtc/webrtc_impl.h @@ -25,6 +25,7 @@ #include "connections/implementation/mediums/webrtc.h" #include "connections/implementation/mediums/webrtc/connection_flow.h" #include "connections/implementation/mediums/webrtc/session_description_wrapper.h" +#include "connections/implementation/mediums/webrtc/webrtc.h" #include "connections/implementation/mediums/webrtc_peer_id.h" #include "connections/implementation/mediums/webrtc_socket.h" #include "internal/platform/byte_array.h" @@ -35,7 +36,6 @@ #include "internal/platform/mutex.h" #include "internal/platform/runnable.h" #include "internal/platform/scheduled_executor.h" -#include "internal/platform/webrtc.h" #include "proto/mediums/web_rtc_signaling_frames.pb.h" #include "webrtc/api/jsep.h" #include "webrtc/rtc_base/network_constants.h" diff --git a/connections/implementation/mediums/webrtc/webrtc_impl_test.cc b/connections/implementation/mediums/webrtc/webrtc_impl_test.cc index ce58c3ff..6b50243b 100644 --- a/connections/implementation/mediums/webrtc/webrtc_impl_test.cc +++ b/connections/implementation/mediums/webrtc/webrtc_impl_test.cc @@ -22,6 +22,9 @@ #include "protobuf-matchers/protocol-buffer-matchers.h" #include "gtest/gtest.h" #include "absl/strings/string_view.h" +#include "connections/implementation/mediums/webrtc.h" +#include "connections/implementation/mediums/webrtc/fake_webrtc.h" +#include "connections/implementation/mediums/webrtc/webrtc.h" #include "connections/implementation/mediums/webrtc_peer_id.h" #include "connections/implementation/mediums/webrtc_socket.h" #include "internal/platform/byte_array.h" @@ -31,8 +34,6 @@ #include "internal/platform/feature_flags.h" #include "internal/platform/future.h" #include "internal/platform/medium_environment.h" -#include "internal/platform/webrtc.h" -#include "internal/test/fake_webrtc.h" namespace nearby { namespace connections { diff --git a/internal/platform/BUILD b/internal/platform/BUILD index c7d13d0f..e293cc42 100644 --- a/internal/platform/BUILD +++ b/internal/platform/BUILD @@ -335,7 +335,6 @@ cc_library( "bluetooth_classic.h", "credential_storage_impl.h", "file.h", - "webrtc.h", "wifi.h", "wifi_direct.h", "wifi_hotspot.h", @@ -365,8 +364,6 @@ cc_library( "//internal/platform/implementation:platform", "//internal/platform/implementation:types", "//internal/platform/implementation:wifi_utils", - # "//third_party/webrtc/files/stable/webrtc/api:create_peerconnection_factory", # buildcleaner: keep - # "//third_party/webrtc/files/stable/webrtc/api:peer_connection_interface", "@com_google_absl//absl/base:core_headers", "@com_google_absl//absl/container:flat_hash_map", "@com_google_absl//absl/container:flat_hash_set", diff --git a/internal/platform/implementation/g3/wifi.h b/internal/platform/implementation/g3/wifi.h index f1439ace..48e287b6 100644 --- a/internal/platform/implementation/g3/wifi.h +++ b/internal/platform/implementation/g3/wifi.h @@ -17,6 +17,9 @@ #include +#include "absl/base/thread_annotations.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" #include "absl/synchronization/mutex.h" #include "internal/platform/implementation/wifi.h" #include "internal/platform/medium_environment.h" diff --git a/internal/platform/implementation/windows/BUILD b/internal/platform/implementation/windows/BUILD index 90b7528c..077a83b7 100644 --- a/internal/platform/implementation/windows/BUILD +++ b/internal/platform/implementation/windows/BUILD @@ -363,12 +363,6 @@ cc_library( "//internal/platform/implementation/shared:count_down_latch", "//internal/platform/implementation/windows/generated:types", "//third_party/intel/pie", - # "//third_party/webrtc/files/stable/webrtc/api:create_modular_peer_connection_factory", - # "//third_party/webrtc/files/stable/webrtc/api:data_channel_interface", - # "//third_party/webrtc/files/stable/webrtc/api:peer_connection_interface", - # "//third_party/webrtc/files/stable/webrtc/api:rtc_error", - # "//third_party/webrtc/files/stable/webrtc/api:scoped_refptr", - "//third_party/webrtc/files/stable/webrtc/rtc_base:threading", "@com_google_absl//absl/base:core_headers", "@com_google_absl//absl/base:nullability", "@com_google_absl//absl/container:flat_hash_map", diff --git a/internal/test/BUILD b/internal/test/BUILD index 589e9f35..7046cd8d 100644 --- a/internal/test/BUILD +++ b/internal/test/BUILD @@ -42,7 +42,6 @@ cc_library( "//internal/base:file_path", "//internal/base:files", "//internal/network:types", - "//internal/platform:comm", "//internal/platform:logging", "//internal/platform:types", "//internal/platform/implementation:types",