OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 play_count_(0), | 366 play_count_(0), |
367 rec_count_(0), | 367 rec_count_(0), |
368 audio_stream_(nullptr) {} | 368 audio_stream_(nullptr) {} |
369 | 369 |
370 virtual ~MockAudioTransport() {} | 370 virtual ~MockAudioTransport() {} |
371 | 371 |
372 MOCK_METHOD10(RecordedDataIsAvailable, | 372 MOCK_METHOD10(RecordedDataIsAvailable, |
373 int32_t(const void* audioSamples, | 373 int32_t(const void* audioSamples, |
374 const size_t nSamples, | 374 const size_t nSamples, |
375 const size_t nBytesPerSample, | 375 const size_t nBytesPerSample, |
376 const uint8_t nChannels, | 376 const size_t nChannels, |
377 const uint32_t samplesPerSec, | 377 const uint32_t samplesPerSec, |
378 const uint32_t totalDelayMS, | 378 const uint32_t totalDelayMS, |
379 const int32_t clockDrift, | 379 const int32_t clockDrift, |
380 const uint32_t currentMicLevel, | 380 const uint32_t currentMicLevel, |
381 const bool keyPressed, | 381 const bool keyPressed, |
382 uint32_t& newMicLevel)); | 382 uint32_t& newMicLevel)); |
383 MOCK_METHOD8(NeedMorePlayData, | 383 MOCK_METHOD8(NeedMorePlayData, |
384 int32_t(const size_t nSamples, | 384 int32_t(const size_t nSamples, |
385 const size_t nBytesPerSample, | 385 const size_t nBytesPerSample, |
386 const uint8_t nChannels, | 386 const size_t nChannels, |
387 const uint32_t samplesPerSec, | 387 const uint32_t samplesPerSec, |
388 void* audioSamples, | 388 void* audioSamples, |
389 size_t& nSamplesOut, | 389 size_t& nSamplesOut, |
390 int64_t* elapsed_time_ms, | 390 int64_t* elapsed_time_ms, |
391 int64_t* ntp_time_ms)); | 391 int64_t* ntp_time_ms)); |
392 | 392 |
393 // Set default actions of the mock object. We are delegating to fake | 393 // Set default actions of the mock object. We are delegating to fake |
394 // implementations (of AudioStreamInterface) here. | 394 // implementations (of AudioStreamInterface) here. |
395 void HandleCallbacks(EventWrapper* test_is_done, | 395 void HandleCallbacks(EventWrapper* test_is_done, |
396 AudioStreamInterface* audio_stream, | 396 AudioStreamInterface* audio_stream, |
397 size_t num_callbacks) { | 397 size_t num_callbacks) { |
398 test_is_done_ = test_is_done; | 398 test_is_done_ = test_is_done; |
399 audio_stream_ = audio_stream; | 399 audio_stream_ = audio_stream; |
400 num_callbacks_ = num_callbacks; | 400 num_callbacks_ = num_callbacks; |
401 if (play_mode()) { | 401 if (play_mode()) { |
402 ON_CALL(*this, NeedMorePlayData(_, _, _, _, _, _, _, _)) | 402 ON_CALL(*this, NeedMorePlayData(_, _, _, _, _, _, _, _)) |
403 .WillByDefault( | 403 .WillByDefault( |
404 Invoke(this, &MockAudioTransport::RealNeedMorePlayData)); | 404 Invoke(this, &MockAudioTransport::RealNeedMorePlayData)); |
405 } | 405 } |
406 if (rec_mode()) { | 406 if (rec_mode()) { |
407 ON_CALL(*this, RecordedDataIsAvailable(_, _, _, _, _, _, _, _, _, _)) | 407 ON_CALL(*this, RecordedDataIsAvailable(_, _, _, _, _, _, _, _, _, _)) |
408 .WillByDefault( | 408 .WillByDefault( |
409 Invoke(this, &MockAudioTransport::RealRecordedDataIsAvailable)); | 409 Invoke(this, &MockAudioTransport::RealRecordedDataIsAvailable)); |
410 } | 410 } |
411 } | 411 } |
412 | 412 |
413 int32_t RealRecordedDataIsAvailable(const void* audioSamples, | 413 int32_t RealRecordedDataIsAvailable(const void* audioSamples, |
414 const size_t nSamples, | 414 const size_t nSamples, |
415 const size_t nBytesPerSample, | 415 const size_t nBytesPerSample, |
416 const uint8_t nChannels, | 416 const size_t nChannels, |
417 const uint32_t samplesPerSec, | 417 const uint32_t samplesPerSec, |
418 const uint32_t totalDelayMS, | 418 const uint32_t totalDelayMS, |
419 const int32_t clockDrift, | 419 const int32_t clockDrift, |
420 const uint32_t currentMicLevel, | 420 const uint32_t currentMicLevel, |
421 const bool keyPressed, | 421 const bool keyPressed, |
422 uint32_t& newMicLevel) { | 422 uint32_t& newMicLevel) { |
423 EXPECT_TRUE(rec_mode()) << "No test is expecting these callbacks."; | 423 EXPECT_TRUE(rec_mode()) << "No test is expecting these callbacks."; |
424 rec_count_++; | 424 rec_count_++; |
425 // Process the recorded audio stream if an AudioStreamInterface | 425 // Process the recorded audio stream if an AudioStreamInterface |
426 // implementation exists. | 426 // implementation exists. |
427 if (audio_stream_) { | 427 if (audio_stream_) { |
428 audio_stream_->Write(audioSamples, nSamples); | 428 audio_stream_->Write(audioSamples, nSamples); |
429 } | 429 } |
430 if (ReceivedEnoughCallbacks()) { | 430 if (ReceivedEnoughCallbacks()) { |
431 test_is_done_->Set(); | 431 test_is_done_->Set(); |
432 } | 432 } |
433 return 0; | 433 return 0; |
434 } | 434 } |
435 | 435 |
436 int32_t RealNeedMorePlayData(const size_t nSamples, | 436 int32_t RealNeedMorePlayData(const size_t nSamples, |
437 const size_t nBytesPerSample, | 437 const size_t nBytesPerSample, |
438 const uint8_t nChannels, | 438 const size_t nChannels, |
439 const uint32_t samplesPerSec, | 439 const uint32_t samplesPerSec, |
440 void* audioSamples, | 440 void* audioSamples, |
441 size_t& nSamplesOut, | 441 size_t& nSamplesOut, |
442 int64_t* elapsed_time_ms, | 442 int64_t* elapsed_time_ms, |
443 int64_t* ntp_time_ms) { | 443 int64_t* ntp_time_ms) { |
444 EXPECT_TRUE(play_mode()) << "No test is expecting these callbacks."; | 444 EXPECT_TRUE(play_mode()) << "No test is expecting these callbacks."; |
445 play_count_++; | 445 play_count_++; |
446 nSamplesOut = nSamples; | 446 nSamplesOut = nSamples; |
447 // Read (possibly processed) audio stream samples to be played out if an | 447 // Read (possibly processed) audio stream samples to be played out if an |
448 // AudioStreamInterface implementation exists. | 448 // AudioStreamInterface implementation exists. |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 StopPlayout(); | 827 StopPlayout(); |
828 StopRecording(); | 828 StopRecording(); |
829 // Verify that the correct number of transmitted impulses are detected. | 829 // Verify that the correct number of transmitted impulses are detected. |
830 EXPECT_EQ(latency_audio_stream->num_latency_values(), | 830 EXPECT_EQ(latency_audio_stream->num_latency_values(), |
831 static_cast<size_t>( | 831 static_cast<size_t>( |
832 kImpulseFrequencyInHz * kMeasureLatencyTimeInSec - 1)); | 832 kImpulseFrequencyInHz * kMeasureLatencyTimeInSec - 1)); |
833 latency_audio_stream->PrintResults(); | 833 latency_audio_stream->PrintResults(); |
834 } | 834 } |
835 | 835 |
836 } // namespace webrtc | 836 } // namespace webrtc |
OLD | NEW |