Move platform dependent part of WebRtcMedium into WebRtcPlatform.

PiperOrigin-RevId: 919888693
This commit is contained in:
Francis Tsui
2026-05-22 15:32:44 -07:00
committed by Copybara-Service
parent b536c8da3a
commit 4e387e7ea7
18 changed files with 25 additions and 70 deletions
@@ -14,17 +14,13 @@
#include "internal/platform/implementation/windows/webrtc.h"
#include <winnls.h>
#include <memory>
#include <optional>
#include <string>
#include <utility>
#include "absl/strings/string_view.h"
#include "connections/implementation/mediums/webrtc/tachyon_express_signaling_messenger.h"
#include "internal/platform/implementation/webrtc.h"
#include "internal/platform/logging.h"
#include "webrtc/api/create_modular_peer_connection_factory.h"
#include "webrtc/api/peer_connection_interface.h"
#include "webrtc/api/rtc_error.h"
@@ -35,20 +31,6 @@ namespace nearby::windows {
using ::nearby::connections::mediums::TachyonExpressSignalingMessenger;
std::string WebRtcMedium::GetDefaultCountryCode() {
wchar_t systemGeoName[LOCALE_NAME_MAX_LENGTH];
if (!GetUserDefaultGeoName(systemGeoName, LOCALE_NAME_MAX_LENGTH)) {
LOG(ERROR) << __func__
<< ": Failed to GetUserDefaultGeoName: " << ". Fall back to US.";
return "US";
}
std::wstring wideGeo(systemGeoName);
std::string systemGeoNameString(wideGeo.begin(), wideGeo.end());
VLOG(1) << "GetUserDefaultGeoName() returns: " << systemGeoNameString;
return systemGeoNameString;
}
void WebRtcMedium::CreatePeerConnection(
webrtc::PeerConnectionObserver* observer, PeerConnectionCallback callback) {
CreatePeerConnection(std::nullopt, observer, std::move(callback));
@@ -17,7 +17,6 @@
#include <memory>
#include <optional>
#include <string>
#include "absl/strings/string_view.h"
#include "internal/platform/implementation/webrtc.h"
@@ -29,11 +28,6 @@ class WebRtcMedium : public api::WebRtcMedium {
public:
~WebRtcMedium() override = default;
// Gets the default two-letter country code associated with current locale.
// For example, en_US locale resolves to "US".
// This follows the ISO 3166-1 Alpha-2 standard.
std::string GetDefaultCountryCode() override;
// Creates and returns a new webrtc::PeerConnectionInterface object via
// |callback|.
void CreatePeerConnection(webrtc::PeerConnectionObserver* observer,
@@ -51,12 +51,6 @@ location::nearby::connections::LocationHint GetCountryCodeLocationHint(
return location_hint;
}
TEST(WebrtcTest, CountryCodeDefault) {
WebRtcMedium medium;
std::string result = medium.GetDefaultCountryCode();
EXPECT_EQ(result, "US");
}
TEST(WebrtcTest, CreatePeerConnectionSucceeds) {
auto observer = std::make_unique<MockPeerConnectionObserver>();
WebRtcMedium medium;