OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/bind.h" | 5 #include "base/bind.h" |
| 6 #include "media/base/audio_decoder_config.h" |
6 #include "media/base/mock_callback.h" | 7 #include "media/base/mock_callback.h" |
7 #include "media/base/mock_filter_host.h" | 8 #include "media/base/mock_filter_host.h" |
8 #include "media/base/test_data_util.h" | 9 #include "media/base/test_data_util.h" |
9 #include "media/filters/chunk_demuxer.h" | 10 #include "media/filters/chunk_demuxer.h" |
10 #include "media/filters/chunk_demuxer_client.h" | 11 #include "media/filters/chunk_demuxer_client.h" |
11 #include "media/webm/cluster_builder.h" | 12 #include "media/webm/cluster_builder.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
13 | 14 |
14 using ::testing::AnyNumber; | 15 using ::testing::AnyNumber; |
15 using ::testing::InSequence; | 16 using ::testing::InSequence; |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 | 179 |
179 TEST_F(ChunkDemuxerTest, TestInit) { | 180 TEST_F(ChunkDemuxerTest, TestInit) { |
180 // Test no streams, audio-only, video-only, and audio & video scenarios. | 181 // Test no streams, audio-only, video-only, and audio & video scenarios. |
181 for (int i = 0; i < 4; i++) { | 182 for (int i = 0; i < 4; i++) { |
182 bool has_audio = (i & 0x1) != 0; | 183 bool has_audio = (i & 0x1) != 0; |
183 bool has_video = (i & 0x2) != 0; | 184 bool has_video = (i & 0x2) != 0; |
184 | 185 |
185 client_.reset(new MockChunkDemuxerClient()); | 186 client_.reset(new MockChunkDemuxerClient()); |
186 demuxer_ = new ChunkDemuxer(client_.get()); | 187 demuxer_ = new ChunkDemuxer(client_.get()); |
187 InitDemuxer(has_audio, has_video); | 188 InitDemuxer(has_audio, has_video); |
188 EXPECT_EQ(demuxer_->GetStream(DemuxerStream::AUDIO).get() != NULL, | 189 |
189 has_audio); | 190 scoped_refptr<DemuxerStream> audio_stream = |
190 EXPECT_EQ(demuxer_->GetStream(DemuxerStream::VIDEO).get() != NULL, | 191 demuxer_->GetStream(DemuxerStream::AUDIO); |
191 has_video); | 192 if (has_audio) { |
| 193 EXPECT_TRUE(audio_stream); |
| 194 |
| 195 const AudioDecoderConfig& config = audio_stream->audio_decoder_config(); |
| 196 EXPECT_EQ(kCodecVorbis, config.codec()); |
| 197 EXPECT_EQ(16, config.bits_per_channel()); |
| 198 EXPECT_EQ(CHANNEL_LAYOUT_STEREO, config.channel_layout()); |
| 199 EXPECT_EQ(44100, config.samples_per_second()); |
| 200 EXPECT_TRUE(config.extra_data()); |
| 201 EXPECT_GT(config.extra_data_size(), 0u); |
| 202 } else { |
| 203 EXPECT_FALSE(audio_stream); |
| 204 } |
| 205 |
| 206 scoped_refptr<DemuxerStream> video_stream = |
| 207 demuxer_->GetStream(DemuxerStream::VIDEO); |
| 208 if (has_video) { |
| 209 EXPECT_TRUE(video_stream); |
| 210 } else { |
| 211 EXPECT_FALSE(video_stream); |
| 212 } |
| 213 |
192 ShutdownDemuxer(); | 214 ShutdownDemuxer(); |
193 demuxer_ = NULL; | 215 demuxer_ = NULL; |
194 } | 216 } |
195 } | 217 } |
196 | 218 |
197 // Makes sure that Seek() reports an error if Shutdown() | 219 // Makes sure that Seek() reports an error if Shutdown() |
198 // is called before the first cluster is passed to the demuxer. | 220 // is called before the first cluster is passed to the demuxer. |
199 TEST_F(ChunkDemuxerTest, TestShutdownBeforeFirstSeekCompletes) { | 221 TEST_F(ChunkDemuxerTest, TestShutdownBeforeFirstSeekCompletes) { |
200 InitDemuxer(true, true); | 222 InitDemuxer(true, true); |
201 | 223 |
202 demuxer_->Seek(base::TimeDelta::FromSeconds(0), | 224 demuxer_->Seek(base::TimeDelta::FromSeconds(0), |
203 NewExpectedStatusCB(PIPELINE_ERROR_ABORT)); | 225 NewExpectedStatusCB(PIPELINE_ERROR_ABORT)); |
204 } | 226 } |
205 | 227 |
206 // Test that Seek() completes successfully when the first cluster | 228 // Test that Seek() completes successfully when the first cluster |
207 // arrives. | 229 // arrives. |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 // Request a few more reads and make sure we immediately get | 623 // Request a few more reads and make sure we immediately get |
602 // end of stream buffers. | 624 // end of stream buffers. |
603 end_of_stream_helper_2.RequestReads(); | 625 end_of_stream_helper_2.RequestReads(); |
604 end_of_stream_helper_2.CheckIfReadDonesWereCalled(true); | 626 end_of_stream_helper_2.CheckIfReadDonesWereCalled(true); |
605 | 627 |
606 end_of_stream_helper_3.RequestReads(); | 628 end_of_stream_helper_3.RequestReads(); |
607 end_of_stream_helper_3.CheckIfReadDonesWereCalled(true); | 629 end_of_stream_helper_3.CheckIfReadDonesWereCalled(true); |
608 } | 630 } |
609 | 631 |
610 } // namespace media | 632 } // namespace media |
OLD | NEW |