| 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 "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 | 173 |
| 174 void OnEncodedAudio(const media::AudioParameters& params, | 174 void OnEncodedAudio(const media::AudioParameters& params, |
| 175 std::unique_ptr<std::string> encoded_data, | 175 std::unique_ptr<std::string> encoded_data, |
| 176 TimeTicks timestamp) { | 176 TimeTicks timestamp) { |
| 177 EXPECT_TRUE(!encoded_data->empty()); | 177 EXPECT_TRUE(!encoded_data->empty()); |
| 178 // Decode |encoded_data| and check we get the expected number of frames | 178 // Decode |encoded_data| and check we get the expected number of frames |
| 179 // per buffer. | 179 // per buffer. |
| 180 EXPECT_EQ(kDefaultSampleRate * kOpusBufferDurationMs / 1000, | 180 EXPECT_EQ(kDefaultSampleRate * kOpusBufferDurationMs / 1000, |
| 181 opus_decode_float( | 181 opus_decode_float( |
| 182 opus_decoder_, reinterpret_cast<uint8_t*>( | 182 opus_decoder_, reinterpret_cast<uint8_t*>( |
| 183 string_as_array(encoded_data.get())), | 183 base::string_as_array(encoded_data.get())), |
| 184 encoded_data->size(), buffer_.get(), kFramesPerBuffer, 0)); | 184 encoded_data->size(), buffer_.get(), kFramesPerBuffer, 0)); |
| 185 | 185 |
| 186 DoOnEncodedAudio(params, *encoded_data, timestamp); | 186 DoOnEncodedAudio(params, *encoded_data, timestamp); |
| 187 } | 187 } |
| 188 | 188 |
| 189 const base::MessageLoop message_loop_; | 189 const base::MessageLoop message_loop_; |
| 190 | 190 |
| 191 // ATR and WebMediaStreamTrack for fooling it. | 191 // ATR and WebMediaStreamTrack for fooling it. |
| 192 std::unique_ptr<AudioTrackRecorder> audio_track_recorder_; | 192 std::unique_ptr<AudioTrackRecorder> audio_track_recorder_; |
| 193 blink::WebMediaStreamTrack blink_track_; | 193 blink::WebMediaStreamTrack blink_track_; |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 | 292 |
| 293 if (GetParam().sample_rate % 100) | 293 if (GetParam().sample_rate % 100) |
| 294 audio_track_recorder_->OnData(*GetFirstSourceAudioBus(), TimeTicks::Now()); | 294 audio_track_recorder_->OnData(*GetFirstSourceAudioBus(), TimeTicks::Now()); |
| 295 | 295 |
| 296 run_loop.Run(); | 296 run_loop.Run(); |
| 297 Mock::VerifyAndClearExpectations(this); | 297 Mock::VerifyAndClearExpectations(this); |
| 298 } | 298 } |
| 299 | 299 |
| 300 INSTANTIATE_TEST_CASE_P(, AudioTrackRecorderTest, ValuesIn(kATRTestParams)); | 300 INSTANTIATE_TEST_CASE_P(, AudioTrackRecorderTest, ValuesIn(kATRTestParams)); |
| 301 } // namespace content | 301 } // namespace content |
| OLD | NEW |