Skip to content

Commit

Permalink
Remove enable_dtls_srtp option
Browse files Browse the repository at this point in the history
This is part of the removal of support for SDES.

Bug: webrtc:11066
Change-Id: I448d0e0032672c04c87b00550ab4b9d792071a0b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/234864
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35262}
  • Loading branch information
Harald Alvestrand authored and WebRTC LUCI CQ committed Oct 26, 2021
1 parent aaa848e commit f9e502d
Show file tree
Hide file tree
Showing 19 changed files with 36 additions and 299 deletions.
6 changes: 0 additions & 6 deletions api/peer_connection_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -427,12 +427,6 @@ class RTC_EXPORT PeerConnectionInterface : public rtc::RefCountInterface {
// Use new combined audio/video bandwidth estimation?
absl::optional<bool> combined_audio_video_bwe;

// TODO(bugs.webrtc.org/9891) - Move to crypto_options
// Can be used to disable DTLS-SRTP. This should never be done, but can be
// useful for testing purposes, for example in setting up a loopback call
// with a single PeerConnection.
absl::optional<bool> enable_dtls_srtp;

/////////////////////////////////////////////////
// The below fields are not part of the standard.
/////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,10 @@ private void createPeerConnectionFactoryInternal(PeerConnectionFactory.Options o
decoderFactory = new SoftwareVideoDecoderFactory();
}

