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}
This commit is contained in:
Niels Möller 2018-08-07 12:32:18 +02:00 committed by Commit Bot
parent 46399993f2
commit f06f923ef0
29 changed files with 364 additions and 595 deletions

View File

@ -469,7 +469,6 @@ if (rtc_include_tests) {
deps = [
":array_view",
":libjingle_peerconnection_api",
":libjingle_peerconnection_test_api",
":ortc_api",
"../rtc_base:checks",
"../rtc_base:rtc_base_approved",

View File

@ -260,4 +260,48 @@ void CopyConstraintsIntoAudioOptions(
}
}
bool CopyConstraintsIntoOfferAnswerOptions(
const MediaConstraintsInterface* constraints,
PeerConnectionInterface::RTCOfferAnswerOptions* offer_answer_options) {
if (!constraints) {
return true;
}
bool value = false;
size_t mandatory_constraints_satisfied = 0;
if (FindConstraint(constraints,
MediaConstraintsInterface::kOfferToReceiveAudio, &value,
&mandatory_constraints_satisfied)) {
offer_answer_options->offer_to_receive_audio =
value ? PeerConnectionInterface::RTCOfferAnswerOptions::
kOfferToReceiveMediaTrue
: 0;
}
if (FindConstraint(constraints,
MediaConstraintsInterface::kOfferToReceiveVideo, &value,
&mandatory_constraints_satisfied)) {
offer_answer_options->offer_to_receive_video =
value ? PeerConnectionInterface::RTCOfferAnswerOptions::
kOfferToReceiveMediaTrue
: 0;
}
if (FindConstraint(constraints,
MediaConstraintsInterface::kVoiceActivityDetection, &value,
&mandatory_constraints_satisfied)) {
offer_answer_options->voice_activity_detection = value;
}
if (FindConstraint(constraints, MediaConstraintsInterface::kUseRtpMux, &value,
&mandatory_constraints_satisfied)) {
offer_answer_options->use_rtp_mux = value;
}
if (FindConstraint(constraints, MediaConstraintsInterface::kIceRestart,
&value, &mandatory_constraints_satisfied)) {
offer_answer_options->ice_restart = value;
}
return mandatory_constraints_satisfied == constraints->GetMandatory().size();
}
} // namespace webrtc

View File

@ -13,9 +13,10 @@
// http://www.w3.org/TR/mediacapture-streams/#mediastreamconstraints and also
// used in WebRTC: http://dev.w3.org/2011/webrtc/editor/webrtc.html#constraints.
// This interface is being deprecated in Chrome, and may be removed
// from WebRTC too.
// https://bugs.chromium.org/p/webrtc/issues/detail?id=5617
// Implementation of the w3c constraints spec is the responsibility of the
// browser. Chrome no longer uses the constraints api declared here, and it will
// be removed from WebRTC.
// https://bugs.chromium.org/p/webrtc/issues/detail?id=9239
#ifndef API_MEDIACONSTRAINTSINTERFACE_H_
#define API_MEDIACONSTRAINTSINTERFACE_H_
@ -144,6 +145,10 @@ void CopyConstraintsIntoAudioOptions(
const MediaConstraintsInterface* constraints,
cricket::AudioOptions* options);
bool CopyConstraintsIntoOfferAnswerOptions(
const MediaConstraintsInterface* constraints,
PeerConnectionInterface::RTCOfferAnswerOptions* offer_answer_options);
} // namespace webrtc
#endif // API_MEDIACONSTRAINTSINTERFACE_H_

View File

@ -31,13 +31,6 @@ PROXY_SIGNALING_THREAD_DESTRUCTOR()
// removed.
using PeerConnectionFactoryInterface::CreateVideoSource;
PROXY_METHOD1(void, SetOptions, const Options&)
PROXY_METHOD5(rtc::scoped_refptr<PeerConnectionInterface>,
CreatePeerConnection,
const PeerConnectionInterface::RTCConfiguration&,
const MediaConstraintsInterface*,
std::unique_ptr<cricket::PortAllocator>,
std::unique_ptr<rtc::RTCCertificateGeneratorInterface>,
PeerConnectionObserver*);
PROXY_METHOD4(rtc::scoped_refptr<PeerConnectionInterface>,
CreatePeerConnection,
const PeerConnectionInterface::RTCConfiguration&,

View File

@ -247,12 +247,4 @@ PeerConnectionFactoryInterface::CreateVideoSource(
return CreateVideoSource(std::unique_ptr<cricket::VideoCapturer>(capturer));
}
rtc::scoped_refptr<VideoTrackSourceInterface>
PeerConnectionFactoryInterface::CreateVideoSource(
cricket::VideoCapturer* capturer,
const MediaConstraintsInterface* constraints) {
return CreateVideoSource(std::unique_ptr<cricket::VideoCapturer>(capturer),
constraints);
}
} // namespace webrtc

View File

