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

Side by Side Diff: media/mp4/mp4_stream_parser_unittest.cc

Issue 10651006: Add Common Encryption support to BMFF, including subsample decryption. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Add wrong subsample size test Created 8 years, 5 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 <algorithm> 5 #include <algorithm>
6 #include <string> 6 #include <string>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 16 matching lines...) Expand all
27 class MP4StreamParserTest : public testing::Test { 27 class MP4StreamParserTest : public testing::Test {
28 public: 28 public:
29 MP4StreamParserTest() 29 MP4StreamParserTest()
30 : parser_(new MP4StreamParser), 30 : parser_(new MP4StreamParser),
31 got_configs_(false) { 31 got_configs_(false) {
32 } 32 }
33 33
34 protected: 34 protected:
35 scoped_ptr<MP4StreamParser> parser_; 35 scoped_ptr<MP4StreamParser> parser_;
36 base::TimeDelta segment_start_; 36 base::TimeDelta segment_start_;
37 bool got_configs_; 37 bool got_configs_;
ddorwin 2012/07/17 01:14:21 s/got/have/ seems better
strobe_ 2012/07/19 02:43:35 Done.
38 38
39 bool AppendData(const uint8* data, size_t length) { 39 bool AppendData(const uint8* data, size_t length) {
40 parser_->Parse(data, length); 40 return parser_->Parse(data, length);
41 return true;
42 } 41 }
43 42
44 bool AppendDataInPieces(const uint8* data, size_t length) { 43 bool AppendDataInPieces(const uint8* data, size_t length) {
45 return AppendDataInPieces(data, length, 7); 44 return AppendDataInPieces(data, length, 7);
ddorwin 2012/07/17 01:14:21 Why 7? That's an odd size.
strobe_ 2012/07/19 02:43:35 Method unused, removed.
46 } 45 }
47 46
48 bool AppendDataInPieces(const uint8* data, size_t length, size_t piece_size) { 47 bool AppendDataInPieces(const uint8* data, size_t length, size_t piece_size) {
49 const uint8* start = data; 48 const uint8* start = data;
50 const uint8* end = data + length; 49 const uint8* end = data + length;
51 while (start < end) { 50 while (start < end) {
52 size_t append_size = std::min(piece_size, 51 size_t append_size = std::min(piece_size,
53 static_cast<size_t>(end - start)); 52 static_cast<size_t>(end - start));
54 if (!AppendData(start, append_size)) 53 if (!AppendData(start, append_size))
55 return false; 54 return false;
(...skipping 20 matching lines...) Expand all
76 return true; 75 return true;
77 } 76 }
78 77
79 bool NewBuffersF(const StreamParser::BufferQueue& bufs) { 78 bool NewBuffersF(const StreamParser::BufferQueue& bufs) {
80 DVLOG(2) << "NewBuffersF: " << bufs.size() << " buffers"; 79 DVLOG(2) << "NewBuffersF: " << bufs.size() << " buffers";
81 for (StreamParser::BufferQueue::const_iterator buf = bufs.begin(); 80 for (StreamParser::BufferQueue::const_iterator buf = bufs.begin();
82 buf != bufs.end(); buf++) { 81 buf != bufs.end(); buf++) {
83 DVLOG(3) << " n=" << buf - bufs.begin() 82 DVLOG(3) << " n=" << buf - bufs.begin()
84 << ", size=" << (*buf)->GetDataSize() 83 << ", size=" << (*buf)->GetDataSize()
85 << ", dur=" << (*buf)->GetDuration().InMilliseconds(); 84 << ", dur=" << (*buf)->GetDuration().InMilliseconds();
86 EXPECT_LE(segment_start_, (*buf)->GetTimestamp()); 85 EXPECT_LE(segment_start_, (*buf)->GetTimestamp());
ddorwin 2012/07/17 01:14:21 You're really testing the timestamp, which means t
strobe_ 2012/07/19 02:43:35 Well, not according to the macro definition ;) Aar
87 } 86 }
88 return true; 87 return true;
89 } 88 }
90 89
91 bool KeyNeededF(scoped_array<uint8> init_data, int init_data_size) { 90 bool KeyNeededF(scoped_array<uint8> init_data, int init_data_size) {
92 DVLOG(1) << "KeyNeededF: " << init_data_size; 91 DVLOG(1) << "KeyNeededF: " << init_data_size;
93 return true; 92 return true;
94 } 93 }
95 94
96 void NewSegmentF(TimeDelta start_dts) { 95 void NewSegmentF(TimeDelta start_dts) {
97 DVLOG(1) << "NewSegmentF: " << start_dts.InMilliseconds(); 96 DVLOG(1) << "NewSegmentF: " << start_dts.InMilliseconds();
98 segment_start_ = start_dts; 97 segment_start_ = start_dts;
99 } 98 }
100 99
101 void InitializeParser() { 100 void InitializeParser() {
102 parser_->Init( 101 parser_->Init(
103 base::Bind(&MP4StreamParserTest::InitF, base::Unretained(this)), 102 base::Bind(&MP4StreamParserTest::InitF, base::Unretained(this)),
104 base::Bind(&MP4StreamParserTest::NewConfigF, base::Unretained(this)), 103 base::Bind(&MP4StreamParserTest::NewConfigF, base::Unretained(this)),
105 base::Bind(&MP4StreamParserTest::NewBuffersF, base::Unretained(this)), 104 base::Bind(&MP4StreamParserTest::NewBuffersF, base::Unretained(this)),
106 base::Bind(&MP4StreamParserTest::NewBuffersF, base::Unretained(this)), 105 base::Bind(&MP4StreamParserTest::NewBuffersF, base::Unretained(this)),
107 base::Bind(&MP4StreamParserTest::KeyNeededF, base::Unretained(this)), 106 base::Bind(&MP4StreamParserTest::KeyNeededF, base::Unretained(this)),
108 base::Bind(&MP4StreamParserTest::NewSegmentF, base::Unretained(this))); 107 base::Bind(&MP4StreamParserTest::NewSegmentF, base::Unretained(this)));
109 } 108 }
110 109
111 bool ParseMP4File(const std::string& filename, int append_size) { 110 bool ParseMP4File(const std::string& filename, int append_size) {
ddorwin 2012/07/17 01:14:21 size=bytes?
strobe_ 2012/07/19 02:43:35 Done.
112 InitializeParser(); 111 InitializeParser();
113 112
114 scoped_refptr<DecoderBuffer> buffer = ReadTestDataFile(filename); 113 scoped_refptr<DecoderBuffer> buffer = ReadTestDataFile(filename);
115 EXPECT_TRUE(AppendDataInPieces(buffer->GetData(), 114 EXPECT_TRUE(AppendDataInPieces(buffer->GetData(),
116 buffer->GetDataSize(), 115 buffer->GetDataSize(),
117 append_size)); 116 append_size));
118 return true; 117 return true;
119 } 118 }
120 }; 119 };
121 120
122 TEST_F(MP4StreamParserTest, TestParseBearDASH) { 121 TEST_F(MP4StreamParserTest, TestParseBearDASH) {
ddorwin 2012/07/17 01:14:21 Is "bear" really relevant to the test? What is int
strobe_ 2012/07/19 02:43:35 Renamed and commented.
123 ParseMP4File("bear.1280x720_dash.mp4", 512); 122 ParseMP4File("bear.1280x720_dash.mp4", 512);
ddorwin 2012/07/17 01:14:21 Unrelated to this CL, is this file really "dash" o
strobe_ 2012/07/19 02:43:35 It complies with 23009-1 6.3.4 and 14496-12 FAMD3
124 } 123 }
125 124
126 TEST_F(MP4StreamParserTest, TestMultiFragmentAppend) { 125 TEST_F(MP4StreamParserTest, TestMultiFragmentAppend) {
127 ParseMP4File("bear.1280x720_dash.mp4", 768432); 126 ParseMP4File("bear.1280x720_dash.mp4", 768432);
ddorwin 2012/07/17 01:14:21 What do the sizes mean?
strobe_ 2012/07/19 02:43:35 Commented.
128 } 127 }
129 128
130 TEST_F(MP4StreamParserTest, TestReinitialization) { 129 TEST_F(MP4StreamParserTest, TestReinitialization) {
131 InitializeParser(); 130 InitializeParser();
ddorwin 2012/07/17 01:14:21 Where is the second initialization? Shouldn't re-i
strobe_ 2012/07/19 02:43:35 Commented.
ddorwin 2012/07/19 06:11:10 Where?
132 131
133 scoped_refptr<DecoderBuffer> buffer = 132 scoped_refptr<DecoderBuffer> buffer =
134 ReadTestDataFile("bear.1280x720_dash.mp4"); 133 ReadTestDataFile("bear.1280x720_dash.mp4");
135 EXPECT_TRUE(AppendDataInPieces(buffer->GetData(), 134 EXPECT_TRUE(AppendDataInPieces(buffer->GetData(),
136 buffer->GetDataSize(), 135 buffer->GetDataSize(),
137 512)); 136 512));
138 EXPECT_TRUE(AppendDataInPieces(buffer->GetData(), 137 EXPECT_TRUE(AppendDataInPieces(buffer->GetData(),
139 buffer->GetDataSize(), 138 buffer->GetDataSize(),
140 512)); 139 512));
141 } 140 }
142 141
143 } // namespace mp4 142 } // namespace mp4
144 } // namespace media 143 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698