OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 int num_dropped_frames) { | 83 int num_dropped_frames) { |
84 // Prepare a simulated EncodedFrame to feed into the AudioDecoder. | 84 // Prepare a simulated EncodedFrame to feed into the AudioDecoder. |
85 scoped_ptr<EncodedFrame> encoded_frame( | 85 scoped_ptr<EncodedFrame> encoded_frame( |
86 new EncodedFrame()); | 86 new EncodedFrame()); |
87 encoded_frame->dependency = EncodedFrame::KEY; | 87 encoded_frame->dependency = EncodedFrame::KEY; |
88 encoded_frame->frame_id = last_frame_id_ + 1 + num_dropped_frames; | 88 encoded_frame->frame_id = last_frame_id_ + 1 + num_dropped_frames; |
89 encoded_frame->referenced_frame_id = encoded_frame->frame_id; | 89 encoded_frame->referenced_frame_id = encoded_frame->frame_id; |
90 last_frame_id_ = encoded_frame->frame_id; | 90 last_frame_id_ = encoded_frame->frame_id; |
91 | 91 |
92 const scoped_ptr<AudioBus> audio_bus( | 92 const scoped_ptr<AudioBus> audio_bus( |
93 audio_bus_factory_->NextAudioBus(duration).Pass()); | 93 audio_bus_factory_->NextAudioBus(duration)); |
94 | 94 |
95 // Encode |audio_bus| into |encoded_frame->data|. | 95 // Encode |audio_bus| into |encoded_frame->data|. |
96 const int num_elements = audio_bus->channels() * audio_bus->frames(); | 96 const int num_elements = audio_bus->channels() * audio_bus->frames(); |
97 std::vector<int16_t> interleaved(num_elements); | 97 std::vector<int16_t> interleaved(num_elements); |
98 audio_bus->ToInterleaved(audio_bus->frames(), sizeof(int16_t), | 98 audio_bus->ToInterleaved(audio_bus->frames(), sizeof(int16_t), |
99 &interleaved.front()); | 99 &interleaved.front()); |
100 if (GetParam().codec == CODEC_AUDIO_PCM16) { | 100 if (GetParam().codec == CODEC_AUDIO_PCM16) { |
101 encoded_frame->data.resize(num_elements * sizeof(int16_t)); | 101 encoded_frame->data.resize(num_elements * sizeof(int16_t)); |
102 int16_t* const pcm_data = | 102 int16_t* const pcm_data = |
103 reinterpret_cast<int16_t*>(encoded_frame->mutable_bytes()); | 103 reinterpret_cast<int16_t*>(encoded_frame->mutable_bytes()); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 AudioDecoderTestScenarios, | 242 AudioDecoderTestScenarios, |
243 AudioDecoderTest, | 243 AudioDecoderTest, |
244 ::testing::Values( | 244 ::testing::Values( |
245 TestScenario(CODEC_AUDIO_PCM16, 1, 8000), | 245 TestScenario(CODEC_AUDIO_PCM16, 1, 8000), |
246 TestScenario(CODEC_AUDIO_PCM16, 2, 48000), | 246 TestScenario(CODEC_AUDIO_PCM16, 2, 48000), |
247 TestScenario(CODEC_AUDIO_OPUS, 1, 8000), | 247 TestScenario(CODEC_AUDIO_OPUS, 1, 8000), |
248 TestScenario(CODEC_AUDIO_OPUS, 2, 48000))); | 248 TestScenario(CODEC_AUDIO_OPUS, 2, 48000))); |
249 | 249 |
250 } // namespace cast | 250 } // namespace cast |
251 } // namespace media | 251 } // namespace media |
OLD | NEW |