Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: content/browser/media/capture/desktop_capture_device_unittest.cc

Issue 1983193002: Decouple capture timestamp and reference time (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resolve Comments Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 #include "content/browser/media/capture/desktop_capture_device.h" 5 #include "content/browser/media/capture/desktop_capture_device.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <string.h> 9 #include <string.h>
10 #include <algorithm> 10 #include <algorithm>
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 // Use a special value for frame pixels to tell pixel bytes apart from the 53 // Use a special value for frame pixels to tell pixel bytes apart from the
54 // padding bytes in the unpacked frame test. 54 // padding bytes in the unpacked frame test.
55 const uint8_t kFakePixelValue = 1; 55 const uint8_t kFakePixelValue = 1;
56 56
57 // Use a special value for the first pixel to verify the result in the inverted 57 // Use a special value for the first pixel to verify the result in the inverted
58 // frame test. 58 // frame test.
59 const uint8_t kFakePixelValueFirst = 2; 59 const uint8_t kFakePixelValueFirst = 2;
60 60
61 class MockDeviceClient : public media::VideoCaptureDevice::Client { 61 class MockDeviceClient : public media::VideoCaptureDevice::Client {
62 public: 62 public:
63 MOCK_METHOD5(OnIncomingCapturedData, 63 MOCK_METHOD6(OnIncomingCapturedData,
64 void(const uint8_t* data, 64 void(const uint8_t* data,
65 int length, 65 int length,
66 const media::VideoCaptureFormat& frame_format, 66 const media::VideoCaptureFormat& frame_format,
67 int rotation, 67 int rotation,
68 const base::TimeTicks& timestamp)); 68 base::TimeTicks reference_time,
69 MOCK_METHOD9(OnIncomingCapturedYuvData, 69 base::TimeDelta timestamp));
70 void(const uint8_t* y_data,
71 const uint8_t* u_data,
72 const uint8_t* v_data,
73 size_t y_stride,
74 size_t u_stride,
75 size_t v_stride,
76 const media::VideoCaptureFormat& frame_format,
77 int clockwise_rotation,
78 const base::TimeTicks& timestamp));
79 MOCK_METHOD0(DoReserveOutputBuffer, void(void)); 70 MOCK_METHOD0(DoReserveOutputBuffer, void(void));
80 MOCK_METHOD0(DoOnIncomingCapturedBuffer, void(void)); 71 MOCK_METHOD0(DoOnIncomingCapturedBuffer, void(void));
81 MOCK_METHOD0(DoOnIncomingCapturedVideoFrame, void(void)); 72 MOCK_METHOD0(DoOnIncomingCapturedVideoFrame, void(void));
82 MOCK_METHOD0(DoResurrectLastOutputBuffer, void(void)); 73 MOCK_METHOD0(DoResurrectLastOutputBuffer, void(void));
83 MOCK_METHOD2(OnError, 74 MOCK_METHOD2(OnError,
84 void(const tracked_objects::Location& from_here, 75 void(const tracked_objects::Location& from_here,
85 const std::string& reason)); 76 const std::string& reason));
86 77
87 // Trampoline methods to workaround GMOCK problems with std::unique_ptr<>. 78 // Trampoline methods to workaround GMOCK problems with std::unique_ptr<>.
88 std::unique_ptr<Buffer> ReserveOutputBuffer( 79 std::unique_ptr<Buffer> ReserveOutputBuffer(
89 const gfx::Size& dimensions, 80 const gfx::Size& dimensions,
90 media::VideoPixelFormat format, 81 media::VideoPixelFormat format,
91 media::VideoPixelStorage storage) override { 82 media::VideoPixelStorage storage) override {
92 EXPECT_TRUE(format == media::PIXEL_FORMAT_I420 && 83 EXPECT_TRUE(format == media::PIXEL_FORMAT_I420 &&
93 storage == media::PIXEL_STORAGE_CPU); 84 storage == media::PIXEL_STORAGE_CPU);
94 DoReserveOutputBuffer(); 85 DoReserveOutputBuffer();
95 return std::unique_ptr<Buffer>(); 86 return std::unique_ptr<Buffer>();
96 } 87 }
97 void OnIncomingCapturedBuffer(std::unique_ptr<Buffer> buffer, 88 void OnIncomingCapturedBuffer(std::unique_ptr<Buffer> buffer,
98 const media::VideoCaptureFormat& frame_format, 89 const media::VideoCaptureFormat& frame_format,
99 const base::TimeTicks& timestamp) override { 90 base::TimeTicks reference_time,
91 base::TimeDelta timestamp) override {
100 DoOnIncomingCapturedBuffer(); 92 DoOnIncomingCapturedBuffer();
101 } 93 }
102 void OnIncomingCapturedVideoFrame( 94 void OnIncomingCapturedVideoFrame(
103 std::unique_ptr<Buffer> buffer, 95 std::unique_ptr<Buffer> buffer,
104 const scoped_refptr<media::VideoFrame>& frame, 96 const scoped_refptr<media::VideoFrame>& frame,
105 const base::TimeTicks& timestamp) override { 97 base::TimeTicks reference_time) override {
106 DoOnIncomingCapturedVideoFrame(); 98 DoOnIncomingCapturedVideoFrame();
107 } 99 }
108 std::unique_ptr<Buffer> ResurrectLastOutputBuffer( 100 std::unique_ptr<Buffer> ResurrectLastOutputBuffer(
109 const gfx::Size& dimensions, 101 const gfx::Size& dimensions,
110 media::VideoPixelFormat format, 102 media::VideoPixelFormat format,
111 media::VideoPixelStorage storage) override { 103 media::VideoPixelStorage storage) override {
112 EXPECT_TRUE(format == media::PIXEL_FORMAT_I420 && 104 EXPECT_TRUE(format == media::PIXEL_FORMAT_I420 &&
113 storage == media::PIXEL_STORAGE_CPU); 105 storage == media::PIXEL_STORAGE_CPU);
114 DoResurrectLastOutputBuffer(); 106 DoResurrectLastOutputBuffer();
115 return std::unique_ptr<Buffer>(); 107 return std::unique_ptr<Buffer>();
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 } // namespace 254 } // namespace
263 255
264 class DesktopCaptureDeviceTest : public testing::Test { 256 class DesktopCaptureDeviceTest : public testing::Test {
265 public: 257 public:
266 void CreateScreenCaptureDevice( 258 void CreateScreenCaptureDevice(
267 std::unique_ptr<webrtc::DesktopCapturer> capturer) { 259 std::unique_ptr<webrtc::DesktopCapturer> capturer) {
268 capture_device_.reset(new DesktopCaptureDevice( 260 capture_device_.reset(new DesktopCaptureDevice(
269 std::move(capturer), DesktopMediaID::TYPE_SCREEN)); 261 std::move(capturer), DesktopMediaID::TYPE_SCREEN));
270 } 262 }
271 263
272 void CopyFrame(const uint8_t* frame, int size, 264 void CopyFrame(const uint8_t* frame,
273 const media::VideoCaptureFormat&, int, base::TimeTicks) { 265 int size,
266 const media::VideoCaptureFormat&,
267 int,
268 base::TimeTicks,
269 base::TimeDelta) {
274 ASSERT_TRUE(output_frame_); 270 ASSERT_TRUE(output_frame_);
275 ASSERT_EQ(output_frame_->stride() * output_frame_->size().height(), size); 271 ASSERT_EQ(output_frame_->stride() * output_frame_->size().height(), size);
276 memcpy(output_frame_->data(), frame, size); 272 memcpy(output_frame_->data(), frame, size);
277 } 273 }
278 274
279 protected: 275 protected:
280 std::unique_ptr<DesktopCaptureDevice> capture_device_; 276 std::unique_ptr<DesktopCaptureDevice> capture_device_;
281 std::unique_ptr<webrtc::DesktopFrame> output_frame_; 277 std::unique_ptr<webrtc::DesktopFrame> output_frame_;
282 }; 278 };
283 279
(...skipping 10 matching lines...) Expand all
294 webrtc::ScreenCapturer::Create( 290 webrtc::ScreenCapturer::Create(
295 webrtc::DesktopCaptureOptions::CreateDefault())); 291 webrtc::DesktopCaptureOptions::CreateDefault()));
296 CreateScreenCaptureDevice(std::move(capturer)); 292 CreateScreenCaptureDevice(std::move(capturer));
297 293
298 media::VideoCaptureFormat format; 294 media::VideoCaptureFormat format;
299 base::WaitableEvent done_event(false, false); 295 base::WaitableEvent done_event(false, false);
300 int frame_size; 296 int frame_size;
301 297
302 std::unique_ptr<MockDeviceClient> client(new MockDeviceClient()); 298 std::unique_ptr<MockDeviceClient> client(new MockDeviceClient());
303 EXPECT_CALL(*client, OnError(_, _)).Times(0); 299 EXPECT_CALL(*client, OnError(_, _)).Times(0);
304 EXPECT_CALL(*client, OnIncomingCapturedData(_, _, _, _, _)).WillRepeatedly( 300 EXPECT_CALL(*client, OnIncomingCapturedData(_, _, _, _, _, _))
305 DoAll(SaveArg<1>(&frame_size), 301 .WillRepeatedly(
306 SaveArg<2>(&format), 302 DoAll(SaveArg<1>(&frame_size), SaveArg<2>(&format),
307 InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal))); 303 InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal)));
308 304
309 media::VideoCaptureParams capture_params; 305 media::VideoCaptureParams capture_params;
310 capture_params.requested_format.frame_size.SetSize(640, 480); 306 capture_params.requested_format.frame_size.SetSize(640, 480);
311 capture_params.requested_format.frame_rate = kFrameRate; 307 capture_params.requested_format.frame_rate = kFrameRate;
312 capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420; 308 capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420;
313 capture_device_->AllocateAndStart(capture_params, std::move(client)); 309 capture_device_->AllocateAndStart(capture_params, std::move(client));
314 EXPECT_TRUE(done_event.TimedWait(TestTimeouts::action_max_timeout())); 310 EXPECT_TRUE(done_event.TimedWait(TestTimeouts::action_max_timeout()));
315 capture_device_->StopAndDeAllocate(); 311 capture_device_->StopAndDeAllocate();
316 312
317 EXPECT_GT(format.frame_size.width(), 0); 313 EXPECT_GT(format.frame_size.width(), 0);
(...skipping 11 matching lines...) Expand all
329 325
330 CreateScreenCaptureDevice( 326 CreateScreenCaptureDevice(
331 std::unique_ptr<webrtc::DesktopCapturer>(mock_capturer)); 327 std::unique_ptr<webrtc::DesktopCapturer>(mock_capturer));
332 328
333 FormatChecker format_checker(gfx::Size(kTestFrameWidth1, kTestFrameHeight1), 329 FormatChecker format_checker(gfx::Size(kTestFrameWidth1, kTestFrameHeight1),
334 gfx::Size(kTestFrameWidth1, kTestFrameHeight1)); 330 gfx::Size(kTestFrameWidth1, kTestFrameHeight1));
335 base::WaitableEvent done_event(false, false); 331 base::WaitableEvent done_event(false, false);
336 332
337 std::unique_ptr<MockDeviceClient> client(new MockDeviceClient()); 333 std::unique_ptr<MockDeviceClient> client(new MockDeviceClient());
338 EXPECT_CALL(*client, OnError(_, _)).Times(0); 334 EXPECT_CALL(*client, OnError(_, _)).Times(0);
339 EXPECT_CALL(*client, OnIncomingCapturedData(_, _, _, _, _)).WillRepeatedly( 335 EXPECT_CALL(*client, OnIncomingCapturedData(_, _, _, _, _, _))
340 DoAll(WithArg<2>(Invoke(&format_checker, 336 .WillRepeatedly(
341 &FormatChecker::ExpectAcceptableSize)), 337 DoAll(WithArg<2>(Invoke(&format_checker,
342 InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal))); 338 &FormatChecker::ExpectAcceptableSize)),
339 InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal)));
343 340
344 media::VideoCaptureParams capture_params; 341 media::VideoCaptureParams capture_params;
345 capture_params.requested_format.frame_size.SetSize(kTestFrameWidth1, 342 capture_params.requested_format.frame_size.SetSize(kTestFrameWidth1,
346 kTestFrameHeight1); 343 kTestFrameHeight1);
347 capture_params.requested_format.frame_rate = kFrameRate; 344 capture_params.requested_format.frame_rate = kFrameRate;
348 capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420; 345 capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420;
349 capture_params.resolution_change_policy = 346 capture_params.resolution_change_policy =
350 media::RESOLUTION_POLICY_FIXED_RESOLUTION; 347 media::RESOLUTION_POLICY_FIXED_RESOLUTION;
351 348
352 capture_device_->AllocateAndStart(capture_params, std::move(client)); 349 capture_device_->AllocateAndStart(capture_params, std::move(client));
(...skipping 17 matching lines...) Expand all
370 FakeScreenCapturer* mock_capturer = new FakeScreenCapturer(); 367 FakeScreenCapturer* mock_capturer = new FakeScreenCapturer();
371 368
372 CreateScreenCaptureDevice( 369 CreateScreenCaptureDevice(
373 std::unique_ptr<webrtc::DesktopCapturer>(mock_capturer)); 370 std::unique_ptr<webrtc::DesktopCapturer>(mock_capturer));
374 371
375 FormatChecker format_checker(gfx::Size(888, 500), gfx::Size(532, 300)); 372 FormatChecker format_checker(gfx::Size(888, 500), gfx::Size(532, 300));
376 base::WaitableEvent done_event(false, false); 373 base::WaitableEvent done_event(false, false);
377 374
378 std::unique_ptr<MockDeviceClient> client(new MockDeviceClient()); 375 std::unique_ptr<MockDeviceClient> client(new MockDeviceClient());
379 EXPECT_CALL(*client, OnError(_,_)).Times(0); 376 EXPECT_CALL(*client, OnError(_,_)).Times(0);
380 EXPECT_CALL(*client, OnIncomingCapturedData(_, _, _, _, _)).WillRepeatedly( 377 EXPECT_CALL(*client, OnIncomingCapturedData(_, _, _, _, _, _))
381 DoAll(WithArg<2>(Invoke(&format_checker, 378 .WillRepeatedly(
382 &FormatChecker::ExpectAcceptableSize)), 379 DoAll(WithArg<2>(Invoke(&format_checker,
383 InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal))); 380 &FormatChecker::ExpectAcceptableSize)),
381 InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal)));
384 382
385 media::VideoCaptureParams capture_params; 383 media::VideoCaptureParams capture_params;
386 const gfx::Size high_def_16_by_9(1920, 1080); 384 const gfx::Size high_def_16_by_9(1920, 1080);
387 ASSERT_GE(high_def_16_by_9.width(), 385 ASSERT_GE(high_def_16_by_9.width(),
388 std::max(kTestFrameWidth1, kTestFrameWidth2)); 386 std::max(kTestFrameWidth1, kTestFrameWidth2));
389 ASSERT_GE(high_def_16_by_9.height(), 387 ASSERT_GE(high_def_16_by_9.height(),
390 std::max(kTestFrameHeight1, kTestFrameHeight2)); 388 std::max(kTestFrameHeight1, kTestFrameHeight2));
391 capture_params.requested_format.frame_size = high_def_16_by_9; 389 capture_params.requested_format.frame_size = high_def_16_by_9;
392 capture_params.requested_format.frame_rate = kFrameRate; 390 capture_params.requested_format.frame_rate = kFrameRate;
393 capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420; 391 capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420;
(...skipping 21 matching lines...) Expand all
415 413
416 CreateScreenCaptureDevice( 414 CreateScreenCaptureDevice(
417 std::unique_ptr<webrtc::DesktopCapturer>(mock_capturer)); 415 std::unique_ptr<webrtc::DesktopCapturer>(mock_capturer));
418 416
419 FormatChecker format_checker(gfx::Size(kTestFrameWidth1, kTestFrameHeight1), 417 FormatChecker format_checker(gfx::Size(kTestFrameWidth1, kTestFrameHeight1),
420 gfx::Size(kTestFrameWidth2, kTestFrameHeight2)); 418 gfx::Size(kTestFrameWidth2, kTestFrameHeight2));
421 base::WaitableEvent done_event(false, false); 419 base::WaitableEvent done_event(false, false);
422 420
423 std::unique_ptr<MockDeviceClient> client(new MockDeviceClient()); 421 std::unique_ptr<MockDeviceClient> client(new MockDeviceClient());
424 EXPECT_CALL(*client, OnError(_,_)).Times(0); 422 EXPECT_CALL(*client, OnError(_,_)).Times(0);
425 EXPECT_CALL(*client, OnIncomingCapturedData(_, _, _, _, _)).WillRepeatedly( 423 EXPECT_CALL(*client, OnIncomingCapturedData(_, _, _, _, _, _))
426 DoAll(WithArg<2>(Invoke(&format_checker, 424 .WillRepeatedly(
427 &FormatChecker::ExpectAcceptableSize)), 425 DoAll(WithArg<2>(Invoke(&format_checker,
428 InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal))); 426 &FormatChecker::ExpectAcceptableSize)),
427 InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal)));
429 428
430 media::VideoCaptureParams capture_params; 429 media::VideoCaptureParams capture_params;
431 const gfx::Size high_def_16_by_9(1920, 1080); 430 const gfx::Size high_def_16_by_9(1920, 1080);
432 ASSERT_GE(high_def_16_by_9.width(), 431 ASSERT_GE(high_def_16_by_9.width(),
433 std::max(kTestFrameWidth1, kTestFrameWidth2)); 432 std::max(kTestFrameWidth1, kTestFrameWidth2));
434 ASSERT_GE(high_def_16_by_9.height(), 433 ASSERT_GE(high_def_16_by_9.height(),
435 std::max(kTestFrameHeight1, kTestFrameHeight2)); 434 std::max(kTestFrameHeight1, kTestFrameHeight2));
436 capture_params.requested_format.frame_size = high_def_16_by_9; 435 capture_params.requested_format.frame_size = high_def_16_by_9;
437 capture_params.requested_format.frame_rate = kFrameRate; 436 capture_params.requested_format.frame_rate = kFrameRate;
438 capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420; 437 capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420;
(...skipping 23 matching lines...) Expand all
462 461
463 media::VideoCaptureFormat format; 462 media::VideoCaptureFormat format;
464 base::WaitableEvent done_event(false, false); 463 base::WaitableEvent done_event(false, false);
465 464
466 int frame_size = 0; 465 int frame_size = 0;
467 output_frame_.reset(new webrtc::BasicDesktopFrame( 466 output_frame_.reset(new webrtc::BasicDesktopFrame(
468 webrtc::DesktopSize(kTestFrameWidth1, kTestFrameHeight1))); 467 webrtc::DesktopSize(kTestFrameWidth1, kTestFrameHeight1)));
469 468
470 std::unique_ptr<MockDeviceClient> client(new MockDeviceClient()); 469 std::unique_ptr<MockDeviceClient> client(new MockDeviceClient());
471 EXPECT_CALL(*client, OnError(_,_)).Times(0); 470 EXPECT_CALL(*client, OnError(_,_)).Times(0);
472 EXPECT_CALL(*client, OnIncomingCapturedData(_, _, _, _, _)).WillRepeatedly( 471 EXPECT_CALL(*client, OnIncomingCapturedData(_, _, _, _, _, _))
473 DoAll(Invoke(this, &DesktopCaptureDeviceTest::CopyFrame), 472 .WillRepeatedly(
474 SaveArg<1>(&frame_size), 473 DoAll(Invoke(this, &DesktopCaptureDeviceTest::CopyFrame),
475 InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal))); 474 SaveArg<1>(&frame_size),
475 InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal)));
476 476
477 media::VideoCaptureParams capture_params; 477 media::VideoCaptureParams capture_params;
478 capture_params.requested_format.frame_size.SetSize(kTestFrameWidth1, 478 capture_params.requested_format.frame_size.SetSize(kTestFrameWidth1,
479 kTestFrameHeight1); 479 kTestFrameHeight1);
480 capture_params.requested_format.frame_rate = kFrameRate; 480 capture_params.requested_format.frame_rate = kFrameRate;
481 capture_params.requested_format.pixel_format = 481 capture_params.requested_format.pixel_format =
482 media::PIXEL_FORMAT_I420; 482 media::PIXEL_FORMAT_I420;
483 483
484 capture_device_->AllocateAndStart(capture_params, std::move(client)); 484 capture_device_->AllocateAndStart(capture_params, std::move(client));
485 485
(...skipping 20 matching lines...) Expand all
506 506
507 media::VideoCaptureFormat format; 507 media::VideoCaptureFormat format;
508 base::WaitableEvent done_event(false, false); 508 base::WaitableEvent done_event(false, false);
509 509
510 int frame_size = 0; 510 int frame_size = 0;
511 output_frame_.reset(new webrtc::BasicDesktopFrame( 511 output_frame_.reset(new webrtc::BasicDesktopFrame(
512 webrtc::DesktopSize(kTestFrameWidth1, kTestFrameHeight1))); 512 webrtc::DesktopSize(kTestFrameWidth1, kTestFrameHeight1)));
513 513
514 std::unique_ptr<MockDeviceClient> client(new MockDeviceClient()); 514 std::unique_ptr<MockDeviceClient> client(new MockDeviceClient());
515 EXPECT_CALL(*client, OnError(_,_)).Times(0); 515 EXPECT_CALL(*client, OnError(_,_)).Times(0);
516 EXPECT_CALL(*client, OnIncomingCapturedData(_, _, _, _, _)).WillRepeatedly( 516 EXPECT_CALL(*client, OnIncomingCapturedData(_, _, _, _, _, _))
517 DoAll(Invoke(this, &DesktopCaptureDeviceTest::CopyFrame), 517 .WillRepeatedly(
518 SaveArg<1>(&frame_size), 518 DoAll(Invoke(this, &DesktopCaptureDeviceTest::CopyFrame),
519 InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal))); 519 SaveArg<1>(&frame_size),
520 InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal)));
520 521
521 media::VideoCaptureParams capture_params; 522 media::VideoCaptureParams capture_params;
522 capture_params.requested_format.frame_size.SetSize(kTestFrameWidth1, 523 capture_params.requested_format.frame_size.SetSize(kTestFrameWidth1,
523 kTestFrameHeight1); 524 kTestFrameHeight1);
524 capture_params.requested_format.frame_rate = kFrameRate; 525 capture_params.requested_format.frame_rate = kFrameRate;
525 capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420; 526 capture_params.requested_format.pixel_format = media::PIXEL_FORMAT_I420;
526 527
527 capture_device_->AllocateAndStart(capture_params, std::move(client)); 528 capture_device_->AllocateAndStart(capture_params, std::move(client));
528 529
529 EXPECT_TRUE(done_event.TimedWait(TestTimeouts::action_max_timeout())); 530 EXPECT_TRUE(done_event.TimedWait(TestTimeouts::action_max_timeout()));
530 done_event.Reset(); 531 done_event.Reset();
531 capture_device_->StopAndDeAllocate(); 532 capture_device_->StopAndDeAllocate();
532 533
533 // Verifies that |output_frame_| has the same pixel values as the inverted 534 // Verifies that |output_frame_| has the same pixel values as the inverted
534 // frame. 535 // frame.
535 std::unique_ptr<webrtc::DesktopFrame> inverted_frame( 536 std::unique_ptr<webrtc::DesktopFrame> inverted_frame(
536 new InvertedDesktopFrame(CreateBasicFrame( 537 new InvertedDesktopFrame(CreateBasicFrame(
537 webrtc::DesktopSize(kTestFrameWidth1, kTestFrameHeight1)))); 538 webrtc::DesktopSize(kTestFrameWidth1, kTestFrameHeight1))));
538 EXPECT_EQ(output_frame_->stride() * output_frame_->size().height(), 539 EXPECT_EQ(output_frame_->stride() * output_frame_->size().height(),
539 frame_size); 540 frame_size);
540 for (int i = 0; i < output_frame_->size().height(); ++i) { 541 for (int i = 0; i < output_frame_->size().height(); ++i) {
541 EXPECT_EQ(0, 542 EXPECT_EQ(0,
542 memcmp(inverted_frame->data() + i * inverted_frame->stride(), 543 memcmp(inverted_frame->data() + i * inverted_frame->stride(),
543 output_frame_->data() + i * output_frame_->stride(), 544 output_frame_->data() + i * output_frame_->stride(),
544 output_frame_->stride())); 545 output_frame_->stride()));
545 } 546 }
546 } 547 }
547 548
548 } // namespace content 549 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698