henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1 | /* |
kjellander | b24317b | 2016-02-10 07:54:43 -0800 | [diff] [blame] | 2 | * Copyright 2012 The WebRTC project authors. All Rights Reserved. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3 | * |
kjellander | b24317b | 2016-02-10 07:54:43 -0800 | [diff] [blame] | 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 9 | */ |
| 10 | |
ossu | 7bb87ee | 2017-01-23 04:56:25 -0800 | [diff] [blame] | 11 | #include "webrtc/pc/test/fakeaudiocapturemodule.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 12 | |
Edward Lemur | c20978e | 2017-07-06 19:44:34 +0200 | [diff] [blame] | 13 | #include "webrtc/rtc_base/checks.h" |
| 14 | #include "webrtc/rtc_base/refcount.h" |
| 15 | #include "webrtc/rtc_base/thread.h" |
| 16 | #include "webrtc/rtc_base/timeutils.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 17 | |
| 18 | // Audio sample value that is high enough that it doesn't occur naturally when |
| 19 | // frames are being faked. E.g. NetEq will not generate this large sample value |
| 20 | // unless it has received an audio frame containing a sample of this value. |
| 21 | // Even simpler buffers would likely just contain audio sample values of 0. |
| 22 | static const int kHighSampleValue = 10000; |
| 23 | |
| 24 | // Same value as src/modules/audio_device/main/source/audio_device_config.h in |
| 25 | // https://code.google.com/p/webrtc/ |
Honghai Zhang | 82d7862 | 2016-05-06 11:29:15 -0700 | [diff] [blame] | 26 | static const int kAdmMaxIdleTimeProcess = 1000; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 27 | |
| 28 | // Constants here are derived by running VoE using a real ADM. |
| 29 | // The constants correspond to 10ms of mono audio at 44kHz. |
| 30 | static const int kTimePerFrameMs = 10; |
Peter Kasting | b7e5054 | 2015-06-11 12:55:50 -0700 | [diff] [blame] | 31 | static const uint8_t kNumberOfChannels = 1; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 32 | static const int kSamplesPerSecond = 44000; |
| 33 | static const int kTotalDelayMs = 0; |
| 34 | static const int kClockDriftMs = 0; |
| 35 | static const uint32_t kMaxVolume = 14392; |
| 36 | |
| 37 | enum { |
wu@webrtc.org | 8804a29 | 2013-10-22 23:09:20 +0000 | [diff] [blame] | 38 | MSG_START_PROCESS, |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 39 | MSG_RUN_PROCESS, |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 40 | }; |
| 41 | |
deadbeef | ee8c6d3 | 2015-08-13 14:27:18 -0700 | [diff] [blame] | 42 | FakeAudioCaptureModule::FakeAudioCaptureModule() |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 43 | : last_process_time_ms_(0), |
deadbeef | ee8c6d3 | 2015-08-13 14:27:18 -0700 | [diff] [blame] | 44 | audio_callback_(nullptr), |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 45 | recording_(false), |
| 46 | playing_(false), |
| 47 | play_is_initialized_(false), |
| 48 | rec_is_initialized_(false), |
| 49 | current_mic_level_(kMaxVolume), |
| 50 | started_(false), |
| 51 | next_frame_time_(0), |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 52 | frames_received_(0) { |
| 53 | } |
| 54 | |
| 55 | FakeAudioCaptureModule::~FakeAudioCaptureModule() { |
deadbeef | ee8c6d3 | 2015-08-13 14:27:18 -0700 | [diff] [blame] | 56 | if (process_thread_) { |
| 57 | process_thread_->Stop(); |
| 58 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 59 | } |
| 60 | |
deadbeef | ee8c6d3 | 2015-08-13 14:27:18 -0700 | [diff] [blame] | 61 | rtc::scoped_refptr<FakeAudioCaptureModule> FakeAudioCaptureModule::Create() { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 62 | rtc::scoped_refptr<FakeAudioCaptureModule> capture_module( |
deadbeef | ee8c6d3 | 2015-08-13 14:27:18 -0700 | [diff] [blame] | 63 | new rtc::RefCountedObject<FakeAudioCaptureModule>()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 64 | if (!capture_module->Initialize()) { |
deadbeef | ee8c6d3 | 2015-08-13 14:27:18 -0700 | [diff] [blame] | 65 | return nullptr; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 66 | } |
| 67 | return capture_module; |
| 68 | } |
| 69 | |
| 70 | int FakeAudioCaptureModule::frames_received() const { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 71 | rtc::CritScope cs(&crit_); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 72 | return frames_received_; |
| 73 | } |
| 74 | |
pkasting@chromium.org | 0b1534c | 2014-12-15 22:09:40 +0000 | [diff] [blame] | 75 | int64_t FakeAudioCaptureModule::TimeUntilNextProcess() { |
Honghai Zhang | 82d7862 | 2016-05-06 11:29:15 -0700 | [diff] [blame] | 76 | const int64_t current_time = rtc::TimeMillis(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 77 | if (current_time < last_process_time_ms_) { |
| 78 | // TODO: wraparound could be handled more gracefully. |
| 79 | return 0; |
| 80 | } |
Honghai Zhang | 82d7862 | 2016-05-06 11:29:15 -0700 | [diff] [blame] | 81 | const int64_t elapsed_time = current_time - last_process_time_ms_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 82 | if (kAdmMaxIdleTimeProcess < elapsed_time) { |
| 83 | return 0; |
| 84 | } |
| 85 | return kAdmMaxIdleTimeProcess - elapsed_time; |
| 86 | } |
| 87 | |
pbos | a26ac92 | 2016-02-25 04:50:01 -0800 | [diff] [blame] | 88 | void FakeAudioCaptureModule::Process() { |
Honghai Zhang | 82d7862 | 2016-05-06 11:29:15 -0700 | [diff] [blame] | 89 | last_process_time_ms_ = rtc::TimeMillis(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 90 | } |
| 91 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 92 | int32_t FakeAudioCaptureModule::ActiveAudioLayer( |
| 93 | AudioLayer* /*audio_layer*/) const { |
nisse | c80e741 | 2017-01-11 05:56:46 -0800 | [diff] [blame] | 94 | RTC_NOTREACHED(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 95 | return 0; |
| 96 | } |
| 97 | |
| 98 | webrtc::AudioDeviceModule::ErrorCode FakeAudioCaptureModule::LastError() const { |
nisse | c80e741 | 2017-01-11 05:56:46 -0800 | [diff] [blame] | 99 | RTC_NOTREACHED(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 100 | return webrtc::AudioDeviceModule::kAdmErrNone; |
| 101 | } |
| 102 | |
| 103 | int32_t FakeAudioCaptureModule::RegisterEventObserver( |
| 104 | webrtc::AudioDeviceObserver* /*event_callback*/) { |
| 105 | // Only used to report warnings and errors. This fake implementation won't |
| 106 | // generate any so discard this callback. |
| 107 | return 0; |
| 108 | } |
| 109 | |
| 110 | int32_t FakeAudioCaptureModule::RegisterAudioCallback( |
| 111 | webrtc::AudioTransport* audio_callback) { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 112 | rtc::CritScope cs(&crit_callback_); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 113 | audio_callback_ = audio_callback; |
| 114 | return 0; |
| 115 | } |
| 116 | |
| 117 | int32_t FakeAudioCaptureModule::Init() { |
| 118 | // Initialize is called by the factory method. Safe to ignore this Init call. |
| 119 | return 0; |
| 120 | } |
| 121 | |
| 122 | int32_t FakeAudioCaptureModule::Terminate() { |
| 123 | // Clean up in the destructor. No action here, just success. |
| 124 | return 0; |
| 125 | } |
| 126 | |
| 127 | bool FakeAudioCaptureModule::Initialized() const { |
nisse | c80e741 | 2017-01-11 05:56:46 -0800 | [diff] [blame] | 128 | RTC_NOTREACHED(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 129 | return 0; |
| 130 | } |
| 131 | |
| 132 | int16_t FakeAudioCaptureModule::PlayoutDevices() { |
nisse | c80e741 | 2017-01-11 05:56:46 -0800 | [diff] [blame] | 133 | RTC_NOTREACHED(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 134 | return 0; |
| 135 | } |
| 136 | |
| 137 | int16_t FakeAudioCaptureModule::RecordingDevices() { |
nisse | c80e741 | 2017-01-11 05:56:46 -0800 | [diff] [blame] | 138 | RTC_NOTREACHED(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 139 | return 0; |
| 140 | } |
| 141 | |
| 142 | int32_t FakeAudioCaptureModule::PlayoutDeviceName( |
| 143 | uint16_t /*index*/, |
| 144 | char /*name*/[webrtc::kAdmMaxDeviceNameSize], |
| 145 | char /*guid*/[webrtc::kAdmMaxGuidSize]) { |
nisse | c80e741 | 2017-01-11 05:56:46 -0800 | [diff] [blame] | 146 | RTC_NOTREACHED(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 147 | return 0; |
| 148 | } |
| 149 | |
| 150 | int32_t FakeAudioCaptureModule::RecordingDeviceName( |
| 151 | uint16_t /*index*/, |
| 152 | char /*name*/[webrtc::kAdmMaxDeviceNameSize], |
| 153 | char /*guid*/[webrtc::kAdmMaxGuidSize]) { |
nisse | c80e741 | 2017-01-11 05:56:46 -0800 | [diff] [blame] | 154 | RTC_NOTREACHED(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 155 | return 0; |
| 156 | } |
| 157 | |
| 158 | int32_t FakeAudioCaptureModule::SetPlayoutDevice(uint16_t /*index*/) { |
| 159 | // No playout device, just playing from file. Return success. |
| 160 | return 0; |
| 161 | } |
| 162 | |
| 163 | int32_t FakeAudioCaptureModule::SetPlayoutDevice(WindowsDeviceType /*device*/) { |
| 164 | if (play_is_initialized_) { |
| 165 | return -1; |
| 166 | } |
| 167 | return 0; |
| 168 | } |
| 169 | |
| 170 | int32_t FakeAudioCaptureModule::SetRecordingDevice(uint16_t /*index*/) { |
| 171 | // No recording device, just dropping audio. Return success. |
| 172 | return 0; |
| 173 | } |
| 174 | |
| 175 | int32_t FakeAudioCaptureModule::SetRecordingDevice( |
| 176 | WindowsDeviceType /*device*/) { |
| 177 | if (rec_is_initialized_) { |
| 178 | return -1; |
| 179 | } |
| 180 | return 0; |
| 181 | } |
| 182 | |
| 183 | int32_t FakeAudioCaptureModule::PlayoutIsAvailable(bool* /*available*/) { |
nisse | c80e741 | 2017-01-11 05:56:46 -0800 | [diff] [blame] | 184 | RTC_NOTREACHED(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 185 | return 0; |
| 186 | } |
| 187 | |
| 188 | int32_t FakeAudioCaptureModule::InitPlayout() { |
| 189 | play_is_initialized_ = true; |
| 190 | return 0; |
| 191 | } |
| 192 | |
| 193 | bool FakeAudioCaptureModule::PlayoutIsInitialized() const { |
| 194 | return play_is_initialized_; |
| 195 | } |
| 196 | |
| 197 | int32_t FakeAudioCaptureModule::RecordingIsAvailable(bool* /*available*/) { |
nisse | c80e741 | 2017-01-11 05:56:46 -0800 | [diff] [blame] | 198 | RTC_NOTREACHED(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 199 | return 0; |
| 200 | } |
| 201 | |
| 202 | int32_t FakeAudioCaptureModule::InitRecording() { |
| 203 | rec_is_initialized_ = true; |
| 204 | return 0; |
| 205 | } |
| 206 | |
| 207 | bool FakeAudioCaptureModule::RecordingIsInitialized() const { |
solenberg | d53a3f9 | 2016-04-14 13:56:37 -0700 | [diff] [blame] | 208 | return rec_is_initialized_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 209 | } |
| 210 | |
| 211 | int32_t FakeAudioCaptureModule::StartPlayout() { |
| 212 | if (!play_is_initialized_) { |
| 213 | return -1; |
| 214 | } |
wu@webrtc.org | 8804a29 | 2013-10-22 23:09:20 +0000 | [diff] [blame] | 215 | { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 216 | rtc::CritScope cs(&crit_); |
wu@webrtc.org | 8804a29 | 2013-10-22 23:09:20 +0000 | [diff] [blame] | 217 | playing_ = true; |
| 218 | } |
| 219 | bool start = true; |
| 220 | UpdateProcessing(start); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 221 | return 0; |
| 222 | } |
| 223 | |
| 224 | int32_t FakeAudioCaptureModule::StopPlayout() { |
wu@webrtc.org | 8804a29 | 2013-10-22 23:09:20 +0000 | [diff] [blame] | 225 | bool start = false; |
| 226 | { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 227 | rtc::CritScope cs(&crit_); |
wu@webrtc.org | 8804a29 | 2013-10-22 23:09:20 +0000 | [diff] [blame] | 228 | playing_ = false; |
| 229 | start = ShouldStartProcessing(); |
| 230 | } |
| 231 | UpdateProcessing(start); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 232 | return 0; |
| 233 | } |
| 234 | |
| 235 | bool FakeAudioCaptureModule::Playing() const { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 236 | rtc::CritScope cs(&crit_); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 237 | return playing_; |
| 238 | } |
| 239 | |
| 240 | int32_t FakeAudioCaptureModule::StartRecording() { |
| 241 | if (!rec_is_initialized_) { |
| 242 | return -1; |
| 243 | } |
wu@webrtc.org | 8804a29 | 2013-10-22 23:09:20 +0000 | [diff] [blame] | 244 | { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 245 | rtc::CritScope cs(&crit_); |
wu@webrtc.org | 8804a29 | 2013-10-22 23:09:20 +0000 | [diff] [blame] | 246 | recording_ = true; |
| 247 | } |
| 248 | bool start = true; |
| 249 | UpdateProcessing(start); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 250 | return 0; |
| 251 | } |
| 252 | |
| 253 | int32_t FakeAudioCaptureModule::StopRecording() { |
wu@webrtc.org | 8804a29 | 2013-10-22 23:09:20 +0000 | [diff] [blame] | 254 | bool start = false; |
| 255 | { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 256 | rtc::CritScope cs(&crit_); |
wu@webrtc.org | 8804a29 | 2013-10-22 23:09:20 +0000 | [diff] [blame] | 257 | recording_ = false; |
| 258 | start = ShouldStartProcessing(); |
| 259 | } |
| 260 | UpdateProcessing(start); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 261 | return 0; |
| 262 | } |
| 263 | |
| 264 | bool FakeAudioCaptureModule::Recording() const { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 265 | rtc::CritScope cs(&crit_); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 266 | return recording_; |
| 267 | } |
| 268 | |
| 269 | int32_t FakeAudioCaptureModule::SetAGC(bool /*enable*/) { |
| 270 | // No AGC but not needed since audio is pregenerated. Return success. |
| 271 | return 0; |
| 272 | } |
| 273 | |
| 274 | bool FakeAudioCaptureModule::AGC() const { |
nisse | c80e741 | 2017-01-11 05:56:46 -0800 | [diff] [blame] | 275 | RTC_NOTREACHED(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 276 | return 0; |
| 277 | } |
| 278 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 279 | int32_t FakeAudioCaptureModule::InitSpeaker() { |
| 280 | // No speaker, just playing from file. Return success. |
| 281 | return 0; |
| 282 | } |
| 283 | |
| 284 | bool FakeAudioCaptureModule::SpeakerIsInitialized() const { |
nisse | c80e741 | 2017-01-11 05:56:46 -0800 | [diff] [blame] | 285 | RTC_NOTREACHED(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 286 | return 0; |
| 287 | } |
| 288 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 289 | int32_t FakeAudioCaptureModule::InitMicrophone() { |
| 290 | // No microphone, just playing from file. Return success. |
| 291 | return 0; |
| 292 | } |
| 293 | |
| 294 | bool FakeAudioCaptureModule::MicrophoneIsInitialized() const { |
nisse | c80e741 | 2017-01-11 05:56:46 -0800 | [diff] [blame] | 295 | RTC_NOTREACHED(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 296 | return 0; |
| 297 | } |
| 298 | |
| 299 | int32_t FakeAudioCaptureModule::SpeakerVolumeIsAvailable(bool* /*available*/) { |
nisse | c80e741 | 2017-01-11 05:56:46 -0800 | [diff] [blame] | 300 | RTC_NOTREACHED(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 301 | return 0; |
| 302 | } |
| 303 | |
| 304 | int32_t FakeAudioCaptureModule::SetSpeakerVolume(uint32_t /*volume*/) { |
nisse | c80e741 | 2017-01-11 05:56:46 -0800 | [diff] [blame] | 305 | RTC_NOTREACHED(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 306 | return 0; |
| 307 | } |
| 308 | |
| 309 | int32_t FakeAudioCaptureModule::SpeakerVolume(uint32_t* /*volume*/) const { |
nisse | c80e741 | 2017-01-11 05:56:46 -0800 | [diff] [blame] | 310 | RTC_NOTREACHED(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 311 | return 0; |
| 312 | } |
| 313 | |
| 314 | int32_t FakeAudioCaptureModule::MaxSpeakerVolume( |
| 315 | uint32_t* /*max_volume*/) const { |
nisse | c80e741 | 2017-01-11 05:56:46 -0800 | [diff] [blame] | 316 | RTC_NOTREACHED(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 317 | return 0; |
| 318 | } |
| 319 | |
| 320 | int32_t FakeAudioCaptureModule::MinSpeakerVolume( |
| 321 | uint32_t* /*min_volume*/) const { |
nisse | c80e741 | 2017-01-11 05:56:46 -0800 | [diff] [blame] | 322 | RTC_NOTREACHED(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 323 | return 0; |
| 324 | } |
| 325 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 326 | int32_t FakeAudioCaptureModule::MicrophoneVolumeIsAvailable( |
| 327 | bool* /*available*/) { |
nisse | c80e741 | 2017-01-11 05:56:46 -0800 | [diff] [blame] | 328 | RTC_NOTREACHED(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 329 | return 0; |
| 330 | } |
| 331 | |
wu@webrtc.org | 8804a29 | 2013-10-22 23:09:20 +0000 | [diff] [blame] | 332 | int32_t FakeAudioCaptureModule::SetMicrophoneVolume(uint32_t volume) { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 333 | rtc::CritScope cs(&crit_); |
wu@webrtc.org | 8804a29 | 2013-10-22 23:09:20 +0000 | [diff] [blame] | 334 | current_mic_level_ = volume; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 335 | return 0; |
| 336 | } |
| 337 | |
| 338 | int32_t FakeAudioCaptureModule::MicrophoneVolume(uint32_t* volume) const { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 339 | rtc::CritScope cs(&crit_); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 340 | *volume = current_mic_level_; |
| 341 | return 0; |
| 342 | } |
| 343 | |
| 344 | int32_t FakeAudioCaptureModule::MaxMicrophoneVolume( |
| 345 | uint32_t* max_volume) const { |
| 346 | *max_volume = kMaxVolume; |
| 347 | return 0; |
| 348 | } |
| 349 | |
| 350 | int32_t FakeAudioCaptureModule::MinMicrophoneVolume( |
| 351 | uint32_t* /*min_volume*/) const { |
nisse | c80e741 | 2017-01-11 05:56:46 -0800 | [diff] [blame] | 352 | RTC_NOTREACHED(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 353 | return 0; |
| 354 | } |
| 355 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 356 | int32_t FakeAudioCaptureModule::SpeakerMuteIsAvailable(bool* /*available*/) { |
nisse | c80e741 | 2017-01-11 05:56:46 -0800 | [diff] [blame] | 357 | RTC_NOTREACHED(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 358 | return 0; |
| 359 | } |
| 360 | |
| 361 | int32_t FakeAudioCaptureModule::SetSpeakerMute(bool /*enable*/) { |
nisse | c80e741 | 2017-01-11 05:56:46 -0800 | [diff] [blame] | 362 | RTC_NOTREACHED(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 363 | return 0; |
| 364 | } |
| 365 | |
| 366 | int32_t FakeAudioCaptureModule::SpeakerMute(bool* /*enabled*/) const { |
nisse | c80e741 | 2017-01-11 05:56:46 -0800 | [diff] [blame] | 367 | RTC_NOTREACHED(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 368 | return 0; |
| 369 | } |
| 370 | |
| 371 | int32_t FakeAudioCaptureModule::MicrophoneMuteIsAvailable(bool* /*available*/) { |
nisse | c80e741 | 2017-01-11 05:56:46 -0800 | [diff] [blame] | 372 | RTC_NOTREACHED(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 373 | return 0; |
| 374 | } |
| 375 | |
| 376 | int32_t FakeAudioCaptureModule::SetMicrophoneMute(bool /*enable*/) { |
nisse | c80e741 | 2017-01-11 05:56:46 -0800 | [diff] [blame] | 377 | RTC_NOTREACHED(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 378 | return 0; |
| 379 | } |
| 380 | |
| 381 | int32_t FakeAudioCaptureModule::MicrophoneMute(bool* /*enabled*/) const { |
nisse | c80e741 | 2017-01-11 05:56:46 -0800 | [diff] [blame] | 382 | RTC_NOTREACHED(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 383 | return 0; |
| 384 | } |
| 385 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 386 | int32_t FakeAudioCaptureModule::StereoPlayoutIsAvailable( |
| 387 | bool* available) const { |
| 388 | // No recording device, just dropping audio. Stereo can be dropped just |
| 389 | // as easily as mono. |
| 390 | *available = true; |
| 391 | return 0; |
| 392 | } |
| 393 | |
| 394 | int32_t FakeAudioCaptureModule::SetStereoPlayout(bool /*enable*/) { |
| 395 | // No recording device, just dropping audio. Stereo can be dropped just |
| 396 | // as easily as mono. |
| 397 | return 0; |
| 398 | } |
| 399 | |
| 400 | int32_t FakeAudioCaptureModule::StereoPlayout(bool* /*enabled*/) const { |
nisse | c80e741 | 2017-01-11 05:56:46 -0800 | [diff] [blame] | 401 | RTC_NOTREACHED(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 402 | return 0; |
| 403 | } |
| 404 | |
| 405 | int32_t FakeAudioCaptureModule::StereoRecordingIsAvailable( |
| 406 | bool* available) const { |
| 407 | // Keep thing simple. No stereo recording. |
| 408 | *available = false; |
| 409 | return 0; |
| 410 | } |
| 411 | |
| 412 | int32_t FakeAudioCaptureModule::SetStereoRecording(bool enable) { |
| 413 | if (!enable) { |
| 414 | return 0; |
| 415 | } |
| 416 | return -1; |
| 417 | } |
| 418 | |
| 419 | int32_t FakeAudioCaptureModule::StereoRecording(bool* /*enabled*/) const { |
nisse | c80e741 | 2017-01-11 05:56:46 -0800 | [diff] [blame] | 420 | RTC_NOTREACHED(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 421 | return 0; |
| 422 | } |
| 423 | |
| 424 | int32_t FakeAudioCaptureModule::SetRecordingChannel( |
| 425 | const ChannelType channel) { |
| 426 | if (channel != AudioDeviceModule::kChannelBoth) { |
| 427 | // There is no right or left in mono. I.e. kChannelBoth should be used for |
| 428 | // mono. |
nisse | c80e741 | 2017-01-11 05:56:46 -0800 | [diff] [blame] | 429 | RTC_NOTREACHED(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 430 | return -1; |
| 431 | } |
| 432 | return 0; |
| 433 | } |
| 434 | |
| 435 | int32_t FakeAudioCaptureModule::RecordingChannel(ChannelType* channel) const { |
| 436 | // Stereo recording not supported. However, WebRTC ADM returns kChannelBoth |
| 437 | // in that case. Do the same here. |
| 438 | *channel = AudioDeviceModule::kChannelBoth; |
| 439 | return 0; |
| 440 | } |
| 441 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 442 | int32_t FakeAudioCaptureModule::PlayoutDelay(uint16_t* delay_ms) const { |
| 443 | // No delay since audio frames are dropped. |
| 444 | *delay_ms = 0; |
| 445 | return 0; |
| 446 | } |
| 447 | |
| 448 | int32_t FakeAudioCaptureModule::RecordingDelay(uint16_t* /*delay_ms*/) const { |
nisse | c80e741 | 2017-01-11 05:56:46 -0800 | [diff] [blame] | 449 | RTC_NOTREACHED(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 450 | return 0; |
| 451 | } |
| 452 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 453 | int32_t FakeAudioCaptureModule::SetRecordingSampleRate( |
| 454 | const uint32_t /*samples_per_sec*/) { |
nisse | c80e741 | 2017-01-11 05:56:46 -0800 | [diff] [blame] | 455 | RTC_NOTREACHED(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 456 | return 0; |
| 457 | } |
| 458 | |
| 459 | int32_t FakeAudioCaptureModule::RecordingSampleRate( |
| 460 | uint32_t* /*samples_per_sec*/) const { |
nisse | c80e741 | 2017-01-11 05:56:46 -0800 | [diff] [blame] | 461 | RTC_NOTREACHED(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 462 | return 0; |
| 463 | } |
| 464 | |
| 465 | int32_t FakeAudioCaptureModule::SetPlayoutSampleRate( |
| 466 | const uint32_t /*samples_per_sec*/) { |
nisse | c80e741 | 2017-01-11 05:56:46 -0800 | [diff] [blame] | 467 | RTC_NOTREACHED(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 468 | return 0; |
| 469 | } |
| 470 | |
| 471 | int32_t FakeAudioCaptureModule::PlayoutSampleRate( |
| 472 | uint32_t* /*samples_per_sec*/) const { |
nisse | c80e741 | 2017-01-11 05:56:46 -0800 | [diff] [blame] | 473 | RTC_NOTREACHED(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 474 | return 0; |
| 475 | } |
| 476 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 477 | int32_t FakeAudioCaptureModule::SetLoudspeakerStatus(bool /*enable*/) { |
nisse | c80e741 | 2017-01-11 05:56:46 -0800 | [diff] [blame] | 478 | RTC_NOTREACHED(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 479 | return 0; |
| 480 | } |
| 481 | |
| 482 | int32_t FakeAudioCaptureModule::GetLoudspeakerStatus(bool* /*enabled*/) const { |
nisse | c80e741 | 2017-01-11 05:56:46 -0800 | [diff] [blame] | 483 | RTC_NOTREACHED(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 484 | return 0; |
| 485 | } |
| 486 | |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 487 | void FakeAudioCaptureModule::OnMessage(rtc::Message* msg) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 488 | switch (msg->message_id) { |
wu@webrtc.org | 8804a29 | 2013-10-22 23:09:20 +0000 | [diff] [blame] | 489 | case MSG_START_PROCESS: |
| 490 | StartProcessP(); |
| 491 | break; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 492 | case MSG_RUN_PROCESS: |
| 493 | ProcessFrameP(); |
| 494 | break; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 495 | default: |
| 496 | // All existing messages should be caught. Getting here should never |
| 497 | // happen. |
nisse | c80e741 | 2017-01-11 05:56:46 -0800 | [diff] [blame] | 498 | RTC_NOTREACHED(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 499 | } |
| 500 | } |
| 501 | |
| 502 | bool FakeAudioCaptureModule::Initialize() { |
| 503 | // Set the send buffer samples high enough that it would not occur on the |
| 504 | // remote side unless a packet containing a sample of that magnitude has been |
| 505 | // sent to it. Note that the audio processing pipeline will likely distort the |
| 506 | // original signal. |
| 507 | SetSendBuffer(kHighSampleValue); |
Honghai Zhang | 82d7862 | 2016-05-06 11:29:15 -0700 | [diff] [blame] | 508 | last_process_time_ms_ = rtc::TimeMillis(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 509 | return true; |
| 510 | } |
| 511 | |
| 512 | void FakeAudioCaptureModule::SetSendBuffer(int value) { |
| 513 | Sample* buffer_ptr = reinterpret_cast<Sample*>(send_buffer_); |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 514 | const size_t buffer_size_in_samples = |
Peter Kasting | 728d903 | 2015-06-11 14:31:38 -0700 | [diff] [blame] | 515 | sizeof(send_buffer_) / kNumberBytesPerSample; |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 516 | for (size_t i = 0; i < buffer_size_in_samples; ++i) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 517 | buffer_ptr[i] = value; |
| 518 | } |
| 519 | } |
| 520 | |
| 521 | void FakeAudioCaptureModule::ResetRecBuffer() { |
| 522 | memset(rec_buffer_, 0, sizeof(rec_buffer_)); |
| 523 | } |
| 524 | |
| 525 | bool FakeAudioCaptureModule::CheckRecBuffer(int value) { |
| 526 | const Sample* buffer_ptr = reinterpret_cast<const Sample*>(rec_buffer_); |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 527 | const size_t buffer_size_in_samples = |
Peter Kasting | 728d903 | 2015-06-11 14:31:38 -0700 | [diff] [blame] | 528 | sizeof(rec_buffer_) / kNumberBytesPerSample; |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 529 | for (size_t i = 0; i < buffer_size_in_samples; ++i) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 530 | if (buffer_ptr[i] >= value) return true; |
| 531 | } |
| 532 | return false; |
| 533 | } |
| 534 | |
wu@webrtc.org | 8804a29 | 2013-10-22 23:09:20 +0000 | [diff] [blame] | 535 | bool FakeAudioCaptureModule::ShouldStartProcessing() { |
| 536 | return recording_ || playing_; |
| 537 | } |
| 538 | |
| 539 | void FakeAudioCaptureModule::UpdateProcessing(bool start) { |
| 540 | if (start) { |
deadbeef | ee8c6d3 | 2015-08-13 14:27:18 -0700 | [diff] [blame] | 541 | if (!process_thread_) { |
tommi | e725159 | 2017-07-14 14:44:46 -0700 | [diff] [blame] | 542 | process_thread_ = rtc::Thread::Create(); |
deadbeef | ee8c6d3 | 2015-08-13 14:27:18 -0700 | [diff] [blame] | 543 | process_thread_->Start(); |
| 544 | } |
Taylor Brandstetter | 5d97a9a | 2016-06-10 14:17:27 -0700 | [diff] [blame] | 545 | process_thread_->Post(RTC_FROM_HERE, this, MSG_START_PROCESS); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 546 | } else { |
deadbeef | ee8c6d3 | 2015-08-13 14:27:18 -0700 | [diff] [blame] | 547 | if (process_thread_) { |
| 548 | process_thread_->Stop(); |
| 549 | process_thread_.reset(nullptr); |
| 550 | } |
| 551 | started_ = false; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 552 | } |
| 553 | } |
| 554 | |
wu@webrtc.org | 8804a29 | 2013-10-22 23:09:20 +0000 | [diff] [blame] | 555 | void FakeAudioCaptureModule::StartProcessP() { |
nisse | c8ee882 | 2017-01-18 07:20:55 -0800 | [diff] [blame] | 556 | RTC_CHECK(process_thread_->IsCurrent()); |
wu@webrtc.org | 8804a29 | 2013-10-22 23:09:20 +0000 | [diff] [blame] | 557 | if (started_) { |
| 558 | // Already started. |
| 559 | return; |
| 560 | } |
| 561 | ProcessFrameP(); |
| 562 | } |
| 563 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 564 | void FakeAudioCaptureModule::ProcessFrameP() { |
nisse | c8ee882 | 2017-01-18 07:20:55 -0800 | [diff] [blame] | 565 | RTC_CHECK(process_thread_->IsCurrent()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 566 | if (!started_) { |
Honghai Zhang | 82d7862 | 2016-05-06 11:29:15 -0700 | [diff] [blame] | 567 | next_frame_time_ = rtc::TimeMillis(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 568 | started_ = true; |
| 569 | } |
wu@webrtc.org | 8804a29 | 2013-10-22 23:09:20 +0000 | [diff] [blame] | 570 | |
wu@webrtc.org | 8804a29 | 2013-10-22 23:09:20 +0000 | [diff] [blame] | 571 | { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 572 | rtc::CritScope cs(&crit_); |
deadbeef | ee8c6d3 | 2015-08-13 14:27:18 -0700 | [diff] [blame] | 573 | // Receive and send frames every kTimePerFrameMs. |
| 574 | if (playing_) { |
| 575 | ReceiveFrameP(); |
| 576 | } |
| 577 | if (recording_) { |
| 578 | SendFrameP(); |
| 579 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 580 | } |
| 581 | |
| 582 | next_frame_time_ += kTimePerFrameMs; |
Honghai Zhang | 82d7862 | 2016-05-06 11:29:15 -0700 | [diff] [blame] | 583 | const int64_t current_time = rtc::TimeMillis(); |
| 584 | const int64_t wait_time = |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 585 | (next_frame_time_ > current_time) ? next_frame_time_ - current_time : 0; |
Taylor Brandstetter | 5d97a9a | 2016-06-10 14:17:27 -0700 | [diff] [blame] | 586 | process_thread_->PostDelayed(RTC_FROM_HERE, wait_time, this, MSG_RUN_PROCESS); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 587 | } |
| 588 | |
| 589 | void FakeAudioCaptureModule::ReceiveFrameP() { |
nisse | c8ee882 | 2017-01-18 07:20:55 -0800 | [diff] [blame] | 590 | RTC_CHECK(process_thread_->IsCurrent()); |
wu@webrtc.org | 8804a29 | 2013-10-22 23:09:20 +0000 | [diff] [blame] | 591 | { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 592 | rtc::CritScope cs(&crit_callback_); |
wu@webrtc.org | 8804a29 | 2013-10-22 23:09:20 +0000 | [diff] [blame] | 593 | if (!audio_callback_) { |
| 594 | return; |
| 595 | } |
| 596 | ResetRecBuffer(); |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 597 | size_t nSamplesOut = 0; |
wu@webrtc.org | 94454b7 | 2014-06-05 20:34:08 +0000 | [diff] [blame] | 598 | int64_t elapsed_time_ms = 0; |
wu@webrtc.org | cb711f7 | 2014-05-19 17:39:11 +0000 | [diff] [blame] | 599 | int64_t ntp_time_ms = 0; |
| 600 | if (audio_callback_->NeedMorePlayData(kNumberSamples, kNumberBytesPerSample, |
| 601 | kNumberOfChannels, kSamplesPerSecond, |
| 602 | rec_buffer_, nSamplesOut, |
wu@webrtc.org | 94454b7 | 2014-06-05 20:34:08 +0000 | [diff] [blame] | 603 | &elapsed_time_ms, &ntp_time_ms) != 0) { |
nisse | c80e741 | 2017-01-11 05:56:46 -0800 | [diff] [blame] | 604 | RTC_NOTREACHED(); |
wu@webrtc.org | 8804a29 | 2013-10-22 23:09:20 +0000 | [diff] [blame] | 605 | } |
nisse | c8ee882 | 2017-01-18 07:20:55 -0800 | [diff] [blame] | 606 | RTC_CHECK(nSamplesOut == kNumberSamples); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 607 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 608 | // The SetBuffer() function ensures that after decoding, the audio buffer |
| 609 | // should contain samples of similar magnitude (there is likely to be some |
| 610 | // distortion due to the audio pipeline). If one sample is detected to |
| 611 | // have the same or greater magnitude somewhere in the frame, an actual frame |
| 612 | // has been received from the remote side (i.e. faked frames are not being |
| 613 | // pulled). |
wu@webrtc.org | 8804a29 | 2013-10-22 23:09:20 +0000 | [diff] [blame] | 614 | if (CheckRecBuffer(kHighSampleValue)) { |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 615 | rtc::CritScope cs(&crit_); |
wu@webrtc.org | 8804a29 | 2013-10-22 23:09:20 +0000 | [diff] [blame] | 616 | ++frames_received_; |
| 617 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 618 | } |
| 619 | |
| 620 | void FakeAudioCaptureModule::SendFrameP() { |
nisse | c8ee882 | 2017-01-18 07:20:55 -0800 | [diff] [blame] | 621 | RTC_CHECK(process_thread_->IsCurrent()); |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 622 | rtc::CritScope cs(&crit_callback_); |
wu@webrtc.org | 8804a29 | 2013-10-22 23:09:20 +0000 | [diff] [blame] | 623 | if (!audio_callback_) { |
| 624 | return; |
| 625 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 626 | bool key_pressed = false; |
wu@webrtc.org | 8804a29 | 2013-10-22 23:09:20 +0000 | [diff] [blame] | 627 | uint32_t current_mic_level = 0; |
| 628 | MicrophoneVolume(¤t_mic_level); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 629 | if (audio_callback_->RecordedDataIsAvailable(send_buffer_, kNumberSamples, |
| 630 | kNumberBytesPerSample, |
| 631 | kNumberOfChannels, |
| 632 | kSamplesPerSecond, kTotalDelayMs, |
wu@webrtc.org | 8804a29 | 2013-10-22 23:09:20 +0000 | [diff] [blame] | 633 | kClockDriftMs, current_mic_level, |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 634 | key_pressed, |
wu@webrtc.org | 8804a29 | 2013-10-22 23:09:20 +0000 | [diff] [blame] | 635 | current_mic_level) != 0) { |
nisse | c80e741 | 2017-01-11 05:56:46 -0800 | [diff] [blame] | 636 | RTC_NOTREACHED(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 637 | } |
wu@webrtc.org | 8804a29 | 2013-10-22 23:09:20 +0000 | [diff] [blame] | 638 | SetMicrophoneVolume(current_mic_level); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 639 | } |