Skip to content

Commit

Permalink
Delete deprecated CreateAudioSource method, with constraints.
Browse files Browse the repository at this point in the history
Bug: webrtc:9239
Change-Id: I5025b7fd103247e0426ceabedc1216a4f0f0ab34
Reviewed-on: https://webrtc-review.googlesource.com/76560
Commit-Queue: Niels Moller <[email protected]>
Reviewed-by: Karl Wiberg <[email protected]>
Reviewed-by: Harald Alvestrand <[email protected]>
Reviewed-by: Taylor Brandstetter <[email protected]>
Cr-Commit-Position: refs/heads/master@{#23501}
  • Loading branch information
Niels Möller authored and Commit Bot committed Jun 4, 2018
1 parent 0c12d8d commit 2d02e08
Show file tree
Hide file tree
Showing 15 changed files with 29 additions and 135 deletions.
2 changes: 0 additions & 2 deletions api/peerconnectionfactoryproxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -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&)
Expand Down
6 changes: 0 additions & 6 deletions api/peerconnectioninterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion examples/peerconnection/client/conductor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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: "
Expand Down
3 changes: 2 additions & 1 deletion examples/unityplugin/simple_peer_connection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
15 changes: 0 additions & 15 deletions pc/localaudiosource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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)
Expand Down
6 changes: 0 additions & 6 deletions pc/localaudiosource.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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_;
Expand Down
71 changes: 1 addition & 70 deletions pc/localaudiosource_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
6 changes: 3 additions & 3 deletions pc/peerconnection_integrationtest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
10 changes: 5 additions & 5 deletions pc/peerconnectionendtoend_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
9 changes: 0 additions & 9 deletions pc/peerconnectionfactory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
3 changes: 0 additions & 3 deletions pc/peerconnectionfactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions pc/rtcstats_integrationtest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 8 additions & 9 deletions pc/test/peerconnectiontestwrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand All @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions pc/test/peerconnectiontestwrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,11 @@ - (RTCAudioSource *)audioSourceWithConstraints:(nullable RTCMediaConstraints *)c
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];
}

Expand Down

0 comments on commit 2d02e08

Please sign in to comment.