mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 14:46:12 -04:00
Automated Code Change
PiperOrigin-RevId: 752263247
This commit is contained in:
@@ -756,7 +756,7 @@ std::unique_ptr<ConnectionFlow> WebRtc::CreateConnectionFlow(
|
||||
}},
|
||||
},
|
||||
{
|
||||
.adapter_type_changed_cb = {[this](rtc::AdapterType adapter_type) {
|
||||
.adapter_type_changed_cb = {[this](webrtc::AdapterType adapter_type) {
|
||||
OffloadFromThread("rtc-adapter-type-changed",
|
||||
[this, adapter_type]() {
|
||||
if (FeatureFlags::GetInstance()
|
||||
@@ -770,13 +770,13 @@ std::unique_ptr<ConnectionFlow> WebRtc::CreateConnectionFlow(
|
||||
*medium_);
|
||||
}
|
||||
|
||||
void WebRtc::AdapterTypeChangedHandler(rtc::AdapterType adapter_type) {
|
||||
void WebRtc::AdapterTypeChangedHandler(webrtc::AdapterType adapter_type) {
|
||||
MutexLock lock(&mutex_);
|
||||
is_using_cellular_ = adapter_type == rtc::ADAPTER_TYPE_CELLULAR ||
|
||||
adapter_type == rtc::ADAPTER_TYPE_CELLULAR_2G ||
|
||||
adapter_type == rtc::ADAPTER_TYPE_CELLULAR_3G ||
|
||||
adapter_type == rtc::ADAPTER_TYPE_CELLULAR_4G ||
|
||||
adapter_type == rtc::ADAPTER_TYPE_CELLULAR_5G;
|
||||
is_using_cellular_ = adapter_type == webrtc::ADAPTER_TYPE_CELLULAR ||
|
||||
adapter_type == webrtc::ADAPTER_TYPE_CELLULAR_2G ||
|
||||
adapter_type == webrtc::ADAPTER_TYPE_CELLULAR_3G ||
|
||||
adapter_type == webrtc::ADAPTER_TYPE_CELLULAR_4G ||
|
||||
adapter_type == webrtc::ADAPTER_TYPE_CELLULAR_5G;
|
||||
}
|
||||
|
||||
void WebRtc::RemoveConnectionFlow(const WebrtcPeerId& remote_peer_id) {
|
||||
|
||||
@@ -236,7 +236,7 @@ class WebRtc {
|
||||
ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
||||
|
||||
// Runs on |single_thread_executor_|.
|
||||
void AdapterTypeChangedHandler(rtc::AdapterType adapter_type)
|
||||
void AdapterTypeChangedHandler(webrtc::AdapterType adapter_type)
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
|
||||
void OffloadFromThread(const std::string& name, Runnable runnable);
|
||||
|
||||
@@ -187,8 +187,8 @@ void ConnectionFlow::CreateOfferOnSignalingThread(
|
||||
CreateSocketFromDataChannel(result.MoveValue());
|
||||
|
||||
webrtc::PeerConnectionInterface::RTCOfferAnswerOptions options;
|
||||
rtc::scoped_refptr<CreateSessionDescriptionObserverImpl> observer(
|
||||
new rtc::RefCountedObject<CreateSessionDescriptionObserverImpl>(
|
||||
webrtc::scoped_refptr<CreateSessionDescriptionObserverImpl> observer(
|
||||
new webrtc::RefCountedObject<CreateSessionDescriptionObserverImpl>(
|
||||
this, success_future, State::kCreatingOffer,
|
||||
State::kWaitingForAnswer));
|
||||
pc->CreateOffer(observer.get(), options);
|
||||
@@ -218,8 +218,8 @@ void ConnectionFlow::CreateAnswerOnSignalingThread(
|
||||
return;
|
||||
}
|
||||
webrtc::PeerConnectionInterface::RTCOfferAnswerOptions options;
|
||||
rtc::scoped_refptr<CreateSessionDescriptionObserverImpl> observer(
|
||||
new rtc::RefCountedObject<CreateSessionDescriptionObserverImpl>(
|
||||
webrtc::scoped_refptr<CreateSessionDescriptionObserverImpl> observer(
|
||||
new webrtc::RefCountedObject<CreateSessionDescriptionObserverImpl>(
|
||||
this, success_future, State::kCreatingAnswer,
|
||||
State::kWaitingToConnect));
|
||||
auto pc = GetPeerConnection();
|
||||
@@ -230,8 +230,8 @@ bool ConnectionFlow::SetLocalSessionDescription(SessionDescriptionWrapper sdp) {
|
||||
CHECK(!IsRunningOnSignalingThread());
|
||||
if (!sdp.IsValid()) return false;
|
||||
|
||||
rtc::scoped_refptr<SetLocalDescriptionObserver> observer(
|
||||
new rtc::RefCountedObject<SetLocalDescriptionObserver>());
|
||||
webrtc::scoped_refptr<SetLocalDescriptionObserver> observer(
|
||||
new webrtc::RefCountedObject<SetLocalDescriptionObserver>());
|
||||
|
||||
if (!RunOnSignalingThread([this, observer, sdp = std::move(sdp)]() mutable {
|
||||
if (state_ == State::kEnded) {
|
||||
@@ -262,8 +262,8 @@ bool ConnectionFlow::SetRemoteSessionDescription(SessionDescriptionWrapper sdp,
|
||||
State exit_state) {
|
||||
if (!sdp.IsValid()) return false;
|
||||
|
||||
rtc::scoped_refptr<SetRemoteDescriptionObserver> observer(
|
||||
new rtc::RefCountedObject<SetRemoteDescriptionObserver>());
|
||||
webrtc::scoped_refptr<SetRemoteDescriptionObserver> observer(
|
||||
new webrtc::RefCountedObject<SetRemoteDescriptionObserver>());
|
||||
|
||||
if (!RunOnSignalingThread([this, observer, sdp = std::move(sdp),
|
||||
expected_entry_state, exit_state]() mutable {
|
||||
@@ -373,9 +373,9 @@ bool ConnectionFlow::InitPeerConnection(WebRtcMedium& webrtc_medium) {
|
||||
// to access, but it is not safe to access ConnectionFlow member variables
|
||||
// unless the Future::Set() returns true.
|
||||
webrtc_medium.CreatePeerConnection(
|
||||
this,
|
||||
[this, success_future](rtc::scoped_refptr<webrtc::PeerConnectionInterface>
|
||||
peer_connection) mutable {
|
||||
this, [this, success_future](
|
||||
webrtc::scoped_refptr<webrtc::PeerConnectionInterface>
|
||||
peer_connection) mutable {
|
||||
if (!peer_connection) {
|
||||
success_future.Set(false);
|
||||
return;
|
||||
@@ -415,7 +415,7 @@ void ConnectionFlow::OnSignalingStable() {
|
||||
}
|
||||
|
||||
void ConnectionFlow::CreateSocketFromDataChannel(
|
||||
rtc::scoped_refptr<webrtc::DataChannelInterface> data_channel) {
|
||||
webrtc::scoped_refptr<webrtc::DataChannelInterface> data_channel) {
|
||||
NEARBY_LOGS(INFO) << "Creating data channel socket";
|
||||
auto socket =
|
||||
std::make_unique<WebRtcSocket>("WebRtcSocket", std::move(data_channel));
|
||||
@@ -455,7 +455,7 @@ void ConnectionFlow::OnSignalingChange(
|
||||
}
|
||||
|
||||
void ConnectionFlow::OnDataChannel(
|
||||
rtc::scoped_refptr<webrtc::DataChannelInterface> data_channel) {
|
||||
webrtc::scoped_refptr<webrtc::DataChannelInterface> data_channel) {
|
||||
NEARBY_LOGS(INFO) << "OnDataChannel";
|
||||
CHECK(IsRunningOnSignalingThread());
|
||||
CreateSocketFromDataChannel(std::move(data_channel));
|
||||
@@ -486,7 +486,7 @@ void ConnectionFlow::OnRenegotiationNeeded() {
|
||||
}
|
||||
|
||||
void ConnectionFlow::OnIceSelectedCandidatePairChanged(
|
||||
const cricket::CandidatePairChangeEvent& event) {
|
||||
const webrtc::CandidatePairChangeEvent& event) {
|
||||
NEARBY_LOGS(INFO) << "OnIceSelectedCandidatePairChanged";
|
||||
CHECK(IsRunningOnSignalingThread());
|
||||
// TODO(edwinwu) - Implement the unit test for this. We should be able to get
|
||||
@@ -546,29 +546,28 @@ bool ConnectionFlow::RunOnSignalingThread(Runnable&& runnable) {
|
||||
}
|
||||
// We are off signaling thread, so we can't use peer connection's methods
|
||||
// but we can access the signaling thread handle.
|
||||
pc->signaling_thread()->PostTask(
|
||||
[can_run_tasks = std::weak_ptr<void>(can_run_tasks_),
|
||||
task = std::move(runnable)]() mutable {
|
||||
// Don't run the task if the weak_ptr is no longer valid.
|
||||
// shared_ptr |can_run_tasks_| is destroyed on the same thread
|
||||
// (signaling thread). This guarantees that if the weak_ptr is valid
|
||||
// when this task starts, it will stay valid until the task ends.
|
||||
if (!can_run_tasks.lock()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
<< "Peer connection already closed. Cannot run tasks.";
|
||||
return;
|
||||
}
|
||||
task();
|
||||
});
|
||||
pc->signaling_thread()->PostTask([can_run_tasks =
|
||||
std::weak_ptr<void>(can_run_tasks_),
|
||||
task = std::move(runnable)]() mutable {
|
||||
// Don't run the task if the weak_ptr is no longer valid.
|
||||
// shared_ptr |can_run_tasks_| is destroyed on the same thread
|
||||
// (signaling thread). This guarantees that if the weak_ptr is valid
|
||||
// when this task starts, it will stay valid until the task ends.
|
||||
if (!can_run_tasks.lock()) {
|
||||
NEARBY_LOGS(INFO) << "Peer connection already closed. Cannot run tasks.";
|
||||
return;
|
||||
}
|
||||
task();
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ConnectionFlow::IsRunningOnSignalingThread() {
|
||||
return signaling_thread_for_dcheck_only_ != nullptr &&
|
||||
signaling_thread_for_dcheck_only_ == rtc::Thread::Current();
|
||||
signaling_thread_for_dcheck_only_ == webrtc::Thread::Current();
|
||||
}
|
||||
|
||||
rtc::scoped_refptr<webrtc::PeerConnectionInterface>
|
||||
webrtc::scoped_refptr<webrtc::PeerConnectionInterface>
|
||||
ConnectionFlow::GetPeerConnection() {
|
||||
// We must use a mutex to ensure that peer connection is
|
||||
// fully initialized.
|
||||
@@ -578,7 +577,7 @@ ConnectionFlow::GetPeerConnection() {
|
||||
return peer_connection_;
|
||||
}
|
||||
|
||||
rtc::scoped_refptr<webrtc::PeerConnectionInterface>
|
||||
webrtc::scoped_refptr<webrtc::PeerConnectionInterface>
|
||||
ConnectionFlow::GetAndResetPeerConnection() {
|
||||
MutexLock lock(&mutex_);
|
||||
return std::move(peer_connection_);
|
||||
|
||||
@@ -87,8 +87,8 @@ class ConnectionFlow : public webrtc::PeerConnectionObserver {
|
||||
};
|
||||
|
||||
struct AdapterTypeListener {
|
||||
absl::AnyInvocable<void(rtc::AdapterType adapter_type)>
|
||||
adapter_type_changed_cb = DefaultCallback<rtc::AdapterType>();
|
||||
absl::AnyInvocable<void(webrtc::AdapterType adapter_type)>
|
||||
adapter_type_changed_cb = DefaultCallback<webrtc::AdapterType>();
|
||||
};
|
||||
|
||||
// This method blocks on the creation of the peer connection object.
|
||||
@@ -139,18 +139,18 @@ class ConnectionFlow : public webrtc::PeerConnectionObserver {
|
||||
void OnIceCandidate(const webrtc::IceCandidateInterface* candidate) override;
|
||||
void OnSignalingChange(
|
||||
webrtc::PeerConnectionInterface::SignalingState new_state) override;
|
||||
void OnDataChannel(
|
||||
rtc::scoped_refptr<webrtc::DataChannelInterface> data_channel) override;
|
||||
void OnDataChannel(webrtc::scoped_refptr<webrtc::DataChannelInterface>
|
||||
data_channel) override;
|
||||
void OnIceGatheringChange(
|
||||
webrtc::PeerConnectionInterface::IceGatheringState new_state) override;
|
||||
void OnConnectionChange(
|
||||
webrtc::PeerConnectionInterface::PeerConnectionState new_state) override;
|
||||
void OnRenegotiationNeeded() override;
|
||||
void OnIceSelectedCandidatePairChanged(
|
||||
const cricket::CandidatePairChangeEvent& event) override;
|
||||
const webrtc::CandidatePairChangeEvent& event) override;
|
||||
|
||||
// Public because it's used in tests too.
|
||||
rtc::scoped_refptr<webrtc::PeerConnectionInterface> GetPeerConnection();
|
||||
webrtc::scoped_refptr<webrtc::PeerConnectionInterface> GetPeerConnection();
|
||||
|
||||
private:
|
||||
ConnectionFlow(LocalIceCandidateListener local_ice_candidate_listener,
|
||||
@@ -158,7 +158,7 @@ class ConnectionFlow : public webrtc::PeerConnectionObserver {
|
||||
AdapterTypeListener adapter_type_listener);
|
||||
|
||||
// Resets peer connection reference. Returns old value.
|
||||
rtc::scoped_refptr<webrtc::PeerConnectionInterface>
|
||||
webrtc::scoped_refptr<webrtc::PeerConnectionInterface>
|
||||
GetAndResetPeerConnection();
|
||||
void CreateOfferOnSignalingThread(
|
||||
Future<SessionDescriptionWrapper> success_future);
|
||||
@@ -171,7 +171,7 @@ class ConnectionFlow : public webrtc::PeerConnectionObserver {
|
||||
void OnSignalingStable() ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
|
||||
void CreateSocketFromDataChannel(
|
||||
rtc::scoped_refptr<webrtc::DataChannelInterface> data_channel);
|
||||
webrtc::scoped_refptr<webrtc::DataChannelInterface> data_channel);
|
||||
|
||||
// TODO(bfranz): Consider whether this needs to be configurable per platform
|
||||
static constexpr absl::Duration kTimeout = absl::Milliseconds(250);
|
||||
@@ -218,7 +218,7 @@ class ConnectionFlow : public webrtc::PeerConnectionObserver {
|
||||
// because it allows us to do state management on the signaling thread too,
|
||||
// simplifies locking, and we don't have to block the current thread for every
|
||||
// peer connection call.
|
||||
rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_
|
||||
webrtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_
|
||||
ABSL_GUARDED_BY(mutex_);
|
||||
|
||||
// Used to hold a reference to the WebRtcSocket while the data channel is
|
||||
@@ -234,8 +234,8 @@ class ConnectionFlow : public webrtc::PeerConnectionObserver {
|
||||
// This shared_ptr is reset on the signaling thread when ConnectionFlow is
|
||||
// closed. This prevents us from running tasks on the signaling thread when
|
||||
// peer connection is closed. The value stored in |can_run_tasks_| is not
|
||||
// used. We are using std::shared_ptr instead of rtc::WeakPtrFactory because
|
||||
// the former is thread-safe.
|
||||
// used. We are using std::shared_ptr instead of webrtc::WeakPtrFactory
|
||||
// because the former is thread-safe.
|
||||
std::shared_ptr<void> can_run_tasks_ = std::make_shared<int>();
|
||||
|
||||
AdapterTypeListener adapter_type_listener_;
|
||||
|
||||
@@ -81,7 +81,7 @@ TEST_F(ConnectionFlowTest, SuccessfulOfferAnswerFlow) {
|
||||
offerer_socket_future.Set(std::move(socket));
|
||||
}},
|
||||
{.adapter_type_changed_cb =
|
||||
[](rtc::AdapterType adapter_type) {
|
||||
[](webrtc::AdapterType adapter_type) {
|
||||
// Do nothing
|
||||
}},
|
||||
webrtc_medium_offerer);
|
||||
@@ -101,7 +101,7 @@ TEST_F(ConnectionFlowTest, SuccessfulOfferAnswerFlow) {
|
||||
answerer_socket_future.Set(std::move(socket));
|
||||
}},
|
||||
{.adapter_type_changed_cb =
|
||||
[](rtc::AdapterType adapter_type) {
|
||||
[](webrtc::AdapterType adapter_type) {
|
||||
// Do nothing
|
||||
}},
|
||||
webrtc_medium_answerer);
|
||||
@@ -280,7 +280,7 @@ TEST_F(ConnectionFlowTest, TerminateAnswerer) {
|
||||
offerer_socket_future.Set(std::move(socket));
|
||||
}},
|
||||
{.adapter_type_changed_cb =
|
||||
[](rtc::AdapterType adapter_type) {
|
||||
[](webrtc::AdapterType adapter_type) {
|
||||
// Do nothing
|
||||
}},
|
||||
webrtc_medium_offerer);
|
||||
@@ -300,9 +300,9 @@ TEST_F(ConnectionFlowTest, TerminateAnswerer) {
|
||||
answerer_socket_future.Set(std::move(wrapper));
|
||||
}},
|
||||
{.adapter_type_changed_cb =
|
||||
[](rtc::AdapterType adapter_type) {
|
||||
EXPECT_GE(adapter_type, rtc::ADAPTER_TYPE_UNKNOWN);
|
||||
EXPECT_LE(adapter_type, rtc::ADAPTER_TYPE_CELLULAR_5G);
|
||||
[](webrtc::AdapterType adapter_type) {
|
||||
EXPECT_GE(adapter_type, webrtc::ADAPTER_TYPE_UNKNOWN);
|
||||
EXPECT_LE(adapter_type, webrtc::ADAPTER_TYPE_CELLULAR_5G);
|
||||
}},
|
||||
webrtc_medium_answerer);
|
||||
ASSERT_NE(answerer, nullptr);
|
||||
@@ -370,9 +370,9 @@ TEST_F(ConnectionFlowTest, TerminateOfferer) {
|
||||
offerer_socket_future.Set(std::move(socket));
|
||||
}},
|
||||
{.adapter_type_changed_cb =
|
||||
[](rtc::AdapterType adapter_type) {
|
||||
EXPECT_GE(adapter_type, rtc::ADAPTER_TYPE_UNKNOWN);
|
||||
EXPECT_LE(adapter_type, rtc::ADAPTER_TYPE_CELLULAR_5G);
|
||||
[](webrtc::AdapterType adapter_type) {
|
||||
EXPECT_GE(adapter_type, webrtc::ADAPTER_TYPE_UNKNOWN);
|
||||
EXPECT_LE(adapter_type, webrtc::ADAPTER_TYPE_CELLULAR_5G);
|
||||
}},
|
||||
webrtc_medium_offerer);
|
||||
ASSERT_NE(offerer, nullptr);
|
||||
@@ -391,9 +391,9 @@ TEST_F(ConnectionFlowTest, TerminateOfferer) {
|
||||
answerer_socket_future.Set(std::move(wrapper));
|
||||
}},
|
||||
{.adapter_type_changed_cb =
|
||||
[](rtc::AdapterType adapter_type) {
|
||||
EXPECT_GE(adapter_type, rtc::ADAPTER_TYPE_UNKNOWN);
|
||||
EXPECT_LE(adapter_type, rtc::ADAPTER_TYPE_CELLULAR_5G);
|
||||
[](webrtc::AdapterType adapter_type) {
|
||||
EXPECT_GE(adapter_type, webrtc::ADAPTER_TYPE_UNKNOWN);
|
||||
EXPECT_LE(adapter_type, webrtc::ADAPTER_TYPE_CELLULAR_5G);
|
||||
}},
|
||||
webrtc_medium_answerer);
|
||||
ASSERT_NE(answerer, nullptr);
|
||||
|
||||
@@ -14,12 +14,14 @@
|
||||
|
||||
#include "connections/implementation/mediums/webrtc/webrtc_socket_impl.h"
|
||||
|
||||
#include <memory>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "protobuf-matchers/protocol-buffer-matchers.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "internal/platform/byte_array.h"
|
||||
#include "internal/platform/exception.h"
|
||||
#include "webrtc/api/data_channel_interface.h"
|
||||
|
||||
namespace nearby {
|
||||
@@ -33,7 +35,7 @@ namespace {
|
||||
const char kSocketName[] = "TestSocket";
|
||||
|
||||
class MockDataChannel
|
||||
: public rtc::RefCountedObject<webrtc::DataChannelInterface> {
|
||||
: public webrtc::RefCountedObject<webrtc::DataChannelInterface> {
|
||||
public:
|
||||
MOCK_METHOD(void, RegisterObserver, (webrtc::DataChannelObserver*));
|
||||
MOCK_METHOD(void, UnregisterObserver, ());
|
||||
@@ -59,7 +61,8 @@ class MockDataChannel
|
||||
|
||||
TEST(WebRtcSocketTest, ReadFromSocket) {
|
||||
const char* message = "message";
|
||||
rtc::scoped_refptr<MockDataChannel> mock_data_channel(new MockDataChannel());
|
||||
webrtc::scoped_refptr<MockDataChannel> mock_data_channel(
|
||||
new MockDataChannel());
|
||||
WebRtcSocket webrtc_socket(kSocketName, mock_data_channel);
|
||||
|
||||
webrtc_socket.OnMessage(webrtc::DataBuffer{message});
|
||||
@@ -69,7 +72,8 @@ TEST(WebRtcSocketTest, ReadFromSocket) {
|
||||
}
|
||||
|
||||
TEST(WebRtcSocketTest, ReadMultipleMessages) {
|
||||
rtc::scoped_refptr<MockDataChannel> mock_data_channel(new MockDataChannel());
|
||||
webrtc::scoped_refptr<MockDataChannel> mock_data_channel(
|
||||
new MockDataChannel());
|
||||
WebRtcSocket webrtc_socket(kSocketName, mock_data_channel);
|
||||
|
||||
webrtc_socket.OnMessage(webrtc::DataBuffer{"Me"});
|
||||
@@ -94,7 +98,8 @@ TEST(WebRtcSocketTest, ReadMultipleMessages) {
|
||||
|
||||
TEST(WebRtcSocketTest, WriteToSocket) {
|
||||
const ByteArray kMessage{"Message"};
|
||||
rtc::scoped_refptr<MockDataChannel> mock_data_channel(new MockDataChannel());
|
||||
webrtc::scoped_refptr<MockDataChannel> mock_data_channel(
|
||||
new MockDataChannel());
|
||||
WebRtcSocket webrtc_socket(kSocketName, mock_data_channel);
|
||||
|
||||
EXPECT_CALL(*mock_data_channel, Send(testing::_))
|
||||
@@ -104,7 +109,8 @@ TEST(WebRtcSocketTest, WriteToSocket) {
|
||||
|
||||
TEST(WebRtcSocketTest, SendDataBiggerThanMax) {
|
||||
const ByteArray kMessage{kMaxDataSize + 1};
|
||||
rtc::scoped_refptr<MockDataChannel> mock_data_channel(new MockDataChannel());
|
||||
webrtc::scoped_refptr<MockDataChannel> mock_data_channel(
|
||||
new MockDataChannel());
|
||||
WebRtcSocket webrtc_socket(kSocketName, mock_data_channel);
|
||||
|
||||
EXPECT_CALL(*mock_data_channel, Send(testing::_)).Times(0);
|
||||
@@ -114,7 +120,8 @@ TEST(WebRtcSocketTest, SendDataBiggerThanMax) {
|
||||
|
||||
TEST(WebRtcSocketTest, WriteToDataChannelFails) {
|
||||
ByteArray kMessage{"Message"};
|
||||
rtc::scoped_refptr<MockDataChannel> mock_data_channel(new MockDataChannel());
|
||||
webrtc::scoped_refptr<MockDataChannel> mock_data_channel(
|
||||
new MockDataChannel());
|
||||
WebRtcSocket webrtc_socket(kSocketName, mock_data_channel);
|
||||
|
||||
ON_CALL(*mock_data_channel, Send(testing::_))
|
||||
@@ -124,7 +131,8 @@ TEST(WebRtcSocketTest, WriteToDataChannelFails) {
|
||||
}
|
||||
|
||||
TEST(WebRtcSocketTest, Close) {
|
||||
rtc::scoped_refptr<MockDataChannel> mock_data_channel(new MockDataChannel());
|
||||
webrtc::scoped_refptr<MockDataChannel> mock_data_channel(
|
||||
new MockDataChannel());
|
||||
WebRtcSocket webrtc_socket(kSocketName, mock_data_channel);
|
||||
|
||||
EXPECT_CALL(*mock_data_channel, Close());
|
||||
@@ -149,7 +157,8 @@ TEST(WebRtcSocketTest, Close) {
|
||||
|
||||
TEST(WebRtcSocketTest, WriteOnClosedChannel) {
|
||||
ByteArray kMessage{"Message"};
|
||||
rtc::scoped_refptr<MockDataChannel> mock_data_channel(new MockDataChannel());
|
||||
webrtc::scoped_refptr<MockDataChannel> mock_data_channel(
|
||||
new MockDataChannel());
|
||||
WebRtcSocket webrtc_socket(kSocketName, mock_data_channel);
|
||||
webrtc_socket.Close();
|
||||
|
||||
@@ -160,7 +169,8 @@ TEST(WebRtcSocketTest, WriteOnClosedChannel) {
|
||||
|
||||
TEST(WebRtcSocketTest, ReadFromClosedChannel) {
|
||||
ByteArray kMessage{"Message"};
|
||||
rtc::scoped_refptr<MockDataChannel> mock_data_channel(new MockDataChannel());
|
||||
webrtc::scoped_refptr<MockDataChannel> mock_data_channel(
|
||||
new MockDataChannel());
|
||||
WebRtcSocket webrtc_socket(kSocketName, mock_data_channel);
|
||||
ON_CALL(*mock_data_channel, Send(testing::_))
|
||||
.WillByDefault(testing::Return(true));
|
||||
@@ -172,7 +182,8 @@ TEST(WebRtcSocketTest, ReadFromClosedChannel) {
|
||||
}
|
||||
|
||||
TEST(WebRtcSocketTest, DataChannelCloseEventCleansUp) {
|
||||
rtc::scoped_refptr<MockDataChannel> mock_data_channel(new MockDataChannel());
|
||||
webrtc::scoped_refptr<MockDataChannel> mock_data_channel(
|
||||
new MockDataChannel());
|
||||
WebRtcSocket webrtc_socket(kSocketName, mock_data_channel);
|
||||
|
||||
ON_CALL(*mock_data_channel, state())
|
||||
@@ -189,7 +200,8 @@ TEST(WebRtcSocketTest, DataChannelCloseEventCleansUp) {
|
||||
}
|
||||
|
||||
TEST(WebRtcSocketTest, OpenStateTriggersCallback) {
|
||||
rtc::scoped_refptr<MockDataChannel> mock_data_channel(new MockDataChannel());
|
||||
webrtc::scoped_refptr<MockDataChannel> mock_data_channel(
|
||||
new MockDataChannel());
|
||||
WebRtcSocket webrtc_socket(kSocketName, mock_data_channel);
|
||||
|
||||
int socket_ready_cb_called = 0;
|
||||
@@ -209,7 +221,8 @@ TEST(WebRtcSocketTest, OpenStateTriggersCallback) {
|
||||
}
|
||||
|
||||
TEST(WebRtcSocketTest, CloseStateTriggersCallback) {
|
||||
rtc::scoped_refptr<MockDataChannel> mock_data_channel(new MockDataChannel());
|
||||
webrtc::scoped_refptr<MockDataChannel> mock_data_channel(
|
||||
new MockDataChannel());
|
||||
WebRtcSocket webrtc_socket(kSocketName, mock_data_channel);
|
||||
|
||||
int socket_closed_cb_called = 0;
|
||||
|
||||
@@ -80,7 +80,7 @@ void WebRtcMedium::CreatePeerConnection(
|
||||
rtc_config.sdp_semantics = webrtc::SdpSemantics::kUnifiedPlan;
|
||||
webrtc::PeerConnectionDependencies dependencies(observer);
|
||||
|
||||
std::unique_ptr<rtc::Thread> signaling_thread = rtc::Thread::Create();
|
||||
std::unique_ptr<webrtc::Thread> signaling_thread = webrtc::Thread::Create();
|
||||
signaling_thread->SetName("signaling_thread", nullptr);
|
||||
RTC_CHECK(signaling_thread->Start()) << "Failed to start thread";
|
||||
|
||||
@@ -89,7 +89,7 @@ void WebRtcMedium::CreatePeerConnection(
|
||||
webrtc::CreateDefaultTaskQueueFactory();
|
||||
factory_dependencies.signaling_thread = signaling_thread.release();
|
||||
|
||||
rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface>
|
||||
webrtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface>
|
||||
peer_connection_factory = webrtc::CreateModularPeerConnectionFactory(
|
||||
std::move(factory_dependencies));
|
||||
RTC_CHECK(peer_connection_factory != nullptr)
|
||||
|
||||
@@ -49,7 +49,7 @@ class WebRtcSignalingMessenger {
|
||||
class WebRtcMedium {
|
||||
public:
|
||||
using PeerConnectionCallback = absl::AnyInvocable<void(
|
||||
rtc::scoped_refptr<webrtc::PeerConnectionInterface>)>;
|
||||
webrtc::scoped_refptr<webrtc::PeerConnectionInterface>)>;
|
||||
|
||||
virtual ~WebRtcMedium() = default;
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ void WebRtcMedium::CreatePeerConnection(
|
||||
ice_server.urls.emplace_back("stun:stun4.l.google.com:19302");
|
||||
rtc_config.servers.push_back(ice_server);
|
||||
|
||||
std::unique_ptr<rtc::Thread> signaling_thread = rtc::Thread::Create();
|
||||
std::unique_ptr<webrtc::Thread> signaling_thread = webrtc::Thread::Create();
|
||||
signaling_thread->SetName("signaling_thread", nullptr);
|
||||
if (!signaling_thread->Start()) {
|
||||
LOG(FATAL) << "Failed to start thread";
|
||||
@@ -102,7 +102,7 @@ void WebRtcMedium::CreatePeerConnection(
|
||||
webrtc::CreateDefaultTaskQueueFactory();
|
||||
factory_dependencies.signaling_thread = signaling_thread.release();
|
||||
|
||||
rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface>
|
||||
webrtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface>
|
||||
peer_connection_factory = webrtc::CreateModularPeerConnectionFactory(
|
||||
std::move(factory_dependencies));
|
||||
if (options.has_value()) {
|
||||
|
||||
@@ -34,8 +34,8 @@ class MockPeerConnectionObserver : public webrtc::PeerConnectionObserver {
|
||||
void OnSignalingChange(
|
||||
webrtc::PeerConnectionInterface::SignalingState new_state) override {}
|
||||
|
||||
void OnDataChannel(
|
||||
rtc::scoped_refptr<webrtc::DataChannelInterface> data_channel) override {}
|
||||
void OnDataChannel(webrtc::scoped_refptr<webrtc::DataChannelInterface>
|
||||
data_channel) override {}
|
||||
|
||||
void OnIceGatheringChange(
|
||||
webrtc::PeerConnectionInterface::IceGatheringState new_state) override {}
|
||||
@@ -64,7 +64,7 @@ TEST(WebrtcTest, CreatePeerConnectionSucceeds) {
|
||||
WebRtcMedium medium;
|
||||
medium.CreatePeerConnection(
|
||||
std::nullopt, observer.get(),
|
||||
[](rtc::scoped_refptr<webrtc::PeerConnectionInterface>
|
||||
[](webrtc::scoped_refptr<webrtc::PeerConnectionInterface>
|
||||
peer_connection) mutable {
|
||||
if (!peer_connection) {
|
||||
FAIL() << "Peer connection should have been non-null";
|
||||
|
||||
@@ -92,7 +92,7 @@ class WebRtcMedium {
|
||||
.GetFlags()
|
||||
.support_web_rtc_non_cellular_medium && non_cellular_) {
|
||||
std::optional<webrtc::PeerConnectionFactoryInterface::Options> options;
|
||||
options->network_ignore_mask |= rtc::ADAPTER_TYPE_CELLULAR;
|
||||
options->network_ignore_mask |= webrtc::ADAPTER_TYPE_CELLULAR;
|
||||
impl_->CreatePeerConnection(options, observer, std::move(callback));
|
||||
} else {
|
||||
impl_->CreatePeerConnection(observer, std::move(callback));
|
||||
|
||||
Reference in New Issue
Block a user