| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/media/audio_track_recorder.h" | 5 #include "content/renderer/media/audio_track_recorder.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <string> |
| 10 |
| 9 #include "base/bind.h" | 11 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 11 #include "base/macros.h" | 13 #include "base/macros.h" |
| 12 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
| 13 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
| 16 #include "base/time/time.h" |
| 14 #include "content/renderer/media/media_stream_audio_source.h" | 17 #include "content/renderer/media/media_stream_audio_source.h" |
| 15 #include "media/audio/simple_sources.h" | 18 #include "media/audio/simple_sources.h" |
| 16 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 18 #include "third_party/WebKit/public/platform/WebString.h" | 21 #include "third_party/WebKit/public/platform/WebString.h" |
| 19 #include "third_party/WebKit/public/web/WebHeap.h" | 22 #include "third_party/WebKit/public/web/WebHeap.h" |
| 20 #include "third_party/opus/src/include/opus.h" | 23 #include "third_party/opus/src/include/opus.h" |
| 21 | 24 |
| 22 using ::testing::_; | 25 using ::testing::_; |
| 23 using ::testing::DoAll; | 26 using ::testing::DoAll; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 EXPECT_TRUE(error == OPUS_OK && opus_decoder_); | 150 EXPECT_TRUE(error == OPUS_OK && opus_decoder_); |
| 148 | 151 |
| 149 buffer_.reset(new float[kFramesPerBuffer * params.channels()]); | 152 buffer_.reset(new float[kFramesPerBuffer * params.channels()]); |
| 150 } | 153 } |
| 151 | 154 |
| 152 std::unique_ptr<media::AudioBus> GetFirstSourceAudioBus() { | 155 std::unique_ptr<media::AudioBus> GetFirstSourceAudioBus() { |
| 153 std::unique_ptr<media::AudioBus> bus(media::AudioBus::Create( | 156 std::unique_ptr<media::AudioBus> bus(media::AudioBus::Create( |
| 154 first_params_.channels(), first_params_.sample_rate() * | 157 first_params_.channels(), first_params_.sample_rate() * |
| 155 kMediaStreamAudioTrackBufferDurationMs / | 158 kMediaStreamAudioTrackBufferDurationMs / |
| 156 base::Time::kMillisecondsPerSecond)); | 159 base::Time::kMillisecondsPerSecond)); |
| 157 first_source_.OnMoreData(bus.get(), 0, 0); | 160 first_source_.OnMoreData(base::TimeDelta(), base::TimeTicks::Now(), 0, |
| 161 bus.get()); |
| 158 return bus; | 162 return bus; |
| 159 } | 163 } |
| 160 std::unique_ptr<media::AudioBus> GetSecondSourceAudioBus() { | 164 std::unique_ptr<media::AudioBus> GetSecondSourceAudioBus() { |
| 161 std::unique_ptr<media::AudioBus> bus(media::AudioBus::Create( | 165 std::unique_ptr<media::AudioBus> bus(media::AudioBus::Create( |
| 162 second_params_.channels(), second_params_.sample_rate() * | 166 second_params_.channels(), second_params_.sample_rate() * |
| 163 kMediaStreamAudioTrackBufferDurationMs / | 167 kMediaStreamAudioTrackBufferDurationMs / |
| 164 base::Time::kMillisecondsPerSecond)); | 168 base::Time::kMillisecondsPerSecond)); |
| 165 second_source_.OnMoreData(bus.get(), 0, 0); | 169 second_source_.OnMoreData(base::TimeDelta(), base::TimeTicks::Now(), 0, |
| 170 bus.get()); |
| 166 return bus; | 171 return bus; |
| 167 } | 172 } |
| 168 | 173 |
| 169 MOCK_METHOD3(DoOnEncodedAudio, | 174 MOCK_METHOD3(DoOnEncodedAudio, |
| 170 void(const media::AudioParameters& params, | 175 void(const media::AudioParameters& params, |
| 171 std::string encoded_data, | 176 std::string encoded_data, |
| 172 TimeTicks timestamp)); | 177 TimeTicks timestamp)); |
| 173 | 178 |
| 174 void OnEncodedAudio(const media::AudioParameters& params, | 179 void OnEncodedAudio(const media::AudioParameters& params, |
| 175 std::unique_ptr<std::string> encoded_data, | 180 std::unique_ptr<std::string> encoded_data, |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 | 297 |
| 293 if (GetParam().sample_rate % 100) | 298 if (GetParam().sample_rate % 100) |
| 294 audio_track_recorder_->OnData(*GetFirstSourceAudioBus(), TimeTicks::Now()); | 299 audio_track_recorder_->OnData(*GetFirstSourceAudioBus(), TimeTicks::Now()); |
| 295 | 300 |
| 296 run_loop.Run(); | 301 run_loop.Run(); |
| 297 Mock::VerifyAndClearExpectations(this); | 302 Mock::VerifyAndClearExpectations(this); |
| 298 } | 303 } |
| 299 | 304 |
| 300 INSTANTIATE_TEST_CASE_P(, AudioTrackRecorderTest, ValuesIn(kATRTestParams)); | 305 INSTANTIATE_TEST_CASE_P(, AudioTrackRecorderTest, ValuesIn(kATRTestParams)); |
| 301 } // namespace content | 306 } // namespace content |
| OLD | NEW |