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

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

Powered by Google App Engine
This is Rietveld 408576698