| OLD | NEW |
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
| 9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 fake_audio_capture_module_ = FakeAudioCaptureModule::Create( | 51 fake_audio_capture_module_ = FakeAudioCaptureModule::Create( |
| 52 rtc::Thread::Current()); | 52 rtc::Thread::Current()); |
| 53 EXPECT_TRUE(fake_audio_capture_module_.get() != NULL); | 53 EXPECT_TRUE(fake_audio_capture_module_.get() != NULL); |
| 54 } | 54 } |
| 55 | 55 |
| 56 // Callbacks inherited from webrtc::AudioTransport. | 56 // Callbacks inherited from webrtc::AudioTransport. |
| 57 // ADM is pushing data. | 57 // ADM is pushing data. |
| 58 int32_t RecordedDataIsAvailable(const void* audioSamples, | 58 int32_t RecordedDataIsAvailable(const void* audioSamples, |
| 59 const size_t nSamples, | 59 const size_t nSamples, |
| 60 const size_t nBytesPerSample, | 60 const size_t nBytesPerSample, |
| 61 const uint8_t nChannels, | 61 const size_t nChannels, |
| 62 const uint32_t samplesPerSec, | 62 const uint32_t samplesPerSec, |
| 63 const uint32_t totalDelayMS, | 63 const uint32_t totalDelayMS, |
| 64 const int32_t clockDrift, | 64 const int32_t clockDrift, |
| 65 const uint32_t currentMicLevel, | 65 const uint32_t currentMicLevel, |
| 66 const bool keyPressed, | 66 const bool keyPressed, |
| 67 uint32_t& newMicLevel) override { | 67 uint32_t& newMicLevel) override { |
| 68 rec_buffer_bytes_ = nSamples * nBytesPerSample; | 68 rec_buffer_bytes_ = nSamples * nBytesPerSample; |
| 69 if ((rec_buffer_bytes_ == 0) || | 69 if ((rec_buffer_bytes_ == 0) || |
| 70 (rec_buffer_bytes_ > FakeAudioCaptureModule::kNumberSamples * | 70 (rec_buffer_bytes_ > FakeAudioCaptureModule::kNumberSamples * |
| 71 FakeAudioCaptureModule::kNumberBytesPerSample)) { | 71 FakeAudioCaptureModule::kNumberBytesPerSample)) { |
| 72 ADD_FAILURE(); | 72 ADD_FAILURE(); |
| 73 return -1; | 73 return -1; |
| 74 } | 74 } |
| 75 memcpy(rec_buffer_, audioSamples, rec_buffer_bytes_); | 75 memcpy(rec_buffer_, audioSamples, rec_buffer_bytes_); |
| 76 ++push_iterations_; | 76 ++push_iterations_; |
| 77 newMicLevel = currentMicLevel; | 77 newMicLevel = currentMicLevel; |
| 78 return 0; | 78 return 0; |
| 79 } | 79 } |
| 80 | 80 |
| 81 // ADM is pulling data. | 81 // ADM is pulling data. |
| 82 int32_t NeedMorePlayData(const size_t nSamples, | 82 int32_t NeedMorePlayData(const size_t nSamples, |
| 83 const size_t nBytesPerSample, | 83 const size_t nBytesPerSample, |
| 84 const uint8_t nChannels, | 84 const size_t nChannels, |
| 85 const uint32_t samplesPerSec, | 85 const uint32_t samplesPerSec, |
| 86 void* audioSamples, | 86 void* audioSamples, |
| 87 size_t& nSamplesOut, | 87 size_t& nSamplesOut, |
| 88 int64_t* elapsed_time_ms, | 88 int64_t* elapsed_time_ms, |
| 89 int64_t* ntp_time_ms) override { | 89 int64_t* ntp_time_ms) override { |
| 90 ++pull_iterations_; | 90 ++pull_iterations_; |
| 91 const size_t audio_buffer_size = nSamples * nBytesPerSample; | 91 const size_t audio_buffer_size = nSamples * nBytesPerSample; |
| 92 const size_t bytes_out = RecordedDataReceived() ? | 92 const size_t bytes_out = RecordedDataReceived() ? |
| 93 CopyFromRecBuffer(audioSamples, audio_buffer_size): | 93 CopyFromRecBuffer(audioSamples, audio_buffer_size): |
| 94 GenerateZeroBuffer(audioSamples, audio_buffer_size); | 94 GenerateZeroBuffer(audioSamples, audio_buffer_size); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 | 197 |
| 198 EXPECT_EQ(0, fake_audio_capture_module_->InitRecording()); | 198 EXPECT_EQ(0, fake_audio_capture_module_->InitRecording()); |
| 199 EXPECT_EQ(0, fake_audio_capture_module_->StartRecording()); | 199 EXPECT_EQ(0, fake_audio_capture_module_->StartRecording()); |
| 200 | 200 |
| 201 EXPECT_TRUE_WAIT(push_iterations() > 0, kMsInSecond); | 201 EXPECT_TRUE_WAIT(push_iterations() > 0, kMsInSecond); |
| 202 EXPECT_TRUE_WAIT(pull_iterations() > 0, kMsInSecond); | 202 EXPECT_TRUE_WAIT(pull_iterations() > 0, kMsInSecond); |
| 203 | 203 |
| 204 EXPECT_EQ(0, fake_audio_capture_module_->StopPlayout()); | 204 EXPECT_EQ(0, fake_audio_capture_module_->StopPlayout()); |
| 205 EXPECT_EQ(0, fake_audio_capture_module_->StopRecording()); | 205 EXPECT_EQ(0, fake_audio_capture_module_->StopRecording()); |
| 206 } | 206 } |
| OLD | NEW |