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

Issue 2518143004: [Mojo Video Capture] Replace RESOURCE_UTILIZATION with interface ReceiverLoadObserver (Closed)

Created:
4 years ago by chfremer
Modified:
4 years ago
Reviewers:
emircan, mcasas, miu
CC:
chromium-reviews, qsr+mojo_chromium.org, Aaron Boodman, posciak+watch_chromium.org, viettrungluu+watch_chromium.org, jam, yzshen+watch_chromium.org, abarth-chromium, feature-media-reviews_chromium.org, darin-cc_chromium.org, mcasas+watch+vc_chromium.org, xjz+watch_chromium.org, darin (slow to review), miu+watch_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

[Mojo Video Capture] Replace RESOURCE_UTILIZATION with interface ReceiverLoadObserver Replace RESOURCE_UTILIZATION with interface ReceiverLoadObserver The VideoFrame metadata field RESOURCE_UTILIZATION is currently being used as a hidden communication channel for consumers to report back their "utilization" (i.e. how busy they are) to interested producers. It appears that this mechanism is used when using Cast to transmit captured content (e.g. desktop/window/tab sharing). In the Browser process, VideoCaptureController uses this mechanism to report the highest utilization of its clients back to ThreadSafeCaptureOracle, which uses a Destruction Observer to read out the metadata field when the VideoFrame instance it had sent out is destroyed. Besides this mechanism being non-obvious and therefore fragile, it does not work across process boundaries (which we need when switching to a Mojo service). This CL replaces this with a communication channel through a callback interface ReceiverLoadObserver which can be optionally given to VideoCaptureController. Doing so also allows us to move away from using media::VideoFrame for the transport of video frames, at least in the Browser process. This is desirable, because the use of media::VideoFrame has several downsides: 1.) It implies access to a memory-mapped buffer, which we may not need. Some components need to transport video frames but do not need to access their data. 2.) Its interface fails to clearly communicate what information is actually contained. It may be just a frame format and metadata. It may be read/write access to a memory-mapped buffer. And it may or may not contain a shareable handle to a buffer. List of changes: * Have VideoCaptureController communicate client utilization to VideoCaptureDevice via a new interface ConsumerFeedbackObserver. * In VideoCaptureManager, updated factory logic to correctly establish the connection from the controller to the device. * In interface media::VideoCaptureDevice::Client, added a |frame_feedback_id| parameter to producer methods. This is needed to be able to report which particular frame a reported consumer utilization corresponds to. The ThreadSafeCaptureOracle is interested in this information. * Store the |frame_feedback_id| inside instances of media::VideoCaptureDevice::Client::Buffer, which are passed along to the controller. * In VideoCaptureController we now have to keep track of the consumer count for each buffer in order to be able to send out the maximum consumer utilization when all consumers have finished consuming a buffer. We do this by introducing a std::map<int, BufferState> |buffer_id_to_state_map_|. VideoCaptureController is the right place for keeping track of the consumer count, because it is the place where access to a single device is shared to multiple clients. * Also in video_capture_controller.h/cc: * Removed some sync token related code that was unused (and would otherwise have to be modified for this CL) * Instead of holding VideoFrame references in each ControllerClient in a std::map<int, scoped_refptr<VideoFrame>> |active_buffers|, we keep a single VideoFrame reference in the BufferState in |buffer_id_to_state_map|. In the ControllerClients we then only need to track a std::set<int> |buffers_in_use|. Note that the same mechanism of using RESOURCE_UTILIZATION as a communication channel is still in use on the Renderer side, where it is set by media/cast/sender/video_sender.cc and read by video_capture_impl.cc for reporting it back to the browser process. I think it would be better to use a callback interface here as well and treat video frames as read-only. But since this CL does not change the Renderer side, we can leave it as is for now. The following media::VideoCaptureDevice implementations have been updated to listen on the new communication channel: * desktop_capture_device_aura.h * web_contents_video_capture_device.h * screen_capture_device_android.h TODO: There may be implementations in WebRTC that need to be updated as well. This CL is part of the Mojo Video Capture work. For the bigger picture, see [1] CL1.9.7 BUG=584797 TEST= video_capture_unittests, content_unittests, capture_unittests, Apprtc loopback on Debug, Desktop Capture Example extension on Release [1] https://docs.google.com/a/chromium.org/document/d/1Qw7rw1AJy0QHXjha36jZNiEuxsxWslJ_X-zpOhijvI8/edit?usp=sharing Committed: https://crrev.com/a731c83140456ec55db63e3258ad9fdafc996176 Cr-Commit-Position: refs/heads/master@{#436452}

