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 if (test_is_done_) { | 431 if (test_is_done_) { |
432 test_is_done_->Set(); | 432 test_is_done_->Set(); |
433 } | 433 } |
434 } | 434 } |
435 return 0; | 435 return 0; |
436 } | 436 } |
437 | 437 |
438 int32_t RealNeedMorePlayData(const size_t nSamples, | 438 int32_t RealNeedMorePlayData(const size_t nSamples, |
439 const size_t nBytesPerSample, | 439 const size_t nBytesPerSample, |
440 const uint8_t nChannels, | 440 const size_t nChannels, |
441 const uint32_t samplesPerSec, | 441 const uint32_t samplesPerSec, |
442 void* audioSamples, | 442 void* audioSamples, |
443 size_t& nSamplesOut, | 443 size_t& nSamplesOut, |
444 int64_t* elapsed_time_ms, | 444 int64_t* elapsed_time_ms, |
445 int64_t* ntp_time_ms) { | 445 int64_t* ntp_time_ms) { |
446 EXPECT_TRUE(play_mode()) << "No test is expecting these callbacks."; | 446 EXPECT_TRUE(play_mode()) << "No test is expecting these callbacks."; |
447 play_count_++; | 447 play_count_++; |
448 nSamplesOut = nSamples; | 448 nSamplesOut = nSamples; |
449 // Read (possibly processed) audio stream samples to be played out if an | 449 // Read (possibly processed) audio stream samples to be played out if an |
450 // AudioStreamInterface implementation exists. | 450 // AudioStreamInterface implementation exists. |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
838 StopPlayout(); | 838 StopPlayout(); |
839 StopRecording(); | 839 StopRecording(); |
840 // Verify that the correct number of transmitted impulses are detected. | 840 // Verify that the correct number of transmitted impulses are detected. |
841 EXPECT_EQ(latency_audio_stream->num_latency_values(), | 841 EXPECT_EQ(latency_audio_stream->num_latency_values(), |
842 static_cast<size_t>( | 842 static_cast<size_t>( |
843 kImpulseFrequencyInHz * kMeasureLatencyTimeInSec - 1)); | 843 kImpulseFrequencyInHz * kMeasureLatencyTimeInSec - 1)); |
844 latency_audio_stream->PrintResults(); | 844 latency_audio_stream->PrintResults(); |
845 } | 845 } |
846 | 846 |
847 } // namespace webrtc | 847 } // namespace webrtc |
OLD | NEW |