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 #Depends on Patchset: Dependent Patchsets: Messages
Total messages: 56 (43 generated)
|