Patch Set 1 #

Patch Set 2 : Fixes for failing bots #

Total comments: 38

Patch Set 3 : miu's comments #

Patch Set 4 : Fix for hanging test #

Patch Set 5 : Fix capture_unittests #

Patch Set 6 : Fixed usage of VerifyAndClearExpectations #

Total comments: 6

Patch Set 7 : miu's comments #

Total comments: 13

Patch Set 8 : mcasas@ comments #

Patch Set 9 : Fix for android-only code #

Unified diffs Side-by-side diffs Delta from patch set Stats (+549 lines, -266 lines) Patch
M content/browser/media/capture/desktop_capture_device_aura.h View 1 2 3 4 5 6 7 1 chunk +1 line, -0 lines 0 comments Download
M content/browser/media/capture/desktop_capture_device_aura.cc View 1 2 3 4 5 6 7 1 chunk +5 lines, -0 lines 0 comments Download
M content/browser/media/capture/desktop_capture_device_aura_unittest.cc View 1 2 3 chunks +9 lines, -7 lines 0 comments Download
M content/browser/media/capture/desktop_capture_device_unittest.cc View 1 2 10 chunks +18 lines, -15 lines 0 comments Download
M content/browser/media/capture/screen_capture_device_android.h View 1 2 3 4 5 6 7 8 1 chunk +1 line, -0 lines 0 comments Download
M content/browser/media/capture/screen_capture_device_android.cc View 1 2 3 4 5 6 7 8 1 chunk +6 lines, -0 lines 0 comments Download
M content/browser/media/capture/screen_capture_device_android_unittest.cc View 1 2 3 chunks +9 lines, -7 lines 0 comments Download
M content/browser/media/capture/web_contents_video_capture_device.h View 1 2 3 4 5 6 7 1 chunk +1 line, -0 lines 0 comments Download
M content/browser/media/capture/web_contents_video_capture_device.cc View 1 2 3 4 5 6 7 1 chunk +5 lines, -0 lines 0 comments Download
M content/browser/media/capture/web_contents_video_capture_device_unittest.cc View 1 2 4 chunks +20 lines, -11 lines 0 comments Download
M content/browser/renderer_host/media/video_capture_buffer_pool_unittest.cc View 1 2 1 chunk +3 lines, -1 line 0 comments Download
M content/browser/renderer_host/media/video_capture_controller.h View 1 2 3 4 5 6 7 3 chunks +40 lines, -0 lines 0 comments Download
M content/browser/renderer_host/media/video_capture_controller.cc View 1 2 3 4 5 6 7 10 chunks +121 lines, -83 lines 0 comments Download
M content/browser/renderer_host/media/video_capture_controller_unittest.cc View 1 2 3 4 5 6 7 14 chunks +50 lines, -26 lines 0 comments Download
M content/browser/renderer_host/media/video_capture_manager.cc View 1 2 3 4 5 6 7 8 5 chunks +44 lines, -6 lines 0 comments Download
M media/capture/content/screen_capture_device_core.h View 1 2 1 chunk +2 lines, -0 lines 0 comments Download
M media/capture/content/screen_capture_device_core.cc View 1 2 1 chunk +8 lines, -0 lines 0 comments Download
M media/capture/content/thread_safe_capture_oracle.h View 1 chunk +2 lines, -0 lines 0 comments Download
M media/capture/content/thread_safe_capture_oracle.cc View 1 2 3 5 chunks +8 lines, -17 lines 0 comments Download
M media/capture/content/video_capture_oracle.h View 1 2 3 1 chunk +5 lines, -3 lines 0 comments Download
M media/capture/content/video_capture_oracle.cc View 1 2 3 2 chunks +6 lines, -2 lines 0 comments Download
M media/capture/content/video_capture_oracle_unittest.cc View 1 2 3 4 20 chunks +46 lines, -29 lines 0 comments Download
M media/capture/video/fake_video_capture_device.cc View 1 2 1 chunk +4 lines, -3 lines 0 comments Download
M media/capture/video/fake_video_capture_device_unittest.cc View 1 2 3 4 4 chunks +20 lines, -13 lines 0 comments Download
M media/capture/video/video_capture_buffer_pool.h View 1 2 1 chunk +1 line, -0 lines 0 comments Download
M media/capture/video/video_capture_buffer_pool_impl.h View 1 2 2 chunks +2 lines, -0 lines 0 comments Download
M media/capture/video/video_capture_buffer_pool_impl.cc View 1 2 5 chunks +6 lines, -1 line 0 comments Download
M media/capture/video/video_capture_buffer_tracker.h View 1 2 3 chunks +6 lines, -1 line 0 comments Download
M media/capture/video/video_capture_device.h View 1 2 3 4 5 6 7 8 6 chunks +42 lines, -5 lines 0 comments Download
M media/capture/video/video_capture_device_client.h View 1 2 4 chunks +12 lines, -8 lines 0 comments Download
M media/capture/video/video_capture_device_client.cc View 1 2 3 4 5 6 11 chunks +32 lines, -21 lines 0 comments Download
M media/capture/video/video_capture_device_unittest.cc View 1 2 3 4 5 6 7 8 2 chunks +9 lines, -7 lines 0 comments Download
M media/capture/video/video_frame_receiver.h View 2 chunks +5 lines, -0 lines 0 comments Download

