OLD | NEW |
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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 InitializeParser(); | 135 InitializeParser(); |
136 | 136 |
137 scoped_refptr<DecoderBuffer> buffer = ReadTestDataFile(filename); | 137 scoped_refptr<DecoderBuffer> buffer = ReadTestDataFile(filename); |
138 EXPECT_TRUE(AppendDataInPieces(buffer->data(), | 138 EXPECT_TRUE(AppendDataInPieces(buffer->data(), |
139 buffer->data_size(), | 139 buffer->data_size(), |
140 append_bytes)); | 140 append_bytes)); |
141 return true; | 141 return true; |
142 } | 142 } |
143 }; | 143 }; |
144 | 144 |
145 TEST_F(MP4StreamParserTest, TestUnalignedAppend) { | 145 TEST_F(MP4StreamParserTest, UnalignedAppend) { |
146 // Test small, non-segment-aligned appends (small enough to exercise | 146 // Test small, non-segment-aligned appends (small enough to exercise |
147 // incremental append system) | 147 // incremental append system) |
148 ParseMP4File("bear-1280x720-av_frag.mp4", 512); | 148 ParseMP4File("bear-1280x720-av_frag.mp4", 512); |
149 } | 149 } |
150 | 150 |
151 TEST_F(MP4StreamParserTest, TestBytewiseAppend) { | 151 TEST_F(MP4StreamParserTest, BytewiseAppend) { |
152 // Ensure no incremental errors occur when parsing | 152 // Ensure no incremental errors occur when parsing |
153 ParseMP4File("bear-1280x720-av_frag.mp4", 1); | 153 ParseMP4File("bear-1280x720-av_frag.mp4", 1); |
154 } | 154 } |
155 | 155 |
156 TEST_F(MP4StreamParserTest, TestMultiFragmentAppend) { | 156 TEST_F(MP4StreamParserTest, MultiFragmentAppend) { |
157 // Large size ensures multiple fragments are appended in one call (size is | 157 // Large size ensures multiple fragments are appended in one call (size is |
158 // larger than this particular test file) | 158 // larger than this particular test file) |
159 ParseMP4File("bear-1280x720-av_frag.mp4", 768432); | 159 ParseMP4File("bear-1280x720-av_frag.mp4", 768432); |
160 } | 160 } |
161 | 161 |
162 TEST_F(MP4StreamParserTest, TestFlush) { | 162 TEST_F(MP4StreamParserTest, Flush) { |
163 // Flush while reading sample data, then start a new stream. | 163 // Flush while reading sample data, then start a new stream. |
164 InitializeParser(); | 164 InitializeParser(); |
165 | 165 |
166 scoped_refptr<DecoderBuffer> buffer = | 166 scoped_refptr<DecoderBuffer> buffer = |
167 ReadTestDataFile("bear-1280x720-av_frag.mp4"); | 167 ReadTestDataFile("bear-1280x720-av_frag.mp4"); |
168 EXPECT_TRUE(AppendDataInPieces(buffer->data(), 65536, 512)); | 168 EXPECT_TRUE(AppendDataInPieces(buffer->data(), 65536, 512)); |
169 parser_->Flush(); | 169 parser_->Flush(); |
170 EXPECT_TRUE(AppendDataInPieces(buffer->data(), | 170 EXPECT_TRUE(AppendDataInPieces(buffer->data(), |
171 buffer->data_size(), | 171 buffer->data_size(), |
172 512)); | 172 512)); |
173 } | 173 } |
174 | 174 |
175 TEST_F(MP4StreamParserTest, TestReinitialization) { | 175 TEST_F(MP4StreamParserTest, Reinitialization) { |
176 InitializeParser(); | 176 InitializeParser(); |
177 | 177 |
178 scoped_refptr<DecoderBuffer> buffer = | 178 scoped_refptr<DecoderBuffer> buffer = |
179 ReadTestDataFile("bear-1280x720-av_frag.mp4"); | 179 ReadTestDataFile("bear-1280x720-av_frag.mp4"); |
180 EXPECT_TRUE(AppendDataInPieces(buffer->data(), | 180 EXPECT_TRUE(AppendDataInPieces(buffer->data(), |
181 buffer->data_size(), | 181 buffer->data_size(), |
182 512)); | 182 512)); |
183 EXPECT_TRUE(AppendDataInPieces(buffer->data(), | 183 EXPECT_TRUE(AppendDataInPieces(buffer->data(), |
184 buffer->data_size(), | 184 buffer->data_size(), |
185 512)); | 185 512)); |
186 } | 186 } |
187 | 187 |
188 TEST_F(MP4StreamParserTest, TestMPEG2_AAC_LC) { | 188 TEST_F(MP4StreamParserTest, MPEG2_AAC_LC) { |
189 std::set<int> audio_object_types; | 189 std::set<int> audio_object_types; |
190 audio_object_types.insert(kISO_13818_7_AAC_LC); | 190 audio_object_types.insert(kISO_13818_7_AAC_LC); |
191 parser_.reset(new MP4StreamParser(audio_object_types, false)); | 191 parser_.reset(new MP4StreamParser(audio_object_types, false)); |
192 ParseMP4File("bear-mpeg2-aac-only_frag.mp4", 512); | 192 ParseMP4File("bear-mpeg2-aac-only_frag.mp4", 512); |
193 } | 193 } |
194 | 194 |
195 // Test that a moov box is not always required after Flush() is called. | 195 // Test that a moov box is not always required after Flush() is called. |
196 TEST_F(MP4StreamParserTest, TestNoMoovAfterFlush) { | 196 TEST_F(MP4StreamParserTest, NoMoovAfterFlush) { |
197 InitializeParser(); | 197 InitializeParser(); |
198 | 198 |
199 scoped_refptr<DecoderBuffer> buffer = | 199 scoped_refptr<DecoderBuffer> buffer = |
200 ReadTestDataFile("bear-1280x720-av_frag.mp4"); | 200 ReadTestDataFile("bear-1280x720-av_frag.mp4"); |
201 EXPECT_TRUE(AppendDataInPieces(buffer->data(), | 201 EXPECT_TRUE(AppendDataInPieces(buffer->data(), |
202 buffer->data_size(), | 202 buffer->data_size(), |
203 512)); | 203 512)); |
204 parser_->Flush(); | 204 parser_->Flush(); |
205 | 205 |
206 const int kFirstMoofOffset = 1307; | 206 const int kFirstMoofOffset = 1307; |
207 EXPECT_TRUE(AppendDataInPieces(buffer->data() + kFirstMoofOffset, | 207 EXPECT_TRUE(AppendDataInPieces(buffer->data() + kFirstMoofOffset, |
208 buffer->data_size() - kFirstMoofOffset, | 208 buffer->data_size() - kFirstMoofOffset, |
209 512)); | 209 512)); |
210 } | 210 } |
211 | 211 |
212 // TODO(strobe): Create and test media which uses CENC auxiliary info stored | 212 // TODO(strobe): Create and test media which uses CENC auxiliary info stored |
213 // inside a private box | 213 // inside a private box |
214 | 214 |
215 } // namespace mp4 | 215 } // namespace mp4 |
216 } // namespace media | 216 } // namespace media |
OLD | NEW |