OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // This test generate synthetic data. For audio it's a sinusoid waveform with | 5 // This test generate synthetic data. For audio it's a sinusoid waveform with |
6 // frequency kSoundFrequency and different amplitudes. For video it's a pattern | 6 // frequency kSoundFrequency and different amplitudes. For video it's a pattern |
7 // that is shifting by one pixel per frame, each pixels neighbors right and down | 7 // that is shifting by one pixel per frame, each pixels neighbors right and down |
8 // is this pixels value +1, since the pixel value is 8 bit it will wrap | 8 // is this pixels value +1, since the pixel value is 8 bit it will wrap |
9 // frequently within the image. Visually this will create diagonally color bands | 9 // frequently within the image. Visually this will create diagonally color bands |
10 // that moves across the screen | 10 // that moves across the screen |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 int height, | 266 int height, |
267 const base::TimeTicks& capture_time) { | 267 const base::TimeTicks& capture_time) { |
268 ExpectedVideoFrame expected_video_frame; | 268 ExpectedVideoFrame expected_video_frame; |
269 expected_video_frame.start_value = start_value; | 269 expected_video_frame.start_value = start_value; |
270 expected_video_frame.capture_time = capture_time; | 270 expected_video_frame.capture_time = capture_time; |
271 expected_video_frame.width = width; | 271 expected_video_frame.width = width; |
272 expected_video_frame.height = height; | 272 expected_video_frame.height = height; |
273 expected_frame_.push_back(expected_video_frame); | 273 expected_frame_.push_back(expected_video_frame); |
274 } | 274 } |
275 | 275 |
276 void CheckVideoFrame(scoped_ptr<I420VideoFrame> video_frame, | 276 void CheckVideoFrame(const scoped_refptr<media::VideoFrame>& video_frame, |
277 const base::TimeTicks& render_time) { | 277 const base::TimeTicks& render_time) { |
278 ++num_called_; | 278 ++num_called_; |
279 | 279 |
280 EXPECT_FALSE(expected_frame_.empty()); // Test for bug in test code. | 280 EXPECT_FALSE(expected_frame_.empty()); // Test for bug in test code. |
281 ExpectedVideoFrame expected_video_frame = expected_frame_.front(); | 281 ExpectedVideoFrame expected_video_frame = expected_frame_.front(); |
282 expected_frame_.pop_front(); | 282 expected_frame_.pop_front(); |
283 | 283 |
284 base::TimeDelta time_since_capture = | 284 base::TimeDelta time_since_capture = |
285 render_time - expected_video_frame.capture_time; | 285 render_time - expected_video_frame.capture_time; |
286 const base::TimeDelta upper_bound = base::TimeDelta::FromMilliseconds( | 286 const base::TimeDelta upper_bound = base::TimeDelta::FromMilliseconds( |
287 kDefaultRtpMaxDelayMs + kTimerErrorMs); | 287 kDefaultRtpMaxDelayMs + kTimerErrorMs); |
288 | 288 |
289 EXPECT_GE(upper_bound, time_since_capture) | 289 EXPECT_GE(upper_bound, time_since_capture) |
290 << "time_since_capture - upper_bound == " | 290 << "time_since_capture - upper_bound == " |
291 << (time_since_capture - upper_bound).InMicroseconds() << " usec"; | 291 << (time_since_capture - upper_bound).InMicroseconds() << " usec"; |
292 EXPECT_LE(expected_video_frame.capture_time, render_time); | 292 EXPECT_LE(expected_video_frame.capture_time, render_time); |
293 EXPECT_EQ(expected_video_frame.width, video_frame->width); | 293 EXPECT_EQ(expected_video_frame.width, video_frame->coded_size().width()); |
294 EXPECT_EQ(expected_video_frame.height, video_frame->height); | 294 EXPECT_EQ(expected_video_frame.height, video_frame->coded_size().height()); |
295 | 295 |
296 gfx::Size size(expected_video_frame.width, expected_video_frame.height); | 296 gfx::Size size(expected_video_frame.width, expected_video_frame.height); |
297 scoped_refptr<media::VideoFrame> expected_I420_frame = | 297 scoped_refptr<media::VideoFrame> expected_I420_frame = |
298 media::VideoFrame::CreateFrame( | 298 media::VideoFrame::CreateFrame( |
299 VideoFrame::I420, size, gfx::Rect(size), size, base::TimeDelta()); | 299 VideoFrame::I420, size, gfx::Rect(size), size, base::TimeDelta()); |
300 PopulateVideoFrame(expected_I420_frame, expected_video_frame.start_value); | 300 PopulateVideoFrame(expected_I420_frame, expected_video_frame.start_value); |
301 | 301 |
302 double psnr = I420PSNR(*(expected_I420_frame.get()), *(video_frame.get())); | 302 EXPECT_GE(I420PSNR(expected_I420_frame, video_frame), kVideoAcceptedPSNR); |
303 EXPECT_GE(psnr, kVideoAcceptedPSNR); | |
304 } | 303 } |
305 | 304 |
306 int number_times_called() { return num_called_;} | 305 int number_times_called() { return num_called_;} |
307 | 306 |
308 protected: | 307 protected: |
309 virtual ~TestReceiverVideoCallback() {} | 308 virtual ~TestReceiverVideoCallback() {} |
310 | 309 |
311 private: | 310 private: |
312 friend class base::RefCountedThreadSafe<TestReceiverVideoCallback>; | 311 friend class base::RefCountedThreadSafe<TestReceiverVideoCallback>; |
313 | 312 |
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1026 } | 1025 } |
1027 | 1026 |
1028 | 1027 |
1029 // TODO(pwestin): Add repeatable packet loss test. | 1028 // TODO(pwestin): Add repeatable packet loss test. |
1030 // TODO(pwestin): Add test for misaligned send get calls. | 1029 // TODO(pwestin): Add test for misaligned send get calls. |
1031 // TODO(pwestin): Add more tests that does not resample. | 1030 // TODO(pwestin): Add more tests that does not resample. |
1032 // TODO(pwestin): Add test when we have starvation for our RunTask. | 1031 // TODO(pwestin): Add test when we have starvation for our RunTask. |
1033 | 1032 |
1034 } // namespace cast | 1033 } // namespace cast |
1035 } // namespace media | 1034 } // namespace media |
OLD | NEW |