OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 Random rand_; | 178 Random rand_; |
179 | 179 |
180 int64_t max_wait_time_; | 180 int64_t max_wait_time_; |
181 bool tear_down_; | 181 bool tear_down_; |
182 rtc::PlatformThread extract_thread_; | 182 rtc::PlatformThread extract_thread_; |
183 rtc::Event trigger_extract_event_; | 183 rtc::Event trigger_extract_event_; |
184 rtc::Event crit_acquired_event_; | 184 rtc::Event crit_acquired_event_; |
185 rtc::CriticalSection crit_; | 185 rtc::CriticalSection crit_; |
186 }; | 186 }; |
187 | 187 |
188 TEST_F(TestFrameBuffer2, ExtractFromEmptyBuffer) { | 188 // Following tests are timing dependent. Either the timeouts have to |
189 ExtractFrame(); | 189 // be increased by a large margin, which would slow down all trybots, |
190 CheckNoFrame(0); | 190 // or we disable them for the very slow ones, like we do here. |
191 } | 191 #if !defined(ADDRESS_SANITIZER) && !defined(MEMORY_SANITIZER) |
192 | |
193 TEST_F(TestFrameBuffer2, WaitForFrame) { | 192 TEST_F(TestFrameBuffer2, WaitForFrame) { |
194 uint16_t pid = Rand(); | 193 uint16_t pid = Rand(); |
195 uint32_t ts = Rand(); | 194 uint32_t ts = Rand(); |
196 | 195 |
197 ExtractFrame(20); | 196 ExtractFrame(50); |
198 InsertFrame(pid, 0, ts, false); | 197 InsertFrame(pid, 0, ts, false); |
199 CheckFrame(0, pid, 0); | 198 CheckFrame(0, pid, 0); |
200 } | 199 } |
201 | 200 |
202 TEST_F(TestFrameBuffer2, OneSuperFrame) { | 201 TEST_F(TestFrameBuffer2, OneSuperFrame) { |
203 uint16_t pid = Rand(); | 202 uint16_t pid = Rand(); |
204 uint32_t ts = Rand(); | 203 uint32_t ts = Rand(); |
205 | 204 |
206 ExtractFrame(20); | 205 ExtractFrame(50); |
207 InsertFrame(pid, 1, ts, true); | 206 InsertFrame(pid, 1, ts, true); |
208 InsertFrame(pid, 0, ts, false); | 207 InsertFrame(pid, 0, ts, false); |
209 ExtractFrame(); | 208 ExtractFrame(); |
210 | 209 |
211 CheckFrame(0, pid, 0); | 210 CheckFrame(0, pid, 0); |
212 CheckFrame(1, pid, 1); | 211 CheckFrame(1, pid, 1); |
213 } | 212 } |
214 | 213 |
| 214 TEST_F(TestFrameBuffer2, OneLayerStreamReordered) { |
| 215 uint16_t pid = Rand(); |
| 216 uint32_t ts = Rand(); |
| 217 |
| 218 InsertFrame(pid, 0, ts, false); |
| 219 ExtractFrame(); |
| 220 CheckFrame(0, pid, 0); |
| 221 for (int i = 1; i < 10; i += 2) { |
| 222 ExtractFrame(50); |
| 223 InsertFrame(pid + i + 1, 0, ts + (i + 1) * kFps10, false, pid + i); |
| 224 clock_.AdvanceTimeMilliseconds(kFps10); |
| 225 InsertFrame(pid + i, 0, ts + i * kFps10, false, pid + i - 1); |
| 226 clock_.AdvanceTimeMilliseconds(kFps10); |
| 227 ExtractFrame(); |
| 228 CheckFrame(i, pid + i, 0); |
| 229 CheckFrame(i + 1, pid + i + 1, 0); |
| 230 } |
| 231 } |
| 232 #endif // Timing dependent tests. |
| 233 |
| 234 TEST_F(TestFrameBuffer2, ExtractFromEmptyBuffer) { |
| 235 ExtractFrame(); |
| 236 CheckNoFrame(0); |
| 237 } |
| 238 |
215 TEST_F(TestFrameBuffer2, OneLayerStream) { | 239 TEST_F(TestFrameBuffer2, OneLayerStream) { |
216 uint16_t pid = Rand(); | 240 uint16_t pid = Rand(); |
217 uint32_t ts = Rand(); | 241 uint32_t ts = Rand(); |
218 | 242 |
219 InsertFrame(pid, 0, ts, false); | 243 InsertFrame(pid, 0, ts, false); |
220 ExtractFrame(); | 244 ExtractFrame(); |
221 CheckFrame(0, pid, 0); | 245 CheckFrame(0, pid, 0); |
222 for (int i = 1; i < 10; ++i) { | 246 for (int i = 1; i < 10; ++i) { |
223 InsertFrame(pid + i, 0, ts + i * kFps10, false, pid + i - 1); | 247 InsertFrame(pid + i, 0, ts + i * kFps10, false, pid + i - 1); |
224 ExtractFrame(); | 248 ExtractFrame(); |
225 clock_.AdvanceTimeMilliseconds(kFps10); | 249 clock_.AdvanceTimeMilliseconds(kFps10); |
226 CheckFrame(i, pid + i, 0); | 250 CheckFrame(i, pid + i, 0); |
227 } | 251 } |
228 } | 252 } |
229 | 253 |
230 TEST_F(TestFrameBuffer2, OneLayerStreamReordered) { | |
231 uint16_t pid = Rand(); | |
232 uint32_t ts = Rand(); | |
233 | |
234 InsertFrame(pid, 0, ts, false); | |
235 ExtractFrame(); | |
236 CheckFrame(0, pid, 0); | |
237 for (int i = 1; i < 10; i += 2) { | |
238 ExtractFrame(15); | |
239 InsertFrame(pid + i + 1, 0, ts + (i + 1) * kFps10, false, pid + i); | |
240 clock_.AdvanceTimeMilliseconds(kFps10); | |
241 InsertFrame(pid + i, 0, ts + i * kFps10, false, pid + i - 1); | |
242 clock_.AdvanceTimeMilliseconds(kFps10); | |
243 ExtractFrame(); | |
244 CheckFrame(i, pid + i, 0); | |
245 CheckFrame(i + 1, pid + i + 1, 0); | |
246 } | |
247 } | |
248 | |
249 TEST_F(TestFrameBuffer2, DropTemporalLayerSlowDecoder) { | 254 TEST_F(TestFrameBuffer2, DropTemporalLayerSlowDecoder) { |
250 uint16_t pid = Rand(); | 255 uint16_t pid = Rand(); |
251 uint32_t ts = Rand(); | 256 uint32_t ts = Rand(); |
252 | 257 |
253 InsertFrame(pid, 0, ts, false); | 258 InsertFrame(pid, 0, ts, false); |
254 InsertFrame(pid + 1, 0, ts + kFps20, false); | 259 InsertFrame(pid + 1, 0, ts + kFps20, false); |
255 for (int i = 2; i < 10; i += 2) { | 260 for (int i = 2; i < 10; i += 2) { |
256 uint32_t ts_tl0 = ts + i / 2 * kFps10; | 261 uint32_t ts_tl0 = ts + i / 2 * kFps10; |
257 InsertFrame(pid + i, 0, ts_tl0, false, pid + i - 2); | 262 InsertFrame(pid + i, 0, ts_tl0, false, pid + i - 2); |
258 InsertFrame(pid + i + 1, 0, ts_tl0 + kFps20, false, pid + i, pid + i - 1); | 263 InsertFrame(pid + i + 1, 0, ts_tl0 + kFps20, false, pid + i, pid + i - 1); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 InsertFrame(pid + 1, 0, ts, false, pid); | 325 InsertFrame(pid + 1, 0, ts, false, pid); |
321 ExtractFrame(); | 326 ExtractFrame(); |
322 | 327 |
323 CheckFrame(0, pid, 0); | 328 CheckFrame(0, pid, 0); |
324 CheckFrame(1, pid + 2, 0); | 329 CheckFrame(1, pid + 2, 0); |
325 CheckNoFrame(2); | 330 CheckNoFrame(2); |
326 } | 331 } |
327 | 332 |
328 } // namespace video_coding | 333 } // namespace video_coding |
329 } // namespace webrtc | 334 } // namespace webrtc |
OLD | NEW |