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

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

Issue 37793005: move the APM to chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: added a switch, it uses the APM in WebRtc if the switch is off, otherwise use the APM in Chrome. Created 7 years, 1 month 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 | Annotate | Revision Log
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 "content/renderer/media/webrtc_local_audio_source_provider.h" 6 #include "content/renderer/media/webrtc_local_audio_source_provider.h"
7 #include "media/audio/audio_parameters.h" 7 #include "media/audio/audio_parameters.h"
8 #include "media/base/audio_bus.h" 8 #include "media/base/audio_bus.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 i += sink_params_.frames_per_buffer()) { 76 i += sink_params_.frames_per_buffer()) {
77 sink_bus_->Zero(); 77 sink_bus_->Zero();
78 source_provider_->provideInput(audio_data, 78 source_provider_->provideInput(audio_data,
79 sink_params_.frames_per_buffer()); 79 sink_params_.frames_per_buffer());
80 EXPECT_GT(sink_bus_->channel(0)[0], 0); 80 EXPECT_GT(sink_bus_->channel(0)[0], 0);
81 EXPECT_GT(sink_bus_->channel(1)[0], 0); 81 EXPECT_GT(sink_bus_->channel(1)[0], 0);
82 EXPECT_DOUBLE_EQ(sink_bus_->channel(0)[0], sink_bus_->channel(1)[0]); 82 EXPECT_DOUBLE_EQ(sink_bus_->channel(0)[0], sink_bus_->channel(1)[0]);
83 } 83 }
84 } 84 }
85 85
86 TEST_F(WebRtcLocalAudioSourceProviderTest, VerifyAudioProcessingParams) {
87 // Point the WebVector into memory owned by |sink_bus_|.
88 WebKit::WebVector<float*> audio_data(
89 static_cast<size_t>(sink_bus_->channels()));
90 for (size_t i = 0; i < audio_data.size(); ++i)
91 audio_data[i] = sink_bus_->channel(i);
92
93 // Enable the source provider.
94 source_provider_->provideInput(audio_data, sink_params_.frames_per_buffer());
95
96 // Deliver data to |source_provider_| with audio processing params.
97 int source_delay = 5;
98 int source_volume = 255;
99 bool source_key_pressed = true;
100 source_provider_->DeliverData(source_bus_.get(), source_delay,
101 source_volume, source_key_pressed);
102
103 int delay = 0, volume = 0;
104 bool key_pressed = false;
105 source_provider_->GetAudioProcessingParams(&delay, &volume, &key_pressed);
106 EXPECT_EQ(volume, source_volume);
107 EXPECT_EQ(key_pressed, source_key_pressed);
108 int expected_delay = source_delay + static_cast<int>(
109 source_bus_->frames() / source_params_.sample_rate() + 0.5);
110 EXPECT_GE(delay, expected_delay);
111
112 // Sleep a few ms to simulate processing time. This should increase the delay
113 // value as time passes.
114 int cached_delay = delay;
115 const int kSleepMs = 10;
116 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(kSleepMs));
117 source_provider_->GetAudioProcessingParams(&delay, &volume, &key_pressed);
118 EXPECT_GT(delay, cached_delay);
119 }
120
121 } // namespace content 86 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698