Commit 1b163742 authored by tommi@chromium.org's avatar tommi@chromium.org

Feed audio constraints over to WebRtcLocalAudioTrack

and check them to see if audio processing should be applied.
Previously this check was just being based on a device id being
empty or not, which doesn't do the right thing for WebAudio.

BUG=277134

Review URL: https://chromiumcodereview.appspot.com/23171026

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@220617 0039d316-1c4b-4281-b951-d872f2087c98
parent 6ec5acc3
......@@ -70,23 +70,12 @@ struct {
webrtc::MediaConstraintsInterface::kValueTrue},
};
class WebAudioConstraints : public RTCMediaConstraints {
public:
WebAudioConstraints()
: RTCMediaConstraints(WebKit::WebMediaConstraints()) {
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kWebAudioConstraints); ++i) {
webrtc::MediaConstraintsInterface::Constraint constraint;
constraint.key = kWebAudioConstraints[i].key;
constraint.value = kWebAudioConstraints[i].value;
DVLOG(1) << "WebAudioConstraints: " << constraint.key
<< " : " << constraint.value;
mandatory_.push_back(constraint);
}
void ApplyFixedWebAudioConstraints(RTCMediaConstraints* constraints) {
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kWebAudioConstraints); ++i) {
constraints->AddMandatory(kWebAudioConstraints[i].key,
kWebAudioConstraints[i].value, false);
}
virtual ~WebAudioConstraints() {}
};
}
class P2PPortAllocatorFactory : public webrtc::PortAllocatorFactoryInterface {
public:
......@@ -325,6 +314,10 @@ void MediaStreamDependencyFactory::CreateNativeMediaSources(
DLOG(WARNING) << "Failed to create the capturer for device "
<< device_info.device.id;
sources_created.Run(web_stream, false);
// TODO(xians): Don't we need to check if source_observer is observing
// something? If not, then it looks like we have a leak here.
// OTOH, if it _is_ observing something, then the callback might
// be called multiple times which is likely also a bug.
return;
}
......@@ -390,12 +383,16 @@ bool MediaStreamDependencyFactory::AddNativeMediaStreamTrack(
MediaStreamSourceExtraData* source_data =
static_cast<MediaStreamSourceExtraData*>(source.extraData());
// In the future the constraints will belong to the track itself, but
// right now they're on the source, so we fetch them from there.
RTCMediaConstraints track_constraints(source.constraints());
scoped_refptr<WebRtcAudioCapturer> capturer;
if (!source_data) {
if (source.requiresAudioConsumer()) {
// We're adding a WebAudio MediaStream.
// Create a specific capturer for each WebAudio consumer.
capturer = CreateWebAudioSource(&source);
capturer = CreateWebAudioSource(&source, &track_constraints);
source_data =
static_cast<MediaStreamSourceExtraData*>(source.extraData());
} else {
......@@ -418,7 +415,8 @@ bool MediaStreamDependencyFactory::AddNativeMediaStreamTrack(
scoped_refptr<webrtc::AudioTrackInterface> audio_track(
CreateLocalAudioTrack(track_id,
capturer,
source_data->local_audio_source()));
source_data->local_audio_source(),
&track_constraints));
audio_track->set_enabled(track.isEnabled());
return native_stream->AddTrack(audio_track.get());
} else {
......@@ -598,7 +596,8 @@ MediaStreamDependencyFactory::CreateLocalVideoSource(
scoped_refptr<WebRtcAudioCapturer>
MediaStreamDependencyFactory::CreateWebAudioSource(
WebKit::WebMediaStreamSource* source) {
WebKit::WebMediaStreamSource* source,
RTCMediaConstraints* constraints) {
DVLOG(1) << "MediaStreamDependencyFactory::CreateWebAudioSource()";
DCHECK(GetWebRtcAudioDevice());
......@@ -621,9 +620,8 @@ MediaStreamDependencyFactory::CreateWebAudioSource(
// echo cancellation, automatic gain control, noise suppression and
// high-pass filter. SetLocalAudioSource() affects core audio parts in
// third_party/Libjingle.
WebAudioConstraints webaudio_audio_constraints_all_true;
source_data->SetLocalAudioSource(
CreateLocalAudioSource(&webaudio_audio_constraints_all_true).get());
ApplyFixedWebAudioConstraints(constraints);
source_data->SetLocalAudioSource(CreateLocalAudioSource(constraints).get());
source->setExtraData(source_data);
// Replace the default source with WebAudio as source instead.
......@@ -659,12 +657,13 @@ scoped_refptr<webrtc::AudioTrackInterface>
MediaStreamDependencyFactory::CreateLocalAudioTrack(
const std::string& id,
const scoped_refptr<WebRtcAudioCapturer>& capturer,
webrtc::AudioSourceInterface* source) {
webrtc::AudioSourceInterface* source,
const webrtc::MediaConstraintsInterface* constraints) {
// TODO(xians): Merge |source| to the capturer(). We can't do this today
// because only one capturer() is supported while one |source| is created
// for each audio track.
scoped_refptr<WebRtcLocalAudioTrack> audio_track(
WebRtcLocalAudioTrack::Create(id, capturer, source));
WebRtcLocalAudioTrack::Create(id, capturer, source, constraints));
// Add the WebRtcAudioDevice as the sink to the local audio track.
audio_track->AddSink(GetWebRtcAudioDevice());
// Start the audio track. This will hook the |audio_track| to the capturer
......
......@@ -42,6 +42,7 @@ namespace content {
class IpcNetworkManager;
class IpcPacketSocketFactory;
class RTCMediaConstraints;
class VideoCaptureImplManager;
class WebRtcAudioCapturer;
class WebRtcAudioDeviceImpl;
......@@ -161,14 +162,19 @@ class CONTENT_EXPORT MediaStreamDependencyFactory
// specific for a WebAudio source. The created WebAudioCapturerSource
// instance will function as audio source instead of the default
// WebRtcAudioCapturer.
// The |constraints| will be modified to include the default, mandatory
// WebAudio constraints.
virtual scoped_refptr<WebRtcAudioCapturer> CreateWebAudioSource(
WebKit::WebMediaStreamSource* source);
WebKit::WebMediaStreamSource* source,
RTCMediaConstraints* constraints);
// Asks the PeerConnection factory to create a Local AudioTrack object.
virtual scoped_refptr<webrtc::AudioTrackInterface>
CreateLocalAudioTrack(const std::string& id,
const scoped_refptr<WebRtcAudioCapturer>& capturer,
webrtc::AudioSourceInterface* source);
CreateLocalAudioTrack(
const std::string& id,
const scoped_refptr<WebRtcAudioCapturer>& capturer,
webrtc::AudioSourceInterface* source,
const webrtc::MediaConstraintsInterface* constraints);
// Asks the PeerConnection factory to create a Local VideoTrack object.
virtual scoped_refptr<webrtc::VideoTrackInterface>
......
......@@ -408,7 +408,8 @@ MockMediaStreamDependencyFactory::CreateLocalVideoSource(
scoped_refptr<WebRtcAudioCapturer>
MockMediaStreamDependencyFactory::CreateWebAudioSource(
WebKit::WebMediaStreamSource* source) {
WebKit::WebMediaStreamSource* source,
RTCMediaConstraints* constraints) {
return NULL;
}
......@@ -447,11 +448,12 @@ scoped_refptr<webrtc::AudioTrackInterface>
MockMediaStreamDependencyFactory::CreateLocalAudioTrack(
const std::string& id,
const scoped_refptr<WebRtcAudioCapturer>& capturer,
webrtc::AudioSourceInterface* source) {
webrtc::AudioSourceInterface* source,
const webrtc::MediaConstraintsInterface* constraints) {
DCHECK(mock_pc_factory_created_);
DCHECK(!capturer.get());
return WebRtcLocalAudioTrack::Create(
id, WebRtcAudioCapturer::CreateCapturer(), source);
id, WebRtcAudioCapturer::CreateCapturer(), source, constraints);
}
SessionDescriptionInterface*
......
......@@ -127,7 +127,8 @@ class MockMediaStreamDependencyFactory : public MediaStreamDependencyFactory {
bool is_screencast,
const webrtc::MediaConstraintsInterface* constraints) OVERRIDE;
virtual scoped_refptr<WebRtcAudioCapturer> CreateWebAudioSource(
WebKit::WebMediaStreamSource* source) OVERRIDE;
WebKit::WebMediaStreamSource* source,
RTCMediaConstraints* constraints) OVERRIDE;
virtual scoped_refptr<webrtc::MediaStreamInterface>
CreateLocalMediaStream(const std::string& label) OVERRIDE;
virtual scoped_refptr<webrtc::VideoTrackInterface>
......@@ -136,10 +137,11 @@ class MockMediaStreamDependencyFactory : public MediaStreamDependencyFactory {
virtual scoped_refptr<webrtc::VideoTrackInterface>
CreateLocalVideoTrack(const std::string& id,
cricket::VideoCapturer* capturer) OVERRIDE;
virtual scoped_refptr<webrtc::AudioTrackInterface>
CreateLocalAudioTrack(const std::string& id,
const scoped_refptr<WebRtcAudioCapturer>& capturer,
webrtc::AudioSourceInterface* source) OVERRIDE;
virtual scoped_refptr<webrtc::AudioTrackInterface> CreateLocalAudioTrack(
const std::string& id,
const scoped_refptr<WebRtcAudioCapturer>& capturer,
webrtc::AudioSourceInterface* source,
const webrtc::MediaConstraintsInterface* constraints) OVERRIDE;
virtual webrtc::SessionDescriptionInterface* CreateSessionDescription(
const std::string& type,
const std::string& sdp,
......
......@@ -42,6 +42,8 @@ void GetNativeMediaConstraints(
} // namespace
RTCMediaConstraints::RTCMediaConstraints() {}
RTCMediaConstraints::RTCMediaConstraints(
const WebKit::WebMediaConstraints& constraints) {
if (constraints.isNull())
......@@ -71,4 +73,21 @@ void RTCMediaConstraints::AddOptional(const std::string& key,
optional_.push_back(Constraint(key, value));
}
bool RTCMediaConstraints::AddMandatory(const std::string& key,
const std::string& value,
bool override_if_exists) {
for (Constraints::iterator iter = mandatory_.begin();
iter != mandatory_.end();
++iter) {
if (iter->key == key) {
if (override_if_exists)
iter->value = value;
return override_if_exists;
}
}
// The key wasn't found, add it.
mandatory_.push_back(Constraint(key, value));
return true;
}
} // namespace content
......@@ -6,6 +6,7 @@
#define CONTENT_RENDERER_MEDIA_RTC_MEDIA_CONSTRAINTS_H_
#include "base/compiler_specific.h"
#include "content/common/content_export.h"
#include "third_party/libjingle/source/talk/app/webrtc/mediaconstraintsinterface.h"
namespace WebKit {
......@@ -17,14 +18,21 @@ namespace content {
// RTCMediaConstraints acts as a glue layer between WebKits MediaConstraints and
// libjingle webrtc::MediaConstraintsInterface.
// Constraints are used by PeerConnection and getUserMedia API calls.
class RTCMediaConstraints : public webrtc::MediaConstraintsInterface {
class CONTENT_EXPORT RTCMediaConstraints
: public NON_EXPORTED_BASE(webrtc::MediaConstraintsInterface) {
public:
RTCMediaConstraints();
explicit RTCMediaConstraints(
const WebKit::WebMediaConstraints& constraints);
virtual ~RTCMediaConstraints();
virtual const Constraints& GetMandatory() const OVERRIDE;
virtual const Constraints& GetOptional() const OVERRIDE;
void AddOptional(const std::string& key, const std::string& value);
// Adds a mandatory constraint, optionally overriding an existing one.
// If the constraint is already set and |override_if_exists| is false,
// the function will return false, otherwise true.
bool AddMandatory(const std::string& key, const std::string& value,
bool override_if_exists);
protected:
Constraints mandatory_;
......
......@@ -250,10 +250,11 @@ class RTCPeerConnectionHandlerTest : public ::testing::Test {
local_stream.audioTracks(audio_tracks);
const std::string audio_track_id = UTF16ToUTF8(audio_tracks[0].id());
scoped_refptr<WebRtcAudioCapturer> capturer;
RTCMediaConstraints audio_constraints(audio_source.constraints());
scoped_refptr<webrtc::AudioTrackInterface> audio_track(
mock_dependency_factory_->CreateLocalAudioTrack(audio_track_id,
capturer,
NULL));
mock_dependency_factory_->CreateLocalAudioTrack(
audio_track_id, capturer, NULL,
&audio_constraints));
native_stream->AddTrack(audio_track.get());
local_stream.videoTracks(video_tracks);
......@@ -289,6 +290,7 @@ class RTCPeerConnectionHandlerTest : public ::testing::Test {
scoped_refptr<webrtc::AudioTrackInterface> audio_track(
mock_dependency_factory_->CreateLocalAudioTrack(audio_track_label,
capturer,
NULL,
NULL));
stream->AddTrack(audio_track.get());
}
......
......@@ -137,7 +137,7 @@ scoped_refptr<WebRtcLocalAudioTrack>
CreateAndStartLocalAudioTrack(WebRtcAudioCapturer* capturer,
WebRtcAudioCapturerSink* sink) {
scoped_refptr<WebRtcLocalAudioTrack> local_audio_track(
WebRtcLocalAudioTrack::Create(std::string(), capturer, NULL));
WebRtcLocalAudioTrack::Create(std::string(), capturer, NULL, NULL));
local_audio_track->AddSink(sink);
local_audio_track->Start();
return local_audio_track;
......
......@@ -12,34 +12,65 @@ namespace content {
static const char kAudioTrackKind[] = "audio";
namespace {
using webrtc::MediaConstraintsInterface;
// This helper function checks if any audio constraints are set that require
// audio processing to be applied. Right now this is a big, single switch for
// all of the properties, but in the future they'll be handled one by one.
bool NeedsAudioProcessing(
const webrtc::MediaConstraintsInterface* constraints) {
if (!constraints)
return false;
static const char* kAudioProcessingProperties[] = {
MediaConstraintsInterface::kEchoCancellation,
MediaConstraintsInterface::kExperimentalEchoCancellation,
MediaConstraintsInterface::kAutoGainControl,
MediaConstraintsInterface::kExperimentalAutoGainControl,
MediaConstraintsInterface::kNoiseSuppression,
MediaConstraintsInterface::kHighpassFilter,
};
for (size_t i = 0; i < arraysize(kAudioProcessingProperties); ++i) {
bool value = false;
if (webrtc::FindConstraint(constraints, kAudioProcessingProperties[i],
&value, NULL) &&
value) {
return true;
}
}
return false;
}
} // namespace.
scoped_refptr<WebRtcLocalAudioTrack> WebRtcLocalAudioTrack::Create(
const std::string& id,
const scoped_refptr<WebRtcAudioCapturer>& capturer,
webrtc::AudioSourceInterface* track_source) {
webrtc::AudioSourceInterface* track_source,
const webrtc::MediaConstraintsInterface* constraints) {
talk_base::RefCountedObject<WebRtcLocalAudioTrack>* track =
new talk_base::RefCountedObject<WebRtcLocalAudioTrack>(
id, capturer, track_source);
id, capturer, track_source, constraints);
return track;
}
WebRtcLocalAudioTrack::WebRtcLocalAudioTrack(
const std::string& label,
const scoped_refptr<WebRtcAudioCapturer>& capturer,
webrtc::AudioSourceInterface* track_source)
webrtc::AudioSourceInterface* track_source,
const webrtc::MediaConstraintsInterface* constraints)
: webrtc::MediaStreamTrack<webrtc::AudioTrackInterface>(label),
capturer_(capturer),
track_source_(track_source),
need_audio_processing_(!capturer->device_id().empty()) {
need_audio_processing_(NeedsAudioProcessing(constraints)) {
// The capturer with a valid device id is using microphone as source,
// and APM (AudioProcessingModule) is turned on only for microphone data.
DCHECK(capturer.get());
DVLOG(1) << "WebRtcLocalAudioTrack::WebRtcLocalAudioTrack()";
// TODO(tommi): Remove this, feed audio constraints to WebRtcLocalAudioTrack
// and check the constraints. This is here to fix a recent regression whereby
// audio processing is not enabled for WebAudio regardless of the hard coded
// audio constraints. For more info: http://crbug.com/277134
need_audio_processing_ = true;
}
WebRtcLocalAudioTrack::~WebRtcLocalAudioTrack() {
......
......@@ -11,6 +11,7 @@
#include "base/synchronization/lock.h"
#include "base/threading/thread_checker.h"
#include "content/renderer/media/webrtc_audio_device_impl.h"
#include "third_party/libjingle/source/talk/app/webrtc/mediaconstraintsinterface.h"
#include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h"
#include "third_party/libjingle/source/talk/app/webrtc/mediastreamtrack.h"
#include "third_party/libjingle/source/talk/media/base/audiorenderer.h"
......@@ -37,7 +38,8 @@ class CONTENT_EXPORT WebRtcLocalAudioTrack
static scoped_refptr<WebRtcLocalAudioTrack> Create(
const std::string& id,
const scoped_refptr<WebRtcAudioCapturer>& capturer,
webrtc::AudioSourceInterface* stream_source);
webrtc::AudioSourceInterface* stream_source,
const webrtc::MediaConstraintsInterface* constraints);
// Add a sink to the track. This function will trigger a SetCaptureFormat()
// call on the |sink|.
......@@ -72,7 +74,8 @@ class CONTENT_EXPORT WebRtcLocalAudioTrack
protected:
WebRtcLocalAudioTrack(const std::string& label,
const scoped_refptr<WebRtcAudioCapturer>& capturer,
webrtc::AudioSourceInterface* track_source);
webrtc::AudioSourceInterface* track_source,
const webrtc::MediaConstraintsInterface* constraints);
virtual ~WebRtcLocalAudioTrack();
private:
......
......@@ -4,6 +4,7 @@
#include "base/synchronization/waitable_event.h"
#include "base/test/test_timeouts.h"
#include "content/renderer/media/rtc_media_constraints.h"
#include "content/renderer/media/webrtc_audio_capturer.h"
#include "content/renderer/media/webrtc_local_audio_track.h"
#include "media/audio/audio_parameters.h"
......@@ -164,8 +165,10 @@ class WebRtcLocalAudioTrackTest : public ::testing::Test {
// the track is disconnected from the capturer.
TEST_F(WebRtcLocalAudioTrackTest, ConnectAndDisconnectOneSink) {
EXPECT_CALL(*capturer_source_.get(), Start()).WillOnce(Return());
RTCMediaConstraints constraints;
scoped_refptr<WebRtcLocalAudioTrack> track =
WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL);
WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL,
&constraints);
track->Start();
EXPECT_TRUE(track->enabled());
......@@ -187,8 +190,7 @@ TEST_F(WebRtcLocalAudioTrackTest, ConnectAndDisconnectOneSink) {
params.frames_per_buffer(),
0,
0,
// TODO(tommi): Change to |false| when issue 277134 is fixed.
_,
false,
false)).Times(AtLeast(1))
.WillRepeatedly(SignalEvent(&event));
track->AddSink(sink.get());
......@@ -209,8 +211,10 @@ TEST_F(WebRtcLocalAudioTrackTest, ConnectAndDisconnectOneSink) {
// reports on MediaStreamTrack::enabled();
TEST_F(WebRtcLocalAudioTrackTest, DISABLED_DisableEnableAudioTrack) {
EXPECT_CALL(*capturer_source_.get(), Start()).WillOnce(Return());
RTCMediaConstraints constraints;
scoped_refptr<WebRtcLocalAudioTrack> track =
WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL);
WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL,
&constraints);
track->Start();
static_cast<webrtc::AudioTrackInterface*>(track.get())->
GetRenderer()->AddChannel(0);
......@@ -257,8 +261,10 @@ TEST_F(WebRtcLocalAudioTrackTest, DISABLED_DisableEnableAudioTrack) {
// callbacks appear/disappear.
TEST_F(WebRtcLocalAudioTrackTest, MultipleAudioTracks) {
EXPECT_CALL(*capturer_source_.get(), Start()).WillOnce(Return());
RTCMediaConstraints constraints;
scoped_refptr<WebRtcLocalAudioTrack> track_1 =
WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL);
WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL,
&constraints);
track_1->Start();
static_cast<webrtc::AudioTrackInterface*>(track_1.get())->
GetRenderer()->AddChannel(0);
......@@ -275,15 +281,15 @@ TEST_F(WebRtcLocalAudioTrackTest, MultipleAudioTracks) {
params.frames_per_buffer(),
0,
0,
// TODO(tommi): Change to |false| when issue 277134 is fixed.
_,
false,
false)).Times(AtLeast(1))
.WillRepeatedly(SignalEvent(&event_1));
track_1->AddSink(sink_1.get());
EXPECT_TRUE(event_1.TimedWait(TestTimeouts::tiny_timeout()));
scoped_refptr<WebRtcLocalAudioTrack> track_2 =
WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL);
WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL,
&constraints);
track_2->Start();
static_cast<webrtc::AudioTrackInterface*>(track_2.get())->
GetRenderer()->AddChannel(1);
......@@ -303,8 +309,7 @@ TEST_F(WebRtcLocalAudioTrackTest, MultipleAudioTracks) {
params.frames_per_buffer(),
0,
0,
// TODO(tommi): Change to |false| when issue 277134 is fixed.
_,
false,
false)).Times(AtLeast(1))
.WillRepeatedly(SignalEvent(&event_1));
EXPECT_CALL(*sink_2,
......@@ -314,8 +319,7 @@ TEST_F(WebRtcLocalAudioTrackTest, MultipleAudioTracks) {
params.frames_per_buffer(),
0,
0,
// TODO(tommi): Change to |false| when issue 277134 is fixed.
_,
false,
false)).Times(AtLeast(1))
.WillRepeatedly(SignalEvent(&event_2));
track_2->AddSink(sink_2.get());
......@@ -337,8 +341,10 @@ TEST_F(WebRtcLocalAudioTrackTest, MultipleAudioTracks) {
// And it should be fine to not to call Stop() explicitly.
TEST_F(WebRtcLocalAudioTrackTest, StartOneAudioTrack) {
EXPECT_CALL(*capturer_source_.get(), Start()).Times(1);
RTCMediaConstraints constraints;
scoped_refptr<WebRtcLocalAudioTrack> track =
WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL);
WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL,
&constraints);
track->Start();
// When the track goes away, it will automatically stop the
......@@ -354,8 +360,10 @@ TEST_F(WebRtcLocalAudioTrackTest, StartAndStopAudioTracks) {
// Starting the first audio track will start the |capturer_source_|.
base::WaitableEvent event(false, false);
EXPECT_CALL(*capturer_source_.get(), Start()).WillOnce(SignalEvent(&event));
RTCMediaConstraints constraints;
scoped_refptr<WebRtcLocalAudioTrack> track_1 =
WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL);
WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL,
&constraints);
static_cast<webrtc::AudioTrackInterface*>(track_1.get())->
GetRenderer()->AddChannel(0);
track_1->Start();
......@@ -365,10 +373,7 @@ TEST_F(WebRtcLocalAudioTrackTest, StartAndStopAudioTracks) {
scoped_ptr<MockWebRtcAudioCapturerSink> sink(
new MockWebRtcAudioCapturerSink());
event.Reset();
EXPECT_CALL(*sink, CaptureData(_, _, _, _, 0, 0,
// TODO(tommi): Change to |false| when issue 277134 is fixed.
_,
false))
EXPECT_CALL(*sink, CaptureData(_, _, _, _, 0, 0, false, false))
.Times(AnyNumber()).WillRepeatedly(Return());
EXPECT_CALL(*sink, SetCaptureFormat(_)).Times(1);
track_1->AddSink(sink.get());
......@@ -377,7 +382,8 @@ TEST_F(WebRtcLocalAudioTrackTest, StartAndStopAudioTracks) {
// since it has been started.
EXPECT_CALL(*capturer_source_.get(), Start()).Times(0);
scoped_refptr<WebRtcLocalAudioTrack> track_2 =
WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL);
WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL,
&constraints);
track_2->Start();
static_cast<webrtc::AudioTrackInterface*>(track_2.get())->
GetRenderer()->AddChannel(1);
......@@ -407,8 +413,10 @@ TEST_F(WebRtcLocalAudioTrackTest, StartAndStopAudioTracks) {
TEST_F(WebRtcLocalAudioTrackTest, SetNewSourceForCapturerAfterStartTrack) {
// Setup the audio track and start the track.
EXPECT_CALL(*capturer_source_.get(), Start()).Times(1);
RTCMediaConstraints constraints;
scoped_refptr<WebRtcLocalAudioTrack> track =
WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL);
WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL,
&constraints);
track->Start();
// Setting new source to the capturer and the track should still get packets.
......@@ -432,8 +440,10 @@ TEST_F(WebRtcLocalAudioTrackTest, SetNewSourceForCapturerAfterStartTrack) {
TEST_F(WebRtcLocalAudioTrackTest, ConnectTracksToDifferentCapturers) {
// Setup the first audio track and start it.
EXPECT_CALL(*capturer_source_.get(), Start()).Times(1);
RTCMediaConstraints constraints;
scoped_refptr<WebRtcLocalAudioTrack> track_1 =
WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL);
WebRtcLocalAudioTrack::Create(std::string(), capturer_, NULL,
&constraints);
track_1->Start();
// Connect a number of network channels to the |track_1|.
......@@ -448,10 +458,7 @@ TEST_F(WebRtcLocalAudioTrackTest, ConnectTracksToDifferentCapturers) {
EXPECT_CALL(
*sink_1.get(),
CaptureData(
kNumberOfNetworkChannelsForTrack1, 48000, 2, _, 0, 0,
// TODO(tommi): Change to |false| when issue 277134 is fixed.
_,
false))
kNumberOfNetworkChannelsForTrack1, 48000, 2, _, 0, 0, false, false))
.Times(AnyNumber()).WillRepeatedly(Return());
EXPECT_CALL(*sink_1.get(), SetCaptureFormat(_)).Times(1);
track_1->AddSink(sink_1.get());
......@@ -475,7 +482,8 @@ TEST_F(WebRtcLocalAudioTrackTest, ConnectTracksToDifferentCapturers) {
// Setup the second audio track, connect it to the new capturer and start it.
EXPECT_CALL(*new_source.get(), Start()).Times(1);
scoped_refptr<WebRtcLocalAudioTrack> track_2 =
WebRtcLocalAudioTrack::Create(std::string(), new_capturer, NULL);
WebRtcLocalAudioTrack::Create(std::string(), new_capturer, NULL,
&constraints);
track_2->Start();
// Connect a number of network channels to the |track_2|.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment