| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
| 7 #include "media/base/audio_decoder_config.h" | 7 #include "media/base/audio_decoder_config.h" |
| 8 #include "media/base/decoder_buffer.h" | 8 #include "media/base/decoder_buffer.h" |
| 9 #include "media/base/mock_callback.h" | 9 #include "media/base/mock_callback.h" |
| 10 #include "media/base/mock_demuxer_host.h" | 10 #include "media/base/mock_demuxer_host.h" |
| (...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 MockDemuxerHost host_; | 676 MockDemuxerHost host_; |
| 677 | 677 |
| 678 scoped_refptr<ChunkDemuxer> demuxer_; | 678 scoped_refptr<ChunkDemuxer> demuxer_; |
| 679 | 679 |
| 680 private: | 680 private: |
| 681 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxerTest); | 681 DISALLOW_COPY_AND_ASSIGN(ChunkDemuxerTest); |
| 682 }; | 682 }; |
| 683 | 683 |
| 684 TEST_F(ChunkDemuxerTest, TestInit) { | 684 TEST_F(ChunkDemuxerTest, TestInit) { |
| 685 // Test no streams, audio-only, video-only, and audio & video scenarios, | 685 // Test no streams, audio-only, video-only, and audio & video scenarios, |
| 686 // with video content encoded or not. | 686 // with video encrypted or not. |
| 687 for (int i = 0; i < 8; i++) { | 687 for (int i = 0; i < 8; i++) { |
| 688 bool has_audio = (i & 0x1) != 0; | 688 bool has_audio = (i & 0x1) != 0; |
| 689 bool has_video = (i & 0x2) != 0; | 689 bool has_video = (i & 0x2) != 0; |
| 690 bool video_content_encoded = (i & 0x4) != 0; | 690 bool is_video_encrypted = (i & 0x4) != 0; |
| 691 | 691 |
| 692 // No test on invalid combination. | 692 // No test on invalid combination. |
| 693 if (!has_video && video_content_encoded) | 693 if (!has_video && is_video_encrypted) |
| 694 continue; | 694 continue; |
| 695 | 695 |
| 696 CreateNewDemuxer(); | 696 CreateNewDemuxer(); |
| 697 if (has_video && video_content_encoded) | 697 if (has_video && is_video_encrypted) |
| 698 EXPECT_CALL(*this, NeedKeyMock(NotNull(), 16)); | 698 EXPECT_CALL(*this, NeedKeyMock(NotNull(), 16)); |
| 699 | 699 |
| 700 ASSERT_TRUE(InitDemuxer(has_audio, has_video, video_content_encoded)); | 700 ASSERT_TRUE(InitDemuxer(has_audio, has_video, is_video_encrypted)); |
| 701 | 701 |
| 702 scoped_refptr<DemuxerStream> audio_stream = | 702 scoped_refptr<DemuxerStream> audio_stream = |
| 703 demuxer_->GetStream(DemuxerStream::AUDIO); | 703 demuxer_->GetStream(DemuxerStream::AUDIO); |
| 704 if (has_audio) { | 704 if (has_audio) { |
| 705 ASSERT_TRUE(audio_stream); | 705 ASSERT_TRUE(audio_stream); |
| 706 | 706 |
| 707 const AudioDecoderConfig& config = audio_stream->audio_decoder_config(); | 707 const AudioDecoderConfig& config = audio_stream->audio_decoder_config(); |
| 708 EXPECT_EQ(kCodecVorbis, config.codec()); | 708 EXPECT_EQ(kCodecVorbis, config.codec()); |
| 709 EXPECT_EQ(16, config.bits_per_channel()); | 709 EXPECT_EQ(16, config.bits_per_channel()); |
| 710 EXPECT_EQ(CHANNEL_LAYOUT_STEREO, config.channel_layout()); | 710 EXPECT_EQ(CHANNEL_LAYOUT_STEREO, config.channel_layout()); |
| 711 EXPECT_EQ(44100, config.samples_per_second()); | 711 EXPECT_EQ(44100, config.samples_per_second()); |
| 712 EXPECT_TRUE(config.extra_data()); | 712 EXPECT_TRUE(config.extra_data()); |
| 713 EXPECT_GT(config.extra_data_size(), 0u); | 713 EXPECT_GT(config.extra_data_size(), 0u); |
| 714 } else { | 714 } else { |
| 715 EXPECT_FALSE(audio_stream); | 715 EXPECT_FALSE(audio_stream); |
| 716 } | 716 } |
| 717 | 717 |
| 718 scoped_refptr<DemuxerStream> video_stream = | 718 scoped_refptr<DemuxerStream> video_stream = |
| 719 demuxer_->GetStream(DemuxerStream::VIDEO); | 719 demuxer_->GetStream(DemuxerStream::VIDEO); |
| 720 if (has_video) { | 720 if (has_video) { |
| 721 EXPECT_TRUE(video_stream); | 721 EXPECT_TRUE(video_stream); |
| 722 EXPECT_EQ(is_video_encrypted, |
| 723 video_stream->video_decoder_config().is_encrypted()); |
| 722 } else { | 724 } else { |
| 723 EXPECT_FALSE(video_stream); | 725 EXPECT_FALSE(video_stream); |
| 724 } | 726 } |
| 725 | 727 |
| 726 ShutdownDemuxer(); | 728 ShutdownDemuxer(); |
| 727 demuxer_ = NULL; | 729 demuxer_ = NULL; |
| 728 } | 730 } |
| 729 } | 731 } |
| 730 | 732 |
| 731 // Make sure that the demuxer reports an error if Shutdown() | 733 // Make sure that the demuxer reports an error if Shutdown() |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1153 // end of stream buffers. | 1155 // end of stream buffers. |
| 1154 end_of_stream_helper_2.RequestReads(); | 1156 end_of_stream_helper_2.RequestReads(); |
| 1155 end_of_stream_helper_2.CheckIfReadDonesWereCalled(true); | 1157 end_of_stream_helper_2.CheckIfReadDonesWereCalled(true); |
| 1156 | 1158 |
| 1157 end_of_stream_helper_3.RequestReads(); | 1159 end_of_stream_helper_3.RequestReads(); |
| 1158 end_of_stream_helper_3.CheckIfReadDonesWereCalled(true); | 1160 end_of_stream_helper_3.CheckIfReadDonesWereCalled(true); |
| 1159 } | 1161 } |
| 1160 | 1162 |
| 1161 // Make sure AppendData() will accept elements that span multiple calls. | 1163 // Make sure AppendData() will accept elements that span multiple calls. |
| 1162 TEST_F(ChunkDemuxerTest, TestAppendingInPieces) { | 1164 TEST_F(ChunkDemuxerTest, TestAppendingInPieces) { |
| 1163 | |
| 1164 EXPECT_CALL(*this, DemuxerOpened()); | 1165 EXPECT_CALL(*this, DemuxerOpened()); |
| 1165 demuxer_->Initialize( | 1166 demuxer_->Initialize( |
| 1166 &host_, CreateInitDoneCB(kDefaultDuration(), PIPELINE_OK)); | 1167 &host_, CreateInitDoneCB(kDefaultDuration(), PIPELINE_OK)); |
| 1167 | 1168 |
| 1168 ASSERT_EQ(AddId(), ChunkDemuxer::kOk); | 1169 ASSERT_EQ(AddId(), ChunkDemuxer::kOk); |
| 1169 | 1170 |
| 1170 scoped_array<uint8> info_tracks; | 1171 scoped_array<uint8> info_tracks; |
| 1171 int info_tracks_size = 0; | 1172 int info_tracks_size = 0; |
| 1172 CreateInitSegment(true, true, false, &info_tracks, &info_tracks_size); | 1173 CreateInitSegment(true, true, false, &info_tracks, &info_tracks_size); |
| 1173 | 1174 |
| (...skipping 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2311 | 2312 |
| 2312 scoped_ptr<Cluster> cluster_a(kDefaultFirstCluster()); | 2313 scoped_ptr<Cluster> cluster_a(kDefaultFirstCluster()); |
| 2313 ASSERT_TRUE(AppendData(cluster_a->data(), cluster_a->size())); | 2314 ASSERT_TRUE(AppendData(cluster_a->data(), cluster_a->size())); |
| 2314 | 2315 |
| 2315 EXPECT_CALL(host_, SetDuration( | 2316 EXPECT_CALL(host_, SetDuration( |
| 2316 base::TimeDelta::FromMilliseconds(kDefaultFirstClusterEndTimestamp))); | 2317 base::TimeDelta::FromMilliseconds(kDefaultFirstClusterEndTimestamp))); |
| 2317 demuxer_->EndOfStream(PIPELINE_OK); | 2318 demuxer_->EndOfStream(PIPELINE_OK); |
| 2318 } | 2319 } |
| 2319 | 2320 |
| 2320 } // namespace media | 2321 } // namespace media |
| OLD | NEW |