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