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

Issue 2619503003: Split FakeVideoCaptureDevice into classes with single responsibility (Closed)

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

Description

Split FakeVideoCaptureDevice into classes with single responsibility This is mostly a refactoring in preparation of adding support for generating MJPEG as output format as part of the Mojo Video Capture work [1]. For motiviation of separating responsibilities into classes, see [2]. There are two small fixes that change behavior: 1.) Before this CL, when switching the frame delivery to USE_CLIENT_BUFFERS, the default pixel format (for all devices except the 2nd) was switched to ARGB. FakeVideoCaptureDeviceFactory::GetSupportedFormats() would erroneously always report I420 as pixel format, even if ARGB was delivered. Trying to actually use USE_CLIENT_BUFFERS with ARGB anywhere beyond the unit tests, (e.g. using command-line [4]) would crash with a failed CHECK, because ARGB is not actually supported downstream. After this CL, the default pixel format stays I420, even when switching to USE_CLIENT_BUFFERS. 2.) Fixed race condition that could cause the frame delivery from an old session to continue when device is restarted. In order to make reviewing easier, the split out code has not yet been moved to separate files and methods are ordered such that they match up with the equivalent code before the change. This makes it easier to see from the diff what parts of the code have not been touched. Here is an overview of what has moved where: * Creating an instance of FakeVideoCaptureDevice with the same behavior as before now requires some logic for correctly setting up its dependencies. This logic is located in class FakeVideoCaptureDeviceMaker (because the name FakeVideoCaptureDeviceFactory was already taken). * The file-private logic for painting Pacman frames has moved to class PacmanFramePainter with abstraction interface FramePainter. * The logic for delivering frames to the client has moved to a strategy object [3] with interface FrameDeliveryStrategy. The two variants have moved to the implementations called OwnBufferFrameDeliveryStrategy and ClientBufferFrameDeliveryStrategy respectively. * Fake photo functionality has moved to class FakePhotoDevice * The previously duplicated constants for supported frame sizes have been consolidated to kSupportedSizes[], and FakeVideoCaptureDeviceFactory now asks FakeVideoCaptureDevice for its supported sizes via a static method. Updated the unit tests to cover more of the configurable parameter space and sweep through several resolutions. BUG=584797 TEST= out/Default/capture_unittests --gtest_filter="FakeVideoCaptureDevice*" out/Default/chrome --use-fake-device-for-media-stream https://webrtc.github.io/samples/src/content/getusermedia/gum/ out/Default/chrome --use-fake-device-for-media-stream=ownership=client https://webrtc.github.io/samples/src/content/getusermedia/gum/ out/Default/chrome --use-fake-device-for-media-stream=device-count=3 https://webrtc.github.io/samples/src/content/getusermedia/gum/ out/Default/chrome --use-fake-device-for-media-stream=ownership=client,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 [2] https://en.wikipedia.org/wiki/Single_responsibility_principle [3] https://en.wikipedia.org/wiki/Strategy_pattern [4] out/Default/chrome --use-fake-device-for-media-stream=ownership=client https://webrtc.github.io/samples/src/content/getusermedia/gum/ Review-Url: https://codereview.chromium.org/2619503003 Cr-Commit-Position: refs/heads/master@{#450847} Committed: https://chromium.googlesource.com/chromium/src/+/f2feab4a2a71b0c5fcbafbde747bde549029e0b7

Patch Set 1 #

Total comments: 21

Patch Set 2 : mcasas comments & rebase #

Total comments: 9

Patch Set 3 : emircan's comments #

Patch Set 4 : rebase #

Total comments: 18

Patch Set 5 : mcasas@ suggestions #

Patch Set 6 : mcasas@ suggestions pt2 #

Patch Set 7 : Removed FramePainter interface #

Total comments: 9

Patch Set 8 : mcasas@ suggestions #

