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

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

Issue 17408005: Refactored DecoderBuffer to use unix_hacker_style naming. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@localrefactor
Patch Set: Created 7 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 <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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 << ", video=" << vc.IsValidConfig(); 68 << ", video=" << vc.IsValidConfig();
69 configs_received_ = true; 69 configs_received_ = true;
70 return true; 70 return true;
71 } 71 }
72 72
73 bool NewBuffersF(const StreamParser::BufferQueue& bufs) { 73 bool NewBuffersF(const StreamParser::BufferQueue& bufs) {
74 DVLOG(2) << "NewBuffersF: " << bufs.size() << " buffers"; 74 DVLOG(2) << "NewBuffersF: " << bufs.size() << " buffers";
75 for (StreamParser::BufferQueue::const_iterator buf = bufs.begin(); 75 for (StreamParser::BufferQueue::const_iterator buf = bufs.begin();
76 buf != bufs.end(); buf++) { 76 buf != bufs.end(); buf++) {
77 DVLOG(3) << " n=" << buf - bufs.begin() 77 DVLOG(3) << " n=" << buf - bufs.begin()
78 << ", size=" << (*buf)->GetDataSize() 78 << ", size=" << (*buf)->get_data_size()
79 << ", dur=" << (*buf)->GetDuration().InMilliseconds(); 79 << ", dur=" << (*buf)->get_duration().InMilliseconds();
80 EXPECT_GE((*buf)->GetTimestamp(), segment_start_); 80 EXPECT_GE((*buf)->get_timestamp(), segment_start_);
81 } 81 }
82 return true; 82 return true;
83 } 83 }
84 84
85 bool NewTextBuffersF(TextTrack* text_track, 85 bool NewTextBuffersF(TextTrack* text_track,
86 const StreamParser::BufferQueue& buffers) { 86 const StreamParser::BufferQueue& buffers) {
87 return true; 87 return true;
88 } 88 }
89 89
90 bool KeyNeededF(const std::string& type, 90 bool KeyNeededF(const std::string& type,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 base::Bind(&MP4StreamParserTest::NewSegmentF, base::Unretained(this)), 125 base::Bind(&MP4StreamParserTest::NewSegmentF, base::Unretained(this)),
126 base::Bind(&MP4StreamParserTest::EndOfSegmentF, 126 base::Bind(&MP4StreamParserTest::EndOfSegmentF,
127 base::Unretained(this)), 127 base::Unretained(this)),
128 LogCB()); 128 LogCB());
129 } 129 }
130 130
131 bool ParseMP4File(const std::string& filename, int append_bytes) { 131 bool ParseMP4File(const std::string& filename, int append_bytes) {
132 InitializeParser(); 132 InitializeParser();
133 133
134 scoped_refptr<DecoderBuffer> buffer = ReadTestDataFile(filename); 134 scoped_refptr<DecoderBuffer> buffer = ReadTestDataFile(filename);
135 EXPECT_TRUE(AppendDataInPieces(buffer->GetData(), 135 EXPECT_TRUE(AppendDataInPieces(buffer->get_data(),
136 buffer->GetDataSize(), 136 buffer->get_data_size(),
137 append_bytes)); 137 append_bytes));
138 return true; 138 return true;
139 } 139 }
140 }; 140 };
141 141
142 TEST_F(MP4StreamParserTest, TestUnalignedAppend) { 142 TEST_F(MP4StreamParserTest, TestUnalignedAppend) {
143 // Test small, non-segment-aligned appends (small enough to exercise 143 // Test small, non-segment-aligned appends (small enough to exercise
144 // incremental append system) 144 // incremental append system)
145 ParseMP4File("bear-1280x720-av_frag.mp4", 512); 145 ParseMP4File("bear-1280x720-av_frag.mp4", 512);
146 } 146 }
147 147
148 TEST_F(MP4StreamParserTest, TestBytewiseAppend) { 148 TEST_F(MP4StreamParserTest, TestBytewiseAppend) {
149 // Ensure no incremental errors occur when parsing 149 // Ensure no incremental errors occur when parsing
150 ParseMP4File("bear-1280x720-av_frag.mp4", 1); 150 ParseMP4File("bear-1280x720-av_frag.mp4", 1);
151 } 151 }
152 152
153 TEST_F(MP4StreamParserTest, TestMultiFragmentAppend) { 153 TEST_F(MP4StreamParserTest, TestMultiFragmentAppend) {
154 // Large size ensures multiple fragments are appended in one call (size is 154 // Large size ensures multiple fragments are appended in one call (size is
155 // larger than this particular test file) 155 // larger than this particular test file)
156 ParseMP4File("bear-1280x720-av_frag.mp4", 768432); 156 ParseMP4File("bear-1280x720-av_frag.mp4", 768432);
157 } 157 }
158 158
159 TEST_F(MP4StreamParserTest, TestFlush) { 159 TEST_F(MP4StreamParserTest, TestFlush) {
160 // Flush while reading sample data, then start a new stream. 160 // Flush while reading sample data, then start a new stream.
161 InitializeParser(); 161 InitializeParser();
162 162
163 scoped_refptr<DecoderBuffer> buffer = 163 scoped_refptr<DecoderBuffer> buffer =
164 ReadTestDataFile("bear-1280x720-av_frag.mp4"); 164 ReadTestDataFile("bear-1280x720-av_frag.mp4");
165 EXPECT_TRUE(AppendDataInPieces(buffer->GetData(), 65536, 512)); 165 EXPECT_TRUE(AppendDataInPieces(buffer->get_data(), 65536, 512));
166 parser_->Flush(); 166 parser_->Flush();
167 EXPECT_TRUE(AppendDataInPieces(buffer->GetData(), 167 EXPECT_TRUE(AppendDataInPieces(buffer->get_data(),
168 buffer->GetDataSize(), 168 buffer->get_data_size(),
169 512)); 169 512));
170 } 170 }
171 171
172 TEST_F(MP4StreamParserTest, TestReinitialization) { 172 TEST_F(MP4StreamParserTest, TestReinitialization) {
173 InitializeParser(); 173 InitializeParser();
174 174
175 scoped_refptr<DecoderBuffer> buffer = 175 scoped_refptr<DecoderBuffer> buffer =
176 ReadTestDataFile("bear-1280x720-av_frag.mp4"); 176 ReadTestDataFile("bear-1280x720-av_frag.mp4");
177 EXPECT_TRUE(AppendDataInPieces(buffer->GetData(), 177 EXPECT_TRUE(AppendDataInPieces(buffer->get_data(),
178 buffer->GetDataSize(), 178 buffer->get_data_size(),
179 512)); 179 512));
180 EXPECT_TRUE(AppendDataInPieces(buffer->GetData(), 180 EXPECT_TRUE(AppendDataInPieces(buffer->get_data(),
181 buffer->GetDataSize(), 181 buffer->get_data_size(),
182 512)); 182 512));
183 } 183 }
184 184
185 TEST_F(MP4StreamParserTest, TestMPEG2_AAC_LC) { 185 TEST_F(MP4StreamParserTest, TestMPEG2_AAC_LC) {
186 std::set<int> audio_object_types; 186 std::set<int> audio_object_types;
187 audio_object_types.insert(kISO_13818_7_AAC_LC); 187 audio_object_types.insert(kISO_13818_7_AAC_LC);
188 parser_.reset(new MP4StreamParser(audio_object_types, false)); 188 parser_.reset(new MP4StreamParser(audio_object_types, false));
189 ParseMP4File("bear-mpeg2-aac-only_frag.mp4", 512); 189 ParseMP4File("bear-mpeg2-aac-only_frag.mp4", 512);
190 } 190 }
191 191
192 // TODO(strobe): Create and test media which uses CENC auxiliary info stored 192 // TODO(strobe): Create and test media which uses CENC auxiliary info stored
193 // inside a private box 193 // inside a private box
194 194
195 } // namespace mp4 195 } // namespace mp4
196 } // namespace media 196 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698