diff --git a/api/peerconnectionfactoryproxy.h b/api/peerconnectionfactoryproxy.h index 77778092b7..13f8a99697 100644 --- a/api/peerconnectionfactoryproxy.h +++ b/api/peerconnectionfactoryproxy.h @@ -50,8 +50,6 @@ BEGIN_SIGNALING_PROXY_MAP(PeerConnectionFactory) PeerConnectionDependencies); PROXY_METHOD1(rtc::scoped_refptr, CreateLocalMediaStream, const std::string&) - PROXY_METHOD1(rtc::scoped_refptr, - CreateAudioSource, const MediaConstraintsInterface*) PROXY_METHOD1(rtc::scoped_refptr, CreateAudioSource, const cricket::AudioOptions&) diff --git a/api/peerconnectioninterface.h b/api/peerconnectioninterface.h index 53979694a7..ab9f458e01 100644 --- a/api/peerconnectioninterface.h +++ b/api/peerconnectioninterface.h @@ -1331,12 +1331,6 @@ class PeerConnectionFactoryInterface : public rtc::RefCountInterface { // |options| decides audio processing settings. virtual rtc::scoped_refptr CreateAudioSource( const cricket::AudioOptions& options) = 0; - // Deprecated - use version above. - // Can use CopyConstraintsIntoAudioOptions to bridge the gap. - virtual rtc::scoped_refptr CreateAudioSource( - const MediaConstraintsInterface* constraints) { - return nullptr; - } // Creates a VideoTrackSourceInterface from |capturer|. // TODO(deadbeef): We should aim to remove cricket::VideoCapturer from the diff --git a/examples/peerconnection/client/conductor.cc b/examples/peerconnection/client/conductor.cc index 746936e779..b86ba55f31 100644 --- a/examples/peerconnection/client/conductor.cc +++ b/examples/peerconnection/client/conductor.cc @@ -414,7 +414,8 @@ void Conductor::AddTracks() { rtc::scoped_refptr audio_track( peer_connection_factory_->CreateAudioTrack( - kAudioLabel, peer_connection_factory_->CreateAudioSource(nullptr))); + kAudioLabel, peer_connection_factory_->CreateAudioSource( + cricket::AudioOptions()))); auto result_or_error = peer_connection_->AddTrack(audio_track, {kStreamId}); if (!result_or_error.ok()) { RTC_LOG(LS_ERROR) << "Failed to add audio track to PeerConnection: " diff --git a/examples/unityplugin/simple_peer_connection.cc b/examples/unityplugin/simple_peer_connection.cc index 8374d0c1e2..cd85f880ea 100644 --- a/examples/unityplugin/simple_peer_connection.cc +++ b/examples/unityplugin/simple_peer_connection.cc @@ -429,7 +429,8 @@ void SimplePeerConnection::AddStreams(bool audio_only) { rtc::scoped_refptr audio_track( g_peer_connection_factory->CreateAudioTrack( - kAudioLabel, g_peer_connection_factory->CreateAudioSource(nullptr))); + kAudioLabel, g_peer_connection_factory->CreateAudioSource( + cricket::AudioOptions()))); std::string id = audio_track->id(); stream->AddTrack(audio_track); diff --git a/pc/localaudiosource.cc b/pc/localaudiosource.cc index 5c86dd30f9..b2fdd4dcae 100644 --- a/pc/localaudiosource.cc +++ b/pc/localaudiosource.cc @@ -12,22 +12,12 @@ #include -#include "api/mediaconstraintsinterface.h" #include "media/base/mediaengine.h" -using webrtc::MediaConstraintsInterface; using webrtc::MediaSourceInterface; namespace webrtc { -rtc::scoped_refptr LocalAudioSource::Create( - const MediaConstraintsInterface* constraints) { - rtc::scoped_refptr source( - new rtc::RefCountedObject()); - source->Initialize(constraints); - return source; -} - rtc::scoped_refptr LocalAudioSource::Create( const cricket::AudioOptions* audio_options) { rtc::scoped_refptr source( @@ -36,11 +26,6 @@ rtc::scoped_refptr LocalAudioSource::Create( return source; } -void LocalAudioSource::Initialize( - const MediaConstraintsInterface* constraints) { - CopyConstraintsIntoAudioOptions(constraints, &options_); -} - void LocalAudioSource::Initialize( const cricket::AudioOptions* audio_options) { if (!audio_options) diff --git a/pc/localaudiosource.h b/pc/localaudiosource.h index cd17330e1f..c5f65304d0 100644 --- a/pc/localaudiosource.h +++ b/pc/localaudiosource.h @@ -20,14 +20,9 @@ namespace webrtc { -class MediaConstraintsInterface; - class LocalAudioSource : public Notifier { public: // Creates an instance of LocalAudioSource. - static rtc::scoped_refptr Create( - const MediaConstraintsInterface* constraints); - static rtc::scoped_refptr Create( const cricket::AudioOptions* audio_options); @@ -44,7 +39,6 @@ class LocalAudioSource : public Notifier { ~LocalAudioSource() override {} private: - void Initialize(const MediaConstraintsInterface* constraints); void Initialize(const cricket::AudioOptions* audio_options); cricket::AudioOptions options_; diff --git a/pc/localaudiosource_unittest.cc b/pc/localaudiosource_unittest.cc index bf566c627e..b2d87ae3e6 100644 --- a/pc/localaudiosource_unittest.cc +++ b/pc/localaudiosource_unittest.cc @@ -22,75 +22,6 @@ using webrtc::LocalAudioSource; using webrtc::MediaConstraintsInterface; using webrtc::MediaSourceInterface; -TEST(LocalAudioSourceTest, SetValidOptions) { - webrtc::FakeConstraints constraints; - constraints.AddMandatory( - MediaConstraintsInterface::kGoogEchoCancellation, false); - constraints.AddOptional( - MediaConstraintsInterface::kExtendedFilterEchoCancellation, true); - constraints.AddOptional(MediaConstraintsInterface::kDAEchoCancellation, true); - constraints.AddOptional(MediaConstraintsInterface::kAutoGainControl, true); - constraints.AddOptional( - MediaConstraintsInterface::kExperimentalAutoGainControl, true); - constraints.AddMandatory(MediaConstraintsInterface::kNoiseSuppression, false); - constraints.AddOptional(MediaConstraintsInterface::kHighpassFilter, true); - - rtc::scoped_refptr source = - LocalAudioSource::Create(&constraints); - - EXPECT_EQ(false, source->options().echo_cancellation); - EXPECT_EQ(true, source->options().extended_filter_aec); - EXPECT_EQ(true, source->options().delay_agnostic_aec); - EXPECT_EQ(true, source->options().auto_gain_control); - EXPECT_EQ(true, source->options().experimental_agc); - EXPECT_EQ(false, source->options().noise_suppression); - EXPECT_EQ(true, source->options().highpass_filter); -} - -TEST(LocalAudioSourceTest, OptionNotSet) { - webrtc::FakeConstraints constraints; - rtc::scoped_refptr source = - LocalAudioSource::Create(&constraints); - EXPECT_EQ(rtc::nullopt, source->options().highpass_filter); -} - -TEST(LocalAudioSourceTest, MandatoryOverridesOptional) { - webrtc::FakeConstraints constraints; - constraints.AddMandatory( - MediaConstraintsInterface::kGoogEchoCancellation, false); - constraints.AddOptional( - MediaConstraintsInterface::kGoogEchoCancellation, true); - - rtc::scoped_refptr source = - LocalAudioSource::Create(&constraints); - - EXPECT_EQ(false, source->options().echo_cancellation); -} - -TEST(LocalAudioSourceTest, InvalidOptional) { - webrtc::FakeConstraints constraints; - constraints.AddOptional(MediaConstraintsInterface::kHighpassFilter, false); - constraints.AddOptional("invalidKey", false); - - rtc::scoped_refptr source = - LocalAudioSource::Create(&constraints); - - EXPECT_EQ(MediaSourceInterface::kLive, source->state()); - EXPECT_EQ(false, source->options().highpass_filter); -} - -TEST(LocalAudioSourceTest, InvalidMandatory) { - webrtc::FakeConstraints constraints; - constraints.AddMandatory(MediaConstraintsInterface::kHighpassFilter, false); - constraints.AddMandatory("invalidKey", false); - - rtc::scoped_refptr source = - LocalAudioSource::Create(&constraints); - - EXPECT_EQ(MediaSourceInterface::kLive, source->state()); - EXPECT_EQ(false, source->options().highpass_filter); -} - TEST(LocalAudioSourceTest, InitWithAudioOptions) { cricket::AudioOptions audio_options; audio_options.highpass_filter = true; @@ -101,6 +32,6 @@ TEST(LocalAudioSourceTest, InitWithAudioOptions) { TEST(LocalAudioSourceTest, InitWithNoOptions) { rtc::scoped_refptr source = - LocalAudioSource::Create((cricket::AudioOptions*)nullptr); + LocalAudioSource::Create(nullptr); EXPECT_EQ(rtc::nullopt, source->options().highpass_filter); } diff --git a/pc/peerconnection_integrationtest.cc b/pc/peerconnection_integrationtest.cc index ec7f5c1b94..ecd84d1422 100644 --- a/pc/peerconnection_integrationtest.cc +++ b/pc/peerconnection_integrationtest.cc @@ -321,11 +321,11 @@ class PeerConnectionWrapper : public webrtc::PeerConnectionObserver, } rtc::scoped_refptr CreateLocalAudioTrack() { - FakeConstraints constraints; + cricket::AudioOptions options; // Disable highpass filter so that we can get all the test audio frames. - constraints.AddMandatory(MediaConstraintsInterface::kHighpassFilter, false); + options.highpass_filter = false; rtc::scoped_refptr source = - peer_connection_factory_->CreateAudioSource(&constraints); + peer_connection_factory_->CreateAudioSource(options); // TODO(perkj): Test audio source when it is implemented. Currently audio // always use the default input. return peer_connection_factory_->CreateAudioTrack(rtc::CreateRandomUuid(), diff --git a/pc/peerconnectionendtoend_unittest.cc b/pc/peerconnectionendtoend_unittest.cc index 2f5631ac0d..727fa2cf12 100644 --- a/pc/peerconnectionendtoend_unittest.cc +++ b/pc/peerconnectionendtoend_unittest.cc @@ -105,18 +105,18 @@ class PeerConnectionEndToEndBaseTest : public sigslot::has_slots<>, } void GetAndAddUserMedia() { - FakeConstraints audio_constraints; + cricket::AudioOptions audio_options; FakeConstraints video_constraints; - GetAndAddUserMedia(true, audio_constraints, true, video_constraints); + GetAndAddUserMedia(true, audio_options, true, video_constraints); } void GetAndAddUserMedia(bool audio, - const FakeConstraints& audio_constraints, + const cricket::AudioOptions& audio_options, bool video, const FakeConstraints& video_constraints) { - caller_->GetAndAddUserMedia(audio, audio_constraints, + caller_->GetAndAddUserMedia(audio, audio_options, video, video_constraints); - callee_->GetAndAddUserMedia(audio, audio_constraints, + callee_->GetAndAddUserMedia(audio, audio_options, video, video_constraints); } diff --git a/pc/peerconnectionfactory.cc b/pc/peerconnectionfactory.cc index c9fa223283..78a46b83db 100644 --- a/pc/peerconnectionfactory.cc +++ b/pc/peerconnectionfactory.cc @@ -231,15 +231,6 @@ void PeerConnectionFactory::SetOptions(const Options& options) { options_ = options; } -rtc::scoped_refptr -PeerConnectionFactory::CreateAudioSource( - const MediaConstraintsInterface* constraints) { - RTC_DCHECK(signaling_thread_->IsCurrent()); - rtc::scoped_refptr source( - LocalAudioSource::Create(constraints)); - return source; -} - rtc::scoped_refptr PeerConnectionFactory::CreateAudioSource(const cricket::AudioOptions& options) { RTC_DCHECK(signaling_thread_->IsCurrent()); diff --git a/pc/peerconnectionfactory.h b/pc/peerconnectionfactory.h index bce1e4c2e0..67f726a0f7 100644 --- a/pc/peerconnectionfactory.h +++ b/pc/peerconnectionfactory.h @@ -67,9 +67,6 @@ class PeerConnectionFactory : public PeerConnectionFactoryInterface { rtc::scoped_refptr CreateAudioSource( const cricket::AudioOptions& options) override; - // Deprecated, use version without constraints. - rtc::scoped_refptr CreateAudioSource( - const MediaConstraintsInterface* constraints) override; rtc::scoped_refptr CreateVideoSource( std::unique_ptr capturer) override; diff --git a/pc/rtcstats_integrationtest.cc b/pc/rtcstats_integrationtest.cc index 627a05bb9a..8f7f978278 100644 --- a/pc/rtcstats_integrationtest.cc +++ b/pc/rtcstats_integrationtest.cc @@ -118,9 +118,9 @@ class RTCStatsIntegrationTest : public testing::Test { PeerConnectionTestWrapper::Connect(caller_.get(), callee_.get()); // Get user media for audio and video - caller_->GetAndAddUserMedia(true, FakeConstraints(), + caller_->GetAndAddUserMedia(true, cricket::AudioOptions(), true, FakeConstraints()); - callee_->GetAndAddUserMedia(true, FakeConstraints(), + callee_->GetAndAddUserMedia(true, cricket::AudioOptions(), true, FakeConstraints()); // Create data channels diff --git a/pc/test/peerconnectiontestwrapper.cc b/pc/test/peerconnectiontestwrapper.cc index 569a9cc161..3c227b8e57 100644 --- a/pc/test/peerconnectiontestwrapper.cc +++ b/pc/test/peerconnectiontestwrapper.cc @@ -251,10 +251,10 @@ bool PeerConnectionTestWrapper::CheckForVideo() { } void PeerConnectionTestWrapper::GetAndAddUserMedia( - bool audio, const webrtc::FakeConstraints& audio_constraints, + bool audio, const cricket::AudioOptions& audio_options, bool video, const webrtc::FakeConstraints& video_constraints) { rtc::scoped_refptr stream = - GetUserMedia(audio, audio_constraints, video, video_constraints); + GetUserMedia(audio, audio_options, video, video_constraints); for (auto audio_track : stream->GetAudioTracks()) { EXPECT_TRUE(peer_connection_->AddTrack(audio_track, {stream->id()}).ok()); } @@ -264,21 +264,20 @@ void PeerConnectionTestWrapper::GetAndAddUserMedia( } rtc::scoped_refptr - PeerConnectionTestWrapper::GetUserMedia( - bool audio, const webrtc::FakeConstraints& audio_constraints, - bool video, const webrtc::FakeConstraints& video_constraints) { +PeerConnectionTestWrapper::GetUserMedia( + bool audio, const cricket::AudioOptions& audio_options, + bool video, const webrtc::FakeConstraints& video_constraints) { std::string stream_id = kStreamIdBase + rtc::ToString(num_get_user_media_calls_++); rtc::scoped_refptr stream = peer_connection_factory_->CreateLocalMediaStream(stream_id); if (audio) { - FakeConstraints constraints = audio_constraints; + cricket::AudioOptions options = audio_options; // Disable highpass filter so that we can get all the test audio frames. - constraints.AddMandatory( - MediaConstraintsInterface::kHighpassFilter, false); + options.highpass_filter = false; rtc::scoped_refptr source = - peer_connection_factory_->CreateAudioSource(&constraints); + peer_connection_factory_->CreateAudioSource(options); rtc::scoped_refptr audio_track( peer_connection_factory_->CreateAudioTrack(kAudioTrackLabelBase, source)); diff --git a/pc/test/peerconnectiontestwrapper.h b/pc/test/peerconnectiontestwrapper.h index 4d15244eba..a923b585fc 100644 --- a/pc/test/peerconnectiontestwrapper.h +++ b/pc/test/peerconnectiontestwrapper.h @@ -77,7 +77,7 @@ class PeerConnectionTestWrapper void WaitForAudio(); void WaitForVideo(); void GetAndAddUserMedia( - bool audio, const webrtc::FakeConstraints& audio_constraints, + bool audio, const cricket::AudioOptions& audio_options, bool video, const webrtc::FakeConstraints& video_constraints); // sigslots @@ -96,7 +96,7 @@ class PeerConnectionTestWrapper bool CheckForAudio(); bool CheckForVideo(); rtc::scoped_refptr GetUserMedia( - bool audio, const webrtc::FakeConstraints& audio_constraints, + bool audio, const cricket::AudioOptions& audio_options, bool video, const webrtc::FakeConstraints& video_constraints); std::string name_; diff --git a/sdk/objc/Framework/Classes/PeerConnection/RTCPeerConnectionFactory.mm b/sdk/objc/Framework/Classes/PeerConnection/RTCPeerConnectionFactory.mm index 5ebd4e9f9d..263adbdd24 100644 --- a/sdk/objc/Framework/Classes/PeerConnection/RTCPeerConnectionFactory.mm +++ b/sdk/objc/Framework/Classes/PeerConnection/RTCPeerConnectionFactory.mm @@ -175,8 +175,11 @@ if (constraints) { nativeConstraints = constraints.nativeConstraints; } + cricket::AudioOptions options; + CopyConstraintsIntoAudioOptions(nativeConstraints.get(), &options); + rtc::scoped_refptr source = - _nativeFactory->CreateAudioSource(nativeConstraints.get()); + _nativeFactory->CreateAudioSource(options); return [[RTCAudioSource alloc] initWithNativeAudioSource:source]; }