OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 buffer->data_size(), | 153 buffer->data_size(), |
154 append_bytes)); | 154 append_bytes)); |
155 return true; | 155 return true; |
156 } | 156 } |
157 }; | 157 }; |
158 | 158 |
159 TEST_F(Mp2tStreamParserTest, UnalignedAppend17) { | 159 TEST_F(Mp2tStreamParserTest, UnalignedAppend17) { |
160 // Test small, non-segment-aligned appends. | 160 // Test small, non-segment-aligned appends. |
161 InitializeParser(); | 161 InitializeParser(); |
162 ParseMpeg2TsFile("bear-1280x720.ts", 17); | 162 ParseMpeg2TsFile("bear-1280x720.ts", 17); |
163 EXPECT_EQ(video_frame_count_, 81); | |
164 parser_->Flush(); | 163 parser_->Flush(); |
165 EXPECT_EQ(video_frame_count_, 82); | 164 EXPECT_EQ(video_frame_count_, 82); |
166 } | 165 } |
167 | 166 |
168 TEST_F(Mp2tStreamParserTest, UnalignedAppend512) { | 167 TEST_F(Mp2tStreamParserTest, UnalignedAppend512) { |
169 // Test small, non-segment-aligned appends. | 168 // Test small, non-segment-aligned appends. |
170 InitializeParser(); | 169 InitializeParser(); |
171 ParseMpeg2TsFile("bear-1280x720.ts", 512); | 170 ParseMpeg2TsFile("bear-1280x720.ts", 512); |
172 EXPECT_EQ(video_frame_count_, 81); | |
173 parser_->Flush(); | 171 parser_->Flush(); |
174 EXPECT_EQ(video_frame_count_, 82); | 172 EXPECT_EQ(video_frame_count_, 82); |
175 } | 173 } |
176 | 174 |
177 TEST_F(Mp2tStreamParserTest, AppendAfterFlush512) { | 175 TEST_F(Mp2tStreamParserTest, AppendAfterFlush512) { |
178 InitializeParser(); | 176 InitializeParser(); |
179 ParseMpeg2TsFile("bear-1280x720.ts", 512); | 177 ParseMpeg2TsFile("bear-1280x720.ts", 512); |
180 parser_->Flush(); | 178 parser_->Flush(); |
181 | 179 |
182 ParseMpeg2TsFile("bear-1280x720.ts", 512); | 180 ParseMpeg2TsFile("bear-1280x720.ts", 512); |
183 parser_->Flush(); | 181 parser_->Flush(); |
184 } | 182 } |
185 | 183 |
186 TEST_F(Mp2tStreamParserTest, TimestampWrapAround) { | 184 TEST_F(Mp2tStreamParserTest, TimestampWrapAround) { |
187 // "bear-1280x720_ptswraparound.ts" has been transcoded | 185 // "bear-1280x720_ptswraparound.ts" has been transcoded |
188 // from bear-1280x720.mp4 by applying a time offset of 95442s | 186 // from bear-1280x720.mp4 by applying a time offset of 95442s |
189 // (close to 2^33 / 90000) which results in timestamps wrap around | 187 // (close to 2^33 / 90000) which results in timestamps wrap around |
190 // in the Mpeg2 TS stream. | 188 // in the Mpeg2 TS stream. |
191 InitializeParser(); | 189 InitializeParser(); |
192 ParseMpeg2TsFile("bear-1280x720_ptswraparound.ts", 512); | 190 ParseMpeg2TsFile("bear-1280x720_ptswraparound.ts", 512); |
193 EXPECT_EQ(video_frame_count_, 81); | 191 parser_->Flush(); |
| 192 EXPECT_EQ(video_frame_count_, 82); |
194 EXPECT_GE(video_min_dts_, base::TimeDelta::FromSeconds(95443 - 10)); | 193 EXPECT_GE(video_min_dts_, base::TimeDelta::FromSeconds(95443 - 10)); |
195 EXPECT_LE(video_max_dts_, base::TimeDelta::FromSeconds(95443 + 10)); | 194 EXPECT_LE(video_max_dts_, base::TimeDelta::FromSeconds(95443 + 10)); |
196 } | 195 } |
197 | 196 |
198 } // namespace mp2t | 197 } // namespace mp2t |
199 } // namespace media | 198 } // namespace media |
OLD | NEW |