Adding GetConfiguration to PeerConnection.
Just returns the configuration the PC was constructed with, or the last one passed into SetConfiguration. BUG=chromium:587453 Review-Url: https://codereview.webrtc.org/2504103002 Cr-Commit-Position: refs/heads/master@{#15111}
This commit is contained in:
parent
aee0b5d317
commit
46c7389a63
@ -636,8 +636,6 @@ bool PeerConnection::Initialize(
|
||||
stats_.reset(new StatsCollector(this));
|
||||
stats_collector_ = RTCStatsCollector::Create(this);
|
||||
|
||||
enable_ice_renomination_ = configuration.enable_ice_renomination;
|
||||
|
||||
// Initialize the WebRtcSession. It creates transport channels etc.
|
||||
if (!session_->Initialize(factory_->options(), std::move(cert_generator),
|
||||
configuration)) {
|
||||
@ -662,6 +660,8 @@ bool PeerConnection::Initialize(
|
||||
this, &PeerConnection::OnDataChannelDestroyed);
|
||||
session_->SignalDataChannelOpenMessage.connect(
|
||||
this, &PeerConnection::OnDataChannelOpenMessage);
|
||||
|
||||
configuration_ = configuration;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1262,8 +1262,14 @@ void PeerConnection::SetRemoteDescription(
|
||||
MSG_SET_SESSIONDESCRIPTION_SUCCESS, msg);
|
||||
}
|
||||
|
||||
PeerConnectionInterface::RTCConfiguration PeerConnection::GetConfiguration() {
|
||||
return configuration_;
|
||||
}
|
||||
|
||||
bool PeerConnection::SetConfiguration(const RTCConfiguration& configuration) {
|
||||
TRACE_EVENT0("webrtc", "PeerConnection::SetConfiguration");
|
||||
// TODO(deadbeef): Return false and log an error if there are any unsupported
|
||||
// modifications.
|
||||
if (port_allocator_) {
|
||||
if (!network_thread()->Invoke<bool>(
|
||||
RTC_FROM_HERE,
|
||||
@ -1276,7 +1282,7 @@ bool PeerConnection::SetConfiguration(const RTCConfiguration& configuration) {
|
||||
// TODO(deadbeef): Shouldn't have to hop to the worker thread twice...
|
||||
session_->SetIceConfig(session_->ParseIceConfig(configuration));
|
||||
|
||||
enable_ice_renomination_ = configuration.enable_ice_renomination;
|
||||
configuration_ = configuration;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1631,7 +1637,8 @@ bool PeerConnection::GetOptionsForOffer(
|
||||
cricket::TransportOptions();
|
||||
}
|
||||
}
|
||||
session_options->enable_ice_renomination = enable_ice_renomination_;
|
||||
session_options->enable_ice_renomination =
|
||||
configuration_.enable_ice_renomination;
|
||||
|
||||
if (!ExtractMediaSessionOptions(rtc_options, true, session_options)) {
|
||||
return false;
|
||||
@ -1674,7 +1681,8 @@ void PeerConnection::InitializeOptionsForAnswer(
|
||||
cricket::MediaSessionOptions* session_options) {
|
||||
session_options->recv_audio = false;
|
||||
session_options->recv_video = false;
|
||||
session_options->enable_ice_renomination = enable_ice_renomination_;
|
||||
session_options->enable_ice_renomination =
|
||||
configuration_.enable_ice_renomination;
|
||||
}
|
||||
|
||||
void PeerConnection::FinishOptionsForAnswer(
|
||||
|
||||
@ -129,6 +129,7 @@ class PeerConnection : public PeerConnectionInterface,
|
||||
SessionDescriptionInterface* desc) override;
|
||||
void SetRemoteDescription(SetSessionDescriptionObserver* observer,
|
||||
SessionDescriptionInterface* desc) override;
|
||||
PeerConnectionInterface::RTCConfiguration GetConfiguration() override;
|
||||
bool SetConfiguration(
|
||||
const PeerConnectionInterface::RTCConfiguration& configuration) override;
|
||||
bool AddIceCandidate(const IceCandidateInterface* candidate) override;
|
||||
@ -389,6 +390,7 @@ class PeerConnection : public PeerConnectionInterface,
|
||||
SignalingState signaling_state_;
|
||||
IceConnectionState ice_connection_state_;
|
||||
IceGatheringState ice_gathering_state_;
|
||||
PeerConnectionInterface::RTCConfiguration configuration_;
|
||||
|
||||
std::unique_ptr<cricket::PortAllocator> port_allocator_;
|
||||
// The EventLog needs to outlive the media controller.
|
||||
@ -420,8 +422,6 @@ class PeerConnection : public PeerConnectionInterface,
|
||||
|
||||
bool remote_peer_supports_msid_ = false;
|
||||
|
||||
bool enable_ice_renomination_ = false;
|
||||
|
||||
std::vector<rtc::scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>>>
|
||||
senders_;
|
||||
std::vector<
|
||||
|
||||
@ -480,6 +480,11 @@ class PeerConnectionInterface : public rtc::RefCountInterface {
|
||||
return false;
|
||||
}
|
||||
virtual bool UpdateIce(const IceServers& configuration) { return false; }
|
||||
// TODO(deadbeef): Make this pure virtual once all Chrome subclasses of
|
||||
// PeerConnectionInterface implement it.
|
||||
virtual PeerConnectionInterface::RTCConfiguration GetConfiguration() {
|
||||
return PeerConnectionInterface::RTCConfiguration();
|
||||
}
|
||||
// Sets the PeerConnection's global configuration to |config|.
|
||||
// Any changes to STUN/TURN servers or ICE candidate policy will affect the
|
||||
// next gathering phase, and cause the next call to createOffer to generate
|
||||
|
||||
@ -1173,6 +1173,32 @@ TEST_F(PeerConnectionInterfaceTest,
|
||||
EXPECT_TRUE(raw_port_allocator->initialized());
|
||||
}
|
||||
|
||||
// Check that GetConfiguration returns the configuration the PeerConnection was
|
||||
// constructed with, before SetConfiguration is called.
|
||||
TEST_F(PeerConnectionInterfaceTest, GetConfigurationAfterCreatePeerConnection) {
|
||||
PeerConnectionInterface::RTCConfiguration config;
|
||||
config.type = PeerConnectionInterface::kRelay;
|
||||
CreatePeerConnection(config, nullptr);
|
||||
|
||||
PeerConnectionInterface::RTCConfiguration returned_config =
|
||||
pc_->GetConfiguration();
|
||||
EXPECT_EQ(PeerConnectionInterface::kRelay, returned_config.type);
|
||||
}
|
||||
|
||||
// Check that GetConfiguration returns the last configuration passed into
|
||||
// SetConfiguration.
|
||||
TEST_F(PeerConnectionInterfaceTest, GetConfigurationAfterSetConfiguration) {
|
||||
CreatePeerConnection();
|
||||
|
||||
PeerConnectionInterface::RTCConfiguration config;
|
||||
config.type = PeerConnectionInterface::kRelay;
|
||||
EXPECT_TRUE(pc_->SetConfiguration(config));
|
||||
|
||||
PeerConnectionInterface::RTCConfiguration returned_config =
|
||||
pc_->GetConfiguration();
|
||||
EXPECT_EQ(PeerConnectionInterface::kRelay, returned_config.type);
|
||||
}
|
||||
|
||||
TEST_F(PeerConnectionInterfaceTest, AddStreams) {
|
||||
CreatePeerConnection();
|
||||
AddVideoStream(kStreamLabel1);
|
||||
|
||||
@ -63,6 +63,7 @@ BEGIN_SIGNALING_PROXY_MAP(PeerConnection)
|
||||
SessionDescriptionInterface*)
|
||||
PROXY_METHOD2(void, SetRemoteDescription, SetSessionDescriptionObserver*,
|
||||
SessionDescriptionInterface*)
|
||||
PROXY_METHOD0(PeerConnectionInterface::RTCConfiguration, GetConfiguration);
|
||||
PROXY_METHOD1(bool,
|
||||
SetConfiguration,
|
||||
const PeerConnectionInterface::RTCConfiguration&);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user