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

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

Issue 10447035: Introducing DecoderBuffer and general Buffer cleanup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fix! 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 | 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 "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/test_data_util.h" 9 #include "media/base/test_data_util.h"
9 #include "media/filters/chunk_demuxer_client.h" 10 #include "media/filters/chunk_demuxer_client.h"
10 11
11 namespace media { 12 namespace media {
12 13
13 // Key ID of the video track in test file "bear-320x240-encrypted.webm". 14 // Key ID of the video track in test file "bear-320x240-encrypted.webm".
14 static const unsigned char kKeyId[] = 15 static const unsigned char kKeyId[] =
15 "\x11\xa5\x18\x37\xc4\x73\x84\x03\xe5\xe6\x57\xed\x8e\x06\xd9\x7c"; 16 "\x11\xa5\x18\x37\xc4\x73\x84\x03\xe5\xe6\x57\xed\x8e\x06\xd9\x7c";
16 17
17 static const char* kSourceId = "SourceId"; 18 static const char* kSourceId = "SourceId";
18 19
19 // Helper class that emulates calls made on the ChunkDemuxer by the 20 // Helper class that emulates calls made on the ChunkDemuxer by the
20 // Media Source API. 21 // Media Source API.
21 class MockMediaSource : public ChunkDemuxerClient { 22 class MockMediaSource : public ChunkDemuxerClient {
22 public: 23 public:
23 MockMediaSource(const std::string& filename, int initial_append_size) 24 MockMediaSource(const std::string& filename, int initial_append_size)
24 : url_(GetTestDataURL(filename)), 25 : url_(GetTestDataURL(filename)),
25 current_position_(0), 26 current_position_(0),
26 initial_append_size_(initial_append_size) { 27 initial_append_size_(initial_append_size) {
27 ReadTestDataFile(filename, &file_data_, &file_data_size_); 28 file_data_ = ReadTestDataFile(filename);
28 29
29 DCHECK_GT(initial_append_size_, 0); 30 DCHECK_GT(initial_append_size_, 0);
30 DCHECK_LE(initial_append_size_, file_data_size_); 31 DCHECK_LE(initial_append_size_, file_data_->GetDataSize());
31 } 32 }
32 33
33 virtual ~MockMediaSource() {} 34 virtual ~MockMediaSource() {}
34 35
35 void set_decryptor(AesDecryptor* decryptor) { 36 void set_decryptor(AesDecryptor* decryptor) {
36 decryptor_ = decryptor; 37 decryptor_ = decryptor;
37 } 38 }
38 AesDecryptor* decryptor() const { 39 AesDecryptor* decryptor() const {
39 return decryptor_; 40 return decryptor_;
40 } 41 }
41 42
42 const std::string& url() const { return url_; } 43 const std::string& url() const { return url_; }
43 44
44 void Seek(int new_position, int seek_append_size) { 45 void Seek(int new_position, int seek_append_size) {
45 chunk_demuxer_->StartWaitingForSeek(); 46 chunk_demuxer_->StartWaitingForSeek();
46 47
47 DCHECK_GE(new_position, 0); 48 DCHECK_GE(new_position, 0);
48 DCHECK_LT(new_position, file_data_size_); 49 DCHECK_LT(new_position, file_data_->GetDataSize());
49 current_position_ = new_position; 50 current_position_ = new_position;
50 51
51 AppendData(seek_append_size); 52 AppendData(seek_append_size);
52 } 53 }
53 54
54 void AppendData(int size) { 55 void AppendData(int size) {
55 DCHECK(chunk_demuxer_.get()); 56 DCHECK(chunk_demuxer_.get());
56 DCHECK_LT(current_position_, file_data_size_); 57 DCHECK_LT(current_position_, file_data_->GetDataSize());
57 DCHECK_LE(current_position_ + size, file_data_size_); 58 DCHECK_LE(current_position_ + size, file_data_->GetDataSize());
58 CHECK(chunk_demuxer_->AppendData(kSourceId, 59 CHECK(chunk_demuxer_->AppendData(
59 file_data_.get() + current_position_, 60 kSourceId, file_data_->GetData() + current_position_, size));
60 size));
61 current_position_ += size; 61 current_position_ += size;
62 } 62 }
63 63
64 void EndOfStream() { 64 void EndOfStream() {
65 chunk_demuxer_->EndOfStream(PIPELINE_OK); 65 chunk_demuxer_->EndOfStream(PIPELINE_OK);
66 } 66 }
67 67
68 void Abort() { 68 void Abort() {
69 if (!chunk_demuxer_.get()) 69 if (!chunk_demuxer_.get())
70 return; 70 return;
(...skipping 20 matching lines...) Expand all
91 DCHECK_EQ(init_data_size, 16); 91 DCHECK_EQ(init_data_size, 16);
92 DCHECK(decryptor()); 92 DCHECK(decryptor());
93 // In test file bear-320x240-encrypted.webm, the decryption key is equal to 93 // In test file bear-320x240-encrypted.webm, the decryption key is equal to
94 // |init_data|. 94 // |init_data|.
95 decryptor()->AddKey(init_data.get(), init_data_size, 95 decryptor()->AddKey(init_data.get(), init_data_size,
96 init_data.get(), init_data_size); 96 init_data.get(), init_data_size);
97 } 97 }
98 98
99 private: 99 private:
100 std::string url_; 100 std::string url_;
101 scoped_array<uint8> file_data_; 101 scoped_refptr<DecoderBuffer> file_data_;
102 int file_data_size_;
103 int current_position_; 102 int current_position_;
104 int initial_append_size_; 103 int initial_append_size_;
105 scoped_refptr<ChunkDemuxer> chunk_demuxer_; 104 scoped_refptr<ChunkDemuxer> chunk_demuxer_;
106 AesDecryptor* decryptor_; 105 AesDecryptor* decryptor_;
107 }; 106 };
108 107
109 class PipelineIntegrationTest 108 class PipelineIntegrationTest
110 : public testing::Test, 109 : public testing::Test,
111 public PipelineIntegrationTestBase { 110 public PipelineIntegrationTestBase {
112 public: 111 public:
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 232
234 // Verify video decoder & renderer can handle aborted demuxer reads. 233 // Verify video decoder & renderer can handle aborted demuxer reads.
235 TEST_F(PipelineIntegrationTest, ChunkDemuxerAbortRead_VideoOnly) { 234 TEST_F(PipelineIntegrationTest, ChunkDemuxerAbortRead_VideoOnly) {
236 ASSERT_TRUE(TestSeekDuringRead("bear-320x240-video-only.webm", 32768, 235 ASSERT_TRUE(TestSeekDuringRead("bear-320x240-video-only.webm", 32768,
237 base::TimeDelta::FromMilliseconds(200), 236 base::TimeDelta::FromMilliseconds(200),
238 base::TimeDelta::FromMilliseconds(1668), 237 base::TimeDelta::FromMilliseconds(1668),
239 0x1C896, 65536)); 238 0x1C896, 65536));
240 } 239 }
241 240
242 } // namespace media 241 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698