Make WebRtcMedium private to mediums/webrtc.

PiperOrigin-RevId: 918557620
This commit is contained in:
Francis Tsui
2026-05-20 11:28:41 -07:00
committed by Copybara-Service
parent 042b19f94c
commit ab45551b73
14 changed files with 68 additions and 42 deletions
@@ -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",
@@ -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"
@@ -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"
@@ -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 {
@@ -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 <memory>
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
@@ -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 <memory>
#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_
@@ -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 <memory>
#include <optional>
@@ -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_
@@ -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"
@@ -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"
@@ -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 {
-3
View File
@@ -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",
@@ -17,6 +17,9 @@
#include <string>
#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"
@@ -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",
-1
View File
@@ -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",