Delete almost all use of MediaConstraintsInterface in the PeerConnection API
Bug: webrtc:9239
Change-Id: I04f4370f624346bf72c7e4e090b57987b558213b
Reviewed-on: https://webrtc-review.googlesource.com/74420
Commit-Queue: Niels Moller <nisse@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24396}
diff --git a/pc/peerconnectioninterface_unittest.cc b/pc/peerconnectioninterface_unittest.cc
index 1beb347..2f6c0ef 100644
--- a/pc/peerconnectioninterface_unittest.cc
+++ b/pc/peerconnectioninterface_unittest.cc
@@ -22,7 +22,6 @@
#include "api/peerconnectioninterface.h"
#include "api/rtpreceiverinterface.h"
#include "api/rtpsenderinterface.h"
-#include "api/test/fakeconstraints.h"
#include "api/video_codecs/builtin_video_decoder_factory.h"
#include "api/video_codecs/builtin_video_encoder_factory.h"
#include "logging/rtc_event_log/output/rtc_event_log_output_file.h"
@@ -417,7 +416,6 @@
using webrtc::AudioTrackInterface;
using webrtc::DataBuffer;
using webrtc::DataChannelInterface;
-using webrtc::FakeConstraints;
using webrtc::IceCandidateInterface;
using webrtc::MediaConstraintsInterface;
using webrtc::MediaStream;
@@ -707,30 +705,23 @@
}
void CreatePeerConnection() {
- CreatePeerConnection(PeerConnectionInterface::RTCConfiguration(), nullptr);
+ CreatePeerConnection(PeerConnectionInterface::RTCConfiguration());
}
// DTLS does not work in a loopback call, so is disabled for most of the
// tests in this file.
void CreatePeerConnectionWithoutDtls() {
- FakeConstraints no_dtls_constraints;
- no_dtls_constraints.AddMandatory(
- webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, false);
+ RTCConfiguration config;
+ config.enable_dtls_srtp = false;
- CreatePeerConnection(PeerConnectionInterface::RTCConfiguration(),
- &no_dtls_constraints);
- }
-
- void CreatePeerConnection(webrtc::MediaConstraintsInterface* constraints) {
- CreatePeerConnection(PeerConnectionInterface::RTCConfiguration(),
- constraints);
+ CreatePeerConnection(config);
}
void CreatePeerConnectionWithIceTransportsType(
PeerConnectionInterface::IceTransportsType type) {
PeerConnectionInterface::RTCConfiguration config;
config.type = type;
- return CreatePeerConnection(config, nullptr);
+ return CreatePeerConnection(config);
}
void CreatePeerConnectionWithIceServer(const std::string& uri,
@@ -740,12 +731,10 @@
server.uri = uri;
server.password = password;
config.servers.push_back(server);
- CreatePeerConnection(config, nullptr);
+ CreatePeerConnection(config);
}
- void CreatePeerConnection(
- const PeerConnectionInterface::RTCConfiguration& config,
- webrtc::MediaConstraintsInterface* constraints) {
+ void CreatePeerConnection(const RTCConfiguration& config) {
std::unique_ptr<cricket::FakePortAllocator> port_allocator(
new cricket::FakePortAllocator(rtc::Thread::Current(), nullptr));
port_allocator_ = port_allocator.get();
@@ -753,19 +742,16 @@
// Create certificate generator unless DTLS constraint is explicitly set to
// false.
std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator;
- bool dtls;
- if (FindConstraint(constraints,
- webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
- &dtls, nullptr) &&
- dtls) {
+
+ if (config.enable_dtls_srtp.value_or(true)) {
fake_certificate_generator_ = new FakeRTCCertificateGenerator();
cert_generator.reset(fake_certificate_generator_);
}
RTCConfiguration modified_config = config;
modified_config.sdp_semantics = sdp_semantics_;
pc_ = pc_factory_->CreatePeerConnection(
- modified_config, constraints, std::move(port_allocator),
- std::move(cert_generator), &observer_);
+ modified_config, std::move(port_allocator), std::move(cert_generator),
+ &observer_);
ASSERT_TRUE(pc_.get() != NULL);
observer_.SetPeerConnectionInterface(pc_.get());
EXPECT_EQ(PeerConnectionInterface::kStable, observer_.state_);
@@ -778,8 +764,7 @@
config.servers.push_back(server);
config.sdp_semantics = sdp_semantics_;
rtc::scoped_refptr<PeerConnectionInterface> pc =
- pc_factory_->CreatePeerConnection(config, nullptr, nullptr, nullptr,
- &observer_);
+ pc_factory_->CreatePeerConnection(config, nullptr, nullptr, &observer_);
EXPECT_EQ(nullptr, pc);
}
@@ -895,14 +880,14 @@
}
bool DoCreateOfferAnswer(std::unique_ptr<SessionDescriptionInterface>* desc,
- bool offer,
- MediaConstraintsInterface* constraints) {
+ const RTCOfferAnswerOptions* options,
+ bool offer) {
rtc::scoped_refptr<MockCreateSessionDescriptionObserver> observer(
new rtc::RefCountedObject<MockCreateSessionDescriptionObserver>());
if (offer) {
- pc_->CreateOffer(observer, constraints);
+ pc_->CreateOffer(observer, options ? *options : RTCOfferAnswerOptions());
} else {
- pc_->CreateAnswer(observer, constraints);
+ pc_->CreateAnswer(observer, options ? *options : RTCOfferAnswerOptions());
}
EXPECT_EQ_WAIT(true, observer->called(), kTimeout);
*desc = observer->MoveDescription();
@@ -910,13 +895,13 @@
}
bool DoCreateOffer(std::unique_ptr<SessionDescriptionInterface>* desc,
- MediaConstraintsInterface* constraints) {
- return DoCreateOfferAnswer(desc, true, constraints);
+ const RTCOfferAnswerOptions* options) {
+ return DoCreateOfferAnswer(desc, options, true);
}
bool DoCreateAnswer(std::unique_ptr<SessionDescriptionInterface>* desc,
- MediaConstraintsInterface* constraints) {
- return DoCreateOfferAnswer(desc, false, constraints);
+ const RTCOfferAnswerOptions* options) {
+ return DoCreateOfferAnswer(desc, options, false);
}
bool DoSetSessionDescription(
@@ -1359,7 +1344,7 @@
config.candidate_network_policy =
PeerConnectionInterface::kCandidateNetworkPolicyLowCost;
config.ice_candidate_pool_size = 1;
- CreatePeerConnection(config, nullptr);
+ CreatePeerConnection(config);
const cricket::FakePortAllocatorSession* session =
static_cast<const cricket::FakePortAllocatorSession*>(
@@ -1411,8 +1396,8 @@
webrtc::CreateBuiltinVideoDecoderFactory(), nullptr /* audio_mixer */,
nullptr /* audio_processing */));
rtc::scoped_refptr<PeerConnectionInterface> pc(
- pc_factory->CreatePeerConnection(
- config, nullptr, std::move(port_allocator), nullptr, &observer_));
+ pc_factory->CreatePeerConnection(config, std::move(port_allocator),
+ nullptr, &observer_));
// Now validate that the config fields set above were applied to the
// PortAllocator, as flags or otherwise.
@@ -1430,7 +1415,7 @@
TEST_P(PeerConnectionInterfaceTest, GetConfigurationAfterCreatePeerConnection) {
PeerConnectionInterface::RTCConfiguration config;
config.type = PeerConnectionInterface::kRelay;
- CreatePeerConnection(config, nullptr);
+ CreatePeerConnection(config);
PeerConnectionInterface::RTCConfiguration returned_config =
pc_->GetConfiguration();
@@ -1930,9 +1915,10 @@
// This test setup two RTP data channels in loop back.
TEST_P(PeerConnectionInterfaceTest, TestDataChannel) {
- FakeConstraints constraints;
- constraints.SetAllowRtpDataChannels();
- CreatePeerConnection(&constraints);
+ RTCConfiguration config;
+ config.enable_rtp_data_channel = true;
+ config.enable_dtls_srtp = false;
+ CreatePeerConnection(config);
rtc::scoped_refptr<DataChannelInterface> data1 =
pc_->CreateDataChannel("test1", NULL);
rtc::scoped_refptr<DataChannelInterface> data2 =
@@ -1977,9 +1963,10 @@
// This test verifies that sendnig binary data over RTP data channels should
// fail.
TEST_P(PeerConnectionInterfaceTest, TestSendBinaryOnRtpDataChannel) {
- FakeConstraints constraints;
- constraints.SetAllowRtpDataChannels();
- CreatePeerConnection(&constraints);
+ RTCConfiguration config;
+ config.enable_rtp_data_channel = true;
+ config.enable_dtls_srtp = false;
+ CreatePeerConnection(config);
rtc::scoped_refptr<DataChannelInterface> data1 =
pc_->CreateDataChannel("test1", NULL);
rtc::scoped_refptr<DataChannelInterface> data2 =
@@ -2007,9 +1994,10 @@
// This test setup a RTP data channels in loop back and test that a channel is
// opened even if the remote end answer with a zero SSRC.
TEST_P(PeerConnectionInterfaceTest, TestSendOnlyDataChannel) {
- FakeConstraints constraints;
- constraints.SetAllowRtpDataChannels();
- CreatePeerConnection(&constraints);
+ RTCConfiguration config;
+ config.enable_rtp_data_channel = true;
+ config.enable_dtls_srtp = false;
+ CreatePeerConnection(config);
rtc::scoped_refptr<DataChannelInterface> data1 =
pc_->CreateDataChannel("test1", NULL);
std::unique_ptr<MockDataChannelObserver> observer1(
@@ -2029,9 +2017,11 @@
// This test that if a data channel is added in an answer a receive only channel
// channel is created.
TEST_P(PeerConnectionInterfaceTest, TestReceiveOnlyDataChannel) {
- FakeConstraints constraints;
- constraints.SetAllowRtpDataChannels();
- CreatePeerConnection(&constraints);
+ RTCConfiguration config;
+ config.enable_rtp_data_channel = true;
+ config.enable_dtls_srtp = false;
+
+ CreatePeerConnection(config);
std::string offer_label = "offer_channel";
rtc::scoped_refptr<DataChannelInterface> offer_channel =
@@ -2069,9 +2059,9 @@
// requested.
// TODO(perkj): Remove this test once reliable channels are implemented.
TEST_P(PeerConnectionInterfaceTest, CreateReliableRtpDataChannelShouldFail) {
- FakeConstraints constraints;
- constraints.SetAllowRtpDataChannels();
- CreatePeerConnection(&constraints);
+ RTCConfiguration rtc_config;
+ rtc_config.enable_rtp_data_channel = true;
+ CreatePeerConnection(rtc_config);
std::string label = "test";
webrtc::DataChannelInit config;
@@ -2083,9 +2073,9 @@
// Verifies that duplicated label is not allowed for RTP data channel.
TEST_P(PeerConnectionInterfaceTest, RtpDuplicatedLabelNotAllowed) {
- FakeConstraints constraints;
- constraints.SetAllowRtpDataChannels();
- CreatePeerConnection(&constraints);
+ RTCConfiguration config;
+ config.enable_rtp_data_channel = true;
+ CreatePeerConnection(config);
std::string label = "test";
rtc::scoped_refptr<DataChannelInterface> channel =
@@ -2100,9 +2090,9 @@
// This tests that a SCTP data channel is returned using different
// DataChannelInit configurations.
TEST_P(PeerConnectionInterfaceTest, CreateSctpDataChannel) {
- FakeConstraints constraints;
- constraints.SetAllowDtlsSctpDataChannels();
- CreatePeerConnection(&constraints);
+ RTCConfiguration rtc_config;
+ rtc_config.enable_dtls_srtp = true;
+ CreatePeerConnection(rtc_config);
webrtc::DataChannelInit config;
@@ -2138,9 +2128,9 @@
// maxRetransmitTime are set for SCTP data channels.
TEST_P(PeerConnectionInterfaceTest,
CreateSctpDataChannelShouldFailForInvalidConfig) {
- FakeConstraints constraints;
- constraints.SetAllowDtlsSctpDataChannels();
- CreatePeerConnection(&constraints);
+ RTCConfiguration rtc_config;
+ rtc_config.enable_dtls_srtp = true;
+ CreatePeerConnection(rtc_config);
std::string label = "test";
webrtc::DataChannelInit config;
@@ -2156,9 +2146,9 @@
// or out of range should fail.
TEST_P(PeerConnectionInterfaceTest,
CreateSctpDataChannelWithInvalidIdShouldFail) {
- FakeConstraints constraints;
- constraints.SetAllowDtlsSctpDataChannels();
- CreatePeerConnection(&constraints);
+ RTCConfiguration rtc_config;
+ rtc_config.enable_dtls_srtp = true;
+ CreatePeerConnection(rtc_config);
webrtc::DataChannelInit config;
rtc::scoped_refptr<DataChannelInterface> channel;
@@ -2183,10 +2173,9 @@
// Verifies that duplicated label is allowed for SCTP data channel.
TEST_P(PeerConnectionInterfaceTest, SctpDuplicatedLabelAllowed) {
- FakeConstraints constraints;
- constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
- true);
- CreatePeerConnection(&constraints);
+ RTCConfiguration rtc_config;
+ rtc_config.enable_dtls_srtp = true;
+ CreatePeerConnection(rtc_config);
std::string label = "test";
rtc::scoped_refptr<DataChannelInterface> channel =
@@ -2201,9 +2190,10 @@
// This test verifies that OnRenegotiationNeeded is fired for every new RTP
// DataChannel.
TEST_P(PeerConnectionInterfaceTest, RenegotiationNeededForNewRtpDataChannel) {
- FakeConstraints constraints;
- constraints.SetAllowRtpDataChannels();
- CreatePeerConnection(&constraints);
+ RTCConfiguration rtc_config;
+ rtc_config.enable_rtp_data_channel = true;
+ rtc_config.enable_dtls_srtp = false;
+ CreatePeerConnection(rtc_config);
rtc::scoped_refptr<DataChannelInterface> dc1 =
pc_->CreateDataChannel("test1", NULL);
@@ -2217,9 +2207,10 @@
// This test that a data channel closes when a PeerConnection is deleted/closed.
TEST_P(PeerConnectionInterfaceTest, DataChannelCloseWhenPeerConnectionClose) {
- FakeConstraints constraints;
- constraints.SetAllowRtpDataChannels();
- CreatePeerConnection(&constraints);
+ RTCConfiguration rtc_config;
+ rtc_config.enable_rtp_data_channel = true;
+ rtc_config.enable_dtls_srtp = false;
+ CreatePeerConnection(rtc_config);
rtc::scoped_refptr<DataChannelInterface> data1 =
pc_->CreateDataChannel("test1", NULL);
@@ -2242,9 +2233,10 @@
// This tests that RTP data channels can be rejected in an answer.
TEST_P(PeerConnectionInterfaceTest, TestRejectRtpDataChannelInAnswer) {
- FakeConstraints constraints;
- constraints.SetAllowRtpDataChannels();
- CreatePeerConnection(&constraints);
+ RTCConfiguration rtc_config;
+ rtc_config.enable_rtp_data_channel = true;
+ rtc_config.enable_dtls_srtp = false;
+ CreatePeerConnection(rtc_config);
rtc::scoped_refptr<DataChannelInterface> offer_channel(
pc_->CreateDataChannel("offer_channel", NULL));
@@ -2272,8 +2264,8 @@
TEST_P(PeerConnectionInterfaceTest, DISABLED_TestRejectSctpDataChannelInAnswer)
#endif
{
- FakeConstraints constraints;
- CreatePeerConnection(&constraints);
+ RTCConfiguration rtc_config;
+ CreatePeerConnection(rtc_config);
rtc::scoped_refptr<DataChannelInterface> offer_channel(
pc_->CreateDataChannel("offer_channel", NULL));
@@ -2298,10 +2290,9 @@
// FireFox, use it as a remote session description, generate an answer and use
// the answer as a local description.
TEST_P(PeerConnectionInterfaceTest, ReceiveFireFoxOffer) {
- FakeConstraints constraints;
- constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
- true);
- CreatePeerConnection(&constraints);
+ RTCConfiguration rtc_config;
+ rtc_config.enable_dtls_srtp = true;
+ CreatePeerConnection(rtc_config);
AddAudioTrack("audio_label");
AddVideoTrack("video_label");
std::unique_ptr<SessionDescriptionInterface> desc(
@@ -2333,10 +2324,9 @@
// The fallback was previously supported but was removed to simplify the code
// and because it's non-standard.
TEST_P(PeerConnectionInterfaceTest, DtlsSdesFallbackNotSupported) {
- FakeConstraints constraints;
- constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
- true);
- CreatePeerConnection(&constraints);
+ RTCConfiguration rtc_config;
+ rtc_config.enable_dtls_srtp = true;
+ CreatePeerConnection(rtc_config);
// Wait for fake certificate to be generated. Previously, this is what caused
// the "a=crypto" lines to be rejected.
AddAudioTrack("audio_label");
@@ -2378,10 +2368,9 @@
// Test that if we're receiving (but not sending) a track, subsequent offers
// will have m-lines with a=recvonly.
TEST_P(PeerConnectionInterfaceTest, CreateSubsequentRecvOnlyOffer) {
- FakeConstraints constraints;
- constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
- true);
- CreatePeerConnection(&constraints);
+ RTCConfiguration rtc_config;
+ rtc_config.enable_dtls_srtp = true;
+ CreatePeerConnection(rtc_config);
CreateAndSetRemoteOffer(GetSdpStringWithStream1());
CreateAnswerAsLocalDescription();
@@ -2405,10 +2394,9 @@
// offerToReceiveVideo/offerToReceiveAudio constraints are explicitly set to
// false, the generated m-lines will be a=inactive.
TEST_P(PeerConnectionInterfaceTest, CreateSubsequentInactiveOffer) {
- FakeConstraints constraints;
- constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
- true);
- CreatePeerConnection(&constraints);
+ RTCConfiguration rtc_config;
+ rtc_config.enable_dtls_srtp = true;
+ CreatePeerConnection(rtc_config);
CreateAndSetRemoteOffer(GetSdpStringWithStream1());
CreateAnswerAsLocalDescription();
@@ -2416,12 +2404,10 @@
// A new offer would be recvonly, but we'll set the "no receive" constraints
// to make it inactive.
std::unique_ptr<SessionDescriptionInterface> offer;
- FakeConstraints offer_constraints;
- offer_constraints.AddMandatory(
- webrtc::MediaConstraintsInterface::kOfferToReceiveVideo, false);
- offer_constraints.AddMandatory(
- webrtc::MediaConstraintsInterface::kOfferToReceiveAudio, false);
- DoCreateOffer(&offer, &offer_constraints);
+ RTCOfferAnswerOptions options;
+ options.offer_to_receive_audio = 0;
+ options.offer_to_receive_video = 0;
+ DoCreateOffer(&offer, &options);
const cricket::ContentInfo* video_content =
cricket::GetFirstVideoContent(offer->description());
@@ -2461,7 +2447,7 @@
TEST_P(PeerConnectionInterfaceTest, SetConfigurationChangesPruneTurnPortsFlag) {
PeerConnectionInterface::RTCConfiguration config;
config.prune_turn_ports = false;
- CreatePeerConnection(config, nullptr);
+ CreatePeerConnection(config);
config = pc_->GetConfiguration();
EXPECT_FALSE(port_allocator_->prune_turn_ports());
@@ -2476,7 +2462,7 @@
TEST_P(PeerConnectionInterfaceTest, SetConfigurationChangesIceCheckInterval) {
PeerConnectionInterface::RTCConfiguration config;
config.ice_check_min_interval = absl::nullopt;
- CreatePeerConnection(config, nullptr);
+ CreatePeerConnection(config);
config = pc_->GetConfiguration();
config.ice_check_min_interval = 100;
EXPECT_TRUE(pc_->SetConfiguration(config));
@@ -2573,7 +2559,7 @@
config.bundle_policy = PeerConnectionInterface::kBundlePolicyBalanced;
config.rtcp_mux_policy = PeerConnectionInterface::kRtcpMuxPolicyNegotiate;
config.continual_gathering_policy = PeerConnectionInterface::GATHER_ONCE;
- CreatePeerConnection(config, nullptr);
+ CreatePeerConnection(config);
PeerConnectionInterface::RTCConfiguration modified_config =
pc_->GetConfiguration();
@@ -2603,7 +2589,7 @@
TEST_P(PeerConnectionInterfaceTest,
SetConfigurationReturnsRangeErrorForBadCandidatePoolSize) {
PeerConnectionInterface::RTCConfiguration config;
- CreatePeerConnection(config, nullptr);
+ CreatePeerConnection(config);
config = pc_->GetConfiguration();
config.ice_candidate_pool_size = -1;
@@ -2622,7 +2608,7 @@
TEST_P(PeerConnectionInterfaceTest,
SetConfigurationReturnsSyntaxErrorFromBadIceUrls) {
PeerConnectionInterface::RTCConfiguration config;
- CreatePeerConnection(config, nullptr);
+ CreatePeerConnection(config);
config = pc_->GetConfiguration();
PeerConnectionInterface::IceServer bad_server;
@@ -2638,7 +2624,7 @@
TEST_P(PeerConnectionInterfaceTest,
SetConfigurationReturnsInvalidParameterIfCredentialsMissing) {
PeerConnectionInterface::RTCConfiguration config;
- CreatePeerConnection(config, nullptr);
+ CreatePeerConnection(config);
config = pc_->GetConfiguration();
PeerConnectionInterface::IceServer bad_server;
@@ -2753,10 +2739,9 @@
// SDP string is created. In this test the two separate MediaStreams are
// signaled.
TEST_P(PeerConnectionInterfaceTest, UpdateRemoteStreams) {
- FakeConstraints constraints;
- constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
- true);
- CreatePeerConnection(&constraints);
+ RTCConfiguration config;
+ config.enable_dtls_srtp = true;
+ CreatePeerConnection(config);
CreateAndSetRemoteOffer(GetSdpStringWithStream1());
rtc::scoped_refptr<StreamCollection> reference(CreateStreamCollection(1, 1));
@@ -2780,10 +2765,9 @@
// specific behavior.
TEST_F(PeerConnectionInterfaceTestPlanB,
AddRemoveTrackFromExistingRemoteMediaStream) {
- FakeConstraints constraints;
- constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
- true);
- CreatePeerConnection(&constraints);
+ RTCConfiguration config;
+ config.enable_dtls_srtp = true;
+ CreatePeerConnection(config);
std::unique_ptr<SessionDescriptionInterface> desc_ms1 =
CreateSessionDescriptionAndReference(1, 1);
EXPECT_TRUE(DoSetRemoteDescription(std::move(desc_ms1)));
@@ -2824,10 +2808,9 @@
// This tests that remote tracks are ended if a local session description is set
// that rejects the media content type.
TEST_P(PeerConnectionInterfaceTest, RejectMediaContent) {
- FakeConstraints constraints;
- constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
- true);
- CreatePeerConnection(&constraints);
+ RTCConfiguration config;
+ config.enable_dtls_srtp = true;
+ CreatePeerConnection(config);
// First create and set a remote offer, then reject its video content in our
// answer.
CreateAndSetRemoteOffer(kSdpStringWithStream1PlanB);
@@ -2874,10 +2857,9 @@
// of PeerConnection and then PeerConnection tries to reject the track.
// Don't run under Unified Plan since the stream API is not available.
TEST_F(PeerConnectionInterfaceTestPlanB, RemoveTrackThenRejectMediaContent) {
- FakeConstraints constraints;
- constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
- true);
- CreatePeerConnection(&constraints);
+ RTCConfiguration config;
+ config.enable_dtls_srtp = true;
+ CreatePeerConnection(config);
CreateAndSetRemoteOffer(GetSdpStringWithStream1());
MediaStreamInterface* remote_stream = observer_.remote_streams()->at(0);
remote_stream->RemoveTrack(remote_stream->GetVideoTracks()[0]);
@@ -2901,10 +2883,9 @@
// will be created, even if the description contains SSRCs/MSIDs.
// See: https://code.google.com/p/webrtc/issues/detail?id=5054
TEST_P(PeerConnectionInterfaceTest, RecvonlyDescriptionDoesntCreateStream) {
- FakeConstraints constraints;
- constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
- true);
- CreatePeerConnection(&constraints);
+ RTCConfiguration config;
+ config.enable_dtls_srtp = true;
+ CreatePeerConnection(config);
std::string recvonly_offer = GetSdpStringWithStream1();
rtc::replace_substrs(kSendrecv, strlen(kSendrecv), kRecvonly,
@@ -2920,10 +2901,9 @@
// in a subsequent session description.
// Don't run under Unified Plan since this behavior is Plan B specific.
TEST_F(PeerConnectionInterfaceTestPlanB, SdpWithoutMsidCreatesDefaultStream) {
- FakeConstraints constraints;
- constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
- true);
- CreatePeerConnection(&constraints);
+ RTCConfiguration config;
+ config.enable_dtls_srtp = true;
+ CreatePeerConnection(config);
CreateAndSetRemoteOffer(kSdpStringWithoutStreamsAudioOnly);
ASSERT_EQ(1u, observer_.remote_streams()->count());
@@ -2950,10 +2930,9 @@
// Don't run under Unified Plan since this behavior is Plan B specific.
TEST_F(PeerConnectionInterfaceTestPlanB,
SendOnlySdpWithoutMsidCreatesDefaultStream) {
- FakeConstraints constraints;
- constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
- true);
- CreatePeerConnection(&constraints);
+ RTCConfiguration config;
+ config.enable_dtls_srtp = true;
+ CreatePeerConnection(config);
CreateAndSetRemoteOffer(kSdpStringSendOnlyWithoutStreams);
ASSERT_EQ(1u, observer_.remote_streams()->count());
@@ -2968,10 +2947,9 @@
// a remote track that as already been removed from the MediaStream.
// Don't run under Unified Plan since this behavior is Plan B specific.
TEST_F(PeerConnectionInterfaceTestPlanB, RemoveAlreadyGoneRemoteStream) {
- FakeConstraints constraints;
- constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
- true);
- CreatePeerConnection(&constraints);
+ RTCConfiguration config;
+ config.enable_dtls_srtp = true;
+ CreatePeerConnection(config);
CreateAndSetRemoteOffer(GetSdpStringWithStream1());
MediaStreamInterface* remote_stream = observer_.remote_streams()->at(0);
remote_stream->RemoveTrack(remote_stream->GetAudioTracks()[0]);
@@ -2988,10 +2966,9 @@
// Don't run under Unified Plan since this behavior is Plan B specific.
TEST_F(PeerConnectionInterfaceTestPlanB,
SdpWithoutMsidAndStreamsCreatesDefaultStream) {
- FakeConstraints constraints;
- constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
- true);
- CreatePeerConnection(&constraints);
+ RTCConfiguration config;
+ config.enable_dtls_srtp = true;
+ CreatePeerConnection(config);
CreateAndSetRemoteOffer(kSdpStringWithoutStreams);
ASSERT_EQ(1u, observer_.remote_streams()->count());
@@ -3004,10 +2981,9 @@
// description doesn't contain any streams but does support MSID.
// Don't run under Unified Plan since this behavior is Plan B specific.
TEST_F(PeerConnectionInterfaceTestPlanB, SdpWithMsidDontCreatesDefaultStream) {
- FakeConstraints constraints;
- constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
- true);
- CreatePeerConnection(&constraints);
+ RTCConfiguration config;
+ config.enable_dtls_srtp = true;
+ CreatePeerConnection(config);
CreateAndSetRemoteOffer(kSdpStringWithMsidWithoutStreams);
EXPECT_EQ(0u, observer_.remote_streams()->count());
}
@@ -3018,10 +2994,9 @@
// Don't run under Unified Plan since this behavior is Plan B specific.
TEST_F(PeerConnectionInterfaceTestPlanB,
DefaultTracksNotDestroyedAndRecreated) {
- FakeConstraints constraints;
- constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
- true);
- CreatePeerConnection(&constraints);
+ RTCConfiguration config;
+ config.enable_dtls_srtp = true;
+ CreatePeerConnection(config);
CreateAndSetRemoteOffer(kSdpStringWithoutStreamsAudioOnly);
ASSERT_EQ(1u, observer_.remote_streams()->count());
@@ -3040,10 +3015,9 @@
// description is updated to not have any MediaStreams.
// Don't run under Unified Plan since this behavior is Plan B specific.
TEST_F(PeerConnectionInterfaceTestPlanB, VerifyDefaultStreamIsNotCreated) {
- FakeConstraints constraints;
- constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
- true);
- CreatePeerConnection(&constraints);
+ RTCConfiguration config;
+ config.enable_dtls_srtp = true;
+ CreatePeerConnection(config);
CreateAndSetRemoteOffer(GetSdpStringWithStream1());
rtc::scoped_refptr<StreamCollection> reference(CreateStreamCollection(1, 1));
EXPECT_TRUE(
@@ -3057,10 +3031,9 @@
// an endpoint that doesn't signal SSRCs, but signals media stream IDs.
TEST_F(PeerConnectionInterfaceTestPlanB,
SdpWithMsidWithoutSsrcCreatesDefaultStream) {
- FakeConstraints constraints;
- constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
- true);
- CreatePeerConnection(&constraints);
+ RTCConfiguration config;
+ config.enable_dtls_srtp = true;
+ CreatePeerConnection(config);
std::string sdp_string = kSdpStringWithoutStreamsAudioOnly;
// Add a=msid lines to simulate a Unified Plan endpoint that only
// signals stream IDs with a=msid lines.
@@ -3081,10 +3054,9 @@
// a=ssrc msid and a=msid lines for interop signaling with Plan B.
TEST_F(PeerConnectionInterfaceTestPlanB,
SdpWithEmptyMsidAndSsrcCreatesDefaultStreamId) {
- FakeConstraints constraints;
- constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
- true);
- CreatePeerConnection(&constraints);
+ RTCConfiguration config;
+ config.enable_dtls_srtp = true;
+ CreatePeerConnection(config);
// Add a a=msid line to the SDP. This is prioritized when parsing the SDP, so
// the sender's stream ID will be interpreted as no stream IDs.
std::string sdp_string = kSdpStringWithStream1AudioTrackOnly;
@@ -3120,10 +3092,9 @@
// an RtpSender's lifetime isn't determined by when a local description is set.
// Don't run under Unified Plan since this behavior is Plan B specific.
TEST_F(PeerConnectionInterfaceTestPlanB, LocalDescriptionChanged) {
- FakeConstraints constraints;
- constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
- true);
- CreatePeerConnection(&constraints);
+ RTCConfiguration config;
+ config.enable_dtls_srtp = true;
+ CreatePeerConnection(config);
// Create an offer with 1 stream with 2 tracks of each type.
rtc::scoped_refptr<StreamCollection> stream_collection =
@@ -3160,10 +3131,9 @@
// Don't run under Unified Plan since this behavior is Plan B specific.
TEST_F(PeerConnectionInterfaceTestPlanB,
AddLocalStreamAfterLocalDescriptionChanged) {
- FakeConstraints constraints;
- constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
- true);
- CreatePeerConnection(&constraints);
+ RTCConfiguration config;
+ config.enable_dtls_srtp = true;
+ CreatePeerConnection(config);
rtc::scoped_refptr<StreamCollection> stream_collection =
CreateStreamCollection(1, 2);
@@ -3190,10 +3160,9 @@
// changed when SetLocalDescription is called.
TEST_P(PeerConnectionInterfaceTest,
ChangeSsrcOnTrackInLocalSessionDescription) {
- FakeConstraints constraints;
- constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
- true);
- CreatePeerConnection(&constraints);
+ RTCConfiguration config;
+ config.enable_dtls_srtp = true;
+ CreatePeerConnection(config);
AddAudioTrack(kAudioTracks[0]);
AddVideoTrack(kVideoTracks[0]);
@@ -3245,10 +3214,9 @@
// Don't run under Unified Plan since the stream API is not available.
TEST_F(PeerConnectionInterfaceTestPlanB,
SignalSameTracksInSeparateMediaStream) {
- FakeConstraints constraints;
- constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
- true);
- CreatePeerConnection(&constraints);
+ RTCConfiguration config;
+ config.enable_dtls_srtp = true;
+ CreatePeerConnection(config);
rtc::scoped_refptr<StreamCollection> stream_collection =
CreateStreamCollection(2, 1);
@@ -3283,10 +3251,9 @@
// This tests that PeerConnectionObserver::OnAddTrack is correctly called.
TEST_P(PeerConnectionInterfaceTest, OnAddTrackCallback) {
- FakeConstraints constraints;
- constraints.AddMandatory(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
- true);
- CreatePeerConnection(&constraints);
+ RTCConfiguration config;
+ config.enable_dtls_srtp = true;
+ CreatePeerConnection(config);
CreateAndSetRemoteOffer(kSdpStringWithStream1AudioTrackOnly);
EXPECT_EQ(observer_.num_added_tracks_, 1);
EXPECT_EQ(observer_.last_added_track_label_, kAudioTracks[0]);
@@ -3302,9 +3269,7 @@
TEST_P(PeerConnectionInterfaceTest, SetConfigurationCausingIceRestart) {
PeerConnectionInterface::RTCConfiguration config;
config.type = PeerConnectionInterface::kRelay;
- // Need to pass default constraints to prevent disabling of DTLS...
- FakeConstraints default_constraints;
- CreatePeerConnection(config, &default_constraints);
+ CreatePeerConnection(config);
config = pc_->GetConfiguration();
AddAudioTrack(kAudioTracks[0], {kStreamId1});
AddVideoTrack(kVideoTracks[0], {kStreamId1});
@@ -3338,9 +3303,7 @@
TEST_P(PeerConnectionInterfaceTest, SetConfigurationNotCausingIceRestart) {
PeerConnectionInterface::RTCConfiguration config;
config.type = PeerConnectionInterface::kRelay;
- // Need to pass default constraints to prevent disabling of DTLS...
- FakeConstraints default_constraints;
- CreatePeerConnection(config, &default_constraints);
+ CreatePeerConnection(config);
config = pc_->GetConfiguration();
AddAudioTrack(kAudioTracks[0]);
AddVideoTrack(kVideoTracks[0]);
@@ -3374,9 +3337,7 @@
TEST_P(PeerConnectionInterfaceTest, SetConfigurationCausingPartialIceRestart) {
PeerConnectionInterface::RTCConfiguration config;
config.type = PeerConnectionInterface::kRelay;
- // Need to pass default constraints to prevent disabling of DTLS...
- FakeConstraints default_constraints;
- CreatePeerConnection(config, &default_constraints);
+ CreatePeerConnection(config);
config = pc_->GetConfiguration();
AddAudioTrack(kAudioTracks[0], {kStreamId1});
AddVideoTrack(kVideoTracks[0], {kStreamId1});
@@ -3534,11 +3495,11 @@
CreatePeerConnection();
// First, create an offer with audio/video.
- FakeConstraints constraints;
- constraints.SetMandatoryReceiveAudio(true);
- constraints.SetMandatoryReceiveVideo(true);
+ RTCOfferAnswerOptions options;
+ options.offer_to_receive_audio = 1;
+ options.offer_to_receive_video = 1;
std::unique_ptr<SessionDescriptionInterface> offer;
- ASSERT_TRUE(DoCreateOffer(&offer, &constraints));
+ ASSERT_TRUE(DoCreateOffer(&offer, &options));
cricket::SessionDescription* desc = offer->description();
ASSERT_EQ(2u, desc->transport_infos().size());
EXPECT_TRUE(desc->transport_infos()[0].description.HasOption("trickle"));
@@ -3547,7 +3508,7 @@
// Apply the offer as a remote description, then create an answer.
EXPECT_TRUE(DoSetRemoteDescription(std::move(offer)));
std::unique_ptr<SessionDescriptionInterface> answer;
- ASSERT_TRUE(DoCreateAnswer(&answer, &constraints));
+ ASSERT_TRUE(DoCreateAnswer(&answer, &options));
desc = answer->description();
ASSERT_EQ(2u, desc->transport_infos().size());
EXPECT_TRUE(desc->transport_infos()[0].description.HasOption("trickle"));
@@ -3559,7 +3520,7 @@
TEST_P(PeerConnectionInterfaceTest, IceRenominationNotOffered) {
PeerConnectionInterface::RTCConfiguration config;
config.enable_ice_renomination = false;
- CreatePeerConnection(config, nullptr);
+ CreatePeerConnection(config);
AddAudioTrack("foo");
std::unique_ptr<SessionDescriptionInterface> offer;
@@ -3575,7 +3536,7 @@
TEST_P(PeerConnectionInterfaceTest, IceRenominationOptionInOfferAndAnswer) {
PeerConnectionInterface::RTCConfiguration config;
config.enable_ice_renomination = true;
- CreatePeerConnection(config, nullptr);
+ CreatePeerConnection(config);
AddAudioTrack("foo");
std::unique_ptr<SessionDescriptionInterface> offer;
@@ -3602,11 +3563,11 @@
TEST_P(PeerConnectionInterfaceTest, CreateOfferWithOfferToReceiveConstraints) {
CreatePeerConnection();
- FakeConstraints constraints;
- constraints.SetMandatoryReceiveAudio(true);
- constraints.SetMandatoryReceiveVideo(true);
+ RTCOfferAnswerOptions options;
+ options.offer_to_receive_audio = 1;
+ options.offer_to_receive_video = 1;
std::unique_ptr<SessionDescriptionInterface> offer;
- ASSERT_TRUE(DoCreateOffer(&offer, &constraints));
+ ASSERT_TRUE(DoCreateOffer(&offer, &options));
cricket::SessionDescription* desc = offer->description();
const cricket::ContentInfo* audio = cricket::GetFirstAudioContent(desc);
@@ -3627,18 +3588,18 @@
// First, create an offer with audio/video and apply it as a remote
// description.
- FakeConstraints constraints;
- constraints.SetMandatoryReceiveAudio(true);
- constraints.SetMandatoryReceiveVideo(true);
+ RTCOfferAnswerOptions options;
+ options.offer_to_receive_audio = 1;
+ options.offer_to_receive_video = 1;
std::unique_ptr<SessionDescriptionInterface> offer;
- ASSERT_TRUE(DoCreateOffer(&offer, &constraints));
+ ASSERT_TRUE(DoCreateOffer(&offer, &options));
EXPECT_TRUE(DoSetRemoteDescription(std::move(offer)));
// Now create answer that rejects audio/video.
- constraints.SetMandatoryReceiveAudio(false);
- constraints.SetMandatoryReceiveVideo(false);
+ options.offer_to_receive_audio = 0;
+ options.offer_to_receive_video = 0;
std::unique_ptr<SessionDescriptionInterface> answer;
- ASSERT_TRUE(DoCreateAnswer(&answer, &constraints));
+ ASSERT_TRUE(DoCreateAnswer(&answer, &options));
cricket::SessionDescription* desc = answer->description();
const cricket::ContentInfo* audio = cricket::GetFirstAudioContent(desc);
@@ -3659,7 +3620,7 @@
#endif // HAVE_SCTP
PeerConnectionInterface::RTCConfiguration config;
config.bundle_policy = PeerConnectionInterface::kBundlePolicyMaxBundle;
- CreatePeerConnection(config, nullptr);
+ CreatePeerConnection(config);
// First, create an offer with only a data channel and apply it as a remote
// description.
@@ -3745,7 +3706,7 @@
config.ice_regather_interval_range.emplace(1000, 2000);
config.continual_gathering_policy =
PeerConnectionInterface::ContinualGatheringPolicy::GATHER_CONTINUALLY;
- CreatePeerConnection(config, nullptr);
+ CreatePeerConnection(config);
}
// The current bitrate from BitrateSettings is currently clamped
@@ -3990,10 +3951,9 @@
pcf_->Initialize();
}
const cricket::MediaConfig TestCreatePeerConnection(
- const PeerConnectionInterface::RTCConfiguration& config,
- const MediaConstraintsInterface* constraints) {
- rtc::scoped_refptr<PeerConnectionInterface> pc(pcf_->CreatePeerConnection(
- config, constraints, nullptr, nullptr, &observer_));
+ const RTCConfiguration& config) {
+ rtc::scoped_refptr<PeerConnectionInterface> pc(
+ pcf_->CreatePeerConnection(config, nullptr, nullptr, &observer_));
EXPECT_TRUE(pc.get());
return pc->GetConfiguration().media_config;
}
@@ -4006,10 +3966,8 @@
// default RTCConfiguration.
TEST_F(PeerConnectionMediaConfigTest, TestDefaults) {
PeerConnectionInterface::RTCConfiguration config;
- FakeConstraints constraints;
- const cricket::MediaConfig& media_config =
- TestCreatePeerConnection(config, &constraints);
+ const cricket::MediaConfig& media_config = TestCreatePeerConnection(config);
EXPECT_FALSE(media_config.enable_dscp);
EXPECT_TRUE(media_config.video.enable_cpu_adaptation);
@@ -4018,42 +3976,13 @@
EXPECT_FALSE(media_config.video.experiment_cpu_load_estimator);
}
-// This test verifies the DSCP constraint is recognized and passed to
-// the PeerConnection.
-TEST_F(PeerConnectionMediaConfigTest, TestDscpConstraintTrue) {
- PeerConnectionInterface::RTCConfiguration config;
- FakeConstraints constraints;
-
- constraints.AddOptional(webrtc::MediaConstraintsInterface::kEnableDscp, true);
- const cricket::MediaConfig& media_config =
- TestCreatePeerConnection(config, &constraints);
-
- EXPECT_TRUE(media_config.enable_dscp);
-}
-
-// This test verifies the cpu overuse detection constraint is
-// recognized and passed to the PeerConnection.
-TEST_F(PeerConnectionMediaConfigTest, TestCpuOveruseConstraintFalse) {
- PeerConnectionInterface::RTCConfiguration config;
- FakeConstraints constraints;
-
- constraints.AddOptional(
- webrtc::MediaConstraintsInterface::kCpuOveruseDetection, false);
- const cricket::MediaConfig media_config =
- TestCreatePeerConnection(config, &constraints);
-
- EXPECT_FALSE(media_config.video.enable_cpu_adaptation);
-}
-
// This test verifies that the enable_prerenderer_smoothing flag is
// propagated from RTCConfiguration to the PeerConnection.
TEST_F(PeerConnectionMediaConfigTest, TestDisablePrerendererSmoothingTrue) {
PeerConnectionInterface::RTCConfiguration config;
- FakeConstraints constraints;
config.set_prerenderer_smoothing(false);
- const cricket::MediaConfig& media_config =
- TestCreatePeerConnection(config, &constraints);
+ const cricket::MediaConfig& media_config = TestCreatePeerConnection(config);
EXPECT_FALSE(media_config.video.enable_prerenderer_smoothing);
}
@@ -4062,31 +3991,13 @@
// propagated from RTCConfiguration to the PeerConnection.
TEST_F(PeerConnectionMediaConfigTest, TestEnableExperimentCpuLoadEstimator) {
PeerConnectionInterface::RTCConfiguration config;
- FakeConstraints constraints;
config.set_experiment_cpu_load_estimator(true);
- const cricket::MediaConfig& media_config =
- TestCreatePeerConnection(config, &constraints);
+ const cricket::MediaConfig& media_config = TestCreatePeerConnection(config);
EXPECT_TRUE(media_config.video.experiment_cpu_load_estimator);
}
-// This test verifies the suspend below min bitrate constraint is
-// recognized and passed to the PeerConnection.
-TEST_F(PeerConnectionMediaConfigTest,
- TestSuspendBelowMinBitrateConstraintTrue) {
- PeerConnectionInterface::RTCConfiguration config;
- FakeConstraints constraints;
-
- constraints.AddOptional(
- webrtc::MediaConstraintsInterface::kEnableVideoSuspendBelowMinBitrate,
- true);
- const cricket::MediaConfig media_config =
- TestCreatePeerConnection(config, &constraints);
-
- EXPECT_TRUE(media_config.video.suspend_below_min_bitrate);
-}
-
// Tests a few random fields being different.
TEST(RTCConfigurationTest, ComparisonOperators) {
PeerConnectionInterface::RTCConfiguration a;