Depends on Patchset:

Dependent Patchsets:

Messages

Total messages: 56 (43 generated)
chfremer
mcasas@: PTAL miu@: PTAL emircan@: FYI
4 years ago (2016-11-28 20:44:29 UTC) #9
miu
On-the-whole, looks good. Comments on PS2: https://codereview.chromium.org/2518143004/diff/60001/content/browser/renderer_host/media/video_capture_controller.cc File content/browser/renderer_host/media/video_capture_controller.cc (right): https://codereview.chromium.org/2518143004/diff/60001/content/browser/renderer_host/media/video_capture_controller.cc#newcode176 content/browser/renderer_host/media/video_capture_controller.cc:176: buffer_pool_->HoldForConsumers(buffer_id_, 1); Looks ...
4 years ago (2016-12-01 05:25:18 UTC) #17
chfremer
I followed miu's suggestion to get rid of the map from buffer ids to frame ...
4 years ago (2016-12-02 01:28:29 UTC) #19
chfremer
Fixed the issue with the hanging test. Turns out I was a bit careless in ...
4 years ago (2016-12-02 18:49:05 UTC) #22
chfremer
miu@: PTAL mcasas@: PTAL
4 years ago (2016-12-02 18:50:06 UTC) #23
miu
PS6 lgtm % a few nits/considerations: https://codereview.chromium.org/2518143004/diff/140001/content/browser/renderer_host/media/video_capture_controller.cc File content/browser/renderer_host/media/video_capture_controller.cc (right): https://codereview.chromium.org/2518143004/diff/140001/content/browser/renderer_host/media/video_capture_controller.cc#newcode120 content/browser/renderer_host/media/video_capture_controller.cc:120: std::set<int> buffers_in_use; Note ...
4 years ago (2016-12-02 23:29:33 UTC) #32
chfremer
Addressed miu's comments. mcasas@: PTAL https://codereview.chromium.org/2518143004/diff/140001/content/browser/renderer_host/media/video_capture_controller.cc File content/browser/renderer_host/media/video_capture_controller.cc (right): https://codereview.chromium.org/2518143004/diff/140001/content/browser/renderer_host/media/video_capture_controller.cc#newcode120 content/browser/renderer_host/media/video_capture_controller.cc:120: std::set<int> buffers_in_use; On 2016/12/02 ...
4 years ago (2016-12-03 00:30:36 UTC) #36
mcasas
lgtm with some comments to consider. Also, the CL description is daunting... in the future, ...
4 years ago (2016-12-03 01:35:48 UTC) #38
chfremer
Addressed mcasas@ comments. > Also, the CL description is daunting... > in the future, can ...
4 years ago (2016-12-05 18:17:00 UTC) #41
mcasas
still lgtm https://codereview.chromium.org/2518143004/diff/160001/media/capture/video/video_capture_device.h File media/capture/video/video_capture_device.h (right): https://codereview.chromium.org/2518143004/diff/160001/media/capture/video/video_capture_device.h#newcode67 media/capture/video/video_capture_device.h:67: double utilization) {} On 2016/12/05 18:17:00, chfremer ...
4 years ago (2016-12-05 18:26:44 UTC) #42
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2518143004/200001
4 years ago (2016-12-05 23:32:25 UTC) #51
commit-bot: I haz the power
Committed patchset #9 (id:200001)
4 years ago (2016-12-05 23:38:50 UTC) #54
commit-bot: I haz the power
4 years ago (2016-12-05 23:41:46 UTC) #56
Message was sent while issue was closed.
Patchset 9 (id:??) landed as
https://crrev.com/a731c83140456ec55db63e3258ad9fdafc996176
Cr-Commit-Position: refs/heads/master@{#436452}

Powered by Google App Engine
This is Rietveld 408576698