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

Issue 1699553002: Mojo Video Capture service in media/capture (Closed)

Created:
4 years, 10 months ago by mcasas
Modified:
4 years, 9 months ago
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Mojo Video Capture service in media/capture DD: https://goo.gl/Bsmk4u (Iteration from http://crrev.com/1637793004, #ps4) This CL: - Adds media/capture/interfaces and media/capture/service. - new source_set("service") for service/ (mojo module) - has its own capture_unittests BUG=584797 TEST= ./video_capture_service_unittests

Patch Set 1 #

Patch Set 2 : added missing BUILD deps #

Total comments: 15

Patch Set 3 : rockot@s comments #

Total comments: 10

Patch Set 4 : perkj@s comments #

Total comments: 2

Patch Set 5 : emircan@ comments #

Total comments: 20

Patch Set 6 : perkj@ comments - mostly simplifications of the mojom. and renaming #

Total comments: 44

Patch Set 7 : perkj@s and magjed@s comments #

Total comments: 1

Patch Set 8 : emplace --> insert(std::make_pair) #

Patch Set 9 : Rebased to using MojoSharedBufferVideoFrame #

Total comments: 25

Patch Set 10 : perkj@s comments and renaming #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1883 lines, -1 line) Patch
M BUILD.gn View 1 2 3 4 5 6 7 8 9 1 chunk +1 line, -0 lines 0 comments Download
M media/base/BUILD.gn View 1 2 3 4 5 6 7 8 1 chunk +1 line, -1 line 0 comments Download
M media/capture/BUILD.gn View 1 2 3 4 5 6 7 8 9 1 chunk +49 lines, -0 lines 0 comments Download
A media/capture/interfaces/BUILD.gn View 1 1 chunk +16 lines, -0 lines 0 comments Download
A media/capture/interfaces/OWNERS View 1 1 chunk +3 lines, -0 lines 0 comments Download
A media/capture/interfaces/video_capture.mojom View 1 2 3 4 5 6 7 8 9 1 chunk +93 lines, -0 lines 0 comments Download
A media/capture/service/DEPS View 1 chunk +10 lines, -0 lines 0 comments Download
A media/capture/service/OWNERS View 1 1 chunk +3 lines, -0 lines 0 comments Download
A media/capture/service/mock_video_capture_stream_client.h View 1 2 3 4 5 6 7 8 9 1 chunk +44 lines, -0 lines 0 comments Download
A media/capture/service/mock_video_capture_stream_client.cc View 1 2 3 4 5 6 7 8 9 1 chunk +13 lines, -0 lines 0 comments Download
A media/capture/service/video_capture_device_client_impl.h View 1 2 3 4 5 6 7 8 1 chunk +101 lines, -0 lines 0 comments Download
A media/capture/service/video_capture_device_client_impl.cc View 1 2 3 4 5 6 7 8 1 chunk +359 lines, -0 lines 0 comments Download
A media/capture/service/video_capture_device_client_impl_unittest.cc View 1 2 3 4 5 6 7 8 1 chunk +157 lines, -0 lines 0 comments Download
A media/capture/service/video_capture_handler_impl.h View 1 2 3 4 5 6 7 8 9 1 chunk +82 lines, -0 lines 0 comments Download
A media/capture/service/video_capture_handler_impl.cc View 1 2 3 4 5 6 7 8 9 1 chunk +181 lines, -0 lines 0 comments Download
A media/capture/service/video_capture_handler_impl_unittest.cc View 1 2 3 4 5 6 1 chunk +194 lines, -0 lines 0 comments Download
A media/capture/service/video_capture_stream_impl.h View 1 2 3 4 5 6 7 8 9 1 chunk +92 lines, -0 lines 0 comments Download
A media/capture/service/video_capture_stream_impl.cc View 1 2 3 4 5 6 7 8 9 1 chunk +112 lines, -0 lines 0 comments Download
A media/capture/service/video_capture_stream_impl_unittest.cc View 1 2 3 4 5 6 7 8 9 1 chunk +143 lines, -0 lines 0 comments Download
A media/capture/service/video_capture_unittest.cc View 1 2 3 4 5 6 7 8 9 1 chunk +226 lines, -0 lines 0 comments Download
M media/mojo/common/mojo_shared_buffer_video_frame.h View 1 2 3 4 5 6 7 8 1 chunk +3 lines, -0 lines 0 comments Download

