OLD | NEW |
---|---|
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/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/logging.h" | 6 #include "base/logging.h" |
7 #include "content/public/common/content_switches.h" | 7 #include "content/public/common/content_switches.h" |
8 #include "content/renderer/media/mock_media_constraint_factory.h" | 8 #include "content/renderer/media/mock_media_constraint_factory.h" |
9 #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h" | 9 #include "content/renderer/media/webrtc/webrtc_local_audio_track_adapter.h" |
10 #include "content/renderer/media/webrtc_audio_capturer.h" | 10 #include "content/renderer/media/webrtc_audio_capturer.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
70 }; | 70 }; |
71 | 71 |
72 } // namespace | 72 } // namespace |
73 | 73 |
74 class WebRtcAudioCapturerTest : public testing::Test { | 74 class WebRtcAudioCapturerTest : public testing::Test { |
75 protected: | 75 protected: |
76 WebRtcAudioCapturerTest() | 76 WebRtcAudioCapturerTest() |
77 #if defined(OS_ANDROID) | 77 #if defined(OS_ANDROID) |
78 : params_(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, | 78 : params_(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, |
79 media::CHANNEL_LAYOUT_STEREO, 48000, 16, 960) { | 79 media::CHANNEL_LAYOUT_STEREO, 48000, 16, 960) { |
80 // Android works with a buffer size bigger than 20ms. | 80 // Android works with a buffer size bigger than 20ms. |
ajm
2014/08/14 03:33:05
Android using 20ms frames.
| |
81 #else | 81 #else |
82 : params_(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, | 82 : params_(media::AudioParameters::AUDIO_PCM_LOW_LATENCY, |
83 media::CHANNEL_LAYOUT_STEREO, 48000, 16, 128) { | 83 media::CHANNEL_LAYOUT_STEREO, 48000, 16, 128) { |
84 #endif | 84 #endif |
85 } | 85 } |
86 | 86 |
87 void DisableAudioTrackProcessing() { | 87 void DisableAudioTrackProcessing() { |
88 CommandLine::ForCurrentProcess()->AppendSwitch( | 88 CommandLine::ForCurrentProcess()->AppendSwitch( |
89 switches::kDisableAudioTrackProcessing); | 89 switches::kDisableAudioTrackProcessing); |
90 } | 90 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
123 scoped_ptr<media::AudioBus> audio_bus = media::AudioBus::Create(params_); | 123 scoped_ptr<media::AudioBus> audio_bus = media::AudioBus::Create(params_); |
124 audio_bus->Zero(); | 124 audio_bus->Zero(); |
125 | 125 |
126 media::AudioCapturerSource::CaptureCallback* callback = | 126 media::AudioCapturerSource::CaptureCallback* callback = |
127 static_cast<media::AudioCapturerSource::CaptureCallback*>(capturer_); | 127 static_cast<media::AudioCapturerSource::CaptureCallback*>(capturer_); |
128 | 128 |
129 // Verify the sink is getting the correct values. | 129 // Verify the sink is getting the correct values. |
130 EXPECT_CALL(*sink, FormatIsSet()); | 130 EXPECT_CALL(*sink, FormatIsSet()); |
131 EXPECT_CALL(*sink, | 131 EXPECT_CALL(*sink, |
132 OnDataCallback(_, _, delay_ms, expected_volume_value, | 132 OnDataCallback(_, _, delay_ms, expected_volume_value, |
133 need_audio_processing, key_pressed)); | 133 need_audio_processing, key_pressed)) |
134 .Times(AtLeast(1)); | |
ajm
2014/08/14 03:33:05
The error is that this was getting called more tha
| |
134 callback->Capture(audio_bus.get(), delay_ms, volume, key_pressed); | 135 callback->Capture(audio_bus.get(), delay_ms, volume, key_pressed); |
135 | 136 |
136 // Verify the cached values in the capturer fits what we expect. | 137 // Verify the cached values in the capturer fits what we expect. |
137 base::TimeDelta cached_delay; | 138 base::TimeDelta cached_delay; |
138 int cached_volume = !expected_volume_value; | 139 int cached_volume = !expected_volume_value; |
139 bool cached_key_pressed = !key_pressed; | 140 bool cached_key_pressed = !key_pressed; |
140 capturer_->GetAudioProcessingParams(&cached_delay, &cached_volume, | 141 capturer_->GetAudioProcessingParams(&cached_delay, &cached_volume, |
141 &cached_key_pressed); | 142 &cached_key_pressed); |
142 EXPECT_EQ(cached_delay.InMilliseconds(), delay_ms); | 143 EXPECT_EQ(cached_delay.InMilliseconds(), delay_ms); |
143 EXPECT_EQ(cached_volume, expected_volume_value); | 144 EXPECT_EQ(cached_volume, expected_volume_value); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
182 "", "", params_.sample_rate(), | 183 "", "", params_.sample_rate(), |
183 params_.channel_layout(), | 184 params_.channel_layout(), |
184 params_.frames_per_buffer()), | 185 params_.frames_per_buffer()), |
185 constraint_factory.CreateWebMediaConstraints(), NULL, NULL) | 186 constraint_factory.CreateWebMediaConstraints(), NULL, NULL) |
186 ); | 187 ); |
187 EXPECT_TRUE(capturer == NULL); | 188 EXPECT_TRUE(capturer == NULL); |
188 } | 189 } |
189 | 190 |
190 | 191 |
191 } // namespace content | 192 } // namespace content |
OLD | NEW |