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

Issue 2715513008: Make FakeVideoCaptureDeviceFactory configurable to arbitrary fake device configurations (Closed)

Created:
3 years, 9 months ago by chfremer
Modified:
3 years, 9 months ago
CC:
chromium-reviews, posciak+watch_chromium.org, chfremer+watch_chromium.org, jam, feature-media-reviews_chromium.org, darin-cc_chromium.org, mcasas+watch+vc_chromium.org, xjz+watch_chromium.org, miu+watch_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Part of a series of CLs for FakeVideoCaptureDevice with the goal of allowing us to expand our test coverage of the video capture pipeline. Goal of this change: * Make FakeVideoCaptureDeviceFactory configurable to arbitrary fake device configurations. This includes setting up fake devices that support more than one pixel format, e.g. I420 and MJPEG. Approach taken: * Remove class FakeVideoCaptureDeviceMaker and place the logic for creating instances of FakeVideoCaptureDevice into FakeVideoCaptureDeviceFactory::CreateDeviceWithSupportedFormats(). This requires moving the relevant class declaration from fake_video_capture_device.cc to fake_video_capture_device.h. * To allow being switched between different output formats, it is no longer sufficient to provide instances of FakeVideoCaptureDevice with a fixed FrameDeliverer at construction time. Instead, we now provide a FrameDelivererFactory at construction time and have the FakeVideoCaptureDevice request an appropriate FrameDeliverer in AllocateAndStart(). With a new FrameDeliverer being created every time the device is started, there is no longer a need for it to have an Uninitialize() method. * Instead of just snapping to a supported size, fake devices now have to select which supported pixel format to use (since they may support more than one). * Make FakeVideoCaptureDeviceFactory configurable through a public API instead of privately pulling configuration from a command-line string. Configuration through the command-line string still works as before when creating the factory via VideoCaptureDeviceFactory::CreateFactory(). * Added test cases for configuring a fake device that does not support any format. This CL is part of the Mojo Video Capture work. For the bigger picture, see [1] CL12b. BUG=584797 TEST= capture_unittests --gtest_filter="*Fake*" content_unittests --gtest_filter="*Video*" out/Default/chrome --use-fake-device-for-media-stream=device-count=3 https://webrtc.github.io/samples/src/content/getusermedia/gum/ [1] https://docs.google.com/a/chromium.org/document/d/1Qw7rw1AJy0QHXjha36jZNiEuxsxWslJ_X-zpOhijvI8/edit?usp=sharing Review-Url: https://codereview.chromium.org/2715513008 Cr-Commit-Position: refs/heads/master@{#454365} Committed: https://chromium.googlesource.com/chromium/src/+/b0ee07cd95863c50ca5bf553bab82bf54b82d500

Patch Set 1 #

Patch Set 2 : Fix compiler warning. Fix WebRtcDepthCaptureBrowserTest. #

Total comments: 17

Patch Set 3 : emircan@ suggestions #

Total comments: 6
Unified diffs Side-by-side diffs Delta from patch set Stats (+587 lines, -354 lines) Patch
M content/browser/renderer_host/media/media_devices_manager_unittest.cc View 7 chunks +14 lines, -7 lines 0 comments Download
M content/browser/renderer_host/media/media_stream_dispatcher_host_unittest.cc View 3 chunks +3 lines, -3 lines 0 comments Download
M content/browser/renderer_host/media/video_capture_manager_unittest.cc View 1 2 4 chunks +6 lines, -4 lines 0 comments Download
M content/browser/webrtc/webrtc_depth_capture_browsertest.cc View 1 7 chunks +16 lines, -12 lines 0 comments Download
M media/capture/video/fake_video_capture_device.h View 1 2 1 chunk +113 lines, -12 lines 2 comments Download
M media/capture/video/fake_video_capture_device.cc View 1 2 13 chunks +110 lines, -178 lines 4 comments Download
M media/capture/video/fake_video_capture_device_factory.h View 2 chunks +45 lines, -18 lines 0 comments Download
M media/capture/video/fake_video_capture_device_factory.cc View 1 2 4 chunks +201 lines, -79 lines 0 comments Download
M media/capture/video/fake_video_capture_device_unittest.cc View 1 2 9 chunks +71 lines, -39 lines 0 comments Download
M media/capture/video/video_capture_device_factory.cc View 1 chunk +8 lines, -2 lines 0 comments Download

Depends on Patchset:

Dependent Patchsets:

Messages

