Add 2 new virtual methods to IceTransportInternal
This will allow the blink-layer ICE-transport handling code to use the virtual interface class rather than the concrete implementation class. Bug: chromium:864871 Change-Id: I5dfd1f266b3f3eabe42e09ba35afe218d25634b1 Reviewed-on: https://webrtc-review.googlesource.com/c/118360 Commit-Queue: Harald Alvestrand <hta@webrtc.org> Reviewed-by: Steve Anton <steveanton@webrtc.org> Cr-Commit-Position: refs/heads/master@{#26333}
This commit is contained in:
parent
a882fb3ee4
commit
4241cf5ed5
@ -191,6 +191,8 @@ class FakeIceTransport : public IceTransportInternal {
|
|||||||
remote_candidates_.erase(it);
|
remote_candidates_.erase(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RemoveAllRemoteCandidates() override { remote_candidates_.clear(); }
|
||||||
|
|
||||||
bool GetStats(ConnectionInfos* candidate_pair_stats_list,
|
bool GetStats(ConnectionInfos* candidate_pair_stats_list,
|
||||||
CandidateStatsList* candidate_stats_list) override {
|
CandidateStatsList* candidate_stats_list) override {
|
||||||
CandidateStats candidate_stats;
|
CandidateStats candidate_stats;
|
||||||
@ -204,6 +206,8 @@ class FakeIceTransport : public IceTransportInternal {
|
|||||||
|
|
||||||
absl::optional<int> GetRttEstimate() override { return absl::nullopt; }
|
absl::optional<int> GetRttEstimate() override { return absl::nullopt; }
|
||||||
|
|
||||||
|
const Connection* selected_connection() const override { return nullptr; }
|
||||||
|
|
||||||
// Fake PacketTransportInternal implementation.
|
// Fake PacketTransportInternal implementation.
|
||||||
bool writable() const override { return writable_; }
|
bool writable() const override { return writable_; }
|
||||||
bool receiving() const override { return receiving_; }
|
bool receiving() const override { return receiving_; }
|
||||||
|
|||||||
@ -242,6 +242,8 @@ class RTC_EXPORT IceTransportInternal : public rtc::PacketTransportInternal {
|
|||||||
|
|
||||||
virtual void RemoveRemoteCandidate(const Candidate& candidate) = 0;
|
virtual void RemoveRemoteCandidate(const Candidate& candidate) = 0;
|
||||||
|
|
||||||
|
virtual void RemoveAllRemoteCandidates() = 0;
|
||||||
|
|
||||||
virtual IceGatheringState gathering_state() const = 0;
|
virtual IceGatheringState gathering_state() const = 0;
|
||||||
|
|
||||||
// Returns the current stats for this connection.
|
// Returns the current stats for this connection.
|
||||||
@ -252,6 +254,8 @@ class RTC_EXPORT IceTransportInternal : public rtc::PacketTransportInternal {
|
|||||||
// absl::optional if there is none.
|
// absl::optional if there is none.
|
||||||
virtual absl::optional<int> GetRttEstimate() = 0;
|
virtual absl::optional<int> GetRttEstimate() = 0;
|
||||||
|
|
||||||
|
virtual const Connection* selected_connection() const = 0;
|
||||||
|
|
||||||
sigslot::signal1<IceTransportInternal*> SignalGatheringState;
|
sigslot::signal1<IceTransportInternal*> SignalGatheringState;
|
||||||
|
|
||||||
// Handles sending and receiving of candidates.
|
// Handles sending and receiving of candidates.
|
||||||
|
|||||||
@ -62,9 +62,11 @@ class MockIceTransport : public IceTransportInternal {
|
|||||||
void SetRemoteIceMode(IceMode mode) override {}
|
void SetRemoteIceMode(IceMode mode) override {}
|
||||||
void SetIceConfig(const IceConfig& config) override {}
|
void SetIceConfig(const IceConfig& config) override {}
|
||||||
absl::optional<int> GetRttEstimate() override { return absl::nullopt; }
|
absl::optional<int> GetRttEstimate() override { return absl::nullopt; }
|
||||||
|
const Connection* selected_connection() const override { return nullptr; }
|
||||||
void MaybeStartGathering() override {}
|
void MaybeStartGathering() override {}
|
||||||
void AddRemoteCandidate(const Candidate& candidate) override {}
|
void AddRemoteCandidate(const Candidate& candidate) override {}
|
||||||
void RemoveRemoteCandidate(const Candidate& candidate) override {}
|
void RemoveRemoteCandidate(const Candidate& candidate) override {}
|
||||||
|
void RemoveAllRemoteCandidates() override {}
|
||||||
IceGatheringState gathering_state() const override {
|
IceGatheringState gathering_state() const override {
|
||||||
return IceGatheringState::kIceGatheringComplete;
|
return IceGatheringState::kIceGatheringComplete;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -714,6 +714,10 @@ RTCError P2PTransportChannel::ValidateIceConfig(const IceConfig& config) {
|
|||||||
return RTCError::OK();
|
return RTCError::OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Connection* P2PTransportChannel::selected_connection() const {
|
||||||
|
return selected_connection_;
|
||||||
|
}
|
||||||
|
|
||||||
int P2PTransportChannel::check_receiving_interval() const {
|
int P2PTransportChannel::check_receiving_interval() const {
|
||||||
return std::max(MIN_CHECK_RECEIVING_INTERVAL,
|
return std::max(MIN_CHECK_RECEIVING_INTERVAL,
|
||||||
config_.receiving_timeout_or_default() / 10);
|
config_.receiving_timeout_or_default() / 10);
|
||||||
@ -1180,6 +1184,10 @@ void P2PTransportChannel::RemoveRemoteCandidate(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void P2PTransportChannel::RemoveAllRemoteCandidates() {
|
||||||
|
remote_candidates_.clear();
|
||||||
|
}
|
||||||
|
|
||||||
// Creates connections from all of the ports that we care about to the given
|
// Creates connections from all of the ports that we care about to the given
|
||||||
// remote candidate. The return value is true if we created a connection from
|
// remote candidate. The return value is true if we created a connection from
|
||||||
// the origin port.
|
// the origin port.
|
||||||
|
|||||||
@ -112,6 +112,7 @@ class RTC_EXPORT P2PTransportChannel : public IceTransportInternal {
|
|||||||
void ResolveHostnameCandidate(const Candidate& candidate);
|
void ResolveHostnameCandidate(const Candidate& candidate);
|
||||||
void AddRemoteCandidate(const Candidate& candidate) override;
|
void AddRemoteCandidate(const Candidate& candidate) override;
|
||||||
void RemoveRemoteCandidate(const Candidate& candidate) override;
|
void RemoveRemoteCandidate(const Candidate& candidate) override;
|
||||||
|
void RemoveAllRemoteCandidates() override;
|
||||||
// Sets the parameters in IceConfig. We do not set them blindly. Instead, we
|
// Sets the parameters in IceConfig. We do not set them blindly. Instead, we
|
||||||
// only update the parameter if it is considered set in |config|. For example,
|
// only update the parameter if it is considered set in |config|. For example,
|
||||||
// a negative value of receiving_timeout will be considered "not set" and we
|
// a negative value of receiving_timeout will be considered "not set" and we
|
||||||
@ -132,12 +133,12 @@ class RTC_EXPORT P2PTransportChannel : public IceTransportInternal {
|
|||||||
bool GetStats(std::vector<ConnectionInfo>* candidate_pair_stats_list,
|
bool GetStats(std::vector<ConnectionInfo>* candidate_pair_stats_list,
|
||||||
std::vector<CandidateStats>* candidate_stats_list) override;
|
std::vector<CandidateStats>* candidate_stats_list) override;
|
||||||
absl::optional<int> GetRttEstimate() override;
|
absl::optional<int> GetRttEstimate() override;
|
||||||
|
const Connection* selected_connection() const override;
|
||||||
|
|
||||||
// TODO(honghaiz): Remove this method once the reference of it in
|
// TODO(honghaiz): Remove this method once the reference of it in
|
||||||
// Chromoting is removed.
|
// Chromoting is removed.
|
||||||
const Connection* best_connection() const { return selected_connection_; }
|
const Connection* best_connection() const { return selected_connection_; }
|
||||||
|
|
||||||
const Connection* selected_connection() const { return selected_connection_; }
|
|
||||||
void set_incoming_only(bool value) { incoming_only_ = value; }
|
void set_incoming_only(bool value) { incoming_only_ = value; }
|
||||||
|
|
||||||
// Note: These are only for testing purpose.
|
// Note: These are only for testing purpose.
|
||||||
|
|||||||
26
pc/ice_transport_unittest.cc
Normal file
26
pc/ice_transport_unittest.cc
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2019 The WebRTC project authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license
|
||||||
|
* that can be found in the LICENSE file in the root of the source
|
||||||
|
* tree. An additional intellectual property rights grant can be found
|
||||||
|
* in the file PATENTS. All contributing project authors may
|
||||||
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "pc/ice_transport.h"
|
||||||
|
#include "p2p/base/fake_port_allocator.h"
|
||||||
|
|
||||||
|
#include "test/gtest.h"
|
||||||
|
|
||||||
|
namespace webrtc {
|
||||||
|
|
||||||
|
class IceTransportTest : public testing::Test {};
|
||||||
|
|
||||||
|
TEST_F(IceTransportTest, CreateStandaloneIceTransport) {
|
||||||
|
auto port_allocator = new cricket::FakePortAllocator(nullptr, nullptr);
|
||||||
|
auto transport = CreateIceTransport(port_allocator);
|
||||||
|
ASSERT_TRUE(transport->internal());
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace webrtc
|
||||||
Loading…
x
Reference in New Issue
Block a user