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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 #include "media/base/audio_buffer.h" | 6 #include "media/base/audio_buffer.h" |
7 #include "media/base/audio_bus.h" | 7 #include "media/base/audio_bus.h" |
8 #include "media/base/audio_discard_helper.h" | 8 #include "media/base/audio_discard_helper.h" |
9 #include "media/base/buffers.h" | 9 #include "media/base/buffers.h" |
10 #include "media/base/decoder_buffer.h" | 10 #include "media/base/decoder_buffer.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 } | 26 } |
27 | 27 |
28 static scoped_refptr<AudioBuffer> CreateDecodedBuffer(int frames) { | 28 static scoped_refptr<AudioBuffer> CreateDecodedBuffer(int frames) { |
29 return MakeAudioBuffer(kSampleFormatPlanarF32, | 29 return MakeAudioBuffer(kSampleFormatPlanarF32, |
30 CHANNEL_LAYOUT_MONO, | 30 CHANNEL_LAYOUT_MONO, |
31 1, | 31 1, |
32 kSampleRate, | 32 kSampleRate, |
33 0.0f, | 33 0.0f, |
34 kDataStep, | 34 kDataStep, |
35 frames, | 35 frames, |
| 36 kNoTimestamp(), |
36 kNoTimestamp()); | 37 kNoTimestamp()); |
37 } | 38 } |
38 | 39 |
39 static float ExtractDecodedData(const scoped_refptr<AudioBuffer>& buffer, | 40 static float ExtractDecodedData(const scoped_refptr<AudioBuffer>& buffer, |
40 int index) { | 41 int index) { |
41 // This is really inefficient, but we can't access the raw AudioBuffer if any | 42 // This is really inefficient, but we can't access the raw AudioBuffer if any |
42 // start trimming has been applied. | 43 // start trimming has been applied. |
43 scoped_ptr<AudioBus> temp_bus = AudioBus::Create(buffer->channel_count(), 1); | 44 scoped_ptr<AudioBus> temp_bus = AudioBus::Create(buffer->channel_count(), 1); |
44 buffer->ReadFrames(1, index, 0, temp_bus.get()); | 45 buffer->ReadFrames(1, index, 0, temp_bus.get()); |
45 return temp_bus->channel(0)[0]; | 46 return temp_bus->channel(0)[0]; |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 ASSERT_TRUE(discard_helper.ProcessBuffers(encoded_buffer, decoded_buffer)); | 252 ASSERT_TRUE(discard_helper.ProcessBuffers(encoded_buffer, decoded_buffer)); |
252 ASSERT_TRUE(discard_helper.initialized()); | 253 ASSERT_TRUE(discard_helper.initialized()); |
253 EXPECT_EQ(kTimestamp, decoded_buffer->timestamp()); | 254 EXPECT_EQ(kTimestamp, decoded_buffer->timestamp()); |
254 EXPECT_EQ(kDuration / 2, decoded_buffer->duration()); | 255 EXPECT_EQ(kDuration / 2, decoded_buffer->duration()); |
255 EXPECT_EQ(kTestFrames / 2, decoded_buffer->frame_count()); | 256 EXPECT_EQ(kTestFrames / 2, decoded_buffer->frame_count()); |
256 ASSERT_FLOAT_EQ(kDiscardFrames * kDataStep, | 257 ASSERT_FLOAT_EQ(kDiscardFrames * kDataStep, |
257 ExtractDecodedData(decoded_buffer, 0)); | 258 ExtractDecodedData(decoded_buffer, 0)); |
258 } | 259 } |
259 | 260 |
260 } // namespace media | 261 } // namespace media |
OLD | NEW |