// Disable encryption for loopback calls.
if (peerConnectionParameters.loopback) {
options.disableEncryption = true;
}
factory = PeerConnectionFactory.builder()
.setOptions(options)
.setAudioDeviceModule(adm)
Expand Down Expand Up @@ -600,8 +604,6 @@ private void createPeerConnectionInternal() {
rtcConfig.continualGatheringPolicy = PeerConnection.ContinualGatheringPolicy.GATHER_CONTINUALLY;
// Use ECDSA encryption.
rtcConfig.keyType = PeerConnection.KeyType.ECDSA;
// Enable DTLS for normal calls and disable for loopback calls.
rtcConfig.enableDtlsSrtp = !peerConnectionParameters.loopback;
rtcConfig.sdpSemantics = PeerConnection.SdpSemantics.UNIFIED_PLAN;

peerConnection = factory.createPeerConnection(rtcConfig, pcObserver);
Expand Down
6 changes: 4 additions & 2 deletions examples/androidnativeapi/jni/android_call_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,10 @@ void AndroidCallClient::CreatePeerConnection() {
webrtc::MutexLock lock(&pc_mutex_);
webrtc::PeerConnectionInterface::RTCConfiguration config;
config.sdp_semantics = webrtc::SdpSemantics::kUnifiedPlan;
// DTLS SRTP has to be disabled for loopback to work.
config.enable_dtls_srtp = false;
// Encryption has to be disabled for loopback to work.
webrtc::PeerConnectionFactoryInterface::Options options;
options.disable_encryption = true;
pcf_->SetOptions(options);
webrtc::PeerConnectionDependencies deps(pc_observer_.get());
pc_ = pcf_->CreatePeerConnectionOrError(config, std::move(deps)).MoveValue();

Expand Down
6 changes: 4 additions & 2 deletions examples/objcnativeapi/objc/objc_call_client.mm
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,10 @@
webrtc::MutexLock lock(&pc_mutex_);
webrtc::PeerConnectionInterface::RTCConfiguration config;
config.sdp_semantics = webrtc::SdpSemantics::kUnifiedPlan;
// DTLS SRTP has to be disabled for loopback to work.
config.enable_dtls_srtp = false;
// Encryption has to be disabled for loopback to work.
webrtc::PeerConnectionFactoryInterface::Options options;
options.disable_encryption = true;
pcf_->SetOptions(options);
webrtc::PeerConnectionDependencies pc_dependencies(pc_observer_.get());
pc_ = pcf_->CreatePeerConnectionOrError(config, std::move(pc_dependencies)).MoveValue();
RTC_LOG(LS_INFO) << "PeerConnection created: " << pc_;
Expand Down
13 changes: 9 additions & 4 deletions examples/peerconnection/client/conductor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ bool Conductor::InitializePeerConnection() {
return false;
}

if (!CreatePeerConnection(/*dtls=*/true)) {
if (!CreatePeerConnection()) {
main_wnd_->MessageBox("Error", "CreatePeerConnection failed", true);
DeletePeerConnection();
}
Expand All @@ -165,23 +165,28 @@ bool Conductor::ReinitializePeerConnectionForLoopback() {
std::vector<rtc::scoped_refptr<webrtc::RtpSenderInterface>> senders =
peer_connection_->GetSenders();
peer_connection_ = nullptr;
if (CreatePeerConnection(/*dtls=*/false)) {
// Loopback is only possible if encryption is disabled.
webrtc::PeerConnectionFactoryInterface::Options options;
options.disable_encryption = true;
peer_connection_factory_->SetOptions(options);
if (CreatePeerConnection()) {
for (const auto& sender : senders) {
peer_connection_->AddTrack(sender->track(), sender->stream_ids());
}
peer_connection_->CreateOffer(
this, webrtc::PeerConnectionInterface::RTCOfferAnswerOptions());
}
options.disable_encryption = false;
peer_connection_factory_->SetOptions(options);
return peer_connection_ != nullptr;
}

bool Conductor::CreatePeerConnection(bool dtls) {
bool Conductor::CreatePeerConnection() {
RTC_DCHECK(peer_connection_factory_);
RTC_DCHECK(!peer_connection_);

webrtc::PeerConnectionInterface::RTCConfiguration config;
config.sdp_semantics = webrtc::SdpSemantics::kUnifiedPlan;
config.enable_dtls_srtp = dtls;
webrtc::PeerConnectionInterface::IceServer server;
server.uri = GetPeerConnectionString();
config.servers.push_back(server);
Expand Down
2 changes: 1 addition & 1 deletion examples/peerconnection/client/conductor.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Conductor : public webrtc::PeerConnectionObserver,
~Conductor();
bool InitializePeerConnection();
bool ReinitializePeerConnectionForLoopback();
bool CreatePeerConnection(bool dtls);
bool CreatePeerConnection();
void DeletePeerConnection();
void EnsureStreamingUI();
void AddTracks();
Expand Down
1 change: 0 additions & 1 deletion examples/unityplugin/simple_peer_connection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ bool SimplePeerConnection::CreatePeerConnection(const char** turn_urls,
webrtc::PeerConnectionInterface::IceServer stun_server;
stun_server.uri = GetPeerConnectionString();
config_.servers.push_back(stun_server);
config_.enable_dtls_srtp = false;

auto result = g_peer_connection_factory->CreatePeerConnectionOrError(
config_, webrtc::PeerConnectionDependencies(this));
Expand Down
6 changes: 2 additions & 4 deletions pc/peer_connection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,8 @@ bool DtlsEnabled(const PeerConnectionInterface::RTCConfiguration& configuration,
bool default_enabled =
(dependencies.cert_generator || !configuration.certificates.empty());

// The `configuration` can override the default value.
return configuration.enable_dtls_srtp.value_or(default_enabled);
RTC_DCHECK(default_enabled) << "Configuration error: No certs for DTLS";
return default_enabled;
}

} // namespace
Expand All @@ -300,7 +300,6 @@ bool PeerConnectionInterface::RTCConfiguration::operator==(
bool enable_rtp_data_channel;
absl::optional<int> screencast_min_bitrate;
absl::optional<bool> combined_audio_video_bwe;
absl::optional<bool> enable_dtls_srtp;
TcpCandidatePolicy tcp_candidate_policy;
CandidateNetworkPolicy candidate_network_policy;
int audio_jitter_buffer_max_packets;
Expand Down Expand Up @@ -368,7 +367,6 @@ bool PeerConnectionInterface::RTCConfiguration::operator==(
disable_link_local_networks == o.disable_link_local_networks &&
screencast_min_bitrate == o.screencast_min_bitrate &&
combined_audio_video_bwe == o.combined_audio_video_bwe &&
enable_dtls_srtp == o.enable_dtls_srtp &&
ice_candidate_pool_size == o.ice_candidate_pool_size &&
prune_turn_ports == o.prune_turn_ports &&
turn_port_prune_policy == o.turn_port_prune_policy &&
Expand Down
Loading

0 comments on commit f9e502d

Please sign in to comment.