Unified diffs Side-by-side diffs Delta from patch set Stats (+566 lines, -288 lines) Patch
M media/capture/video/fake_video_capture_device.h View 1 2 3 4 2 chunks +11 lines, -60 lines 0 comments Download
M media/capture/video/fake_video_capture_device.cc View 1 2 3 4 5 6 7 12 chunks +415 lines, -154 lines 0 comments Download
M media/capture/video/fake_video_capture_device_factory.h View 1 3 chunks +9 lines, -5 lines 0 comments Download
M media/capture/video/fake_video_capture_device_factory.cc View 1 2 3 4 6 chunks +25 lines, -23 lines 0 comments Download
M media/capture/video/fake_video_capture_device_unittest.cc View 1 2 3 4 5 5 chunks +106 lines, -46 lines 0 comments Download

Messages

Total messages: 45 (28 generated)
chfremer
mcasas@: PTAL emircan@: FYI
3 years, 11 months ago (2017-01-06 20:33:52 UTC) #5
chfremer
On 2017/01/06 20:33:52, chfremer wrote: > mcasas@: PTAL > emircan@: FYI ping
3 years, 11 months ago (2017-01-09 23:11:09 UTC) #8
mcasas
had a few comments to get you started https://codereview.chromium.org/2619503003/diff/1/media/capture/video/fake_video_capture_device.h File media/capture/video/fake_video_capture_device.h (right): https://codereview.chromium.org/2619503003/diff/1/media/capture/video/fake_video_capture_device.h#newcode26 media/capture/video/fake_video_capture_device.h:26: class ...
3 years, 11 months ago (2017-01-12 03:19:16 UTC) #9
chfremer
PTAL https://codereview.chromium.org/2619503003/diff/1/media/capture/video/fake_video_capture_device.h File media/capture/video/fake_video_capture_device.h (right): https://codereview.chromium.org/2619503003/diff/1/media/capture/video/fake_video_capture_device.h#newcode26 media/capture/video/fake_video_capture_device.h:26: class CAPTURE_EXPORT FakeVideoCaptureDeviceMaker { On 2017/01/12 03:19:16, mcasas ...
3 years, 11 months ago (2017-01-18 01:29:52 UTC) #10
emircan
https://codereview.chromium.org/2619503003/diff/20001/media/capture/video/fake_video_capture_device.cc File media/capture/video/fake_video_capture_device.cc (right): https://codereview.chromium.org/2619503003/diff/20001/media/capture/video/fake_video_capture_device.cc#newcode233 media/capture/video/fake_video_capture_device.cc:233: for (int i = 0; i < kSupportedSizesCount; i++) ...
3 years, 10 months ago (2017-01-31 18:47:39 UTC) #11
chfremer
PTAL addressed emircan@'s comments https://codereview.chromium.org/2619503003/diff/20001/media/capture/video/fake_video_capture_device.cc File media/capture/video/fake_video_capture_device.cc (right): https://codereview.chromium.org/2619503003/diff/20001/media/capture/video/fake_video_capture_device.cc#newcode233 media/capture/video/fake_video_capture_device.cc:233: for (int i = 0; ...
3 years, 10 months ago (2017-02-01 00:21:18 UTC) #12
emircan
lgtm https://codereview.chromium.org/2619503003/diff/20001/media/capture/video/fake_video_capture_device.cc File media/capture/video/fake_video_capture_device.cc (right): https://codereview.chromium.org/2619503003/diff/20001/media/capture/video/fake_video_capture_device.cc#newcode628 media/capture/video/fake_video_capture_device.cc:628: base::TimeDelta::FromMicroseconds(1e6 / device_state_->format.frame_rate); On 2017/02/01 00:21:18, chfremer wrote: ...
3 years, 10 months ago (2017-02-01 18:06:04 UTC) #13
mcasas
Couple of questions, almost there. https://codereview.chromium.org/2619503003/diff/1/media/capture/video/fake_video_capture_device.h File media/capture/video/fake_video_capture_device.h (right): https://codereview.chromium.org/2619503003/diff/1/media/capture/video/fake_video_capture_device.h#newcode26 media/capture/video/fake_video_capture_device.h:26: class CAPTURE_EXPORT FakeVideoCaptureDeviceMaker { ...
3 years, 10 months ago (2017-02-15 00:44:19 UTC) #20
chfremer
mcasas@: Please take another look. https://codereview.chromium.org/2619503003/diff/1/media/capture/video/fake_video_capture_device.h File media/capture/video/fake_video_capture_device.h (right): https://codereview.chromium.org/2619503003/diff/1/media/capture/video/fake_video_capture_device.h#newcode26 media/capture/video/fake_video_capture_device.h:26: class CAPTURE_EXPORT FakeVideoCaptureDeviceMaker { ...
3 years, 10 months ago (2017-02-15 01:30:11 UTC) #23
chfremer
Sorry, I missed a couple of comment in my previous reply. Addressed in PatchSet 6 ...
3 years, 10 months ago (2017-02-15 18:11:30 UTC) #28
mcasas
https://codereview.chromium.org/2619503003/diff/1/media/capture/video/fake_video_capture_device.h File media/capture/video/fake_video_capture_device.h (right): https://codereview.chromium.org/2619503003/diff/1/media/capture/video/fake_video_capture_device.h#newcode28 media/capture/video/fake_video_capture_device.h:28: enum class DeliveryMode { USE_OWN_BUFFERS, USE_CLIENT_BUFFERS }; On 2017/02/15 ...
3 years, 10 months ago (2017-02-15 18:23:47 UTC) #29
chfremer
Removed FramePainter abstraction. PTAL https://codereview.chromium.org/2619503003/diff/60001/media/capture/video/fake_video_capture_device.cc File media/capture/video/fake_video_capture_device.cc (right): https://codereview.chromium.org/2619503003/diff/60001/media/capture/video/fake_video_capture_device.cc#newcode82 media/capture/video/fake_video_capture_device.cc:82: }; On 2017/02/15 18:23:47, mcasas ...
3 years, 10 months ago (2017-02-15 18:37:16 UTC) #31
mcasas
lgtm with some suggestions https://codereview.chromium.org/2619503003/diff/120001/media/capture/video/fake_video_capture_device.cc File media/capture/video/fake_video_capture_device.cc (right): https://codereview.chromium.org/2619503003/diff/120001/media/capture/video/fake_video_capture_device.cc#newcode11 media/capture/video/fake_video_capture_device.cc:11: #include "base/atomicops.h" Probably not needed ...
3 years, 10 months ago (2017-02-15 19:06:52 UTC) #33
chfremer
Incorporated improvements suggested by mcasas@. Also, moved FrameDeliverer::first_ref_time_ from protected to private and removed some ...
3 years, 10 months ago (2017-02-15 20:52:06 UTC) #34
mcasas
https://codereview.chromium.org/2619503003/diff/120001/media/capture/video/fake_video_capture_device.cc File media/capture/video/fake_video_capture_device.cc (right): https://codereview.chromium.org/2619503003/diff/120001/media/capture/video/fake_video_capture_device.cc#newcode98 media/capture/video/fake_video_capture_device.cc:98: class FrameDeliveryStrategy { On 2017/02/15 20:52:05, chfremer wrote: > ...
3 years, 10 months ago (2017-02-15 20:56:52 UTC) #35
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/2619503003/140001
3 years, 10 months ago (2017-02-15 23:37:59 UTC) #42
commit-bot: I haz the power
3 years, 10 months ago (2017-02-16 00:52:30 UTC) #45
Message was sent while issue was closed.
Committed patchset #8 (id:140001) as
https://chromium.googlesource.com/chromium/src/+/f2feab4a2a71b0c5fcbafbde747b...

Powered by Google App Engine
This is Rietveld 408576698