Total messages: 30 (21 generated)
chfremer
guidou@: PTAL content/* mcasas@: PTAL media/* emircan@: FYI
3 years, 9 months ago (2017-02-24 17:47:34 UTC) #8
Guido Urdaneta
content lgtm
3 years, 9 months ago (2017-02-27 16:09:33 UTC) #15
emircan
https://codereview.chromium.org/2715513008/diff/40001/media/capture/video/fake_video_capture_device.cc File media/capture/video/fake_video_capture_device.cc (right): https://codereview.chromium.org/2715513008/diff/40001/media/capture/video/fake_video_capture_device.cc#newcode53 media/capture/video/fake_video_capture_device.cc:53: if (requested_format == media::PIXEL_FORMAT_I420) { Merge to a single ...
3 years, 9 months ago (2017-03-01 18:59:01 UTC) #16
chfremer
PTAL. Incorporated suggestions. https://codereview.chromium.org/2715513008/diff/40001/media/capture/video/fake_video_capture_device.cc File media/capture/video/fake_video_capture_device.cc (right): https://codereview.chromium.org/2715513008/diff/40001/media/capture/video/fake_video_capture_device.cc#newcode53 media/capture/video/fake_video_capture_device.cc:53: if (requested_format == media::PIXEL_FORMAT_I420) { On ...
3 years, 9 months ago (2017-03-01 21:55:48 UTC) #18
emircan
lgtm https://codereview.chromium.org/2715513008/diff/40001/media/capture/video/fake_video_capture_device.cc File media/capture/video/fake_video_capture_device.cc (right): https://codereview.chromium.org/2715513008/diff/40001/media/capture/video/fake_video_capture_device.cc#newcode217 media/capture/video/fake_video_capture_device.cc:217: "USE_DEVICE_INTERNAL_BUFFERS."; On 2017/03/01 21:55:48, chfremer wrote: > On ...
3 years, 9 months ago (2017-03-02 20:28:18 UTC) #22
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/2715513008/60001
3 years, 9 months ago (2017-03-02 20:31:46 UTC) #25
commit-bot: I haz the power
Committed patchset #3 (id:60001) as https://chromium.googlesource.com/chromium/src/+/b0ee07cd95863c50ca5bf553bab82bf54b82d500
3 years, 9 months ago (2017-03-02 20:39:47 UTC) #28
mcasas
https://codereview.chromium.org/2715513008/diff/60001/media/capture/video/fake_video_capture_device.cc File media/capture/video/fake_video_capture_device.cc (right): https://codereview.chromium.org/2715513008/diff/60001/media/capture/video/fake_video_capture_device.cc#newcode47 media/capture/video/fake_video_capture_device.cc:47: SUPPORTED_THROUGH_CONVERSION = 1, IIUC SUPPORTED_THROUGH_CONVERSION has only two uses, ...
3 years, 9 months ago (2017-03-02 21:07:09 UTC) #29
chfremer
3 years, 9 months ago (2017-03-02 23:03:04 UTC) #30
Message was sent while issue was closed.
Thanks for the review and comments.

mcasas@, since this one has already landed, I will post a separate CL13b
incorporating your suggestions.

https://codereview.chromium.org/2715513008/diff/60001/media/capture/video/fak...
File media/capture/video/fake_video_capture_device.cc (right):

https://codereview.chromium.org/2715513008/diff/60001/media/capture/video/fak...
media/capture/video/fake_video_capture_device.cc:47:
SUPPORTED_THROUGH_CONVERSION = 1,
On 2017/03/02 21:07:09, mcasas wrote:
> IIUC SUPPORTED_THROUGH_CONVERSION has only
> two uses, so who cares about it? What you want to define here
> is a scale of unsupportedness, which is not what an enum
> is for, and its use inside FindClosestSupportedFormat()
> is obscure because of that.  Ideally, you should be able
> to enumerate the formats in preference order, e.g.
> 
> // VideoPixelFormats in order from most to least preferred.
> static kPreferredVideoPixelFormat kPreferredVideoPixelFormats[] = {
>   // We like these formats less because they are Skia native.
>   PIXEL_FORMAT_RGBA
>   PIXEL_FORMAT_RGB32,
>   // Next-best formats are those that need internal conversion.
>   PIXEL_FORMAT_I420,
>   PIXEL_FORMAT_MJPEG,
>   //...
> };
> 
> If all formats are present then
>   static_assert(sizeof(kPreferredVideoPixelFormats) == PIXEL_FORMAT_MAX,
"bla");
> would be needed.
> 
> Perhaps this list should be a correspondence instead,
> between requested pixel format to produced pixel format,
> again in priority order. Might, I'm not sure.
> 
> 

The root cause for why this admittedly ugly construct was needed is that clients
send their format request to the VCDevice but receive their frames from the
VCDeviceClient, which can perform conversion. 

Since the client also provides the VCDeviceClient, it should probably be itself
responsible to know which conversions it performs. Let me go clean that up in a
follow-up CL while the next CL is under review.

Will do.

https://codereview.chromium.org/2715513008/diff/60001/media/capture/video/fak...
media/capture/video/fake_video_capture_device.cc:97: }
On 2017/03/02 21:07:09, mcasas wrote:
> This code looks very familiar, is also in media_stream_video_source.cc, 
> [1] it'd be cool to have it all in one single place, so that 
> resolution-selecting policies are coherent across chrome. 
> 
> Can be a bug with a TODO().
> 
> [1] vicinity of
>
https://cs.chromium.org/chromium/src/content/renderer/media/media_stream_vide...

I am going to look into it, and will track it as part of CL13b in the design
doc.

https://codereview.chromium.org/2715513008/diff/60001/media/capture/video/fak...
File media/capture/video/fake_video_capture_device.h (right):

https://codereview.chromium.org/2715513008/diff/60001/media/capture/video/fak...
media/capture/video/fake_video_capture_device.h:24: class PacmanFramePainter {
On 2017/03/02 21:07:09, mcasas wrote:
> This class can and should be forward declared here.
> 
> Probably FakeDeviceState, FrameDelivererFactory
> and FakePhotoDevice can also be forward declared
> and defined in the .cc file. 
> 
> It's fine to do it in a follow-up CL

They used to be forward-declared, but I had to move them back to the header,
because the logic for creating instances of FakeVideoCaptureDevice has moved
back to class FakeVideoCaptureDeviceFactory.

Powered by Google App Engine
This is Rietveld 408576698