Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Side by Side Diff: media/filters/chunk_demuxer_unittest.cc

Issue 10910293: Add is_encrypted() in VideoDecoderConfig. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 EXPECT_FALSE(audio_stream->is_encrypted());
714 } else { 715 } else {
715 EXPECT_FALSE(audio_stream); 716 EXPECT_FALSE(audio_stream);
716 } 717 }
717 718
718 scoped_refptr<DemuxerStream> video_stream = 719 scoped_refptr<DemuxerStream> video_stream =
719 demuxer_->GetStream(DemuxerStream::VIDEO); 720 demuxer_->GetStream(DemuxerStream::VIDEO);
720 if (has_video) { 721 if (has_video) {
721 EXPECT_TRUE(video_stream); 722 EXPECT_TRUE(video_stream);
723 EXPECT_EQ(is_video_encrypted, video_stream->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 1579 matching lines...) Expand 10 before | Expand all | Expand 10 after
2311 2313
2312 scoped_ptr<Cluster> cluster_a(kDefaultFirstCluster()); 2314 scoped_ptr<Cluster> cluster_a(kDefaultFirstCluster());
2313 ASSERT_TRUE(AppendData(cluster_a->data(), cluster_a->size())); 2315 ASSERT_TRUE(AppendData(cluster_a->data(), cluster_a->size()));
2314 2316
2315 EXPECT_CALL(host_, SetDuration( 2317 EXPECT_CALL(host_, SetDuration(
2316 base::TimeDelta::FromMilliseconds(kDefaultFirstClusterEndTimestamp))); 2318 base::TimeDelta::FromMilliseconds(kDefaultFirstClusterEndTimestamp)));
2317 demuxer_->EndOfStream(PIPELINE_OK); 2319 demuxer_->EndOfStream(PIPELINE_OK);
2318 } 2320 }
2319 2321
2320 } // namespace media 2322 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698