| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <deque> | 5 #include <deque> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
| 10 #include "media/base/decoder_buffer.h" | 10 #include "media/base/decoder_buffer.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 } | 47 } |
| 48 | 48 |
| 49 buffer->SetDuration(base::TimeDelta()); | 49 buffer->SetDuration(base::TimeDelta()); |
| 50 encoded_audio_.push_back(buffer); | 50 encoded_audio_.push_back(buffer); |
| 51 } | 51 } |
| 52 | 52 |
| 53 // Push in an EOS buffer. | 53 // Push in an EOS buffer. |
| 54 encoded_audio_.push_back(DecoderBuffer::CreateEOSBuffer()); | 54 encoded_audio_.push_back(DecoderBuffer::CreateEOSBuffer()); |
| 55 | 55 |
| 56 config_.Initialize(kCodecVorbis, | 56 config_.Initialize(kCodecVorbis, |
| 57 16, | 57 kSampleFormatPlanarF32, |
| 58 CHANNEL_LAYOUT_STEREO, | 58 CHANNEL_LAYOUT_STEREO, |
| 59 44100, | 59 44100, |
| 60 vorbis_extradata_->GetData(), | 60 vorbis_extradata_->GetData(), |
| 61 vorbis_extradata_->GetDataSize(), | 61 vorbis_extradata_->GetDataSize(), |
| 62 false, // Not encrypted. | 62 false, // Not encrypted. |
| 63 true); | 63 true); |
| 64 } | 64 } |
| 65 | 65 |
| 66 virtual ~FFmpegAudioDecoderTest() {} | 66 virtual ~FFmpegAudioDecoderTest() {} |
| 67 | 67 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 | 121 |
| 122 std::deque<scoped_refptr<DecoderBuffer> > encoded_audio_; | 122 std::deque<scoped_refptr<DecoderBuffer> > encoded_audio_; |
| 123 std::deque<scoped_refptr<Buffer> > decoded_audio_; | 123 std::deque<scoped_refptr<Buffer> > decoded_audio_; |
| 124 | 124 |
| 125 AudioDecoderConfig config_; | 125 AudioDecoderConfig config_; |
| 126 }; | 126 }; |
| 127 | 127 |
| 128 TEST_F(FFmpegAudioDecoderTest, Initialize) { | 128 TEST_F(FFmpegAudioDecoderTest, Initialize) { |
| 129 Initialize(); | 129 Initialize(); |
| 130 | 130 |
| 131 EXPECT_EQ(16, decoder_->bits_per_channel()); | 131 EXPECT_EQ(config_.bits_per_channel(), decoder_->bits_per_channel()); |
| 132 EXPECT_EQ(CHANNEL_LAYOUT_STEREO, decoder_->channel_layout()); | 132 EXPECT_EQ(config_.channel_layout(), decoder_->channel_layout()); |
| 133 EXPECT_EQ(44100, decoder_->samples_per_second()); | 133 EXPECT_EQ(config_.samples_per_second(), decoder_->samples_per_second()); |
| 134 } | 134 } |
| 135 | 135 |
| 136 TEST_F(FFmpegAudioDecoderTest, ProduceAudioSamples) { | 136 TEST_F(FFmpegAudioDecoderTest, ProduceAudioSamples) { |
| 137 Initialize(); | 137 Initialize(); |
| 138 | 138 |
| 139 // Vorbis requires N+1 packets to produce audio data for N packets. | 139 // Vorbis requires N+1 packets to produce audio data for N packets. |
| 140 // | 140 // |
| 141 // This will should result in the demuxer receiving three reads for two | 141 // This will should result in the demuxer receiving three reads for two |
| 142 // requests to produce audio samples. | 142 // requests to produce audio samples. |
| 143 EXPECT_CALL(*demuxer_, Read(_)) | 143 EXPECT_CALL(*demuxer_, Read(_)) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 169 | 169 |
| 170 EXPECT_CALL(*demuxer_, Read(_)) | 170 EXPECT_CALL(*demuxer_, Read(_)) |
| 171 .WillOnce(InvokeReadPacket(this)); | 171 .WillOnce(InvokeReadPacket(this)); |
| 172 Read(); | 172 Read(); |
| 173 | 173 |
| 174 EXPECT_EQ(decoded_audio_.size(), 1u); | 174 EXPECT_EQ(decoded_audio_.size(), 1u); |
| 175 EXPECT_TRUE(decoded_audio_[0].get() == NULL); | 175 EXPECT_TRUE(decoded_audio_[0].get() == NULL); |
| 176 } | 176 } |
| 177 | 177 |
| 178 } // namespace media | 178 } // namespace media |
| OLD | NEW |