@ -846,22 +846,12 @@ class PeerConnectionInterface : public rtc::RefCountInterface {
// Create a new offer.
// The CreateSessionDescriptionObserver callback will be called when done.
virtual void CreateOffer(CreateSessionDescriptionObserver* observer,
const MediaConstraintsInterface* constraints) {}
// TODO(jiayl): remove the default impl and the old interface when chromium
// code is updated.
virtual void CreateOffer(CreateSessionDescriptionObserver* observer,
const RTCOfferAnswerOptions& options) {}
const RTCOfferAnswerOptions& options) = 0;
// Create an answer to an offer.
// The CreateSessionDescriptionObserver callback will be called when done.
virtual void CreateAnswer(CreateSessionDescriptionObserver* observer,
const RTCOfferAnswerOptions& options) {}
// Deprecated - use version above.
// TODO(hta): Remove and remove default implementations when all callers
// are updated.
virtual void CreateAnswer(CreateSessionDescriptionObserver* observer,
const MediaConstraintsInterface* constraints) {}
const RTCOfferAnswerOptions& options) = 0;
// Sets the local session description.
// The PeerConnection takes the ownership of |desc| even if it fails.
@ -1293,10 +1283,6 @@ class PeerConnectionFactoryInterface : public rtc::RefCountInterface {
// TODO(deadbeef): Remove these once safe to do so.
virtual rtc::scoped_refptr<VideoTrackSourceInterface> CreateVideoSource(
cricket::VideoCapturer* capturer);
virtual rtc::scoped_refptr<VideoTrackSourceInterface> CreateVideoSource(
cricket::VideoCapturer* capturer,
const MediaConstraintsInterface* constraints);
// Creates a new local VideoTrack. The same |source| can be used in several
// tracks.
virtual rtc::scoped_refptr<VideoTrackInterface> CreateVideoTrack(

View File

@ -85,14 +85,6 @@ PROXY_CONSTMETHOD0(const SessionDescriptionInterface*,
current_local_description)
PROXY_CONSTMETHOD0(const SessionDescriptionInterface*,
current_remote_description)
PROXY_METHOD2(void,
CreateOffer,
CreateSessionDescriptionObserver*,
const MediaConstraintsInterface*)
PROXY_METHOD2(void,
CreateAnswer,
CreateSessionDescriptionObserver*,
const MediaConstraintsInterface*)
PROXY_METHOD2(void,
CreateOffer,
CreateSessionDescriptionObserver*,

View File

@ -721,7 +721,6 @@ if (is_linux || is_win) {
deps += [
"../api:libjingle_peerconnection_api",
"../api:libjingle_peerconnection_test_api",
"../api/audio_codecs:builtin_audio_decoder_factory",
"../api/audio_codecs:builtin_audio_encoder_factory",
"../api/video:video_frame",
@ -853,7 +852,6 @@ if (is_win || is_android) {
}
deps = [
"../api:libjingle_peerconnection_api",
"../api:libjingle_peerconnection_test_api",
"../api/audio_codecs:builtin_audio_decoder_factory",
"../api/audio_codecs:builtin_audio_encoder_factory",
"../api/video:video_frame",

View File

@ -16,7 +16,6 @@
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
#include "api/audio_codecs/builtin_audio_encoder_factory.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 "examples/peerconnection/client/defaults.h"

View File

@ -15,7 +15,6 @@
#include "absl/memory/memory.h"
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
#include "api/audio_codecs/builtin_audio_encoder_factory.h"
#include "api/test/fakeconstraints.h"
#include "api/videosourceproxy.h"
#include "media/engine/internaldecoderfactory.h"
#include "media/engine/internalencoderfactory.h"
@ -164,12 +163,11 @@ bool SimplePeerConnection::CreatePeerConnection(const char** turn_urls,
webrtc::PeerConnectionInterface::IceServer stun_server;
stun_server.uri = GetPeerConnectionString();
config_.servers.push_back(stun_server);
webrtc::FakeConstraints constraints;
constraints.SetAllowDtlsSctpDataChannels();
config_.enable_rtp_data_channel = true;
config_.enable_dtls_srtp = false;
peer_connection_ = g_peer_connection_factory->CreatePeerConnection(
config_, &constraints, nullptr, nullptr, this);
config_, nullptr, nullptr, this);
return peer_connection_.get() != nullptr;
}
@ -207,12 +205,12 @@ bool SimplePeerConnection::CreateOffer() {
if (!peer_connection_.get())
return false;
webrtc::FakeConstraints constraints;
webrtc::PeerConnectionInterface::RTCOfferAnswerOptions options;
if (mandatory_receive_) {
constraints.SetMandatoryReceiveAudio(true);
constraints.SetMandatoryReceiveVideo(true);
options.offer_to_receive_audio = true;
options.offer_to_receive_video = true;
}
peer_connection_->CreateOffer(this, &constraints);
peer_connection_->CreateOffer(this, options);
return true;
}
@ -220,12 +218,12 @@ bool SimplePeerConnection::CreateAnswer() {
if (!peer_connection_.get())
return false;
webrtc::FakeConstraints constraints;
webrtc::PeerConnectionInterface::RTCOfferAnswerOptions options;
if (mandatory_receive_) {
constraints.SetMandatoryReceiveAudio(true);
constraints.SetMandatoryReceiveVideo(true);
options.offer_to_receive_audio = true;
options.offer_to_receive_video = true;
}
peer_connection_->CreateAnswer(this, &constraints);
peer_connection_->CreateAnswer(this, options);
return true;
}

View File

@ -338,7 +338,6 @@ if (rtc_include_tests) {
deps = [
":pc_test_utils",
"../api:libjingle_peerconnection_api",
"../api:libjingle_peerconnection_test_api",
"../api:rtc_stats_api",
"../api/audio_codecs:builtin_audio_decoder_factory",
"../api/audio_codecs:builtin_audio_encoder_factory",

View File

@ -13,14 +13,11 @@
#include <string>
#include <vector>
#include "api/test/fakeconstraints.h"
#include "media/base/fakemediaengine.h"
#include "media/base/fakevideorenderer.h"
#include "rtc_base/gunit.h"
using webrtc::LocalAudioSource;
using webrtc::MediaConstraintsInterface;
using webrtc::MediaSourceInterface;
TEST(LocalAudioSourceTest, InitWithAudioOptions) {
cricket::AudioOptions audio_options;

View File

@ -773,50 +773,6 @@ void ExtractSharedMediaSessionOptions(
session_options->bundle_enabled = rtc_options.use_rtp_mux;
}
bool ConvertConstraintsToOfferAnswerOptions(
const MediaConstraintsInterface* constraints,
PeerConnectionInterface::RTCOfferAnswerOptions* offer_answer_options) {
if (!constraints) {
return true;
}
bool value = false;
size_t mandatory_constraints_satisfied = 0;
if (FindConstraint(constraints,
MediaConstraintsInterface::kOfferToReceiveAudio, &value,
&mandatory_constraints_satisfied)) {
offer_answer_options->offer_to_receive_audio =
value ? PeerConnectionInterface::RTCOfferAnswerOptions::
kOfferToReceiveMediaTrue
: 0;
}
if (FindConstraint(constraints,
MediaConstraintsInterface::kOfferToReceiveVideo, &value,
&mandatory_constraints_satisfied)) {
offer_answer_options->offer_to_receive_video =
value ? PeerConnectionInterface::RTCOfferAnswerOptions::
kOfferToReceiveMediaTrue
: 0;
}
if (FindConstraint(constraints,
MediaConstraintsInterface::kVoiceActivityDetection, &value,
&mandatory_constraints_satisfied)) {
offer_answer_options->voice_activity_detection = value;
}
if (FindConstraint(constraints, MediaConstraintsInterface::kUseRtpMux, &value,
&mandatory_constraints_satisfied)) {
offer_answer_options->use_rtp_mux = value;
}
if (FindConstraint(constraints, MediaConstraintsInterface::kIceRestart,
&value, &mandatory_constraints_satisfied)) {
offer_answer_options->ice_restart = value;
}
return mandatory_constraints_satisfied == constraints->GetMandatory().size();
}
PeerConnection::PeerConnection(PeerConnectionFactory* factory,
std::unique_ptr<RtcEventLog> event_log,
std::unique_ptr<Call> call)
@ -1732,23 +1688,6 @@ rtc::scoped_refptr<DataChannelInterface> PeerConnection::CreateDataChannel(
return DataChannelProxy::Create(signaling_thread(), channel.get());
}
void PeerConnection::CreateOffer(CreateSessionDescriptionObserver* observer,
const MediaConstraintsInterface* constraints) {
TRACE_EVENT0("webrtc", "PeerConnection::CreateOffer");
PeerConnectionInterface::RTCOfferAnswerOptions offer_answer_options;
// Always create an offer even if |ConvertConstraintsToOfferAnswerOptions|
// returns false for now. Because |ConvertConstraintsToOfferAnswerOptions|
// compares the mandatory fields parsed with the mandatory fields added in the
// |constraints| and some downstream applications might create offers with
// mandatory fields which would not be parsed in the helper method. For
// example, in Chromium/remoting, |kEnableDtlsSrtp| is added to the
// |constraints| as a mandatory field but it is not parsed.
ConvertConstraintsToOfferAnswerOptions(constraints, &offer_answer_options);
CreateOffer(observer, offer_answer_options);
}
void PeerConnection::CreateOffer(CreateSessionDescriptionObserver* observer,
const RTCOfferAnswerOptions& options) {
TRACE_EVENT0("webrtc", "PeerConnection::CreateOffer");
@ -1861,29 +1800,6 @@ PeerConnection::GetReceivingTransceiversOfType(cricket::MediaType media_type) {
return receiving_transceivers;
}
void PeerConnection::CreateAnswer(
CreateSessionDescriptionObserver* observer,
const MediaConstraintsInterface* constraints) {
TRACE_EVENT0("webrtc", "PeerConnection::CreateAnswer");
if (!observer) {
RTC_LOG(LS_ERROR) << "CreateAnswer - observer is NULL.";
return;
}
PeerConnectionInterface::RTCOfferAnswerOptions offer_answer_options;
if (!ConvertConstraintsToOfferAnswerOptions(constraints,
&offer_answer_options)) {
std::string error = "CreateAnswer called with invalid constraints.";
RTC_LOG(LS_ERROR) << error;
PostCreateSessionDescriptionFailure(
observer, RTCError(RTCErrorType::INVALID_PARAMETER, std::move(error)));
return;
}
CreateAnswer(observer, offer_answer_options);
}
void PeerConnection::CreateAnswer(CreateSessionDescriptionObserver* observer,
const RTCOfferAnswerOptions& options) {
TRACE_EVENT0("webrtc", "PeerConnection::CreateAnswer");

View File

@ -157,14 +157,8 @@ class PeerConnection : public PeerConnectionInternal,
const override;
// JSEP01
// Deprecated, use version without constraints.
void CreateOffer(CreateSessionDescriptionObserver* observer,
const MediaConstraintsInterface* constraints) override;
void CreateOffer(CreateSessionDescriptionObserver* observer,
const RTCOfferAnswerOptions& options) override;
// Deprecated, use version without constraints.
void CreateAnswer(CreateSessionDescriptionObserver* observer,
const MediaConstraintsInterface* constraints) override;
void CreateAnswer(CreateSessionDescriptionObserver* observer,
const RTCOfferAnswerOptions& options) override;
void SetLocalDescription(SetSessionDescriptionObserver* observer,

View File

@ -598,9 +598,11 @@ TEST_P(PeerConnectionCryptoDtlsCertGenTest, TestCertificateGeneration) {
new rtc::RefCountedObject<MockCreateSessionDescriptionObserver>();
observers.push_back(observer);
if (sdp_type_ == SdpType::kOffer) {
pc->pc()->CreateOffer(observer, nullptr);
pc->pc()->CreateOffer(observer,
PeerConnectionInterface::RTCOfferAnswerOptions());
} else {
pc->pc()->CreateAnswer(observer, nullptr);
pc->pc()->CreateAnswer(observer,
PeerConnectionInterface::RTCOfferAnswerOptions());
}
}
for (auto& observer : observers) {

View File

@ -975,9 +975,9 @@ class PeerConnectionIceConfigTest : public testing::Test {
new cricket::FakePortAllocator(rtc::Thread::Current(), nullptr));
port_allocator_ = port_allocator.get();
rtc::scoped_refptr<PeerConnectionInterface> pc(
pc_factory_->CreatePeerConnection(
config, nullptr /* constraint */, std::move(port_allocator),
nullptr /* cert_generator */, &observer_));
pc_factory_->CreatePeerConnection(config, std::move(port_allocator),
nullptr /* cert_generator */,
&observer_));
EXPECT_TRUE(pc.get());
pc_ = std::move(pc.get());
}

View File

@ -28,7 +28,6 @@
#include "api/peerconnectioninterface.h"
#include "api/peerconnectionproxy.h"
#include "api/rtpreceiverinterface.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 "api/video_codecs/sdp_video_format.h"
@ -81,7 +80,6 @@ using webrtc::DataChannelInterface;
using webrtc::DtmfSender;
using webrtc::DtmfSenderInterface;
using webrtc::DtmfSenderObserverInterface;
using webrtc::FakeConstraints;
using webrtc::FakeVideoTrackRenderer;
using webrtc::MediaConstraintsInterface;
using webrtc::MediaStreamInterface;
@ -236,8 +234,8 @@ class PeerConnectionWrapper : public webrtc::PeerConnectionObserver,
PeerConnectionWrapper* client(new PeerConnectionWrapper(debug_name));
webrtc::PeerConnectionDependencies dependencies(nullptr);
dependencies.cert_generator = std::move(cert_generator);
if (!client->Init(nullptr, nullptr, nullptr, std::move(dependencies),
network_thread, worker_thread, nullptr)) {
if (!client->Init(nullptr, nullptr, std::move(dependencies), network_thread,
worker_thread, nullptr)) {
delete client;
return nullptr;
}
@ -561,8 +559,7 @@ class PeerConnectionWrapper : public webrtc::PeerConnectionObserver,
explicit PeerConnectionWrapper(const std::string& debug_name)
: debug_name_(debug_name) {}
bool Init(const MediaConstraintsInterface* constraints,
const PeerConnectionFactory::Options* options,
bool Init(const PeerConnectionFactory::Options* options,
const PeerConnectionInterface::RTCConfiguration* config,
webrtc::PeerConnectionDependencies dependencies,
rtc::Thread* network_thread,
@ -619,13 +616,11 @@ class PeerConnectionWrapper : public webrtc::PeerConnectionObserver,
}
dependencies.allocator = std::move(port_allocator);
peer_connection_ =
CreatePeerConnection(constraints, config, std::move(dependencies));
peer_connection_ = CreatePeerConnection(config, std::move(dependencies));
return peer_connection_.get() != nullptr;
}
rtc::scoped_refptr<webrtc::PeerConnectionInterface> CreatePeerConnection(
const MediaConstraintsInterface* constraints,
const PeerConnectionInterface::RTCConfiguration* config,
webrtc::PeerConnectionDependencies dependencies) {
PeerConnectionInterface::RTCConfiguration modified_config;
@ -640,12 +635,6 @@ class PeerConnectionWrapper : public webrtc::PeerConnectionObserver,
// ratios and not specific resolutions, is this even necessary?
modified_config.set_cpu_adaptation(false);
// Use the legacy interface.
if (constraints != nullptr) {
return peer_connection_factory_->CreatePeerConnection(
modified_config, constraints, std::move(dependencies.allocator),
std::move(dependencies.cert_generator), this);
}
dependencies.observer = this;
return peer_connection_factory_->CreatePeerConnection(
modified_config, std::move(dependencies));
@ -1154,7 +1143,6 @@ class PeerConnectionIntegrationBaseTest : public testing::Test {
// log factory will be used.
std::unique_ptr<PeerConnectionWrapper> CreatePeerConnectionWrapper(
const std::string& debug_name,
const MediaConstraintsInterface* constraints,
const PeerConnectionFactory::Options* options,
const RTCConfiguration* config,
webrtc::PeerConnectionDependencies dependencies,
@ -1171,9 +1159,9 @@ class PeerConnectionIntegrationBaseTest : public testing::Test {
std::unique_ptr<PeerConnectionWrapper> client(
new PeerConnectionWrapper(debug_name));
if (!client->Init(constraints, options, &modified_config,
std::move(dependencies), network_thread_.get(),
worker_thread_.get(), std::move(event_log_factory))) {
if (!client->Init(options, &modified_config, std::move(dependencies),
network_thread_.get(), worker_thread_.get(),
std::move(event_log_factory))) {
return nullptr;
}
return client;
@ -1182,13 +1170,12 @@ class PeerConnectionIntegrationBaseTest : public testing::Test {
std::unique_ptr<PeerConnectionWrapper>
CreatePeerConnectionWrapperWithFakeRtcEventLog(
const std::string& debug_name,
const MediaConstraintsInterface* constraints,
const PeerConnectionFactory::Options* options,
const RTCConfiguration* config,
webrtc::PeerConnectionDependencies dependencies) {
std::unique_ptr<webrtc::FakeRtcEventLogFactory> event_log_factory(
new webrtc::FakeRtcEventLogFactory(rtc::Thread::Current()));
return CreatePeerConnectionWrapper(debug_name, constraints, options, config,
return CreatePeerConnectionWrapper(debug_name, options, config,
std::move(dependencies),
std::move(event_log_factory));
}
@ -1210,37 +1197,24 @@ class PeerConnectionIntegrationBaseTest : public testing::Test {
SdpSemantics original_semantics = sdp_semantics_;
sdp_semantics_ = caller_semantics;
caller_ = CreatePeerConnectionWrapper(
"Caller", nullptr, nullptr, nullptr,
webrtc::PeerConnectionDependencies(nullptr), nullptr);
"Caller", nullptr, nullptr, webrtc::PeerConnectionDependencies(nullptr),
nullptr);
sdp_semantics_ = callee_semantics;
callee_ = CreatePeerConnectionWrapper(
"Callee", nullptr, nullptr, nullptr,
webrtc::PeerConnectionDependencies(nullptr), nullptr);
"Callee", nullptr, nullptr, webrtc::PeerConnectionDependencies(nullptr),
nullptr);
sdp_semantics_ = original_semantics;
return caller_ && callee_;
}
bool CreatePeerConnectionWrappersWithConstraints(
MediaConstraintsInterface* caller_constraints,
MediaConstraintsInterface* callee_constraints) {
caller_ = CreatePeerConnectionWrapper(
"Caller", caller_constraints, nullptr, nullptr,
webrtc::PeerConnectionDependencies(nullptr), nullptr);
callee_ = CreatePeerConnectionWrapper(
"Callee", callee_constraints, nullptr, nullptr,
webrtc::PeerConnectionDependencies(nullptr), nullptr);
return caller_ && callee_;
}
bool CreatePeerConnectionWrappersWithConfig(
const PeerConnectionInterface::RTCConfiguration& caller_config,
const PeerConnectionInterface::RTCConfiguration& callee_config) {
caller_ = CreatePeerConnectionWrapper(
"Caller", nullptr, nullptr, &caller_config,
"Caller", nullptr, &caller_config,
webrtc::PeerConnectionDependencies(nullptr), nullptr);
callee_ = CreatePeerConnectionWrapper(
"Callee", nullptr, nullptr, &callee_config,
"Callee", nullptr, &callee_config,
webrtc::PeerConnectionDependencies(nullptr), nullptr);
return caller_ && callee_;
}
@ -1251,10 +1225,10 @@ class PeerConnectionIntegrationBaseTest : public testing::Test {
const PeerConnectionInterface::RTCConfiguration& callee_config,
webrtc::PeerConnectionDependencies callee_dependencies) {
caller_ =
CreatePeerConnectionWrapper("Caller", nullptr, nullptr, &caller_config,
CreatePeerConnectionWrapper("Caller", nullptr, &caller_config,
std::move(caller_dependencies), nullptr);
callee_ =
CreatePeerConnectionWrapper("Callee", nullptr, nullptr, &callee_config,
CreatePeerConnectionWrapper("Callee", nullptr, &callee_config,
std::move(callee_dependencies), nullptr);
return caller_ && callee_;
}
@ -1263,10 +1237,10 @@ class PeerConnectionIntegrationBaseTest : public testing::Test {
const PeerConnectionFactory::Options& caller_options,
const PeerConnectionFactory::Options& callee_options) {
caller_ = CreatePeerConnectionWrapper(
"Caller", nullptr, &caller_options, nullptr,
"Caller", &caller_options, nullptr,
webrtc::PeerConnectionDependencies(nullptr), nullptr);
callee_ = CreatePeerConnectionWrapper(
"Callee", nullptr, &callee_options, nullptr,
"Callee", &callee_options, nullptr,
webrtc::PeerConnectionDependencies(nullptr), nullptr);
return caller_ && callee_;
}
@ -1274,10 +1248,10 @@ class PeerConnectionIntegrationBaseTest : public testing::Test {
bool CreatePeerConnectionWrappersWithFakeRtcEventLog() {
PeerConnectionInterface::RTCConfiguration default_config;
caller_ = CreatePeerConnectionWrapperWithFakeRtcEventLog(
"Caller", nullptr, nullptr, &default_config,
"Caller", nullptr, &default_config,
webrtc::PeerConnectionDependencies(nullptr));
callee_ = CreatePeerConnectionWrapperWithFakeRtcEventLog(
"Callee", nullptr, nullptr, &default_config,
"Callee", nullptr, &default_config,
webrtc::PeerConnectionDependencies(nullptr));
return caller_ && callee_;
}
@ -1290,7 +1264,7 @@ class PeerConnectionIntegrationBaseTest : public testing::Test {
webrtc::PeerConnectionDependencies dependencies(nullptr);
dependencies.cert_generator = std::move(cert_generator);
return CreatePeerConnectionWrapper("New Peer", nullptr, nullptr, nullptr,
return CreatePeerConnectionWrapper("New Peer", nullptr, nullptr,
std::move(dependencies), nullptr);
}
@ -2906,10 +2880,10 @@ TEST_P(PeerConnectionIntegrationTest, EndToEndCallWithGcmCipher) {
// This test sets up a call between two parties with audio, video and an RTP
// data channel.
TEST_P(PeerConnectionIntegrationTest, EndToEndCallWithRtpDataChannel) {
FakeConstraints setup_constraints;
setup_constraints.SetAllowRtpDataChannels();
ASSERT_TRUE(CreatePeerConnectionWrappersWithConstraints(&setup_constraints,
&setup_constraints));
PeerConnectionInterface::RTCConfiguration rtc_config;
rtc_config.enable_rtp_data_channel = true;
rtc_config.enable_dtls_srtp = false;
ASSERT_TRUE(CreatePeerConnectionWrappersWithConfig(rtc_config, rtc_config));
ConnectFakeSignaling();
// Expect that data channel created on caller side will show up for callee as
// well.
@ -2942,10 +2916,10 @@ TEST_P(PeerConnectionIntegrationTest, EndToEndCallWithRtpDataChannel) {
TEST_P(PeerConnectionIntegrationTest,
RtpDataChannelSignaledClosedInCalleeOffer) {
// Same procedure as above test.
FakeConstraints setup_constraints;
setup_constraints.SetAllowRtpDataChannels();
ASSERT_TRUE(CreatePeerConnectionWrappersWithConstraints(&setup_constraints,
&setup_constraints));
PeerConnectionInterface::RTCConfiguration rtc_config;
rtc_config.enable_rtp_data_channel = true;
rtc_config.enable_dtls_srtp = false;
ASSERT_TRUE(CreatePeerConnectionWrappersWithConfig(rtc_config, rtc_config));
ConnectFakeSignaling();
caller()->CreateDataChannel();
caller()->AddAudioVideoTracks();
@ -2984,10 +2958,10 @@ TEST_P(PeerConnectionIntegrationTest,
virtual_socket_server()->set_delay_mean(5); // 5 ms per hop.
virtual_socket_server()->UpdateDelayDistribution();
FakeConstraints constraints;
constraints.SetAllowRtpDataChannels();
ASSERT_TRUE(
CreatePeerConnectionWrappersWithConstraints(&constraints, &constraints));
PeerConnectionInterface::RTCConfiguration rtc_config;
rtc_config.enable_rtp_data_channel = true;
rtc_config.enable_dtls_srtp = false;
ASSERT_TRUE(CreatePeerConnectionWrappersWithConfig(rtc_config, rtc_config));
ConnectFakeSignaling();
caller()->CreateDataChannel();
caller()->CreateAndSetAndSignalOffer();
@ -3023,16 +2997,15 @@ TEST_P(PeerConnectionIntegrationTest,
// This test sets up a call between two parties with audio, video and but only
// the caller client supports RTP data channels.
TEST_P(PeerConnectionIntegrationTest, RtpDataChannelsRejectedByCallee) {
FakeConstraints setup_constraints_1;
setup_constraints_1.SetAllowRtpDataChannels();
PeerConnectionInterface::RTCConfiguration rtc_config_1;
rtc_config_1.enable_rtp_data_channel = true;
// Must disable DTLS to make negotiation succeed.
setup_constraints_1.SetMandatory(MediaConstraintsInterface::kEnableDtlsSrtp,
false);
FakeConstraints setup_constraints_2;
setup_constraints_2.SetMandatory(MediaConstraintsInterface::kEnableDtlsSrtp,
false);
ASSERT_TRUE(CreatePeerConnectionWrappersWithConstraints(
&setup_constraints_1, &setup_constraints_2));
rtc_config_1.enable_dtls_srtp = false;
PeerConnectionInterface::RTCConfiguration rtc_config_2;
rtc_config_2.enable_dtls_srtp = false;
rtc_config_2.enable_dtls_srtp = false;
ASSERT_TRUE(
CreatePeerConnectionWrappersWithConfig(rtc_config_1, rtc_config_2));
ConnectFakeSignaling();
caller()->CreateDataChannel();
caller()->AddAudioVideoTracks();
@ -3049,10 +3022,10 @@ TEST_P(PeerConnectionIntegrationTest, RtpDataChannelsRejectedByCallee) {
// This test sets up a call between two parties with audio, and video. When
// audio and video is setup and flowing, an RTP data channel is negotiated.
TEST_P(PeerConnectionIntegrationTest, AddRtpDataChannelInSubsequentOffer) {
FakeConstraints setup_constraints;
setup_constraints.SetAllowRtpDataChannels();
ASSERT_TRUE(CreatePeerConnectionWrappersWithConstraints(&setup_constraints,
&setup_constraints));
PeerConnectionInterface::RTCConfiguration rtc_config;
rtc_config.enable_rtp_data_channel = true;
rtc_config.enable_dtls_srtp = false;
ASSERT_TRUE(CreatePeerConnectionWrappersWithConfig(rtc_config, rtc_config));
ConnectFakeSignaling();
// Do initial offer/answer with audio/video.
caller()->AddAudioVideoTracks();

View File

@ -11,7 +11,6 @@
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
#include "api/audio_codecs/builtin_audio_encoder_factory.h"
#include "api/stats/rtcstats_objects.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 "p2p/base/testturnserver.h"

View File

@ -76,16 +76,13 @@ class PeerConnectionEndToEndBaseTest : public sigslot::has_slots<>,
}
void CreatePcs(
const MediaConstraintsInterface* pc_constraints,
rtc::scoped_refptr<webrtc::AudioEncoderFactory> audio_encoder_factory1,
rtc::scoped_refptr<webrtc::AudioDecoderFactory> audio_decoder_factory1,
rtc::scoped_refptr<webrtc::AudioEncoderFactory> audio_encoder_factory2,
rtc::scoped_refptr<webrtc::AudioDecoderFactory> audio_decoder_factory2) {
EXPECT_TRUE(caller_->CreatePc(pc_constraints, config_,
audio_encoder_factory1,
EXPECT_TRUE(caller_->CreatePc(config_, audio_encoder_factory1,
audio_decoder_factory1));
EXPECT_TRUE(callee_->CreatePc(pc_constraints, config_,
audio_encoder_factory2,
EXPECT_TRUE(callee_->CreatePc(config_, audio_encoder_factory2,
audio_decoder_factory2));
PeerConnectionTestWrapper::Connect(caller_.get(), callee_.get());
@ -96,10 +93,9 @@ class PeerConnectionEndToEndBaseTest : public sigslot::has_slots<>,
}
void CreatePcs(
const MediaConstraintsInterface* pc_constraints,
rtc::scoped_refptr<webrtc::AudioEncoderFactory> audio_encoder_factory,
rtc::scoped_refptr<webrtc::AudioDecoderFactory> audio_decoder_factory) {
CreatePcs(pc_constraints, audio_encoder_factory, audio_decoder_factory,
CreatePcs(audio_encoder_factory, audio_decoder_factory,
audio_encoder_factory, audio_decoder_factory);
}
@ -117,7 +113,10 @@ class PeerConnectionEndToEndBaseTest : public sigslot::has_slots<>,
callee_->GetAndAddUserMedia(audio, audio_options, video, video_constraints);
}
void Negotiate() { caller_->CreateOffer(NULL); }
void Negotiate() {
caller_->CreateOffer(
webrtc::PeerConnectionInterface::RTCOfferAnswerOptions());
}
void WaitForCallEstablished() {
caller_->WaitForCallEstablished();
@ -373,18 +372,16 @@ struct AudioDecoderUnicornSparklesRainbow {
TEST_P(PeerConnectionEndToEndTest, Call) {
rtc::scoped_refptr<webrtc::AudioDecoderFactory> real_decoder_factory =
webrtc::CreateBuiltinAudioDecoderFactory();
CreatePcs(nullptr, webrtc::CreateBuiltinAudioEncoderFactory(),
CreatePcs(webrtc::CreateBuiltinAudioEncoderFactory(),
CreateForwardingMockDecoderFactory(real_decoder_factory.get()));
GetAndAddUserMedia();
Negotiate();
WaitForCallEstablished();
}
TEST_P(PeerConnectionEndToEndTest, CallWithLegacySdp) {
FakeConstraints pc_constraints;
pc_constraints.AddMandatory(MediaConstraintsInterface::kEnableDtlsSrtp,
false);
CreatePcs(&pc_constraints, webrtc::CreateBuiltinAudioEncoderFactory(),
TEST_P(PeerConnectionEndToEndTest, CallWithSdesKeyNegotiation) {
config_.enable_dtls_srtp = false;
CreatePcs(webrtc::CreateBuiltinAudioEncoderFactory(),
webrtc::CreateBuiltinAudioDecoderFactory());
GetAndAddUserMedia();
Negotiate();
@ -446,8 +443,7 @@ TEST_P(PeerConnectionEndToEndTest, CallWithCustomCodec) {
std::vector<webrtc::AudioCodecPairId> encoder_id1, encoder_id2, decoder_id1,
decoder_id2;
CreatePcs(nullptr,
rtc::scoped_refptr<webrtc::AudioEncoderFactory>(
CreatePcs(rtc::scoped_refptr<webrtc::AudioEncoderFactory>(
new rtc::RefCountedObject<IdLoggingAudioEncoderFactory>(
webrtc::CreateAudioEncoderFactory<
AudioEncoderUnicornSparklesRainbow>(),
@ -486,7 +482,7 @@ TEST_P(PeerConnectionEndToEndTest, CallWithCustomCodec) {
// Verifies that a DataChannel created before the negotiation can transition to
// "OPEN" and transfer data.
TEST_P(PeerConnectionEndToEndTest, CreateDataChannelBeforeNegotiate) {
CreatePcs(nullptr, webrtc::CreateBuiltinAudioEncoderFactory(),
CreatePcs(webrtc::CreateBuiltinAudioEncoderFactory(),
webrtc::MockAudioDecoderFactory::CreateEmptyFactory());
webrtc::DataChannelInit init;
@ -511,7 +507,7 @@ TEST_P(PeerConnectionEndToEndTest, CreateDataChannelBeforeNegotiate) {
// Verifies that a DataChannel created after the negotiation can transition to
// "OPEN" and transfer data.
TEST_P(PeerConnectionEndToEndTest, CreateDataChannelAfterNegotiate) {
CreatePcs(nullptr, webrtc::CreateBuiltinAudioEncoderFactory(),
CreatePcs(webrtc::CreateBuiltinAudioEncoderFactory(),
webrtc::MockAudioDecoderFactory::CreateEmptyFactory());
webrtc::DataChannelInit init;
@ -543,7 +539,7 @@ TEST_P(PeerConnectionEndToEndTest, CreateDataChannelAfterNegotiate) {
// Verifies that a DataChannel created can transfer large messages.
TEST_P(PeerConnectionEndToEndTest, CreateDataChannelLargeTransfer) {
CreatePcs(nullptr, webrtc::CreateBuiltinAudioEncoderFactory(),
CreatePcs(webrtc::CreateBuiltinAudioEncoderFactory(),
webrtc::MockAudioDecoderFactory::CreateEmptyFactory());
webrtc::DataChannelInit init;
@ -577,7 +573,7 @@ TEST_P(PeerConnectionEndToEndTest, CreateDataChannelLargeTransfer) {
// Verifies that DataChannel IDs are even/odd based on the DTLS roles.
TEST_P(PeerConnectionEndToEndTest, DataChannelIdAssignment) {
CreatePcs(nullptr, webrtc::CreateBuiltinAudioEncoderFactory(),
CreatePcs(webrtc::CreateBuiltinAudioEncoderFactory(),
webrtc::MockAudioDecoderFactory::CreateEmptyFactory());
webrtc::DataChannelInit init;
@ -605,7 +601,7 @@ TEST_P(PeerConnectionEndToEndTest, DataChannelIdAssignment) {
// there are multiple DataChannels.
TEST_P(PeerConnectionEndToEndTest,
MessageTransferBetweenTwoPairsOfDataChannels) {
CreatePcs(nullptr, webrtc::CreateBuiltinAudioEncoderFactory(),
CreatePcs(webrtc::CreateBuiltinAudioEncoderFactory(),
webrtc::MockAudioDecoderFactory::CreateEmptyFactory());
webrtc::DataChannelInit init;
@ -645,7 +641,7 @@ TEST_P(PeerConnectionEndToEndTest,
// channel, and the closed channel was incorrectly still assigned to the ID.
TEST_P(PeerConnectionEndToEndTest,
DataChannelFromOpenWorksAfterPreviousChannelClosed) {
CreatePcs(nullptr, webrtc::CreateBuiltinAudioEncoderFactory(),
CreatePcs(webrtc::CreateBuiltinAudioEncoderFactory(),
webrtc::MockAudioDecoderFactory::CreateEmptyFactory());
webrtc::DataChannelInit init;
@ -678,7 +674,7 @@ TEST_P(PeerConnectionEndToEndTest,
// closing before creating the second one.
TEST_P(PeerConnectionEndToEndTest,
DataChannelFromOpenWorksWhilePreviousChannelClosing) {
CreatePcs(nullptr, webrtc::CreateBuiltinAudioEncoderFactory(),
CreatePcs(webrtc::CreateBuiltinAudioEncoderFactory(),
webrtc::MockAudioDecoderFactory::CreateEmptyFactory());
webrtc::DataChannelInit init;
@ -709,7 +705,7 @@ TEST_P(PeerConnectionEndToEndTest,
// reference count), no memory access violation will occur.
// See: https://code.google.com/p/chromium/issues/detail?id=565048
TEST_P(PeerConnectionEndToEndTest, CloseDataChannelRemotelyWhileNotReferenced) {
CreatePcs(nullptr, webrtc::CreateBuiltinAudioEncoderFactory(),
CreatePcs(webrtc::CreateBuiltinAudioEncoderFactory(),
webrtc::MockAudioDecoderFactory::CreateEmptyFactory());
webrtc::DataChannelInit init;

View File

@ -329,23 +329,6 @@ void PeerConnectionFactory::StopAecDump() {
channel_manager_->StopAecDump();
}
rtc::scoped_refptr<PeerConnectionInterface>
PeerConnectionFactory::CreatePeerConnection(
const PeerConnectionInterface::RTCConfiguration& configuration_in,
const MediaConstraintsInterface* constraints,
std::unique_ptr<cricket::PortAllocator> allocator,
std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator,
PeerConnectionObserver* observer) {
RTC_DCHECK(signaling_thread_->IsCurrent());
// We merge constraints and configuration into a single configuration.
PeerConnectionInterface::RTCConfiguration configuration = configuration_in;
CopyConstraintsIntoRtcConfiguration(constraints, &configuration);
return CreatePeerConnection(configuration, std::move(allocator),
std::move(cert_generator), observer);
}
rtc::scoped_refptr<PeerConnectionInterface>
PeerConnectionFactory::CreatePeerConnection(
const PeerConnectionInterface::RTCConfiguration& configuration,

View File

@ -42,14 +42,6 @@ class PeerConnectionFactory : public PeerConnectionFactoryInterface {
void SetOptions(const Options& options) override;
// Deprecated, use version without constraints.
rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnection(
const PeerConnectionInterface::RTCConfiguration& configuration,
const MediaConstraintsInterface* constraints,
std::unique_ptr<cricket::PortAllocator> allocator,
std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator,
PeerConnectionObserver* observer) override;
rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnection(
const PeerConnectionInterface::RTCConfiguration& configuration,
std::unique_ptr<cricket::PortAllocator> allocator,

View File

@ -178,7 +178,7 @@ TEST(PeerConnectionFactoryTestInternal, DISABLED_CreatePCUsingInternalModules) {
std::unique_ptr<FakeRTCCertificateGenerator> cert_generator(
new FakeRTCCertificateGenerator());
rtc::scoped_refptr<PeerConnectionInterface> pc(factory->CreatePeerConnection(
config, nullptr, nullptr, std::move(cert_generator), &observer));
config, nullptr, std::move(cert_generator), &observer));
EXPECT_TRUE(pc.get() != nullptr);
}
@ -264,9 +264,9 @@ TEST_F(PeerConnectionFactoryTest, CreatePCUsingIceServers) {
config.servers.push_back(ice_server);
std::unique_ptr<FakeRTCCertificateGenerator> cert_generator(
new FakeRTCCertificateGenerator());
rtc::scoped_refptr<PeerConnectionInterface> pc(factory_->CreatePeerConnection(
config, nullptr, std::move(port_allocator_), std::move(cert_generator),
&observer_));
rtc::scoped_refptr<PeerConnectionInterface> pc(
factory_->CreatePeerConnection(config, std::move(port_allocator_),
std::move(cert_generator), &observer_));
ASSERT_TRUE(pc.get() != NULL);
cricket::ServerAddresses stun_servers;
rtc::SocketAddress stun1("stun.l.google.com", 19302);
@ -294,9 +294,9 @@ TEST_F(PeerConnectionFactoryTest, CreatePCUsingIceServersUrls) {
config.servers.push_back(ice_server);
std::unique_ptr<FakeRTCCertificateGenerator> cert_generator(
new FakeRTCCertificateGenerator());
rtc::scoped_refptr<PeerConnectionInterface> pc(factory_->CreatePeerConnection(
config, nullptr, std::move(port_allocator_), std::move(cert_generator),
&observer_));
rtc::scoped_refptr<PeerConnectionInterface> pc(
factory_->CreatePeerConnection(config, std::move(port_allocator_),
std::move(cert_generator), &observer_));
ASSERT_TRUE(pc.get() != NULL);
cricket::ServerAddresses stun_servers;
rtc::SocketAddress stun1("stun.l.google.com", 19302);
@ -323,9 +323,9 @@ TEST_F(PeerConnectionFactoryTest, CreatePCUsingNoUsernameInUri) {
config.servers.push_back(ice_server);
std::unique_ptr<FakeRTCCertificateGenerator> cert_generator(
new FakeRTCCertificateGenerator());
rtc::scoped_refptr<PeerConnectionInterface> pc(factory_->CreatePeerConnection(
config, nullptr, std::move(port_allocator_), std::move(cert_generator),
&observer_));
rtc::scoped_refptr<PeerConnectionInterface> pc(
factory_->CreatePeerConnection(config, std::move(port_allocator_),
std::move(cert_generator), &observer_));
ASSERT_TRUE(pc.get() != NULL);
std::vector<cricket::RelayServerConfig> turn_servers;
cricket::RelayServerConfig turn("test.com", 1234, kTurnUsername,
@ -344,9 +344,9 @@ TEST_F(PeerConnectionFactoryTest, CreatePCUsingTurnUrlWithTransportParam) {
config.servers.push_back(ice_server);
std::unique_ptr<FakeRTCCertificateGenerator> cert_generator(
new FakeRTCCertificateGenerator());
rtc::scoped_refptr<PeerConnectionInterface> pc(factory_->CreatePeerConnection(
config, nullptr, std::move(port_allocator_), std::move(cert_generator),
&observer_));
rtc::scoped_refptr<PeerConnectionInterface> pc(
factory_->CreatePeerConnection(config, std::move(port_allocator_),
std::move(cert_generator), &observer_));
ASSERT_TRUE(pc.get() != NULL);
std::vector<cricket::RelayServerConfig> turn_servers;
cricket::RelayServerConfig turn("hello.com", kDefaultStunPort, "test",
@ -369,9 +369,9 @@ TEST_F(PeerConnectionFactoryTest, CreatePCUsingSecureTurnUrl) {
config.servers.push_back(ice_server);
std::unique_ptr<FakeRTCCertificateGenerator> cert_generator(
new FakeRTCCertificateGenerator());
rtc::scoped_refptr<PeerConnectionInterface> pc(factory_->CreatePeerConnection(
config, nullptr, std::move(port_allocator_), std::move(cert_generator),
&observer_));
rtc::scoped_refptr<PeerConnectionInterface> pc(
factory_->CreatePeerConnection(config, std::move(port_allocator_),
std::move(cert_generator), &observer_));
ASSERT_TRUE(pc.get() != NULL);
std::vector<cricket::RelayServerConfig> turn_servers;
cricket::RelayServerConfig turn1("hello.com", kDefaultStunTlsPort, "test",
@ -404,9 +404,9 @@ TEST_F(PeerConnectionFactoryTest, CreatePCUsingIPLiteralAddress) {
config.servers.push_back(ice_server);
std::unique_ptr<FakeRTCCertificateGenerator> cert_generator(
new FakeRTCCertificateGenerator());
rtc::scoped_refptr<PeerConnectionInterface> pc(factory_->CreatePeerConnection(
config, nullptr, std::move(port_allocator_), std::move(cert_generator),
&observer_));
rtc::scoped_refptr<PeerConnectionInterface> pc(
factory_->CreatePeerConnection(config, std::move(port_allocator_),
std::move(cert_generator), &observer_));
ASSERT_TRUE(pc.get() != NULL);
cricket::ServerAddresses stun_servers;
rtc::SocketAddress stun1("1.2.3.4", 1234);

View File

@ -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::AudioTrack;
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 @@ class PeerConnectionInterfaceBaseTest : public testing::Test {
}
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 @@ class PeerConnectionInterfaceBaseTest : public testing::Test {
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 @@ class PeerConnectionInterfaceBaseTest : public testing::Test {
// 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 @@ class PeerConnectionInterfaceBaseTest : public testing::Test {
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 @@ class PeerConnectionInterfaceBaseTest : public testing::Test {
}
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 @@ class PeerConnectionInterfaceBaseTest : public testing::Test {
}
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 @@ TEST_P(PeerConnectionInterfaceTest, CreatePeerConnectionWithPooledCandidates) {
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 @@ TEST_P(PeerConnectionInterfaceTest,
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,
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 @@ TEST_P(PeerConnectionInterfaceTest, GetRTCStatsBeforeAndAfterCalling) {
// 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 @@ TEST_P(PeerConnectionInterfaceTest, TestDataChannel) {
// 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 @@ TEST_P(PeerConnectionInterfaceTest, TestSendBinaryOnRtpDataChannel) {
// 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 @@ TEST_P(PeerConnectionInterfaceTest, TestSendOnlyDataChannel) {
// 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 @@ TEST_P(PeerConnectionInterfaceTest, TestReceiveOnlyDataChannel) {
// 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 @@ TEST_P(PeerConnectionInterfaceTest, CreateReliableRtpDataChannelShouldFail) {
// 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 @@ TEST_P(PeerConnectionInterfaceTest, RtpDuplicatedLabelNotAllowed) {
// 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 @@ TEST_P(PeerConnectionInterfaceTest, CreateSctpDataChannel) {
// 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 @@ TEST_P(PeerConnectionInterfaceTest,
// 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 @@ TEST_P(PeerConnectionInterfaceTest,
// 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 @@ TEST_P(PeerConnectionInterfaceTest, SctpDuplicatedLabelAllowed) {
// 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 @@ TEST_P(PeerConnectionInterfaceTest, RenegotiationNeededForNewRtpDataChannel) {
// 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 @@ TEST_P(PeerConnectionInterfaceTest, DataChannelCloseWhenPeerConnectionClose) {
// 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, TestRejectSctpDataChannelInAnswer)
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 @@ TEST_P(PeerConnectionInterfaceTest, DISABLED_TestRejectSctpDataChannelInAnswer)
// 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 @@ TEST_P(PeerConnectionInterfaceTest, ReceiveFireFoxOffer) {
// 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_P(PeerConnectionInterfaceTest, ReceiveUpdatedAudioOfferWithBadCodecs) {
// 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 @@ TEST_P(PeerConnectionInterfaceTest, CreateSubsequentRecvOnlyOffer) {
// 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 @@ TEST_P(PeerConnectionInterfaceTest, CreateSubsequentInactiveOffer) {
// 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, SetConfigurationChangesCandidateFilter) {
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, SetConfigurationChangesPruneTurnPortsFlag) {
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 @@ TEST_P(PeerConnectionInterfaceTest,
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,
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,
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,
TEST_P(PeerConnectionInterfaceTest,
SetConfigurationReturnsInvalidParameterIfCredentialsMissing) {
PeerConnectionInterface::RTCConfiguration config;
CreatePeerConnection(config, nullptr);
CreatePeerConnection(config);
config = pc_->GetConfiguration();
PeerConnectionInterface::IceServer bad_server;
@ -2753,10 +2739,9 @@ TEST_P(PeerConnectionInterfaceTest, CloseAndGetStats) {
// 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 @@ TEST_P(PeerConnectionInterfaceTest, UpdateRemoteStreams) {
// 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 @@ TEST_F(PeerConnectionInterfaceTestPlanB,
// 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 @@ TEST_P(PeerConnectionInterfaceTest, RejectMediaContent) {
// 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 @@ TEST_F(PeerConnectionInterfaceTestPlanB, RemoveTrackThenRejectMediaContent) {
// 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 @@ TEST_P(PeerConnectionInterfaceTest, RecvonlyDescriptionDoesntCreateStream) {
// 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 @@ TEST_F(PeerConnectionInterfaceTestPlanB, SdpWithoutMsidCreatesDefaultStream) {
// 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 @@ TEST_F(PeerConnectionInterfaceTestPlanB,
// 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 @@ TEST_F(PeerConnectionInterfaceTestPlanB, RemoveAlreadyGoneRemoteStream) {
// 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 @@ TEST_F(PeerConnectionInterfaceTestPlanB,
// 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 @@ TEST_F(PeerConnectionInterfaceTestPlanB, SdpWithMsidDontCreatesDefaultStream) {
// 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 @@ TEST_F(PeerConnectionInterfaceTestPlanB,
// 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 @@ TEST_F(PeerConnectionInterfaceTestPlanB, VerifyDefaultStreamIsNotCreated) {
// 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 @@ TEST_F(PeerConnectionInterfaceTestPlanB,
// 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 @@ TEST_F(PeerConnectionInterfaceTestPlanB,
// 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 @@ TEST_F(PeerConnectionInterfaceTestPlanB, LocalDescriptionChanged) {
// 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 @@ TEST_F(PeerConnectionInterfaceTestPlanB,
// 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 @@ TEST_P(PeerConnectionInterfaceTest,
// 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 @@ TEST_F(PeerConnectionInterfaceTestPlanB,
// 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, OnAddTrackCallback) {
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, SetConfigurationCausingIceRestart) {
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, SetConfigurationNotCausingIceRestart) {
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 @@ TEST_P(PeerConnectionInterfaceTest, OffersAndAnswersHaveTrickleIceOption) {
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 @@ TEST_P(PeerConnectionInterfaceTest, OffersAndAnswersHaveTrickleIceOption) {
// 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, OffersAndAnswersHaveTrickleIceOption) {
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, IceRenominationNotOffered) {
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, IceRenominationOptionInOfferAndAnswer) {
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 @@ TEST_F(PeerConnectionInterfaceTestPlanB,
// 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 @@ TEST_P(PeerConnectionInterfaceTest,
#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 @@ TEST_P(PeerConnectionInterfaceTest,
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 @@ class PeerConnectionMediaConfigTest : public testing::Test {
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 @@ class PeerConnectionMediaConfigTest : public testing::Test {
// 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 @@ TEST_F(PeerConnectionMediaConfigTest, TestDefaults) {
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 @@ TEST_F(PeerConnectionMediaConfigTest, TestDisablePrerendererSmoothingTrue) {
// 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;

View File

@ -109,11 +109,9 @@ class RTCStatsIntegrationTest : public testing::Test {
PeerConnectionInterface::IceServer ice_server;
ice_server.uri = "stun:1.1.1.1:3478";
config.servers.push_back(ice_server);
EXPECT_TRUE(caller_->CreatePc(nullptr, config,
CreateBuiltinAudioEncoderFactory(),
EXPECT_TRUE(caller_->CreatePc(config, CreateBuiltinAudioEncoderFactory(),
CreateBuiltinAudioDecoderFactory()));
EXPECT_TRUE(callee_->CreatePc(nullptr, config,
CreateBuiltinAudioEncoderFactory(),
EXPECT_TRUE(callee_->CreatePc(config, CreateBuiltinAudioEncoderFactory(),
CreateBuiltinAudioDecoderFactory()));
PeerConnectionTestWrapper::Connect(caller_.get(), callee_.get());
@ -129,7 +127,7 @@ class RTCStatsIntegrationTest : public testing::Test {
callee_->CreateDataChannel("data", init);
// Negotiate and wait for call to establish
caller_->CreateOffer(nullptr);
caller_->CreateOffer(PeerConnectionInterface::RTCOfferAnswerOptions());
caller_->WaitForCallEstablished();
callee_->WaitForCallEstablished();
}

View File

@ -139,18 +139,12 @@ class FakePeerConnectionBase : public PeerConnectionInternal {
return nullptr;
}
void CreateOffer(CreateSessionDescriptionObserver* observer,
const MediaConstraintsInterface* constraints) override {}
void CreateOffer(CreateSessionDescriptionObserver* observer,
const RTCOfferAnswerOptions& options) override {}
void CreateAnswer(CreateSessionDescriptionObserver* observer,
const RTCOfferAnswerOptions& options) override {}
void CreateAnswer(CreateSessionDescriptionObserver* observer,
const MediaConstraintsInterface* constraints) override {}
void SetLocalDescription(SetSessionDescriptionObserver* observer,
SessionDescriptionInterface* desc) override {}

View File

@ -69,7 +69,6 @@ PeerConnectionTestWrapper::PeerConnectionTestWrapper(
PeerConnectionTestWrapper::~PeerConnectionTestWrapper() {}
bool PeerConnectionTestWrapper::CreatePc(
const MediaConstraintsInterface* constraints,
const webrtc::PeerConnectionInterface::RTCConfiguration& config,
rtc::scoped_refptr<webrtc::AudioEncoderFactory> audio_encoder_factory,
rtc::scoped_refptr<webrtc::AudioDecoderFactory> audio_decoder_factory) {
@ -95,8 +94,7 @@ bool PeerConnectionTestWrapper::CreatePc(
std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator(
new FakeRTCCertificateGenerator());
peer_connection_ = peer_connection_factory_->CreatePeerConnection(
config, constraints, std::move(port_allocator), std::move(cert_generator),
this);
config, std::move(port_allocator), std::move(cert_generator), this);
return peer_connection_.get() != NULL;
}
@ -153,21 +151,21 @@ void PeerConnectionTestWrapper::OnSuccess(SessionDescriptionInterface* desc) {
}
void PeerConnectionTestWrapper::CreateOffer(
const MediaConstraintsInterface* constraints) {
const webrtc::PeerConnectionInterface::RTCOfferAnswerOptions& options) {
RTC_LOG(LS_INFO) << "PeerConnectionTestWrapper " << name_ << ": CreateOffer.";
peer_connection_->CreateOffer(this, constraints);
peer_connection_->CreateOffer(this, options);
}
void PeerConnectionTestWrapper::CreateAnswer(
const MediaConstraintsInterface* constraints) {
const webrtc::PeerConnectionInterface::RTCOfferAnswerOptions& options) {
RTC_LOG(LS_INFO) << "PeerConnectionTestWrapper " << name_
<< ": CreateAnswer.";
peer_connection_->CreateAnswer(this, constraints);
peer_connection_->CreateAnswer(this, options);
}
void PeerConnectionTestWrapper::ReceiveOfferSdp(const std::string& sdp) {
SetRemoteDescription(SdpType::kOffer, sdp);
CreateAnswer(NULL);
CreateAnswer(webrtc::PeerConnectionInterface::RTCOfferAnswerOptions());
}
void PeerConnectionTestWrapper::ReceiveAnswerSdp(const std::string& sdp) {

View File

@ -35,7 +35,6 @@ class PeerConnectionTestWrapper
virtual ~PeerConnectionTestWrapper();
bool CreatePc(
const webrtc::MediaConstraintsInterface* constraints,
const webrtc::PeerConnectionInterface::RTCConfiguration& config,
rtc::scoped_refptr<webrtc::AudioEncoderFactory> audio_encoder_factory,
rtc::scoped_refptr<webrtc::AudioDecoderFactory> audio_decoder_factory);
@ -66,8 +65,10 @@ class PeerConnectionTestWrapper
void OnSuccess(webrtc::SessionDescriptionInterface* desc) override;
void OnFailure(webrtc::RTCError) override {}
void CreateOffer(const webrtc::MediaConstraintsInterface* constraints);
void CreateAnswer(const webrtc::MediaConstraintsInterface* constraints);
void CreateOffer(
const webrtc::PeerConnectionInterface::RTCOfferAnswerOptions& options);
void CreateAnswer(
const webrtc::PeerConnectionInterface::RTCOfferAnswerOptions& options);
void ReceiveOfferSdp(const std::string& sdp);
void ReceiveAnswerSdp(const std::string& sdp);
void AddIceCandidate(const std::string& sdp_mid,

View File

@ -451,7 +451,9 @@ static void JNI_PeerConnection_CreateOffer(
rtc::scoped_refptr<CreateSdpObserverJni> observer(
new rtc::RefCountedObject<CreateSdpObserverJni>(jni, j_observer,
std::move(constraints)));
ExtractNativePC(jni, j_pc)->CreateOffer(observer, observer->constraints());
PeerConnectionInterface::RTCOfferAnswerOptions options;
CopyConstraintsIntoOfferAnswerOptions(observer->constraints(), &options);
ExtractNativePC(jni, j_pc)->CreateOffer(observer, options);
}
static void JNI_PeerConnection_CreateAnswer(
@ -464,7 +466,9 @@ static void JNI_PeerConnection_CreateAnswer(
rtc::scoped_refptr<CreateSdpObserverJni> observer(
new rtc::RefCountedObject<CreateSdpObserverJni>(jni, j_observer,
std::move(constraints)));
ExtractNativePC(jni, j_pc)->CreateAnswer(observer, observer->constraints());
PeerConnectionInterface::RTCOfferAnswerOptions options;
CopyConstraintsIntoOfferAnswerOptions(observer->constraints(), &options);
ExtractNativePC(jni, j_pc)->CreateAnswer(observer, options);
}
static void JNI_PeerConnection_SetLocalDescription(

View File

@ -448,7 +448,10 @@ void PeerConnectionDelegateAdapter::OnRemoveTrack(
rtc::scoped_refptr<webrtc::CreateSessionDescriptionObserverAdapter>
observer(new rtc::RefCountedObject
<webrtc::CreateSessionDescriptionObserverAdapter>(completionHandler));
_peerConnection->CreateOffer(observer, constraints.nativeConstraints.get());
webrtc::PeerConnectionInterface::RTCOfferAnswerOptions options;
CopyConstraintsIntoOfferAnswerOptions(constraints.nativeConstraints.get(), &options);
_peerConnection->CreateOffer(observer, options);
}
- (void)answerForConstraints:(RTCMediaConstraints *)constraints
@ -458,7 +461,10 @@ void PeerConnectionDelegateAdapter::OnRemoveTrack(
rtc::scoped_refptr<webrtc::CreateSessionDescriptionObserverAdapter>
observer(new rtc::RefCountedObject
<webrtc::CreateSessionDescriptionObserverAdapter>(completionHandler));
_peerConnection->CreateAnswer(observer, constraints.nativeConstraints.get());
webrtc::PeerConnectionInterface::RTCOfferAnswerOptions options;
CopyConstraintsIntoOfferAnswerOptions(constraints.nativeConstraints.get(), &options);
_peerConnection->CreateAnswer(observer, options);
}
- (void)setLocalDescription:(RTCSessionDescription *)sdp