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

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

Issue 10535029: Add support for encrypted WebM files as defined in the RFC. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Addressing comments in the CL. Created 8 years, 6 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
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 "media/filters/pipeline_integration_test_base.h" 5 #include "media/filters/pipeline_integration_test_base.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "media/base/decoder_buffer.h" 8 #include "media/base/decoder_buffer.h"
9 #include "media/base/test_data_util.h" 9 #include "media/base/test_data_util.h"
10 #include "media/filters/chunk_demuxer_client.h" 10 #include "media/filters/chunk_demuxer_client.h"
11 11
12 namespace media { 12 namespace media {
13 13
14 // Key ID of the video track in test file "bear-320x240-encrypted.webm". 14 // Key used to encrypt video track in test file "bear-320x240-encrypted.webm".
15 static const unsigned char kKeyId[] = 15 static const unsigned char kKey[] = {
16 "\x11\xa5\x18\x37\xc4\x73\x84\x03\xe5\xe6\x57\xed\x8e\x06\xd9\x7c"; 16 0x5b, 0x4e, 0xe8, 0xb6, 0xd0, 0x7e, 0x4e, 0x58, 0xea, 0x24, 0x4c, 0x40, 0x13,
17 0xfd, 0xb5, 0x2d
18 };
17 19
18 static const char* kSourceId = "SourceId"; 20 static const char* kSourceId = "SourceId";
19 21
20 // Helper class that emulates calls made on the ChunkDemuxer by the 22 // Helper class that emulates calls made on the ChunkDemuxer by the
21 // Media Source API. 23 // Media Source API.
22 class MockMediaSource : public ChunkDemuxerClient { 24 class MockMediaSource : public ChunkDemuxerClient {
23 public: 25 public:
24 MockMediaSource(const std::string& filename, int initial_append_size, 26 MockMediaSource(const std::string& filename, int initial_append_size,
25 bool has_audio, bool has_video) 27 bool has_audio, bool has_video)
26 : url_(GetTestDataURL(filename)), 28 : url_(GetTestDataURL(filename)),
27 current_position_(0), 29 current_position_(0),
28 initial_append_size_(initial_append_size), 30 initial_append_size_(initial_append_size),
29 has_audio_(has_audio), 31 has_audio_(has_audio),
30 has_video_(has_video) { 32 has_video_(has_video) {
31 file_data_ = ReadTestDataFile(filename); 33 file_data_ = ReadTestDataFile(filename);
32 34
33 DCHECK_GT(initial_append_size_, 0); 35 DCHECK_GT(initial_append_size_, 0);
34 DCHECK_LE(initial_append_size_, file_data_->GetDataSize()); 36 DCHECK_LE(initial_append_size_, file_data_->GetDataSize());
35 } 37 }
36 38
37 virtual ~MockMediaSource() {} 39 virtual ~MockMediaSource() {}
38 40
39 void set_decryptor(AesDecryptor* decryptor) { 41 void set_decryptor(HmacAesDecryptor* decryptor) {
40 decryptor_ = decryptor; 42 decryptor_ = decryptor;
41 } 43 }
42 AesDecryptor* decryptor() const { 44 HmacAesDecryptor* decryptor() const {
43 return decryptor_; 45 return decryptor_;
44 } 46 }
45 47
46 const std::string& url() const { return url_; } 48 const std::string& url() const { return url_; }
47 49
48 void Seek(int new_position, int seek_append_size) { 50 void Seek(int new_position, int seek_append_size) {
49 chunk_demuxer_->StartWaitingForSeek(); 51 chunk_demuxer_->StartWaitingForSeek();
50 52
51 chunk_demuxer_->Abort(kSourceId); 53 chunk_demuxer_->Abort(kSourceId);
52 54
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 chunk_demuxer_->AddId(kSourceId, "video/webm", codecs); 92 chunk_demuxer_->AddId(kSourceId, "video/webm", codecs);
91 AppendData(initial_append_size_); 93 AppendData(initial_append_size_);
92 } 94 }
93 95
94 virtual void DemuxerClosed() { 96 virtual void DemuxerClosed() {
95 chunk_demuxer_ = NULL; 97 chunk_demuxer_ = NULL;
96 } 98 }
97 99
98 virtual void KeyNeeded(scoped_array<uint8> init_data, int init_data_size) { 100 virtual void KeyNeeded(scoped_array<uint8> init_data, int init_data_size) {
99 DCHECK(init_data.get()); 101 DCHECK(init_data.get());
100 DCHECK_EQ(init_data_size, 16);
101 DCHECK(decryptor()); 102 DCHECK(decryptor());
102 // In test file bear-320x240-encrypted.webm, the decryption key is equal to
103 // |init_data|.
104 decryptor()->AddKey(init_data.get(), init_data_size, 103 decryptor()->AddKey(init_data.get(), init_data_size,
105 init_data.get(), init_data_size); 104 kKey, sizeof(kKey) - 1);
106 } 105 }
107 106
108 private: 107 private:
109 std::string url_; 108 std::string url_;
110 scoped_refptr<DecoderBuffer> file_data_; 109 scoped_refptr<DecoderBuffer> file_data_;
111 int current_position_; 110 int current_position_;
112 int initial_append_size_; 111 int initial_append_size_;
113 bool has_audio_; 112 bool has_audio_;
114 bool has_video_; 113 bool has_video_;
115 scoped_refptr<ChunkDemuxer> chunk_demuxer_; 114 scoped_refptr<ChunkDemuxer> chunk_demuxer_;
116 AesDecryptor* decryptor_; 115 HmacAesDecryptor* decryptor_;
117 }; 116 };
118 117
119 class PipelineIntegrationTest 118 class PipelineIntegrationTest
120 : public testing::Test, 119 : public testing::Test,
121 public PipelineIntegrationTestBase { 120 public PipelineIntegrationTestBase {
122 public: 121 public:
123 void StartPipelineWithMediaSource(MockMediaSource& source) { 122 void StartPipelineWithMediaSource(MockMediaSource& source) {
124 pipeline_->Start( 123 pipeline_->Start(
125 CreateFilterCollection(&source), 124 CreateFilterCollection(&source),
126 base::Bind(&PipelineIntegrationTest::OnEnded, base::Unretained(this)), 125 base::Bind(&PipelineIntegrationTest::OnEnded, base::Unretained(this)),
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 253
255 // Verify video decoder & renderer can handle aborted demuxer reads. 254 // Verify video decoder & renderer can handle aborted demuxer reads.
256 TEST_F(PipelineIntegrationTest, ChunkDemuxerAbortRead_VideoOnly) { 255 TEST_F(PipelineIntegrationTest, ChunkDemuxerAbortRead_VideoOnly) {
257 ASSERT_TRUE(TestSeekDuringRead("bear-320x240-video-only.webm", 32768, 256 ASSERT_TRUE(TestSeekDuringRead("bear-320x240-video-only.webm", 32768,
258 base::TimeDelta::FromMilliseconds(200), 257 base::TimeDelta::FromMilliseconds(200),
259 base::TimeDelta::FromMilliseconds(1668), 258 base::TimeDelta::FromMilliseconds(1668),
260 0x1C896, 65536, false, true)); 259 0x1C896, 65536, false, true));
261 } 260 }
262 261
263 } // namespace media 262 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698