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

Issue 1128213005: Passing Native Texture backed Video Frame from Renderer to GPU process (Closed)

Created:
5 years, 7 months ago by emircan
Modified:
5 years, 6 months ago
CC:
chromium-reviews, mlamouri+watch-content_chromium.org, posciak+watch_chromium.org, jam, mcasas+watch_chromium.org, sievers+watch_chromium.org, jbauman+watch_chromium.org, feature-media-reviews_chromium.org, darin-cc_chromium.org, kalyank, mkwst+moarreviews-renderer_chromium.org, piman+watch_chromium.org, danakj+watch_chromium.org, wjia+watch_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

This CL enables passing a Native Texture backed media::VideoFrame from Renderer process to Video Encode Accelerator in GPU process. This is a part of Zero Copy Capture for CrOs plan: https://docs.google.com/document/d/1lobWf168_Kq05TLNLX81gRQwY5oe4k2t3oP-XTBEpIo - VideoFrameWrapper points to the underlying media::VideoFrame via native_handle() - WebRtcVideoCapturerAdapter uses VideoFrameWrapper to pass Native Texture backed VideoFrame - RTCVideoEncoder accesses the media::VideoFrame via native_handle() and passes - GpuVideoEncodeAcceleratorHost::Encode checks the VideoFrame::storage_type() and passes IPC calls: AcceleratedVideoEncoderMsg_EncodeSharedMemory or AcceleratedVideoEncoderMsg_EncodeNativeTexture - AcceleratedVideoEncoderMsg_EncodeNativeTexture passes the underlying gpu::MailboxHolder * Another alternative would be passing a gpu::Mailbox and rebuilding it, but I found this IPC call passing a gpu::MailboxHolder and thought it might be OK. https://code.google.com/p/chromium/codesearch#chromium/src/content/common/media/video_capture_messages.h&rcl=1431704469&l=40 - AcceleratedVideoEncoderMsg_EncodeNativeTexture is handled by GpuVideoEncodeAccelerator::OnEncodeNativeTexture in GPU process which rebuilds a VideoFrame by using the incoming gpu::MailboxHolder for media::VideoFrame::WrapNativeTexture() In the follow-up CLs: - Modify GLImage such that it can return the underlying data_ptr() and plane information - Pass GpuCommandBufferStub to V4L2VideoEncodeAccelerator - Use sync_point_manager() to wait for the sync_point on the incoming texture in VEA and use texture_manager() in V4L2EA/V4L2IP to access the underlying texture&image, such that the underlying data -described in the step above- can be used for encode - Redesign RTCVideoEncoder to work with non-ShMem media::VideoFrames - Tweak RTCVideoEncoder::Impl::CreateAndInitializeVEA() to initialize VEA with the correct formats rather than just expecting I420. - Tweak V4L2 image processor to initialize VEA with the correct formats rather than just expecting I420->NV12 - Check the fallbacks and handling of VideoFrames inside WebRTC classes such as VieCapturer BUG=485323, 440843 TEST= Run a successful AppRTC loopback using: - FakeVideoCaptureDevice which outputs Native Texture backed Video Frame - FakeVideoEncodeAccelerator which works with the incoming Native Texture https://docs.google.com/a/google.com/document/d/1a-5LZ0UTftpiu07wqYswxm2Ci6rDLKAUUx5al4C0ZTg/edit?usp=sharing - https://review.webrtc.org/50909005/ applied

Patch Set 1 : #

Total comments: 9

Patch Set 2 : posciak@ and magjed@ comments. #

Total comments: 20

Patch Set 3 : mcasas@ comments. #

Patch Set 4 : Rebased #

Patch Set 5 : Fixed msvc issues. #

Patch Set 6 : Passing a Texture+SharedMemory video frame. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+139 lines, -125 lines) Patch
M content/common/gpu/client/gpu_video_encode_accelerator_host.h View 1 2 3 4 5 2 chunks +1 line, -6 lines 0 comments Download
M content/common/gpu/client/gpu_video_encode_accelerator_host.cc View 1 2 3 4 5 1 chunk +33 lines, -25 lines 0 comments Download
M content/common/gpu/gpu_messages.h View 1 2 3 4 5 2 chunks +14 lines, -8 lines 0 comments Download
M content/common/gpu/media/gpu_video_encode_accelerator.h View 1 2 3 4 5 2 chunks +3 lines, -7 lines 0 comments Download
M content/common/gpu/media/gpu_video_encode_accelerator.cc View 1 2 3 4 5 5 chunks +27 lines, -30 lines 0 comments Download
M content/renderer/media/rtc_video_encoder.cc View 1 2 3 4 5 2 chunks +45 lines, -41 lines 0 comments Download
M content/renderer/media/webrtc/webrtc_video_capturer_adapter.cc View 1 2 3 4 5 3 chunks +16 lines, -8 lines 0 comments Download

Messages

