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

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

Issue 10829470: Support for parsing encrypted WebM streams by src. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressing comments Created 7 years, 9 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_demuxer_host.h" 9 #include "media/base/mock_demuxer_host.h"
10 #include "media/base/test_data_util.h" 10 #include "media/base/test_data_util.h"
11 #include "media/base/test_helpers.h" 11 #include "media/base/test_helpers.h"
12 #include "media/filters/chunk_demuxer.h" 12 #include "media/filters/chunk_demuxer.h"
13 #include "media/webm/cluster_builder.h" 13 #include "media/webm/cluster_builder.h"
14 #include "media/webm/webm_constants.h" 14 #include "media/webm/webm_constants.h"
15 #include "media/webm/webm_crypto_helpers.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 17
17 using ::testing::AnyNumber; 18 using ::testing::AnyNumber;
18 using ::testing::Exactly; 19 using ::testing::Exactly;
19 using ::testing::InSequence; 20 using ::testing::InSequence;
20 using ::testing::NotNull; 21 using ::testing::NotNull;
21 using ::testing::Return; 22 using ::testing::Return;
22 using ::testing::SaveArg; 23 using ::testing::SaveArg;
23 using ::testing::SetArgumentPointee; 24 using ::testing::SetArgumentPointee;
24 using ::testing::_; 25 using ::testing::_;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 static const int kAudioTrackNum = 2; 60 static const int kAudioTrackNum = 2;
60 61
61 static const int kAudioBlockDuration = 23; 62 static const int kAudioBlockDuration = 23;
62 static const int kVideoBlockDuration = 33; 63 static const int kVideoBlockDuration = 33;
63 64
64 static const char kSourceId[] = "SourceId"; 65 static const char kSourceId[] = "SourceId";
65 static const char kDefaultFirstClusterRange[] = "{ [0,46) }"; 66 static const char kDefaultFirstClusterRange[] = "{ [0,46) }";
66 static const int kDefaultFirstClusterEndTimestamp = 66; 67 static const int kDefaultFirstClusterEndTimestamp = 66;
67 static const int kDefaultSecondClusterEndTimestamp = 132; 68 static const int kDefaultSecondClusterEndTimestamp = 132;
68 69
69 static const char kWebMInitDataType[] = "video/webm";
70
71 base::TimeDelta kDefaultDuration() { 70 base::TimeDelta kDefaultDuration() {
72 return base::TimeDelta::FromMilliseconds(201224); 71 return base::TimeDelta::FromMilliseconds(201224);
73 } 72 }
74 73
75 // Write an integer into buffer in the form of vint that spans 8 bytes. 74 // Write an integer into buffer in the form of vint that spans 8 bytes.
76 // The data pointed by |buffer| should be at least 8 bytes long. 75 // The data pointed by |buffer| should be at least 8 bytes long.
77 // |number| should be in the range 0 <= number < 0x00FFFFFFFFFFFFFF. 76 // |number| should be in the range 0 <= number < 0x00FFFFFFFFFFFFFF.
78 static void WriteInt64(uint8* buffer, int64 number) { 77 static void WriteInt64(uint8* buffer, int64 number) {
79 DCHECK(number >= 0 && number < GG_LONGLONG(0x00FFFFFFFFFFFFFF)); 78 DCHECK(number >= 0 && number < GG_LONGLONG(0x00FFFFFFFFFFFFFF));
80 buffer[0] = 0x01; 79 buffer[0] = 0x01;
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 if ((!has_audio && is_audio_encrypted) || 776 if ((!has_audio && is_audio_encrypted) ||
778 (!has_video && is_video_encrypted)) { 777 (!has_video && is_video_encrypted)) {
779 continue; 778 continue;
780 } 779 }
781 780
782 CreateNewDemuxer(); 781 CreateNewDemuxer();
783 782
784 if (is_audio_encrypted || is_video_encrypted) { 783 if (is_audio_encrypted || is_video_encrypted) {
785 int need_key_count = (is_audio_encrypted ? 1 : 0) + 784 int need_key_count = (is_audio_encrypted ? 1 : 0) +
786 (is_video_encrypted ? 1 : 0); 785 (is_video_encrypted ? 1 : 0);
787 EXPECT_CALL(*this, NeedKeyMock(kWebMInitDataType, NotNull(), 16)) 786 EXPECT_CALL(*this, NeedKeyMock(kWebMEncryptInitDataType, NotNull(), 16))
788 .Times(Exactly(need_key_count)); 787 .Times(Exactly(need_key_count));
789 } 788 }
790 789
791 ASSERT_TRUE(InitDemuxerWithEncryptionInfo( 790 ASSERT_TRUE(InitDemuxerWithEncryptionInfo(
792 has_audio, has_video, is_audio_encrypted, is_video_encrypted)); 791 has_audio, has_video, is_audio_encrypted, is_video_encrypted));
793 792
794 scoped_refptr<DemuxerStream> audio_stream = 793 scoped_refptr<DemuxerStream> audio_stream =
795 demuxer_->GetStream(DemuxerStream::AUDIO); 794 demuxer_->GetStream(DemuxerStream::AUDIO);
796 if (has_audio) { 795 if (has_audio) {
797 ASSERT_TRUE(audio_stream); 796 ASSERT_TRUE(audio_stream);
(...skipping 1739 matching lines...) Expand 10 before | Expand all | Expand 10 after
2537 // call. This can happen if video element gets destroyed before 2536 // call. This can happen if video element gets destroyed before
2538 // the pipeline has a chance to initialize the demuxer. 2537 // the pipeline has a chance to initialize the demuxer.
2539 TEST_F(ChunkDemuxerTest, TestShutdownBeforeInitialize) { 2538 TEST_F(ChunkDemuxerTest, TestShutdownBeforeInitialize) {
2540 demuxer_->Shutdown(); 2539 demuxer_->Shutdown();
2541 demuxer_->Initialize( 2540 demuxer_->Initialize(
2542 &host_, CreateInitDoneCB(DEMUXER_ERROR_COULD_NOT_OPEN)); 2541 &host_, CreateInitDoneCB(DEMUXER_ERROR_COULD_NOT_OPEN));
2543 message_loop_.RunUntilIdle(); 2542 message_loop_.RunUntilIdle();
2544 } 2543 }
2545 2544
2546 } // namespace media 2545 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698