Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(351)

Side by Side Diff: content/renderer/media/webrtc_local_audio_source_provider_unittest.cc

Issue 227743004: Added a kEchoCancellation constraint to turn off the audio processing. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: moved some of the constraints code to MediaAudioConstraints class, and hope it makes the code more … Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/logging.h" 5 #include "base/logging.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "content/renderer/media/mock_media_constraint_factory.h"
7 #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h" 8 #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h"
8 #include "content/renderer/media/webrtc_audio_capturer.h" 9 #include "content/renderer/media/webrtc_audio_capturer.h"
9 #include "content/renderer/media/webrtc_local_audio_source_provider.h" 10 #include "content/renderer/media/webrtc_local_audio_source_provider.h"
10 #include "content/renderer/media/webrtc_local_audio_track.h" 11 #include "content/renderer/media/webrtc_local_audio_track.h"
11 #include "media/audio/audio_parameters.h" 12 #include "media/audio/audio_parameters.h"
12 #include "media/base/audio_bus.h" 13 #include "media/base/audio_bus.h"
13 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
14 #include "third_party/WebKit/public/platform/WebMediaConstraints.h"
15 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" 15 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h"
16 16
17 namespace content { 17 namespace content {
18 18
19 class WebRtcLocalAudioSourceProviderTest : public testing::Test { 19 class WebRtcLocalAudioSourceProviderTest : public testing::Test {
20 protected: 20 protected:
21 virtual void SetUp() OVERRIDE { 21 virtual void SetUp() OVERRIDE {
22 source_params_.Reset(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, 22 source_params_.Reset(media::AudioParameters::AUDIO_PCM_LOW_LATENCY,
23 media::CHANNEL_LAYOUT_MONO, 1, 0, 48000, 16, 480); 23 media::CHANNEL_LAYOUT_MONO, 1, 0, 48000, 16, 480);
24 sink_params_.Reset( 24 sink_params_.Reset(
25 media::AudioParameters::AUDIO_PCM_LOW_LATENCY, 25 media::AudioParameters::AUDIO_PCM_LOW_LATENCY,
26 media::CHANNEL_LAYOUT_STEREO, 2, 0, 44100, 16, 26 media::CHANNEL_LAYOUT_STEREO, 2, 0, 44100, 16,
27 WebRtcLocalAudioSourceProvider::kWebAudioRenderBufferSize); 27 WebRtcLocalAudioSourceProvider::kWebAudioRenderBufferSize);
28 const int length = 28 const int length =
29 source_params_.frames_per_buffer() * source_params_.channels(); 29 source_params_.frames_per_buffer() * source_params_.channels();
30 source_data_.reset(new int16[length]); 30 source_data_.reset(new int16[length]);
31 sink_bus_ = media::AudioBus::Create(sink_params_); 31 sink_bus_ = media::AudioBus::Create(sink_params_);
32 blink::WebMediaConstraints constraints; 32 MockMediaConstraintFactory constraint_factory;
33 scoped_refptr<WebRtcAudioCapturer> capturer( 33 scoped_refptr<WebRtcAudioCapturer> capturer(
34 WebRtcAudioCapturer::CreateCapturer(-1, StreamDeviceInfo(), 34 WebRtcAudioCapturer::CreateCapturer(
35 constraints, NULL)); 35 -1, StreamDeviceInfo(),
36 constraint_factory.CreateWebMediaConstraints(), NULL));
36 scoped_refptr<WebRtcLocalAudioTrackAdapter> adapter( 37 scoped_refptr<WebRtcLocalAudioTrackAdapter> adapter(
37 WebRtcLocalAudioTrackAdapter::Create(std::string(), NULL)); 38 WebRtcLocalAudioTrackAdapter::Create(std::string(), NULL));
38 scoped_ptr<WebRtcLocalAudioTrack> native_track( 39 scoped_ptr<WebRtcLocalAudioTrack> native_track(
39 new WebRtcLocalAudioTrack(adapter, capturer, NULL)); 40 new WebRtcLocalAudioTrack(adapter, capturer, NULL));
40 blink::WebMediaStreamSource audio_source; 41 blink::WebMediaStreamSource audio_source;
41 audio_source.initialize(base::UTF8ToUTF16("dummy_source_id"), 42 audio_source.initialize(base::UTF8ToUTF16("dummy_source_id"),
42 blink::WebMediaStreamSource::TypeAudio, 43 blink::WebMediaStreamSource::TypeAudio,
43 base::UTF8ToUTF16("dummy_source_name")); 44 base::UTF8ToUTF16("dummy_source_name"));
44 blink_track_.initialize(blink::WebString::fromUTF8("audio_track"), 45 blink_track_.initialize(blink::WebString::fromUTF8("audio_track"),
45 audio_source); 46 audio_source);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 // Stop the audio track. 129 // Stop the audio track.
129 WebRtcLocalAudioTrack* native_track = static_cast<WebRtcLocalAudioTrack*>( 130 WebRtcLocalAudioTrack* native_track = static_cast<WebRtcLocalAudioTrack*>(
130 MediaStreamTrack::GetTrack(blink_track_)); 131 MediaStreamTrack::GetTrack(blink_track_));
131 native_track->Stop(); 132 native_track->Stop();
132 133
133 // Delete the source provider. 134 // Delete the source provider.
134 source_provider_.reset(); 135 source_provider_.reset();
135 } 136 }
136 137
137 } // namespace content 138 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698