| 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 "content/browser/renderer_host/media/video_capture_controller.h" | 5 #include "content/browser/renderer_host/media/video_capture_controller.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <utility> | 12 #include <utility> |
| 13 | 13 |
| 14 #include "base/bind.h" | 14 #include "base/bind.h" |
| 15 #include "base/bind_helpers.h" | 15 #include "base/bind_helpers.h" |
| 16 #include "base/location.h" | 16 #include "base/location.h" |
| 17 #include "base/macros.h" | 17 #include "base/macros.h" |
| 18 #include "base/memory/ptr_util.h" | 18 #include "base/memory/ptr_util.h" |
| 19 #include "base/memory/ref_counted.h" | 19 #include "base/memory/ref_counted.h" |
| 20 #include "base/run_loop.h" | 20 #include "base/run_loop.h" |
| 21 #include "base/single_thread_task_runner.h" | 21 #include "base/single_thread_task_runner.h" |
| 22 #include "base/threading/thread_task_runner_handle.h" | 22 #include "base/threading/thread_task_runner_handle.h" |
| 23 #include "content/browser/renderer_host/media/media_stream_provider.h" | 23 #include "content/browser/renderer_host/media/media_stream_provider.h" |
| 24 #include "content/browser/renderer_host/media/mock_video_capture_provider.h" |
| 24 #include "content/browser/renderer_host/media/video_capture_controller_event_han
dler.h" | 25 #include "content/browser/renderer_host/media/video_capture_controller_event_han
dler.h" |
| 25 #include "content/browser/renderer_host/media/video_capture_gpu_jpeg_decoder.h" | 26 #include "content/browser/renderer_host/media/video_capture_gpu_jpeg_decoder.h" |
| 26 #include "content/browser/renderer_host/media/video_capture_manager.h" | 27 #include "content/browser/renderer_host/media/video_capture_manager.h" |
| 27 #include "content/common/media/media_stream_options.h" | 28 #include "content/common/media/media_stream_options.h" |
| 28 #include "content/public/browser/browser_thread.h" | 29 #include "content/public/browser/browser_thread.h" |
| 29 #include "content/public/test/test_browser_thread_bundle.h" | 30 #include "content/public/test/test_browser_thread_bundle.h" |
| 30 #include "media/base/video_frame_metadata.h" | 31 #include "media/base/video_frame_metadata.h" |
| 31 #include "media/base/video_util.h" | 32 #include "media/base/video_util.h" |
| 32 #include "media/capture/video/video_capture_buffer_pool_impl.h" | 33 #include "media/capture/video/video_capture_buffer_pool_impl.h" |
| 33 #include "media/capture/video/video_capture_buffer_tracker_factory_impl.h" | 34 #include "media/capture/video/video_capture_buffer_tracker_factory_impl.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 base::Bind(base::IgnoreResult(&VideoCaptureController::RemoveClient), | 109 base::Bind(base::IgnoreResult(&VideoCaptureController::RemoveClient), |
| 109 base::Unretained(controller_), id, this)); | 110 base::Unretained(controller_), id, this)); |
| 110 } | 111 } |
| 111 | 112 |
| 112 VideoCaptureController* controller_; | 113 VideoCaptureController* controller_; |
| 113 media::VideoPixelFormat expected_pixel_format_ = media::PIXEL_FORMAT_I420; | 114 media::VideoPixelFormat expected_pixel_format_ = media::PIXEL_FORMAT_I420; |
| 114 double resource_utilization_; | 115 double resource_utilization_; |
| 115 bool enable_auto_return_buffer_on_buffer_ready_ = true; | 116 bool enable_auto_return_buffer_on_buffer_ready_ = true; |
| 116 }; | 117 }; |
| 117 | 118 |
| 118 class MockConsumerFeedbackObserver | |
| 119 : public media::VideoFrameConsumerFeedbackObserver { | |
| 120 public: | |
| 121 MOCK_METHOD2(OnUtilizationReport, | |
| 122 void(int frame_feedback_id, double utilization)); | |
| 123 }; | |
| 124 | |
| 125 class MockBuildableVideoCaptureDevice : public BuildableVideoCaptureDevice { | |
| 126 public: | |
| 127 void CreateAndStartDeviceAsync( | |
| 128 VideoCaptureController* controller, | |
| 129 const media::VideoCaptureParams& params, | |
| 130 BuildableVideoCaptureDevice::Callbacks* callbacks, | |
| 131 base::OnceClosure done_cb) override {} | |
| 132 void ReleaseDeviceAsync(VideoCaptureController* controller, | |
| 133 base::OnceClosure done_cb) override {} | |
| 134 bool IsDeviceAlive() const override { return false; } | |
| 135 void GetPhotoCapabilities( | |
| 136 media::VideoCaptureDevice::GetPhotoCapabilitiesCallback callback) | |
| 137 const override {} | |
| 138 void SetPhotoOptions( | |
| 139 media::mojom::PhotoSettingsPtr settings, | |
| 140 media::VideoCaptureDevice::SetPhotoOptionsCallback callback) override {} | |
| 141 void TakePhoto( | |
| 142 media::VideoCaptureDevice::TakePhotoCallback callback) override {} | |
| 143 void MaybeSuspendDevice() override {} | |
| 144 void ResumeDevice() override {} | |
| 145 void RequestRefreshFrame() override {} | |
| 146 void SetDesktopCaptureWindowIdAsync(gfx::NativeViewId window_id, | |
| 147 base::OnceClosure done_cb) override {} | |
| 148 }; | |
| 149 | |
| 150 // Test fixture for testing a unit consisting of an instance of | 119 // Test fixture for testing a unit consisting of an instance of |
| 151 // VideoCaptureController connected to an instance of VideoCaptureDeviceClient, | 120 // VideoCaptureController connected to an instance of VideoCaptureDeviceClient, |
| 152 // an instance of VideoCaptureBufferPoolImpl, as well as related threading glue | 121 // an instance of VideoCaptureBufferPoolImpl, as well as related threading glue |
| 153 // that replicates how it is used in production. | 122 // that replicates how it is used in production. |
| 154 class VideoCaptureControllerTest | 123 class VideoCaptureControllerTest |
| 155 : public testing::Test, | 124 : public testing::Test, |
| 156 public testing::WithParamInterface<media::VideoPixelFormat> { | 125 public testing::WithParamInterface<media::VideoPixelFormat> { |
| 157 public: | 126 public: |
| 158 VideoCaptureControllerTest() | 127 VideoCaptureControllerTest() |
| 159 : arbitrary_format_(gfx::Size(320, 240), 30, media::PIXEL_FORMAT_I420), | 128 : arbitrary_format_(gfx::Size(320, 240), 30, media::PIXEL_FORMAT_I420), |
| 160 arbitrary_route_id_(0x99), | 129 arbitrary_route_id_(0x99), |
| 161 arbitrary_session_id_(100) {} | 130 arbitrary_session_id_(100) {} |
| 162 ~VideoCaptureControllerTest() override {} | 131 ~VideoCaptureControllerTest() override {} |
| 163 | 132 |
| 164 protected: | 133 protected: |
| 165 static const int kPoolSize = 3; | 134 static const int kPoolSize = 3; |
| 166 | 135 |
| 167 void SetUp() override { | 136 void SetUp() override { |
| 168 const std::string arbitrary_device_id = "arbitrary_device_id"; | 137 const std::string arbitrary_device_id = "arbitrary_device_id"; |
| 169 const MediaStreamType arbitrary_stream_type = | 138 const MediaStreamType arbitrary_stream_type = |
| 170 content::MEDIA_DEVICE_VIDEO_CAPTURE; | 139 content::MEDIA_DEVICE_VIDEO_CAPTURE; |
| 171 const media::VideoCaptureParams arbitrary_params; | 140 const media::VideoCaptureParams arbitrary_params; |
| 172 auto buildable_device = base::MakeUnique<MockBuildableVideoCaptureDevice>(); | 141 auto device_launcher = base::MakeUnique<MockVideoCaptureDeviceLauncher>(); |
| 173 controller_ = new VideoCaptureController( | 142 controller_ = new VideoCaptureController( |
| 174 arbitrary_device_id, arbitrary_stream_type, arbitrary_params, | 143 arbitrary_device_id, arbitrary_stream_type, arbitrary_params, |
| 175 std::move(buildable_device)); | 144 std::move(device_launcher)); |
| 176 InitializeNewDeviceClientAndBufferPoolInstances(); | 145 InitializeNewDeviceClientAndBufferPoolInstances(); |
| 177 auto consumer_feedback_observer = | 146 auto mock_launched_device = |
| 178 base::MakeUnique<MockConsumerFeedbackObserver>(); | 147 base::MakeUnique<MockLaunchedVideoCaptureDevice>(); |
| 179 mock_consumer_feedback_observer_ = consumer_feedback_observer.get(); | 148 mock_launched_device_ = mock_launched_device.get(); |
| 180 controller_->SetConsumerFeedbackObserver( | 149 controller_->OnDeviceLaunched(std::move(mock_launched_device)); |
| 181 std::move(consumer_feedback_observer)); | |
| 182 client_a_.reset( | 150 client_a_.reset( |
| 183 new MockVideoCaptureControllerEventHandler(controller_.get())); | 151 new MockVideoCaptureControllerEventHandler(controller_.get())); |
| 184 client_b_.reset( | 152 client_b_.reset( |
| 185 new MockVideoCaptureControllerEventHandler(controller_.get())); | 153 new MockVideoCaptureControllerEventHandler(controller_.get())); |
| 186 } | 154 } |
| 187 | 155 |
| 188 void TearDown() override { base::RunLoop().RunUntilIdle(); } | 156 void TearDown() override { base::RunLoop().RunUntilIdle(); } |
| 189 | 157 |
| 190 void InitializeNewDeviceClientAndBufferPoolInstances() { | 158 void InitializeNewDeviceClientAndBufferPoolInstances() { |
| 191 buffer_pool_ = new media::VideoCaptureBufferPoolImpl( | 159 buffer_pool_ = new media::VideoCaptureBufferPoolImpl( |
| (...skipping 23 matching lines...) Expand all Loading... |
| 215 format, rotation, base::TimeTicks(), base::TimeDelta(), | 183 format, rotation, base::TimeTicks(), base::TimeDelta(), |
| 216 frame_feedback_id); | 184 frame_feedback_id); |
| 217 } | 185 } |
| 218 | 186 |
| 219 TestBrowserThreadBundle bundle_; | 187 TestBrowserThreadBundle bundle_; |
| 220 scoped_refptr<media::VideoCaptureBufferPool> buffer_pool_; | 188 scoped_refptr<media::VideoCaptureBufferPool> buffer_pool_; |
| 221 std::unique_ptr<MockVideoCaptureControllerEventHandler> client_a_; | 189 std::unique_ptr<MockVideoCaptureControllerEventHandler> client_a_; |
| 222 std::unique_ptr<MockVideoCaptureControllerEventHandler> client_b_; | 190 std::unique_ptr<MockVideoCaptureControllerEventHandler> client_b_; |
| 223 scoped_refptr<VideoCaptureController> controller_; | 191 scoped_refptr<VideoCaptureController> controller_; |
| 224 std::unique_ptr<media::VideoCaptureDevice::Client> device_client_; | 192 std::unique_ptr<media::VideoCaptureDevice::Client> device_client_; |
| 225 MockConsumerFeedbackObserver* mock_consumer_feedback_observer_; | 193 MockLaunchedVideoCaptureDevice* mock_launched_device_; |
| 226 const float arbitrary_frame_rate_ = 10.0f; | 194 const float arbitrary_frame_rate_ = 10.0f; |
| 227 const base::TimeTicks arbitrary_reference_time_ = base::TimeTicks(); | 195 const base::TimeTicks arbitrary_reference_time_ = base::TimeTicks(); |
| 228 const base::TimeDelta arbitrary_timestamp_ = base::TimeDelta(); | 196 const base::TimeDelta arbitrary_timestamp_ = base::TimeDelta(); |
| 229 const media::VideoCaptureFormat arbitrary_format_; | 197 const media::VideoCaptureFormat arbitrary_format_; |
| 230 const VideoCaptureControllerID arbitrary_route_id_; | 198 const VideoCaptureControllerID arbitrary_route_id_; |
| 231 const media::VideoCaptureSessionId arbitrary_session_id_; | 199 const media::VideoCaptureSessionId arbitrary_session_id_; |
| 232 | 200 |
| 233 private: | 201 private: |
| 234 DISALLOW_COPY_AND_ASSIGN(VideoCaptureControllerTest); | 202 DISALLOW_COPY_AND_ASSIGN(VideoCaptureControllerTest); |
| 235 }; | 203 }; |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 { | 341 { |
| 374 InSequence s; | 342 InSequence s; |
| 375 EXPECT_CALL(*client_a_, DoBufferCreated(client_a_route_2, _)); | 343 EXPECT_CALL(*client_a_, DoBufferCreated(client_a_route_2, _)); |
| 376 EXPECT_CALL(*client_a_, | 344 EXPECT_CALL(*client_a_, |
| 377 DoBufferReady(client_a_route_2, device_format.frame_size)); | 345 DoBufferReady(client_a_route_2, device_format.frame_size)); |
| 378 } | 346 } |
| 379 client_a_->resource_utilization_ = 0.5; | 347 client_a_->resource_utilization_ = 0.5; |
| 380 client_b_->resource_utilization_ = -1.0; | 348 client_b_->resource_utilization_ = -1.0; |
| 381 // Expect VideoCaptureController to call the load observer with a | 349 // Expect VideoCaptureController to call the load observer with a |
| 382 // resource utilization of 0.5 (the largest of all reported values). | 350 // resource utilization of 0.5 (the largest of all reported values). |
| 383 EXPECT_CALL(*mock_consumer_feedback_observer_, | 351 EXPECT_CALL(*mock_launched_device_, |
| 384 OnUtilizationReport(arbitrary_frame_feedback_id, 0.5)); | 352 OnUtilizationReport(arbitrary_frame_feedback_id, 0.5)); |
| 385 | 353 |
| 386 device_client_->OnIncomingCapturedBuffer(std::move(buffer), device_format, | 354 device_client_->OnIncomingCapturedBuffer(std::move(buffer), device_format, |
| 387 arbitrary_reference_time_, | 355 arbitrary_reference_time_, |
| 388 arbitrary_timestamp_); | 356 arbitrary_timestamp_); |
| 389 | 357 |
| 390 base::RunLoop().RunUntilIdle(); | 358 base::RunLoop().RunUntilIdle(); |
| 391 Mock::VerifyAndClearExpectations(client_a_.get()); | 359 Mock::VerifyAndClearExpectations(client_a_.get()); |
| 392 Mock::VerifyAndClearExpectations(client_b_.get()); | 360 Mock::VerifyAndClearExpectations(client_b_.get()); |
| 393 Mock::VerifyAndClearExpectations(mock_consumer_feedback_observer_); | 361 Mock::VerifyAndClearExpectations(mock_launched_device_); |
| 394 | 362 |
| 395 // Second buffer which ought to use the same shared memory buffer. In this | 363 // Second buffer which ought to use the same shared memory buffer. In this |
| 396 // case pretend that the Buffer pointer is held by the device for a long | 364 // case pretend that the Buffer pointer is held by the device for a long |
| 397 // delay. This shouldn't affect anything. | 365 // delay. This shouldn't affect anything. |
| 398 const int arbitrary_frame_feedback_id_2 = 102; | 366 const int arbitrary_frame_feedback_id_2 = 102; |
| 399 media::VideoCaptureDevice::Client::Buffer buffer2 = | 367 media::VideoCaptureDevice::Client::Buffer buffer2 = |
| 400 device_client_->ReserveOutputBuffer( | 368 device_client_->ReserveOutputBuffer( |
| 401 device_format.frame_size, device_format.pixel_format, | 369 device_format.frame_size, device_format.pixel_format, |
| 402 device_format.pixel_storage, arbitrary_frame_feedback_id_2); | 370 device_format.pixel_storage, arbitrary_frame_feedback_id_2); |
| 403 ASSERT_TRUE(buffer2.is_valid()); | 371 ASSERT_TRUE(buffer2.is_valid()); |
| 404 auto buffer2_access = buffer2.handle_provider->GetHandleForInProcessAccess(); | 372 auto buffer2_access = buffer2.handle_provider->GetHandleForInProcessAccess(); |
| 405 memset(buffer2_access->data(), buffer_no++, buffer2_access->mapped_size()); | 373 memset(buffer2_access->data(), buffer_no++, buffer2_access->mapped_size()); |
| 406 client_a_->resource_utilization_ = 0.5; | 374 client_a_->resource_utilization_ = 0.5; |
| 407 client_b_->resource_utilization_ = 3.14; | 375 client_b_->resource_utilization_ = 3.14; |
| 408 // Expect VideoCaptureController to call the load observer with a | 376 // Expect VideoCaptureController to call the load observer with a |
| 409 // resource utilization of 3.14 (the largest of all reported values). | 377 // resource utilization of 3.14 (the largest of all reported values). |
| 410 EXPECT_CALL(*mock_consumer_feedback_observer_, | 378 EXPECT_CALL(*mock_launched_device_, |
| 411 OnUtilizationReport(arbitrary_frame_feedback_id_2, 3.14)); | 379 OnUtilizationReport(arbitrary_frame_feedback_id_2, 3.14)); |
| 412 | 380 |
| 413 device_client_->OnIncomingCapturedBuffer(std::move(buffer2), device_format, | 381 device_client_->OnIncomingCapturedBuffer(std::move(buffer2), device_format, |
| 414 arbitrary_reference_time_, | 382 arbitrary_reference_time_, |
| 415 arbitrary_timestamp_); | 383 arbitrary_timestamp_); |
| 416 | 384 |
| 417 // The buffer should be delivered to the clients in any order. | 385 // The buffer should be delivered to the clients in any order. |
| 418 { | 386 { |
| 419 InSequence s; | 387 InSequence s; |
| 420 EXPECT_CALL(*client_a_, DoBufferCreated(client_a_route_1, _)); | 388 EXPECT_CALL(*client_a_, DoBufferCreated(client_a_route_1, _)); |
| 421 EXPECT_CALL(*client_a_, | 389 EXPECT_CALL(*client_a_, |
| 422 DoBufferReady(client_a_route_1, device_format.frame_size)); | 390 DoBufferReady(client_a_route_1, device_format.frame_size)); |
| 423 } | 391 } |
| 424 { | 392 { |
| 425 InSequence s; | 393 InSequence s; |
| 426 EXPECT_CALL(*client_b_, DoBufferCreated(client_b_route_1, _)); | 394 EXPECT_CALL(*client_b_, DoBufferCreated(client_b_route_1, _)); |
| 427 EXPECT_CALL(*client_b_, | 395 EXPECT_CALL(*client_b_, |
| 428 DoBufferReady(client_b_route_1, device_format.frame_size)); | 396 DoBufferReady(client_b_route_1, device_format.frame_size)); |
| 429 } | 397 } |
| 430 { | 398 { |
| 431 InSequence s; | 399 InSequence s; |
| 432 EXPECT_CALL(*client_a_, DoBufferCreated(client_a_route_2, _)); | 400 EXPECT_CALL(*client_a_, DoBufferCreated(client_a_route_2, _)); |
| 433 EXPECT_CALL(*client_a_, | 401 EXPECT_CALL(*client_a_, |
| 434 DoBufferReady(client_a_route_2, device_format.frame_size)); | 402 DoBufferReady(client_a_route_2, device_format.frame_size)); |
| 435 } | 403 } |
| 436 base::RunLoop().RunUntilIdle(); | 404 base::RunLoop().RunUntilIdle(); |
| 437 Mock::VerifyAndClearExpectations(client_a_.get()); | 405 Mock::VerifyAndClearExpectations(client_a_.get()); |
| 438 Mock::VerifyAndClearExpectations(client_b_.get()); | 406 Mock::VerifyAndClearExpectations(client_b_.get()); |
| 439 Mock::VerifyAndClearExpectations(mock_consumer_feedback_observer_); | 407 Mock::VerifyAndClearExpectations(mock_launched_device_); |
| 440 | 408 |
| 441 // Add a fourth client now that some buffers have come through. | 409 // Add a fourth client now that some buffers have come through. |
| 442 controller_->AddClient(client_b_route_2, client_b_.get(), 1, session_1); | 410 controller_->AddClient(client_b_route_2, client_b_.get(), 1, session_1); |
| 443 Mock::VerifyAndClearExpectations(client_b_.get()); | 411 Mock::VerifyAndClearExpectations(client_b_.get()); |
| 444 | 412 |
| 445 // Third, fourth, and fifth buffers. Pretend they all arrive at the same time. | 413 // Third, fourth, and fifth buffers. Pretend they all arrive at the same time. |
| 446 for (int i = 0; i < kPoolSize; i++) { | 414 for (int i = 0; i < kPoolSize; i++) { |
| 447 const int arbitrary_frame_feedback_id = 200 + i; | 415 const int arbitrary_frame_feedback_id = 200 + i; |
| 448 media::VideoCaptureDevice::Client::Buffer buffer = | 416 media::VideoCaptureDevice::Client::Buffer buffer = |
| 449 device_client_->ReserveOutputBuffer( | 417 device_client_->ReserveOutputBuffer( |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 const int stub_frame_feedback_id = frame_index; | 614 const int stub_frame_feedback_id = frame_index; |
| 647 const float stub_consumer_utilization = | 615 const float stub_consumer_utilization = |
| 648 static_cast<float>(frame_index) / kTestFrameSequenceLength; | 616 static_cast<float>(frame_index) / kTestFrameSequenceLength; |
| 649 | 617 |
| 650 client_a_->resource_utilization_ = stub_consumer_utilization; | 618 client_a_->resource_utilization_ = stub_consumer_utilization; |
| 651 | 619 |
| 652 EXPECT_CALL(*client_a_, | 620 EXPECT_CALL(*client_a_, |
| 653 DoBufferReady(route_id, arbitrary_format.frame_size)) | 621 DoBufferReady(route_id, arbitrary_format.frame_size)) |
| 654 .Times(1); | 622 .Times(1); |
| 655 EXPECT_CALL( | 623 EXPECT_CALL( |
| 656 *mock_consumer_feedback_observer_, | 624 *mock_launched_device_, |
| 657 OnUtilizationReport(stub_frame_feedback_id, stub_consumer_utilization)) | 625 OnUtilizationReport(stub_frame_feedback_id, stub_consumer_utilization)) |
| 658 .Times(1); | 626 .Times(1); |
| 659 | 627 |
| 660 // Device prepares and pushes a frame. | 628 // Device prepares and pushes a frame. |
| 661 // For the first half of the frames we exercise ReserveOutputBuffer() while | 629 // For the first half of the frames we exercise ReserveOutputBuffer() while |
| 662 // for the second half we exercise ResurrectLastOutputBuffer(). | 630 // for the second half we exercise ResurrectLastOutputBuffer(). |
| 663 // The frame is expected to arrive at |client_a_|.DoBufferReady(), which | 631 // The frame is expected to arrive at |client_a_|.DoBufferReady(), which |
| 664 // automatically notifies |controller_| that it has finished consuming it. | 632 // automatically notifies |controller_| that it has finished consuming it. |
| 665 media::VideoCaptureDevice::Client::Buffer buffer; | 633 media::VideoCaptureDevice::Client::Buffer buffer; |
| 666 if (frame_index < kTestFrameSequenceLength / 2) { | 634 if (frame_index < kTestFrameSequenceLength / 2) { |
| 667 buffer = device_client_->ReserveOutputBuffer( | 635 buffer = device_client_->ReserveOutputBuffer( |
| 668 arbitrary_format.frame_size, arbitrary_format.pixel_format, | 636 arbitrary_format.frame_size, arbitrary_format.pixel_format, |
| 669 arbitrary_format.pixel_storage, stub_frame_feedback_id); | 637 arbitrary_format.pixel_storage, stub_frame_feedback_id); |
| 670 } else { | 638 } else { |
| 671 buffer = device_client_->ResurrectLastOutputBuffer( | 639 buffer = device_client_->ResurrectLastOutputBuffer( |
| 672 arbitrary_format.frame_size, arbitrary_format.pixel_format, | 640 arbitrary_format.frame_size, arbitrary_format.pixel_format, |
| 673 arbitrary_format.pixel_storage, stub_frame_feedback_id); | 641 arbitrary_format.pixel_storage, stub_frame_feedback_id); |
| 674 } | 642 } |
| 675 ASSERT_TRUE(buffer.is_valid()); | 643 ASSERT_TRUE(buffer.is_valid()); |
| 676 device_client_->OnIncomingCapturedBuffer( | 644 device_client_->OnIncomingCapturedBuffer( |
| 677 std::move(buffer), arbitrary_format, arbitrary_reference_time_, | 645 std::move(buffer), arbitrary_format, arbitrary_reference_time_, |
| 678 arbitrary_timestamp_); | 646 arbitrary_timestamp_); |
| 679 | 647 |
| 680 base::RunLoop().RunUntilIdle(); | 648 base::RunLoop().RunUntilIdle(); |
| 681 Mock::VerifyAndClearExpectations(client_a_.get()); | 649 Mock::VerifyAndClearExpectations(client_a_.get()); |
| 682 Mock::VerifyAndClearExpectations(mock_consumer_feedback_observer_); | 650 Mock::VerifyAndClearExpectations(mock_launched_device_); |
| 683 } | 651 } |
| 684 } | 652 } |
| 685 | 653 |
| 686 TEST_F(VideoCaptureControllerTest, | 654 TEST_F(VideoCaptureControllerTest, |
| 687 DeviceClientIsReleasedBeforeAnyBufferWasShared) { | 655 DeviceClientIsReleasedBeforeAnyBufferWasShared) { |
| 688 // Register |client_a_| at |controller_|. | 656 // Register |client_a_| at |controller_|. |
| 689 media::VideoCaptureParams requested_params; | 657 media::VideoCaptureParams requested_params; |
| 690 requested_params.requested_format = arbitrary_format_; | 658 requested_params.requested_format = arbitrary_format_; |
| 691 controller_->AddClient(arbitrary_route_id_, client_a_.get(), | 659 controller_->AddClient(arbitrary_route_id_, client_a_.get(), |
| 692 arbitrary_session_id_, requested_params); | 660 arbitrary_session_id_, requested_params); |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 863 EXPECT_CALL(*client_b_, OnStarted(_)); | 831 EXPECT_CALL(*client_b_, OnStarted(_)); |
| 864 device_client_->OnStarted(); | 832 device_client_->OnStarted(); |
| 865 | 833 |
| 866 // VideoCaptureController will take care of the OnStarted event for the | 834 // VideoCaptureController will take care of the OnStarted event for the |
| 867 // clients who join later. | 835 // clients who join later. |
| 868 EXPECT_CALL(*client_a_, OnStarted(_)); | 836 EXPECT_CALL(*client_a_, OnStarted(_)); |
| 869 controller_->AddClient(client_a_route_2, client_a_.get(), 200, session_200); | 837 controller_->AddClient(client_a_route_2, client_a_.get(), 200, session_200); |
| 870 } | 838 } |
| 871 } | 839 } |
| 872 } // namespace content | 840 } // namespace content |
| OLD | NEW |