Delete deprecated CreateAudioSource method, with constraints.

Bug: webrtc:9239
Change-Id: I5025b7fd103247e0426ceabedc1216a4f0f0ab34
Reviewed-on: https://webrtc-review.googlesource.com/76560
Commit-Queue: Niels Moller <nisse@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23501}
This commit is contained in:
Niels Möller 2018-05-21 11:23:35 +02:00 committed by Commit Bot
parent 0c12d8d8c6
commit 2d02e085de
15 changed files with 29 additions and 135 deletions

View File

@ -50,8 +50,6 @@ BEGIN_SIGNALING_PROXY_MAP(PeerConnectionFactory)
PeerConnectionDependencies);
PROXY_METHOD1(rtc::scoped_refptr<MediaStreamInterface>,
CreateLocalMediaStream, const std::string&)
PROXY_METHOD1(rtc::scoped_refptr<AudioSourceInterface>,
CreateAudioSource, const MediaConstraintsInterface*)
PROXY_METHOD1(rtc::scoped_refptr<AudioSourceInterface>,
CreateAudioSource,
const cricket::AudioOptions&)

View File

@ -1331,12 +1331,6 @@ class PeerConnectionFactoryInterface : public rtc::RefCountInterface {
// |options| decides audio processing settings.
virtual rtc::scoped_refptr<AudioSourceInterface> CreateAudioSource(
const cricket::AudioOptions& options) = 0;
// Deprecated - use version above.
// Can use CopyConstraintsIntoAudioOptions to bridge the gap.
virtual rtc::scoped_refptr<AudioSourceInterface> CreateAudioSource(
const MediaConstraintsInterface* constraints) {
return nullptr;
}
// Creates a VideoTrackSourceInterface from |capturer|.
// TODO(deadbeef): We should aim to remove cricket::VideoCapturer from the

View File

@ -414,7 +414,8 @@ void Conductor::AddTracks() {
rtc::scoped_refptr<webrtc::AudioTrackInterface> 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: "

View File

@ -429,7 +429,8 @@ void SimplePeerConnection::AddStreams(bool audio_only) {
rtc::scoped_refptr<webrtc::AudioTrackInterface> 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);

View File

@ -12,22 +12,12 @@
#include <vector>
#include "api/mediaconstraintsinterface.h"
#include "media/base/mediaengine.h"
using webrtc::MediaConstraintsInterface;
using webrtc::MediaSourceInterface;
namespace webrtc {
rtc::scoped_refptr<LocalAudioSource> LocalAudioSource::Create(
const MediaConstraintsInterface* constraints) {
rtc::scoped_refptr<LocalAudioSource> source(
new rtc::RefCountedObject<LocalAudioSource>());
source->Initialize(constraints);
return source;
}
rtc::scoped_refptr<LocalAudioSource> LocalAudioSource::Create(
const cricket::AudioOptions* audio_options) {
rtc::scoped_refptr<LocalAudioSource> source(
@ -36,11 +26,6 @@ rtc::scoped_refptr<LocalAudioSource> LocalAudioSource::Create(
return source;
}
void LocalAudioSource::Initialize(
const MediaConstraintsInterface* constraints) {
CopyConstraintsIntoAudioOptions(constraints, &options_);
}
void LocalAudioSource::Initialize(
const cricket::AudioOptions* audio_options) {
if (!audio_options)

View File

@ -20,14 +20,9 @@
namespace webrtc {
class MediaConstraintsInterface;
class LocalAudioSource : public Notifier<AudioSourceInterface> {
public:
// Creates an instance of LocalAudioSource.
static rtc::scoped_refptr<LocalAudioSource> Create(
const MediaConstraintsInterface* constraints);
static rtc::scoped_refptr<LocalAudioSource> Create(
const cricket::AudioOptions* audio_options);
@ -44,7 +39,6 @@ class LocalAudioSource : public Notifier<AudioSourceInterface> {
~LocalAudioSource() override {}
private:
void Initialize(const MediaConstraintsInterface* constraints);
void Initialize(const cricket::AudioOptions* audio_options);
cricket::AudioOptions options_;

View File

@ -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<LocalAudioSource> 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<LocalAudioSource> 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<LocalAudioSource> 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<LocalAudioSource> 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<LocalAudioSource> 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<LocalAudioSource> source =
LocalAudioSource::Create((cricket::AudioOptions*)nullptr);
LocalAudioSource::Create(nullptr);
EXPECT_EQ(rtc::nullopt, source->options().highpass_filter);
}

View File

@ -321,11 +321,11 @@ class PeerConnectionWrapper : public webrtc::PeerConnectionObserver,
}
rtc::scoped_refptr<webrtc::AudioTrackInterface> 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<webrtc::AudioSourceInterface> 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(),

View File

@ -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);
}

View File

@ -231,15 +231,6 @@ void PeerConnectionFactory::SetOptions(const Options& options) {
options_ = options;
}
rtc::scoped_refptr<AudioSourceInterface>
PeerConnectionFactory::CreateAudioSource(
const MediaConstraintsInterface* constraints) {
RTC_DCHECK(signaling_thread_->IsCurrent());
rtc::scoped_refptr<LocalAudioSource> source(
LocalAudioSource::Create(constraints));
return source;
}
rtc::scoped_refptr<AudioSourceInterface>
PeerConnectionFactory::CreateAudioSource(const cricket::AudioOptions& options) {
RTC_DCHECK(signaling_thread_->IsCurrent());

View File

@ -67,9 +67,6 @@ class PeerConnectionFactory : public PeerConnectionFactoryInterface {
rtc::scoped_refptr<AudioSourceInterface> CreateAudioSource(
const cricket::AudioOptions& options) override;
// Deprecated, use version without constraints.
rtc::scoped_refptr<AudioSourceInterface> CreateAudioSource(
const MediaConstraintsInterface* constraints) override;
rtc::scoped_refptr<VideoTrackSourceInterface> CreateVideoSource(
std::unique_ptr<cricket::VideoCapturer> capturer) override;

View File

@ -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

View File

@ -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<webrtc::MediaStreamInterface> 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<webrtc::MediaStreamInterface>
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<webrtc::MediaStreamInterface> 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<webrtc::AudioSourceInterface> source =
peer_connection_factory_->CreateAudioSource(&constraints);
peer_connection_factory_->CreateAudioSource(options);
rtc::scoped_refptr<webrtc::AudioTrackInterface> audio_track(
peer_connection_factory_->CreateAudioTrack(kAudioTrackLabelBase,
source));

View File

@ -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<webrtc::MediaStreamInterface> 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_;

View File

@ -175,8 +175,11 @@
if (constraints) {
nativeConstraints = constraints.nativeConstraints;
}
cricket::AudioOptions options;
CopyConstraintsIntoAudioOptions(nativeConstraints.get(), &options);
rtc::scoped_refptr<webrtc::AudioSourceInterface> source =
_nativeFactory->CreateAudioSource(nativeConstraints.get());
_nativeFactory->CreateAudioSource(options);
return [[RTCAudioSource alloc] initWithNativeAudioSource:source];
}