OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include "webrtc/api/test/fakeaudiocapturemodule.h" | 11 #include "webrtc/api/test/fakeaudiocapturemodule.h" |
12 | 12 |
| 13 #include "webrtc/base/checks.h" |
13 #include "webrtc/base/common.h" | 14 #include "webrtc/base/common.h" |
14 #include "webrtc/base/refcount.h" | 15 #include "webrtc/base/refcount.h" |
15 #include "webrtc/base/thread.h" | 16 #include "webrtc/base/thread.h" |
16 #include "webrtc/base/timeutils.h" | 17 #include "webrtc/base/timeutils.h" |
17 | 18 |
18 // Audio sample value that is high enough that it doesn't occur naturally when | 19 // 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 // 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 // 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 // Even simpler buffers would likely just contain audio sample values of 0. |
22 static const int kHighSampleValue = 10000; | 23 static const int kHighSampleValue = 10000; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 } | 85 } |
85 return kAdmMaxIdleTimeProcess - elapsed_time; | 86 return kAdmMaxIdleTimeProcess - elapsed_time; |
86 } | 87 } |
87 | 88 |
88 void FakeAudioCaptureModule::Process() { | 89 void FakeAudioCaptureModule::Process() { |
89 last_process_time_ms_ = rtc::TimeMillis(); | 90 last_process_time_ms_ = rtc::TimeMillis(); |
90 } | 91 } |
91 | 92 |
92 int32_t FakeAudioCaptureModule::ActiveAudioLayer( | 93 int32_t FakeAudioCaptureModule::ActiveAudioLayer( |
93 AudioLayer* /*audio_layer*/) const { | 94 AudioLayer* /*audio_layer*/) const { |
94 ASSERT(false); | 95 RTC_NOTREACHED(); |
95 return 0; | 96 return 0; |
96 } | 97 } |
97 | 98 |
98 webrtc::AudioDeviceModule::ErrorCode FakeAudioCaptureModule::LastError() const { | 99 webrtc::AudioDeviceModule::ErrorCode FakeAudioCaptureModule::LastError() const { |
99 ASSERT(false); | 100 RTC_NOTREACHED(); |
100 return webrtc::AudioDeviceModule::kAdmErrNone; | 101 return webrtc::AudioDeviceModule::kAdmErrNone; |
101 } | 102 } |
102 | 103 |
103 int32_t FakeAudioCaptureModule::RegisterEventObserver( | 104 int32_t FakeAudioCaptureModule::RegisterEventObserver( |
104 webrtc::AudioDeviceObserver* /*event_callback*/) { | 105 webrtc::AudioDeviceObserver* /*event_callback*/) { |
105 // Only used to report warnings and errors. This fake implementation won't | 106 // Only used to report warnings and errors. This fake implementation won't |
106 // generate any so discard this callback. | 107 // generate any so discard this callback. |
107 return 0; | 108 return 0; |
108 } | 109 } |
109 | 110 |
110 int32_t FakeAudioCaptureModule::RegisterAudioCallback( | 111 int32_t FakeAudioCaptureModule::RegisterAudioCallback( |
111 webrtc::AudioTransport* audio_callback) { | 112 webrtc::AudioTransport* audio_callback) { |
112 rtc::CritScope cs(&crit_callback_); | 113 rtc::CritScope cs(&crit_callback_); |
113 audio_callback_ = audio_callback; | 114 audio_callback_ = audio_callback; |
114 return 0; | 115 return 0; |
115 } | 116 } |
116 | 117 |
117 int32_t FakeAudioCaptureModule::Init() { | 118 int32_t FakeAudioCaptureModule::Init() { |
118 // Initialize is called by the factory method. Safe to ignore this Init call. | 119 // Initialize is called by the factory method. Safe to ignore this Init call. |
119 return 0; | 120 return 0; |
120 } | 121 } |
121 | 122 |
122 int32_t FakeAudioCaptureModule::Terminate() { | 123 int32_t FakeAudioCaptureModule::Terminate() { |
123 // Clean up in the destructor. No action here, just success. | 124 // Clean up in the destructor. No action here, just success. |
124 return 0; | 125 return 0; |
125 } | 126 } |
126 | 127 |
127 bool FakeAudioCaptureModule::Initialized() const { | 128 bool FakeAudioCaptureModule::Initialized() const { |
128 ASSERT(false); | 129 RTC_NOTREACHED(); |
129 return 0; | 130 return 0; |
130 } | 131 } |
131 | 132 |
132 int16_t FakeAudioCaptureModule::PlayoutDevices() { | 133 int16_t FakeAudioCaptureModule::PlayoutDevices() { |
133 ASSERT(false); | 134 RTC_NOTREACHED(); |
134 return 0; | 135 return 0; |
135 } | 136 } |
136 | 137 |
137 int16_t FakeAudioCaptureModule::RecordingDevices() { | 138 int16_t FakeAudioCaptureModule::RecordingDevices() { |
138 ASSERT(false); | 139 RTC_NOTREACHED(); |
139 return 0; | 140 return 0; |
140 } | 141 } |
141 | 142 |
142 int32_t FakeAudioCaptureModule::PlayoutDeviceName( | 143 int32_t FakeAudioCaptureModule::PlayoutDeviceName( |
143 uint16_t /*index*/, | 144 uint16_t /*index*/, |
144 char /*name*/[webrtc::kAdmMaxDeviceNameSize], | 145 char /*name*/[webrtc::kAdmMaxDeviceNameSize], |
145 char /*guid*/[webrtc::kAdmMaxGuidSize]) { | 146 char /*guid*/[webrtc::kAdmMaxGuidSize]) { |
146 ASSERT(false); | 147 RTC_NOTREACHED(); |
147 return 0; | 148 return 0; |
148 } | 149 } |
149 | 150 |
150 int32_t FakeAudioCaptureModule::RecordingDeviceName( | 151 int32_t FakeAudioCaptureModule::RecordingDeviceName( |
151 uint16_t /*index*/, | 152 uint16_t /*index*/, |
152 char /*name*/[webrtc::kAdmMaxDeviceNameSize], | 153 char /*name*/[webrtc::kAdmMaxDeviceNameSize], |
153 char /*guid*/[webrtc::kAdmMaxGuidSize]) { | 154 char /*guid*/[webrtc::kAdmMaxGuidSize]) { |
154 ASSERT(false); | 155 RTC_NOTREACHED(); |
155 return 0; | 156 return 0; |
156 } | 157 } |
157 | 158 |
158 int32_t FakeAudioCaptureModule::SetPlayoutDevice(uint16_t /*index*/) { | 159 int32_t FakeAudioCaptureModule::SetPlayoutDevice(uint16_t /*index*/) { |
159 // No playout device, just playing from file. Return success. | 160 // No playout device, just playing from file. Return success. |
160 return 0; | 161 return 0; |
161 } | 162 } |
162 | 163 |
163 int32_t FakeAudioCaptureModule::SetPlayoutDevice(WindowsDeviceType /*device*/) { | 164 int32_t FakeAudioCaptureModule::SetPlayoutDevice(WindowsDeviceType /*device*/) { |
164 if (play_is_initialized_) { | 165 if (play_is_initialized_) { |
165 return -1; | 166 return -1; |
166 } | 167 } |
167 return 0; | 168 return 0; |
168 } | 169 } |
169 | 170 |
170 int32_t FakeAudioCaptureModule::SetRecordingDevice(uint16_t /*index*/) { | 171 int32_t FakeAudioCaptureModule::SetRecordingDevice(uint16_t /*index*/) { |
171 // No recording device, just dropping audio. Return success. | 172 // No recording device, just dropping audio. Return success. |
172 return 0; | 173 return 0; |
173 } | 174 } |
174 | 175 |
175 int32_t FakeAudioCaptureModule::SetRecordingDevice( | 176 int32_t FakeAudioCaptureModule::SetRecordingDevice( |
176 WindowsDeviceType /*device*/) { | 177 WindowsDeviceType /*device*/) { |
177 if (rec_is_initialized_) { | 178 if (rec_is_initialized_) { |
178 return -1; | 179 return -1; |
179 } | 180 } |
180 return 0; | 181 return 0; |
181 } | 182 } |
182 | 183 |
183 int32_t FakeAudioCaptureModule::PlayoutIsAvailable(bool* /*available*/) { | 184 int32_t FakeAudioCaptureModule::PlayoutIsAvailable(bool* /*available*/) { |
184 ASSERT(false); | 185 RTC_NOTREACHED(); |
185 return 0; | 186 return 0; |
186 } | 187 } |
187 | 188 |
188 int32_t FakeAudioCaptureModule::InitPlayout() { | 189 int32_t FakeAudioCaptureModule::InitPlayout() { |
189 play_is_initialized_ = true; | 190 play_is_initialized_ = true; |
190 return 0; | 191 return 0; |
191 } | 192 } |
192 | 193 |
193 bool FakeAudioCaptureModule::PlayoutIsInitialized() const { | 194 bool FakeAudioCaptureModule::PlayoutIsInitialized() const { |
194 return play_is_initialized_; | 195 return play_is_initialized_; |
195 } | 196 } |
196 | 197 |
197 int32_t FakeAudioCaptureModule::RecordingIsAvailable(bool* /*available*/) { | 198 int32_t FakeAudioCaptureModule::RecordingIsAvailable(bool* /*available*/) { |
198 ASSERT(false); | 199 RTC_NOTREACHED(); |
199 return 0; | 200 return 0; |
200 } | 201 } |
201 | 202 |
202 int32_t FakeAudioCaptureModule::InitRecording() { | 203 int32_t FakeAudioCaptureModule::InitRecording() { |
203 rec_is_initialized_ = true; | 204 rec_is_initialized_ = true; |
204 return 0; | 205 return 0; |
205 } | 206 } |
206 | 207 |
207 bool FakeAudioCaptureModule::RecordingIsInitialized() const { | 208 bool FakeAudioCaptureModule::RecordingIsInitialized() const { |
208 return rec_is_initialized_; | 209 return rec_is_initialized_; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 rtc::CritScope cs(&crit_); | 266 rtc::CritScope cs(&crit_); |
266 return recording_; | 267 return recording_; |
267 } | 268 } |
268 | 269 |
269 int32_t FakeAudioCaptureModule::SetAGC(bool /*enable*/) { | 270 int32_t FakeAudioCaptureModule::SetAGC(bool /*enable*/) { |
270 // No AGC but not needed since audio is pregenerated. Return success. | 271 // No AGC but not needed since audio is pregenerated. Return success. |
271 return 0; | 272 return 0; |
272 } | 273 } |
273 | 274 |
274 bool FakeAudioCaptureModule::AGC() const { | 275 bool FakeAudioCaptureModule::AGC() const { |
275 ASSERT(false); | 276 RTC_NOTREACHED(); |
276 return 0; | 277 return 0; |
277 } | 278 } |
278 | 279 |
279 int32_t FakeAudioCaptureModule::SetWaveOutVolume(uint16_t /*volume_left*/, | 280 int32_t FakeAudioCaptureModule::SetWaveOutVolume(uint16_t /*volume_left*/, |
280 uint16_t /*volume_right*/) { | 281 uint16_t /*volume_right*/) { |
281 ASSERT(false); | 282 RTC_NOTREACHED(); |
282 return 0; | 283 return 0; |
283 } | 284 } |
284 | 285 |
285 int32_t FakeAudioCaptureModule::WaveOutVolume( | 286 int32_t FakeAudioCaptureModule::WaveOutVolume( |
286 uint16_t* /*volume_left*/, | 287 uint16_t* /*volume_left*/, |
287 uint16_t* /*volume_right*/) const { | 288 uint16_t* /*volume_right*/) const { |
288 ASSERT(false); | 289 RTC_NOTREACHED(); |
289 return 0; | 290 return 0; |
290 } | 291 } |
291 | 292 |
292 int32_t FakeAudioCaptureModule::InitSpeaker() { | 293 int32_t FakeAudioCaptureModule::InitSpeaker() { |
293 // No speaker, just playing from file. Return success. | 294 // No speaker, just playing from file. Return success. |
294 return 0; | 295 return 0; |
295 } | 296 } |
296 | 297 |
297 bool FakeAudioCaptureModule::SpeakerIsInitialized() const { | 298 bool FakeAudioCaptureModule::SpeakerIsInitialized() const { |
298 ASSERT(false); | 299 RTC_NOTREACHED(); |
299 return 0; | 300 return 0; |
300 } | 301 } |
301 | 302 |
302 int32_t FakeAudioCaptureModule::InitMicrophone() { | 303 int32_t FakeAudioCaptureModule::InitMicrophone() { |
303 // No microphone, just playing from file. Return success. | 304 // No microphone, just playing from file. Return success. |
304 return 0; | 305 return 0; |
305 } | 306 } |
306 | 307 |
307 bool FakeAudioCaptureModule::MicrophoneIsInitialized() const { | 308 bool FakeAudioCaptureModule::MicrophoneIsInitialized() const { |
308 ASSERT(false); | 309 RTC_NOTREACHED(); |
309 return 0; | 310 return 0; |
310 } | 311 } |
311 | 312 |
312 int32_t FakeAudioCaptureModule::SpeakerVolumeIsAvailable(bool* /*available*/) { | 313 int32_t FakeAudioCaptureModule::SpeakerVolumeIsAvailable(bool* /*available*/) { |
313 ASSERT(false); | 314 RTC_NOTREACHED(); |
314 return 0; | 315 return 0; |
315 } | 316 } |
316 | 317 |
317 int32_t FakeAudioCaptureModule::SetSpeakerVolume(uint32_t /*volume*/) { | 318 int32_t FakeAudioCaptureModule::SetSpeakerVolume(uint32_t /*volume*/) { |
318 ASSERT(false); | 319 RTC_NOTREACHED(); |
319 return 0; | 320 return 0; |
320 } | 321 } |
321 | 322 |
322 int32_t FakeAudioCaptureModule::SpeakerVolume(uint32_t* /*volume*/) const { | 323 int32_t FakeAudioCaptureModule::SpeakerVolume(uint32_t* /*volume*/) const { |
323 ASSERT(false); | 324 RTC_NOTREACHED(); |
324 return 0; | 325 return 0; |
325 } | 326 } |
326 | 327 |
327 int32_t FakeAudioCaptureModule::MaxSpeakerVolume( | 328 int32_t FakeAudioCaptureModule::MaxSpeakerVolume( |
328 uint32_t* /*max_volume*/) const { | 329 uint32_t* /*max_volume*/) const { |
329 ASSERT(false); | 330 RTC_NOTREACHED(); |
330 return 0; | 331 return 0; |
331 } | 332 } |
332 | 333 |
333 int32_t FakeAudioCaptureModule::MinSpeakerVolume( | 334 int32_t FakeAudioCaptureModule::MinSpeakerVolume( |
334 uint32_t* /*min_volume*/) const { | 335 uint32_t* /*min_volume*/) const { |
335 ASSERT(false); | 336 RTC_NOTREACHED(); |
336 return 0; | 337 return 0; |
337 } | 338 } |
338 | 339 |
339 int32_t FakeAudioCaptureModule::SpeakerVolumeStepSize( | 340 int32_t FakeAudioCaptureModule::SpeakerVolumeStepSize( |
340 uint16_t* /*step_size*/) const { | 341 uint16_t* /*step_size*/) const { |
341 ASSERT(false); | 342 RTC_NOTREACHED(); |
342 return 0; | 343 return 0; |
343 } | 344 } |
344 | 345 |
345 int32_t FakeAudioCaptureModule::MicrophoneVolumeIsAvailable( | 346 int32_t FakeAudioCaptureModule::MicrophoneVolumeIsAvailable( |
346 bool* /*available*/) { | 347 bool* /*available*/) { |
347 ASSERT(false); | 348 RTC_NOTREACHED(); |
348 return 0; | 349 return 0; |
349 } | 350 } |
350 | 351 |
351 int32_t FakeAudioCaptureModule::SetMicrophoneVolume(uint32_t volume) { | 352 int32_t FakeAudioCaptureModule::SetMicrophoneVolume(uint32_t volume) { |
352 rtc::CritScope cs(&crit_); | 353 rtc::CritScope cs(&crit_); |
353 current_mic_level_ = volume; | 354 current_mic_level_ = volume; |
354 return 0; | 355 return 0; |
355 } | 356 } |
356 | 357 |
357 int32_t FakeAudioCaptureModule::MicrophoneVolume(uint32_t* volume) const { | 358 int32_t FakeAudioCaptureModule::MicrophoneVolume(uint32_t* volume) const { |
358 rtc::CritScope cs(&crit_); | 359 rtc::CritScope cs(&crit_); |
359 *volume = current_mic_level_; | 360 *volume = current_mic_level_; |
360 return 0; | 361 return 0; |
361 } | 362 } |
362 | 363 |
363 int32_t FakeAudioCaptureModule::MaxMicrophoneVolume( | 364 int32_t FakeAudioCaptureModule::MaxMicrophoneVolume( |
364 uint32_t* max_volume) const { | 365 uint32_t* max_volume) const { |
365 *max_volume = kMaxVolume; | 366 *max_volume = kMaxVolume; |
366 return 0; | 367 return 0; |
367 } | 368 } |
368 | 369 |
369 int32_t FakeAudioCaptureModule::MinMicrophoneVolume( | 370 int32_t FakeAudioCaptureModule::MinMicrophoneVolume( |
370 uint32_t* /*min_volume*/) const { | 371 uint32_t* /*min_volume*/) const { |
371 ASSERT(false); | 372 RTC_NOTREACHED(); |
372 return 0; | 373 return 0; |
373 } | 374 } |
374 | 375 |
375 int32_t FakeAudioCaptureModule::MicrophoneVolumeStepSize( | 376 int32_t FakeAudioCaptureModule::MicrophoneVolumeStepSize( |
376 uint16_t* /*step_size*/) const { | 377 uint16_t* /*step_size*/) const { |
377 ASSERT(false); | 378 RTC_NOTREACHED(); |
378 return 0; | 379 return 0; |
379 } | 380 } |
380 | 381 |
381 int32_t FakeAudioCaptureModule::SpeakerMuteIsAvailable(bool* /*available*/) { | 382 int32_t FakeAudioCaptureModule::SpeakerMuteIsAvailable(bool* /*available*/) { |
382 ASSERT(false); | 383 RTC_NOTREACHED(); |
383 return 0; | 384 return 0; |
384 } | 385 } |
385 | 386 |
386 int32_t FakeAudioCaptureModule::SetSpeakerMute(bool /*enable*/) { | 387 int32_t FakeAudioCaptureModule::SetSpeakerMute(bool /*enable*/) { |
387 ASSERT(false); | 388 RTC_NOTREACHED(); |
388 return 0; | 389 return 0; |
389 } | 390 } |
390 | 391 |
391 int32_t FakeAudioCaptureModule::SpeakerMute(bool* /*enabled*/) const { | 392 int32_t FakeAudioCaptureModule::SpeakerMute(bool* /*enabled*/) const { |
392 ASSERT(false); | 393 RTC_NOTREACHED(); |
393 return 0; | 394 return 0; |
394 } | 395 } |
395 | 396 |
396 int32_t FakeAudioCaptureModule::MicrophoneMuteIsAvailable(bool* /*available*/) { | 397 int32_t FakeAudioCaptureModule::MicrophoneMuteIsAvailable(bool* /*available*/) { |
397 ASSERT(false); | 398 RTC_NOTREACHED(); |
398 return 0; | 399 return 0; |
399 } | 400 } |
400 | 401 |
401 int32_t FakeAudioCaptureModule::SetMicrophoneMute(bool /*enable*/) { | 402 int32_t FakeAudioCaptureModule::SetMicrophoneMute(bool /*enable*/) { |
402 ASSERT(false); | 403 RTC_NOTREACHED(); |
403 return 0; | 404 return 0; |
404 } | 405 } |
405 | 406 |
406 int32_t FakeAudioCaptureModule::MicrophoneMute(bool* /*enabled*/) const { | 407 int32_t FakeAudioCaptureModule::MicrophoneMute(bool* /*enabled*/) const { |
407 ASSERT(false); | 408 RTC_NOTREACHED(); |
408 return 0; | 409 return 0; |
409 } | 410 } |
410 | 411 |
411 int32_t FakeAudioCaptureModule::MicrophoneBoostIsAvailable( | 412 int32_t FakeAudioCaptureModule::MicrophoneBoostIsAvailable( |
412 bool* /*available*/) { | 413 bool* /*available*/) { |
413 ASSERT(false); | 414 RTC_NOTREACHED(); |
414 return 0; | 415 return 0; |
415 } | 416 } |
416 | 417 |
417 int32_t FakeAudioCaptureModule::SetMicrophoneBoost(bool /*enable*/) { | 418 int32_t FakeAudioCaptureModule::SetMicrophoneBoost(bool /*enable*/) { |
418 ASSERT(false); | 419 RTC_NOTREACHED(); |
419 return 0; | 420 return 0; |
420 } | 421 } |
421 | 422 |
422 int32_t FakeAudioCaptureModule::MicrophoneBoost(bool* /*enabled*/) const { | 423 int32_t FakeAudioCaptureModule::MicrophoneBoost(bool* /*enabled*/) const { |
423 ASSERT(false); | 424 RTC_NOTREACHED(); |
424 return 0; | 425 return 0; |
425 } | 426 } |
426 | 427 |
427 int32_t FakeAudioCaptureModule::StereoPlayoutIsAvailable( | 428 int32_t FakeAudioCaptureModule::StereoPlayoutIsAvailable( |
428 bool* available) const { | 429 bool* available) const { |
429 // No recording device, just dropping audio. Stereo can be dropped just | 430 // No recording device, just dropping audio. Stereo can be dropped just |
430 // as easily as mono. | 431 // as easily as mono. |
431 *available = true; | 432 *available = true; |
432 return 0; | 433 return 0; |
433 } | 434 } |
434 | 435 |
435 int32_t FakeAudioCaptureModule::SetStereoPlayout(bool /*enable*/) { | 436 int32_t FakeAudioCaptureModule::SetStereoPlayout(bool /*enable*/) { |
436 // No recording device, just dropping audio. Stereo can be dropped just | 437 // No recording device, just dropping audio. Stereo can be dropped just |
437 // as easily as mono. | 438 // as easily as mono. |
438 return 0; | 439 return 0; |
439 } | 440 } |
440 | 441 |
441 int32_t FakeAudioCaptureModule::StereoPlayout(bool* /*enabled*/) const { | 442 int32_t FakeAudioCaptureModule::StereoPlayout(bool* /*enabled*/) const { |
442 ASSERT(false); | 443 RTC_NOTREACHED(); |
443 return 0; | 444 return 0; |
444 } | 445 } |
445 | 446 |
446 int32_t FakeAudioCaptureModule::StereoRecordingIsAvailable( | 447 int32_t FakeAudioCaptureModule::StereoRecordingIsAvailable( |
447 bool* available) const { | 448 bool* available) const { |
448 // Keep thing simple. No stereo recording. | 449 // Keep thing simple. No stereo recording. |
449 *available = false; | 450 *available = false; |
450 return 0; | 451 return 0; |
451 } | 452 } |
452 | 453 |
453 int32_t FakeAudioCaptureModule::SetStereoRecording(bool enable) { | 454 int32_t FakeAudioCaptureModule::SetStereoRecording(bool enable) { |
454 if (!enable) { | 455 if (!enable) { |
455 return 0; | 456 return 0; |
456 } | 457 } |
457 return -1; | 458 return -1; |
458 } | 459 } |
459 | 460 |
460 int32_t FakeAudioCaptureModule::StereoRecording(bool* /*enabled*/) const { | 461 int32_t FakeAudioCaptureModule::StereoRecording(bool* /*enabled*/) const { |
461 ASSERT(false); | 462 RTC_NOTREACHED(); |
462 return 0; | 463 return 0; |
463 } | 464 } |
464 | 465 |
465 int32_t FakeAudioCaptureModule::SetRecordingChannel( | 466 int32_t FakeAudioCaptureModule::SetRecordingChannel( |
466 const ChannelType channel) { | 467 const ChannelType channel) { |
467 if (channel != AudioDeviceModule::kChannelBoth) { | 468 if (channel != AudioDeviceModule::kChannelBoth) { |
468 // There is no right or left in mono. I.e. kChannelBoth should be used for | 469 // There is no right or left in mono. I.e. kChannelBoth should be used for |
469 // mono. | 470 // mono. |
470 ASSERT(false); | 471 RTC_NOTREACHED(); |
471 return -1; | 472 return -1; |
472 } | 473 } |
473 return 0; | 474 return 0; |
474 } | 475 } |
475 | 476 |
476 int32_t FakeAudioCaptureModule::RecordingChannel(ChannelType* channel) const { | 477 int32_t FakeAudioCaptureModule::RecordingChannel(ChannelType* channel) const { |
477 // Stereo recording not supported. However, WebRTC ADM returns kChannelBoth | 478 // Stereo recording not supported. However, WebRTC ADM returns kChannelBoth |
478 // in that case. Do the same here. | 479 // in that case. Do the same here. |
479 *channel = AudioDeviceModule::kChannelBoth; | 480 *channel = AudioDeviceModule::kChannelBoth; |
480 return 0; | 481 return 0; |
481 } | 482 } |
482 | 483 |
483 int32_t FakeAudioCaptureModule::SetPlayoutBuffer(const BufferType /*type*/, | 484 int32_t FakeAudioCaptureModule::SetPlayoutBuffer(const BufferType /*type*/, |
484 uint16_t /*size_ms*/) { | 485 uint16_t /*size_ms*/) { |
485 ASSERT(false); | 486 RTC_NOTREACHED(); |
486 return 0; | 487 return 0; |
487 } | 488 } |
488 | 489 |
489 int32_t FakeAudioCaptureModule::PlayoutBuffer(BufferType* /*type*/, | 490 int32_t FakeAudioCaptureModule::PlayoutBuffer(BufferType* /*type*/, |
490 uint16_t* /*size_ms*/) const { | 491 uint16_t* /*size_ms*/) const { |
491 ASSERT(false); | 492 RTC_NOTREACHED(); |
492 return 0; | 493 return 0; |
493 } | 494 } |
494 | 495 |
495 int32_t FakeAudioCaptureModule::PlayoutDelay(uint16_t* delay_ms) const { | 496 int32_t FakeAudioCaptureModule::PlayoutDelay(uint16_t* delay_ms) const { |
496 // No delay since audio frames are dropped. | 497 // No delay since audio frames are dropped. |
497 *delay_ms = 0; | 498 *delay_ms = 0; |
498 return 0; | 499 return 0; |
499 } | 500 } |
500 | 501 |
501 int32_t FakeAudioCaptureModule::RecordingDelay(uint16_t* /*delay_ms*/) const { | 502 int32_t FakeAudioCaptureModule::RecordingDelay(uint16_t* /*delay_ms*/) const { |
502 ASSERT(false); | 503 RTC_NOTREACHED(); |
503 return 0; | 504 return 0; |
504 } | 505 } |
505 | 506 |
506 int32_t FakeAudioCaptureModule::CPULoad(uint16_t* /*load*/) const { | 507 int32_t FakeAudioCaptureModule::CPULoad(uint16_t* /*load*/) const { |
507 ASSERT(false); | 508 RTC_NOTREACHED(); |
508 return 0; | 509 return 0; |
509 } | 510 } |
510 | 511 |
511 int32_t FakeAudioCaptureModule::StartRawOutputFileRecording( | 512 int32_t FakeAudioCaptureModule::StartRawOutputFileRecording( |
512 const char /*pcm_file_name_utf8*/[webrtc::kAdmMaxFileNameSize]) { | 513 const char /*pcm_file_name_utf8*/[webrtc::kAdmMaxFileNameSize]) { |
513 ASSERT(false); | 514 RTC_NOTREACHED(); |
514 return 0; | 515 return 0; |
515 } | 516 } |
516 | 517 |
517 int32_t FakeAudioCaptureModule::StopRawOutputFileRecording() { | 518 int32_t FakeAudioCaptureModule::StopRawOutputFileRecording() { |
518 ASSERT(false); | 519 RTC_NOTREACHED(); |
519 return 0; | 520 return 0; |
520 } | 521 } |
521 | 522 |
522 int32_t FakeAudioCaptureModule::StartRawInputFileRecording( | 523 int32_t FakeAudioCaptureModule::StartRawInputFileRecording( |
523 const char /*pcm_file_name_utf8*/[webrtc::kAdmMaxFileNameSize]) { | 524 const char /*pcm_file_name_utf8*/[webrtc::kAdmMaxFileNameSize]) { |
524 ASSERT(false); | 525 RTC_NOTREACHED(); |
525 return 0; | 526 return 0; |
526 } | 527 } |
527 | 528 |
528 int32_t FakeAudioCaptureModule::StopRawInputFileRecording() { | 529 int32_t FakeAudioCaptureModule::StopRawInputFileRecording() { |
529 ASSERT(false); | 530 RTC_NOTREACHED(); |
530 return 0; | 531 return 0; |
531 } | 532 } |
532 | 533 |
533 int32_t FakeAudioCaptureModule::SetRecordingSampleRate( | 534 int32_t FakeAudioCaptureModule::SetRecordingSampleRate( |
534 const uint32_t /*samples_per_sec*/) { | 535 const uint32_t /*samples_per_sec*/) { |
535 ASSERT(false); | 536 RTC_NOTREACHED(); |
536 return 0; | 537 return 0; |
537 } | 538 } |
538 | 539 |
539 int32_t FakeAudioCaptureModule::RecordingSampleRate( | 540 int32_t FakeAudioCaptureModule::RecordingSampleRate( |
540 uint32_t* /*samples_per_sec*/) const { | 541 uint32_t* /*samples_per_sec*/) const { |
541 ASSERT(false); | 542 RTC_NOTREACHED(); |
542 return 0; | 543 return 0; |
543 } | 544 } |
544 | 545 |
545 int32_t FakeAudioCaptureModule::SetPlayoutSampleRate( | 546 int32_t FakeAudioCaptureModule::SetPlayoutSampleRate( |
546 const uint32_t /*samples_per_sec*/) { | 547 const uint32_t /*samples_per_sec*/) { |
547 ASSERT(false); | 548 RTC_NOTREACHED(); |
548 return 0; | 549 return 0; |
549 } | 550 } |
550 | 551 |
551 int32_t FakeAudioCaptureModule::PlayoutSampleRate( | 552 int32_t FakeAudioCaptureModule::PlayoutSampleRate( |
552 uint32_t* /*samples_per_sec*/) const { | 553 uint32_t* /*samples_per_sec*/) const { |
553 ASSERT(false); | 554 RTC_NOTREACHED(); |
554 return 0; | 555 return 0; |
555 } | 556 } |
556 | 557 |
557 int32_t FakeAudioCaptureModule::ResetAudioDevice() { | 558 int32_t FakeAudioCaptureModule::ResetAudioDevice() { |
558 ASSERT(false); | 559 RTC_NOTREACHED(); |
559 return 0; | 560 return 0; |
560 } | 561 } |
561 | 562 |
562 int32_t FakeAudioCaptureModule::SetLoudspeakerStatus(bool /*enable*/) { | 563 int32_t FakeAudioCaptureModule::SetLoudspeakerStatus(bool /*enable*/) { |
563 ASSERT(false); | 564 RTC_NOTREACHED(); |
564 return 0; | 565 return 0; |
565 } | 566 } |
566 | 567 |
567 int32_t FakeAudioCaptureModule::GetLoudspeakerStatus(bool* /*enabled*/) const { | 568 int32_t FakeAudioCaptureModule::GetLoudspeakerStatus(bool* /*enabled*/) const { |
568 ASSERT(false); | 569 RTC_NOTREACHED(); |
569 return 0; | 570 return 0; |
570 } | 571 } |
571 | 572 |
572 void FakeAudioCaptureModule::OnMessage(rtc::Message* msg) { | 573 void FakeAudioCaptureModule::OnMessage(rtc::Message* msg) { |
573 switch (msg->message_id) { | 574 switch (msg->message_id) { |
574 case MSG_START_PROCESS: | 575 case MSG_START_PROCESS: |
575 StartProcessP(); | 576 StartProcessP(); |
576 break; | 577 break; |
577 case MSG_RUN_PROCESS: | 578 case MSG_RUN_PROCESS: |
578 ProcessFrameP(); | 579 ProcessFrameP(); |
579 break; | 580 break; |
580 default: | 581 default: |
581 // All existing messages should be caught. Getting here should never | 582 // All existing messages should be caught. Getting here should never |
582 // happen. | 583 // happen. |
583 ASSERT(false); | 584 RTC_NOTREACHED(); |
584 } | 585 } |
585 } | 586 } |
586 | 587 |
587 bool FakeAudioCaptureModule::Initialize() { | 588 bool FakeAudioCaptureModule::Initialize() { |
588 // Set the send buffer samples high enough that it would not occur on the | 589 // Set the send buffer samples high enough that it would not occur on the |
589 // remote side unless a packet containing a sample of that magnitude has been | 590 // remote side unless a packet containing a sample of that magnitude has been |
590 // sent to it. Note that the audio processing pipeline will likely distort the | 591 // sent to it. Note that the audio processing pipeline will likely distort the |
591 // original signal. | 592 // original signal. |
592 SetSendBuffer(kHighSampleValue); | 593 SetSendBuffer(kHighSampleValue); |
593 last_process_time_ms_ = rtc::TimeMillis(); | 594 last_process_time_ms_ = rtc::TimeMillis(); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 return; | 680 return; |
680 } | 681 } |
681 ResetRecBuffer(); | 682 ResetRecBuffer(); |
682 size_t nSamplesOut = 0; | 683 size_t nSamplesOut = 0; |
683 int64_t elapsed_time_ms = 0; | 684 int64_t elapsed_time_ms = 0; |
684 int64_t ntp_time_ms = 0; | 685 int64_t ntp_time_ms = 0; |
685 if (audio_callback_->NeedMorePlayData(kNumberSamples, kNumberBytesPerSample, | 686 if (audio_callback_->NeedMorePlayData(kNumberSamples, kNumberBytesPerSample, |
686 kNumberOfChannels, kSamplesPerSecond, | 687 kNumberOfChannels, kSamplesPerSecond, |
687 rec_buffer_, nSamplesOut, | 688 rec_buffer_, nSamplesOut, |
688 &elapsed_time_ms, &ntp_time_ms) != 0) { | 689 &elapsed_time_ms, &ntp_time_ms) != 0) { |
689 ASSERT(false); | 690 RTC_NOTREACHED(); |
690 } | 691 } |
691 ASSERT(nSamplesOut == kNumberSamples); | 692 ASSERT(nSamplesOut == kNumberSamples); |
692 } | 693 } |
693 // The SetBuffer() function ensures that after decoding, the audio buffer | 694 // The SetBuffer() function ensures that after decoding, the audio buffer |
694 // should contain samples of similar magnitude (there is likely to be some | 695 // should contain samples of similar magnitude (there is likely to be some |
695 // distortion due to the audio pipeline). If one sample is detected to | 696 // distortion due to the audio pipeline). If one sample is detected to |
696 // have the same or greater magnitude somewhere in the frame, an actual frame | 697 // have the same or greater magnitude somewhere in the frame, an actual frame |
697 // has been received from the remote side (i.e. faked frames are not being | 698 // has been received from the remote side (i.e. faked frames are not being |
698 // pulled). | 699 // pulled). |
699 if (CheckRecBuffer(kHighSampleValue)) { | 700 if (CheckRecBuffer(kHighSampleValue)) { |
(...skipping 11 matching lines...) Expand all Loading... |
711 bool key_pressed = false; | 712 bool key_pressed = false; |
712 uint32_t current_mic_level = 0; | 713 uint32_t current_mic_level = 0; |
713 MicrophoneVolume(¤t_mic_level); | 714 MicrophoneVolume(¤t_mic_level); |
714 if (audio_callback_->RecordedDataIsAvailable(send_buffer_, kNumberSamples, | 715 if (audio_callback_->RecordedDataIsAvailable(send_buffer_, kNumberSamples, |
715 kNumberBytesPerSample, | 716 kNumberBytesPerSample, |
716 kNumberOfChannels, | 717 kNumberOfChannels, |
717 kSamplesPerSecond, kTotalDelayMs, | 718 kSamplesPerSecond, kTotalDelayMs, |
718 kClockDriftMs, current_mic_level, | 719 kClockDriftMs, current_mic_level, |
719 key_pressed, | 720 key_pressed, |
720 current_mic_level) != 0) { | 721 current_mic_level) != 0) { |
721 ASSERT(false); | 722 RTC_NOTREACHED(); |
722 } | 723 } |
723 SetMicrophoneVolume(current_mic_level); | 724 SetMicrophoneVolume(current_mic_level); |
724 } | 725 } |
725 | |
OLD | NEW |