Messages

Total messages: 61 (38 generated)
mcasas
Sorry for the delay in updating this CL, shifting around code in media took forever. ...
4 years, 9 months ago (2016-02-29 17:58:24 UTC) #32
perkj_chrome
Adding Tommi as well. Tommi - do you know more of mojo than I do? ...
4 years, 9 months ago (2016-03-01 08:01:21 UTC) #35
Ken Rockot(use gerrit already)
Looks pretty good overall. Some comments from a first pass https://codereview.chromium.org/1699553002/diff/420001/media/capture/interfaces/video_capture.mojom File media/capture/interfaces/video_capture.mojom (right): https://codereview.chromium.org/1699553002/diff/420001/media/capture/interfaces/video_capture.mojom#newcode10 ...
4 years, 9 months ago (2016-03-02 02:52:08 UTC) #36
perkj_chrome
Sorry but I am having trouble understanding how this fits into the current architecture and ...
4 years, 9 months ago (2016-03-02 13:14:10 UTC) #38
mcasas
guys PTAL https://codereview.chromium.org/1699553002/diff/420001/media/capture/interfaces/video_capture.mojom File media/capture/interfaces/video_capture.mojom (right): https://codereview.chromium.org/1699553002/diff/420001/media/capture/interfaces/video_capture.mojom#newcode10 media/capture/interfaces/video_capture.mojom:10: module media.video_capture; On 2016/03/02 02:52:08, Ken Rockot ...
4 years, 9 months ago (2016-03-02 19:53:51 UTC) #39
emircan
https://codereview.chromium.org/1699553002/diff/440001/media/capture/service/mojo_video_frame.cc File media/capture/service/mojo_video_frame.cc (right): https://codereview.chromium.org/1699553002/diff/440001/media/capture/service/mojo_video_frame.cc#newcode46 media/capture/service/mojo_video_frame.cc:46: return false; DVLOG(ERROR) here can be useful. https://codereview.chromium.org/1699553002/diff/440001/media/capture/service/stream_impl.h File ...
4 years, 9 months ago (2016-03-02 21:52:10 UTC) #40
mcasas
PTAL https://codereview.chromium.org/1699553002/diff/460001/media/capture/service/video_capture_device_client_impl.cc File media/capture/service/video_capture_device_client_impl.cc (right): https://codereview.chromium.org/1699553002/diff/460001/media/capture/service/video_capture_device_client_impl.cc#newcode316 media/capture/service/video_capture_device_client_impl.cc:316: frame->metadata()->Clear(); On 2016/03/02 21:52:10, emircan wrote: > I ...
4 years, 9 months ago (2016-03-03 01:02:13 UTC) #41
Ken Rockot(use gerrit already)
mojo bits lgtm btw
4 years, 9 months ago (2016-03-03 01:05:05 UTC) #42
perkj_chrome
https://codereview.chromium.org/1699553002/diff/480001/media/capture/interfaces/video_capture.mojom File media/capture/interfaces/video_capture.mojom (right): https://codereview.chromium.org/1699553002/diff/480001/media/capture/interfaces/video_capture.mojom#newcode76 media/capture/interfaces/video_capture.mojom:76: // The Stream interface abstracts a distinct local source ...
4 years, 9 months ago (2016-03-03 13:12:42 UTC) #43
magjed_chromium
https://codereview.chromium.org/1699553002/diff/480001/media/base/video_frame.h File media/base/video_frame.h (right): https://codereview.chromium.org/1699553002/diff/480001/media/base/video_frame.h#newcode428 media/base/video_frame.h:428: void set_data(size_t plane, uint8_t* ptr); I don't like these ...
4 years, 9 months ago (2016-03-03 14:20:58 UTC) #44
mcasas
perkj@ PTAL Let me know if you want me to rename the files/classes: StreamImpl -> ...
4 years, 9 months ago (2016-03-03 18:41:15 UTC) #45
emircan
lgtm. This is good start for moving things to mojo. I think it is better ...
4 years, 9 months ago (2016-03-03 19:51:16 UTC) #46
mcasas
On 2016/03/03 19:51:16, emircan wrote: > lgtm. This is good start for moving things to ...
4 years, 9 months ago (2016-03-04 15:29:38 UTC) #47
perkj_chrome
If I understand things right- this is browser side only. So then - should this ...
4 years, 9 months ago (2016-03-04 15:34:02 UTC) #48
magjed_chromium
This is way too much new code for me to review in one CL - ...
4 years, 9 months ago (2016-03-04 15:41:42 UTC) #49
mcasas
PTAL. Reducing the number of files: let me rebase to the MojoVideoFrame landing (which is ...
4 years, 9 months ago (2016-03-04 19:59:46 UTC) #50
mcasas
https://codereview.chromium.org/1699553002/diff/520001/media/capture/service/stream_impl.cc File media/capture/service/stream_impl.cc (right): https://codereview.chromium.org/1699553002/diff/520001/media/capture/service/stream_impl.cc#newcode92 media/capture/service/stream_impl.cc:92: in_use_video_frames_.emplace(buffer_id, frame); Some builders still fail with "../../media/capture/service/stream_impl.cc:92:24: error: ...
4 years, 9 months ago (2016-03-04 22:00:27 UTC) #51
magjed_chromium
https://codereview.chromium.org/1699553002/diff/500001/media/capture/interfaces/video_capture.mojom File media/capture/interfaces/video_capture.mojom (right): https://codereview.chromium.org/1699553002/diff/500001/media/capture/interfaces/video_capture.mojom#newcode36 media/capture/interfaces/video_capture.mojom:36: handle<shared_buffer> storage_handle; On 2016/03/04 19:59:45, mcasas wrote: > On ...
4 years, 9 months ago (2016-03-07 15:36:24 UTC) #52
mcasas
https://codereview.chromium.org/1699553002/diff/500001/media/capture/interfaces/video_capture.mojom File media/capture/interfaces/video_capture.mojom (right): https://codereview.chromium.org/1699553002/diff/500001/media/capture/interfaces/video_capture.mojom#newcode36 media/capture/interfaces/video_capture.mojom:36: handle<shared_buffer> storage_handle; On 2016/03/07 15:36:24, magjed_chromium wrote: > On ...
4 years, 9 months ago (2016-03-07 20:57:50 UTC) #53
perkj_chrome
A few more. https://codereview.chromium.org/1699553002/diff/500001/media/capture/interfaces/video_capture.mojom File media/capture/interfaces/video_capture.mojom (right): https://codereview.chromium.org/1699553002/diff/500001/media/capture/interfaces/video_capture.mojom#newcode57 media/capture/interfaces/video_capture.mojom:57: int64 timestamp; On 2016/03/04 19:59:45, mcasas ...
4 years, 9 months ago (2016-03-07 23:58:27 UTC) #54
mcasas
perkj@ PTAL https://codereview.chromium.org/1699553002/diff/560001/media/capture/interfaces/video_capture.mojom File media/capture/interfaces/video_capture.mojom (right): https://codereview.chromium.org/1699553002/diff/560001/media/capture/interfaces/video_capture.mojom#newcode66 media/capture/interfaces/video_capture.mojom:66: // An error has ocurred; the capture ...
4 years, 9 months ago (2016-03-08 23:57:29 UTC) #58
magjed_chromium
https://codereview.chromium.org/1699553002/diff/500001/media/capture/interfaces/video_capture.mojom File media/capture/interfaces/video_capture.mojom (right): https://codereview.chromium.org/1699553002/diff/500001/media/capture/interfaces/video_capture.mojom#newcode36 media/capture/interfaces/video_capture.mojom:36: handle<shared_buffer> storage_handle; On 2016/03/07 20:57:49, mcasas wrote: > On ...
4 years, 9 months ago (2016-03-09 14:11:18 UTC) #59
mcasas
4 years, 9 months ago (2016-03-18 18:57:05 UTC) #60
On 2016/03/09 14:11:18, magjed_chromium wrote:
>
https://codereview.chromium.org/1699553002/diff/500001/media/capture/interfac...
> File media/capture/interfaces/video_capture.mojom (right):
> 
>
https://codereview.chromium.org/1699553002/diff/500001/media/capture/interfac...
> media/capture/interfaces/video_capture.mojom:36: handle<shared_buffer>
> storage_handle;
> On 2016/03/07 20:57:49, mcasas wrote:
> > On 2016/03/07 15:36:24, magjed_chromium wrote:
> > > On 2016/03/04 19:59:45, mcasas wrote:
> > > > On 2016/03/04 15:41:42, magjed_chromium wrote:
> > > > > |storage_handle| contains all the data, right? Don't we need plane
> > offsets,
> > > > > strides etc?
> > > > 
> > > > Not yet. Offsets are not used in capture and 
> > > > the strides are the |coded_size|.
> > > 
> > > With plane offsets I mean: how do you calculate the pointer for the U and
V
> > > plane from |storage_handle|? When you say that the strides are in
> > |coded_size|,
> > > do you mean that everything is tightly packed? 
> > Yes.
> > > Otherwise strides are not the
> > > same as |coded_size|, that's why we have both strides and coded_size in
> > > VideoFrame.
> > Correct. But that capability of VideoFrame is not used
> > for capturing scenarios.
> 
> Acknowledged.
> 
>
https://codereview.chromium.org/1699553002/diff/500001/media/capture/service/...
> File media/capture/service/stream_impl.cc (right):
> 
>
https://codereview.chromium.org/1699553002/diff/500001/media/capture/service/...
> media/capture/service/stream_impl.cc:110: DCHECK(video_frame ==
> in_use_video_frames_.end()) << "Buffer id " << buffer_id
> On 2016/03/07 20:57:49, mcasas wrote:
> > On 2016/03/07 15:36:24, magjed_chromium wrote:
> > > On 2016/03/04 19:59:45, mcasas wrote:
> > > > On 2016/03/04 15:41:42, magjed_chromium wrote:
> > > > > Shouldn't this be DCHECK(video_frame != in_use_video_frames_.end())? 
> > > > 
> > > > Yes thanks.
> > > > 
> > > > > Is this code executed in any test?
> > > > 
> > > > This method is exercised in both StreamImplTest and
> > > > VideoCaptureTest.
> > > 
> > > Then why didn't the tests fail?
> > 
> > The capture tests are only compiled in gn builds
> > and probably those do not exercise the full set
> > of unittests.
> 
> Ok. It's a bit worrying that a DCHECK with 100% failure ratio goes unnoticed.
> 
>
https://codereview.chromium.org/1699553002/diff/500001/media/capture/service/...
> File media/capture/service/stream_impl.h (right):
> 
>
https://codereview.chromium.org/1699553002/diff/500001/media/capture/service/...
> media/capture/service/stream_impl.h:85: std::map<int32_t, const
> scoped_refptr<MojoVideoFrame>&> in_use_video_frames_;
> On 2016/03/07 20:57:49, mcasas wrote:
> > On 2016/03/07 15:36:24, magjed_chromium wrote:
> > > On 2016/03/04 19:59:45, mcasas wrote:
> > > > On 2016/03/04 15:41:42, magjed_chromium wrote:
> > > > > The value type in this std::map is a const-ref, which looks super
> > dangerous.
> > > > > Shouldn't it be a scoped_refptr<MojoVideoFrame>, i.e. a non-ref? 
> > > > 
> > > > Done.
> > > > 
> > > > > Also, I don't
> > > > > see the frames being used anywhere, so why not use a set instead of a
> map?
> > > Is
> > > > it
> > > > > a map to keep the frames alive?
> > > > 
> > > > We search for the |buffer_id| in OnFrameConsumed().
> > > >   const auto video_frame = video_frames_in_use_.find(buffer_id);
> > > 
> > > Yes, but you never access the mapped frame in the |video_frame| iterator
> which
> > > is of type std::pair<const key_type,mapped_type>, where key_type is
int32_t
> > and
> > > mapped_type is a MojoVideoFrame. Why have a mapped object if you don't
> access
> > > it? You can use the exact same code video_frames_in_use_.find(buffer_id);
> > where
> > > |video_frames_in_use_| is a set<int32_t>.
> > 
> > Maybe we're not understanding how I thought this
> > was supposed to work :)
> > VCDCImpl has a pool of Mojo...VideoFrames. Each
> > time a frame of this type is created, an associated
> > MojoSharedBuffer is created and mapped, and remains
> > so during the lifetime of the said VideoFrame. A VF
> > can only be inside the Pool, hence "available" or not,
> > and then it's in use. When a VF is taken out of the pool,
> > StreamImpl receives it and assigns a number to it; this 
> > number is bound to the release callback. 
> > 
> > Only the constituents of the VideoFrame are sent across 
> > the Mojo channel, where each StreamClient(s) will 
> > reconstruct a peer VideoFrame. The original VideoFrame 
> > must stay alive and "in use" until the StreamClient is finished.
> > 
> > When the client is finished with the VideoFrame, it will ping 
> > us back via OnFrameConsumed() callback where the 
> > |buffer_id| is bound. Then we find the VideoFrame by
> > id and remove it from the list. We need to keep the
> > VideoFrame alive on this side of the Mojo boundary,
> > hence I chose to keep them all lined up in a map.
> > 
> > So basically a VF is either in the VCDCImpl's Pool or
> > is kept here until the Mojo clients are finished. Much
> > simpler than the current design in renderer_host.
> > 
> > (Ok, is slightly more complex because the VFs being 
> > taken out of the Pool are wrapped into another VF.)
> > 
> > So I'm not sure what you don't grok. Is it that
> > you'd like to remove the |in_use_video_frames_| 
> > and bind the VideoFrame themselves to the release 
> > callback...? 
> 
> I didn't grok the purpose of this map since you don't use the mapped frames.
The
> only purpose I could think of was to keep the frames alive, but you captured
the
> scoped_refptr by-ref so that would not help the frames stay alive. Can you add
a
> comment that the purpose of the map is to keep the frames alive? It's also a
bit
> worrying that the tests didn't catch that the frames were not kept alive. I
> guess the frames were returned immediately to the pool previously so that you
> would never allocate more than one frame. Can you add a test that checks that
a
> new frame is received if the previous frame is not returned?
> 
> Actually, your suggestion to bind the scoped_refptrs directly to the release
> callback seems cleaner if you don't plan to use |in_use_video_frames_| for
> anything else.
> 
>
https://codereview.chromium.org/1699553002/diff/560001/media/capture/service/...
> File media/capture/service/video_capture_device_client_impl.cc (right):
> 
>
https://codereview.chromium.org/1699553002/diff/560001/media/capture/service/...
> media/capture/service/video_capture_device_client_impl.cc:120: // N.B.: All of
> the logic throughout this method is lifted directly from
> On 2016/03/07 20:57:49, mcasas wrote:
> > On 2016/03/07 15:36:24, magjed_chromium wrote:
> > > Can you split out the duplicated logic into a function instead? It looks
> like
> > > the only difference with existing
> > > VideoCaptureDeviceClient:OnIncomingCapturedData() is how you reserve the
> > output
> > > buffer and that you don't use an external jpeg decoder. I think you can
> > refactor
> > > the bulk of this function into:
> > > bool ConvertToPackedI420(
> > >     const uint8_t* src_data,
> > >     int src_length, 
> > >     uint8* dst_y,
> > >     uint8* dst_u,
> > >     uint8* dst_v,
> > >     const media::VideoCaptureFormat& frame_format,
> > >     int clockwise_rotation);
> > 
> > Are you proposing I take out the common parts
> > into a method (e.g. of VideoCaptureDevice) that
> > can be used from here and from content/?
> > What would be the final goal of such a move? Note
> > that, in time, the implementation here should be 
> > the norm and the one in content/ should be
> > deprecated.  Besides, like you say, here no MJPEG
> > is supported and in content/, 
> > ReserveI420OutputBuffer() is used instead.
> > IMHO there are too many differences, and I'm
> > not looking forward to another preparatory CL
> > taking a week to brief in all the reviewers, review
> > and land.
> 
> Yes, I'm proposing that you take out the common parts into a non-member
method:
> bool ConvertToPackedI420(
>     const uint8_t* src_data,
>     int src_length, 
>     uint8* dst_y,
>     uint8* dst_u,
>     uint8* dst_v,
>     const media::VideoCaptureFormat& frame_format,
>     int clockwise_rotation);
> that you can use here and from content/.
> The goal with such a move is to reduce the ~100 duplicated lines of code here.
I
> understand that you plan to eventually remove the implementation in content/,
> but I suspect it will take months before that happens. The differences, i.e.
> support for external MJPEG decoder and ReserveI420OutputBuffer() are outside
the
> proposed new helper function, i.e. you call them before the helper function,
so
> it's not a problem. Landing just the new helper function will not take a week.
> IMHO if you would split this huge CL up, it wouldn't be so difficult to
review,
> and I don't think it would take much longer than landing it in one big chunk.

I won't be having time for this CL any time
soon, so closing it.

Thanks for your time reviewers!

Powered by Google App Engine
This is Rietveld 408576698