Total messages: 32 (25 generated)
emircan
Please take a look.
5 years, 7 months ago (2015-05-15 19:59:14 UTC) #4
emircan
Ping. Please take a look. I rebased using the new media::VideoFrame structure to check for ...
5 years, 6 months ago (2015-06-02 21:39:39 UTC) #7
magjed_chromium
lgtm, but the bots don't seem happy https://codereview.chromium.org/1128213005/diff/60001/content/common/gpu/media/gpu_video_encode_accelerator.h File content/common/gpu/media/gpu_video_encode_accelerator.h (right): https://codereview.chromium.org/1128213005/diff/60001/content/common/gpu/media/gpu_video_encode_accelerator.h#newcode93 content/common/gpu/media/gpu_video_encode_accelerator.h:93: void EncodeFrameFinished(int32 ...
5 years, 6 months ago (2015-06-03 08:40:00 UTC) #8
Pawel Osciak
Would you be able to test this on a non-fake device as well please? Any ...
5 years, 6 months ago (2015-06-03 10:28:56 UTC) #9
emircan
On 2015/06/03 10:28:56, Pawel Osciak wrote: > Would you be able to test this on ...
5 years, 6 months ago (2015-06-03 20:56:12 UTC) #10
mcasas
Looking good, some minor comments. https://codereview.chromium.org/1128213005/diff/360001/content/common/gpu/client/gpu_video_encode_accelerator_host.cc File content/common/gpu/client/gpu_video_encode_accelerator_host.cc (right): https://codereview.chromium.org/1128213005/diff/360001/content/common/gpu/client/gpu_video_encode_accelerator_host.cc#newcode120 content/common/gpu/client/gpu_video_encode_accelerator_host.cc:120: bool rv = false; ...
5 years, 6 months ago (2015-06-04 15:20:56 UTC) #26
emircan
5 years, 6 months ago (2015-06-04 22:04:41 UTC) #29
https://codereview.chromium.org/1128213005/diff/360001/content/common/gpu/cli...
File content/common/gpu/client/gpu_video_encode_accelerator_host.cc (right):

https://codereview.chromium.org/1128213005/diff/360001/content/common/gpu/cli...
content/common/gpu/client/gpu_video_encode_accelerator_host.cc:120: bool rv =
false;
On 2015/06/04 15:20:55, mcasas wrote:
> s/rv/return_val/ or similar?

Done.

https://codereview.chromium.org/1128213005/diff/360001/content/common/gpu/cli...
content/common/gpu/client/gpu_video_encode_accelerator_host.cc:124: rv =
EncodeSharedMemory(frame, force_keyframe);
On 2015/06/04 15:20:55, mcasas wrote:
> What about
> 
> const bool encoded_ok = (frame->IsMappable()) 
>     ? EncodeSharedMemory(frame, force_keyframe)
>     : EncodeNativeTexture(frame, force_keyframe);
> 
> The less clients touch explicitly the STORAGE_* the better.

IsMappable() covers STORAGE_OWNED_MEMORY and STORAGE_UNOWNED_MEMORY as well, and
they don't provide shared_memory_handle() which we ShareToGpuProcess() and use
in the IPC call. Here we are specifically looking for STORAGE_SHMEM.

https://codereview.chromium.org/1128213005/diff/360001/content/common/gpu/cli...
content/common/gpu/client/gpu_video_encode_accelerator_host.cc:185: Send(new
AcceleratedVideoEncoderMsg_EncodeNativeTexture(
On 2015/06/04 15:20:55, mcasas wrote:
> DCHECK_EQ(frame->storage_type(), STORAGE_TEXTURE) ?
> I think ATM is the only non-mappable type we can receive
> here, i.e. no DMABUFS or HOLEs, correct?

Correct. Passing only the mailbox.

https://codereview.chromium.org/1128213005/diff/360001/content/common/gpu/cli...
content/common/gpu/client/gpu_video_encode_accelerator_host.cc:194: if
(!base::SharedMemory::IsHandleValid(frame->shared_memory_handle())) {
On 2015/06/04 15:20:55, mcasas wrote:
> DCHECK_EQ(frame->storage_type(), STORAGE_SHMEM)?
> Although is done inside shared_memory_handle(), I don't
> think is superfluous to encode such an assumption here.

Done.

https://codereview.chromium.org/1128213005/diff/360001/content/common/gpu/cli...
File content/common/gpu/client/gpu_video_encode_accelerator_host.h (right):

https://codereview.chromium.org/1128213005/diff/360001/content/common/gpu/cli...
content/common/gpu/client/gpu_video_encode_accelerator_host.h:20: 
On 2015/06/04 15:20:55, mcasas wrote:
> i know this is not your code, but please remove the gaps around
> forward class declarations in ad-hoc namespace references
> (l.20, 22, 26, 28).

Done.

https://codereview.chromium.org/1128213005/diff/360001/content/common/gpu/gpu...
File content/common/gpu/gpu_messages.h (right):

https://codereview.chromium.org/1128213005/diff/360001/content/common/gpu/gpu...
content/common/gpu/gpu_messages.h:708: // Queue a input buffer to the encoder to
encode. |frame_id| will be returned by
On 2015/06/04 15:20:55, mcasas wrote:
> s/Queue a input buffer/Queue a shared memory/?

Done.

https://codereview.chromium.org/1128213005/diff/360001/content/common/gpu/med...
File content/common/gpu/media/gpu_video_encode_accelerator.cc (right):

https://codereview.chromium.org/1128213005/diff/360001/content/common/gpu/med...
content/common/gpu/media/gpu_video_encode_accelerator.cc:115:
IPC_MESSAGE_HANDLER(AcceleratedVideoEncoderMsg_EncodeSharedMemory,
On 2015/06/04 15:20:55, mcasas wrote:
> Indent here and in l.117 to match l.119 etc.
> I know, they're unorthodox.

Done.

https://codereview.chromium.org/1128213005/diff/360001/content/common/gpu/med...
content/common/gpu/media/gpu_video_encode_accelerator.cc:294:
DCHECK(!mailbox_holder.mailbox.IsZero());
On 2015/06/04 15:20:56, mcasas wrote:
> nit: pass these DCHECKs to the beginning of the method?

Done.

https://codereview.chromium.org/1128213005/diff/360001/content/common/gpu/med...
content/common/gpu/media/gpu_video_encode_accelerator.cc:363: // Just let shm
fall out of scope.
On 2015/06/04 15:20:55, mcasas wrote:
> s/shm/|shm|/

Done.

Powered by Google App Engine
This is Rietveld 408576698