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

Side by Side Diff: content/common/gpu/media/gpu_video_encode_accelerator.cc

Issue 1656433002: Sample code: IPC Transport object for GPU Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: GpuMemoryBufferService + Transport object. TODO: Eliminate ChildThreadImpl dependency Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/common/gpu/media/gpu_video_encode_accelerator.h" 5 #include "content/common/gpu/media/gpu_video_encode_accelerator.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/shared_memory.h" 10 #include "base/memory/shared_memory.h"
11 #include "base/numerics/safe_math.h" 11 #include "base/numerics/safe_math.h"
12 #include "base/sys_info.h" 12 #include "base/sys_info.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "content/common/gpu/client/gpu_memory_buffer_impl.h" 14 #include "content/common/gpu/client/gpu_memory_buffer_impl.h"
15 #include "content/common/gpu/gpu_channel.h" 15 #include "content/common/gpu/gpu_channel.h"
16 #include "content/common/gpu/gpu_messages.h" 16 #include "content/common/gpu/gpu_messages.h"
17 #include "content/common/gpu/media/gpu_video_accelerator_util.h" 17 #include "content/common/gpu/media/gpu_video_accelerator_util.h"
18 #include "content/common/gpu/video_encode_params.h"
18 #include "content/public/common/content_switches.h" 19 #include "content/public/common/content_switches.h"
19 #include "ipc/ipc_message_macros.h" 20 #include "ipc/ipc_message_macros.h"
20 #include "media/base/bind_to_current_loop.h" 21 #include "media/base/bind_to_current_loop.h"
21 #include "media/base/limits.h" 22 #include "media/base/limits.h"
22 #include "media/base/video_frame.h" 23 #include "media/base/video_frame.h"
23 24
24 #if defined(OS_CHROMEOS) 25 #if defined(OS_CHROMEOS)
25 #if defined(USE_V4L2_CODEC) 26 #if defined(USE_V4L2_CODEC)
26 #include "content/common/gpu/media/v4l2_video_encode_accelerator.h" 27 #include "content/common/gpu/media/v4l2_video_encode_accelerator.h"
27 #endif 28 #endif
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 // static 232 // static
232 scoped_ptr<media::VideoEncodeAccelerator> 233 scoped_ptr<media::VideoEncodeAccelerator>
233 GpuVideoEncodeAccelerator::CreateAndroidVEA() { 234 GpuVideoEncodeAccelerator::CreateAndroidVEA() {
234 scoped_ptr<media::VideoEncodeAccelerator> encoder; 235 scoped_ptr<media::VideoEncodeAccelerator> encoder;
235 #if defined(OS_ANDROID) && defined(ENABLE_WEBRTC) 236 #if defined(OS_ANDROID) && defined(ENABLE_WEBRTC)
236 encoder.reset(new AndroidVideoEncodeAccelerator()); 237 encoder.reset(new AndroidVideoEncodeAccelerator());
237 #endif 238 #endif
238 return encoder; 239 return encoder;
239 } 240 }
240 241
241 void GpuVideoEncodeAccelerator::OnEncode( 242 void GpuVideoEncodeAccelerator::OnEncode(const VideoEncodeParams& params) {
242 const AcceleratedVideoEncoderMsg_Encode_Params& params) {
243 DVLOG(3) << "GpuVideoEncodeAccelerator::OnEncode: frame_id = " 243 DVLOG(3) << "GpuVideoEncodeAccelerator::OnEncode: frame_id = "
244 << params.frame_id << ", buffer_size=" << params.buffer_size 244 << params.frame_id << ", buffer_size=" << params.buffer_size
245 << ", force_keyframe=" << params.force_keyframe; 245 << ", force_keyframe=" << params.force_keyframe;
246 DCHECK_EQ(media::PIXEL_FORMAT_I420, input_format_); 246 DCHECK_EQ(media::PIXEL_FORMAT_I420, input_format_);
247 247
248 // Wrap into a SharedMemory in the beginning, so that |params.buffer_handle| 248 // Wrap into a SharedMemory in the beginning, so that |params.buffer_handle|
249 // is cleaned properly in case of an early return. 249 // is cleaned properly in case of an early return.
250 scoped_ptr<base::SharedMemory> shm( 250 scoped_ptr<base::SharedMemory> shm(
251 new base::SharedMemory(params.buffer_handle, true)); 251 new base::SharedMemory(params.buffer_handle, true));
252 252
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 } 302 }
303 frame->AddDestructionObserver( 303 frame->AddDestructionObserver(
304 media::BindToCurrentLoop( 304 media::BindToCurrentLoop(
305 base::Bind(&GpuVideoEncodeAccelerator::EncodeFrameFinished, 305 base::Bind(&GpuVideoEncodeAccelerator::EncodeFrameFinished,
306 weak_this_factory_.GetWeakPtr(), 306 weak_this_factory_.GetWeakPtr(),
307 params.frame_id, 307 params.frame_id,
308 base::Passed(&shm)))); 308 base::Passed(&shm))));
309 encoder_->Encode(frame, params.force_keyframe); 309 encoder_->Encode(frame, params.force_keyframe);
310 } 310 }
311 311
312 void GpuVideoEncodeAccelerator::OnEncode2( 312 void GpuVideoEncodeAccelerator::OnEncode2(const VideoEncodeParams2& params) {
313 const AcceleratedVideoEncoderMsg_Encode_Params2& params) {
314 DVLOG(3) << "GpuVideoEncodeAccelerator::OnEncode2: frame_id = " 313 DVLOG(3) << "GpuVideoEncodeAccelerator::OnEncode2: frame_id = "
315 << params.frame_id << ", size=" << params.size.ToString() 314 << params.frame_id << ", size=" << params.size.ToString()
316 << ", force_keyframe=" << params.force_keyframe << ", handle type=" 315 << ", force_keyframe=" << params.force_keyframe << ", handle type="
317 << params.gpu_memory_buffer_handles[0].type; 316 << params.gpu_memory_buffer_handles[0].type;
318 DCHECK_EQ(media::PIXEL_FORMAT_I420, input_format_); 317 DCHECK_EQ(media::PIXEL_FORMAT_I420, input_format_);
319 DCHECK_EQ(media::VideoFrame::NumPlanes(input_format_), 318 DCHECK_EQ(media::VideoFrame::NumPlanes(input_format_),
320 params.gpu_memory_buffer_handles.size()); 319 params.gpu_memory_buffer_handles.size());
321 320
322 bool map_result = true; 321 bool map_result = true;
323 uint8_t* data[media::VideoFrame::kMaxPlanes]; 322 uint8_t* data[media::VideoFrame::kMaxPlanes];
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 stub_->channel()->Send(message); 453 stub_->channel()->Send(message);
455 } 454 }
456 455
457 void GpuVideoEncodeAccelerator::SendCreateEncoderReply(IPC::Message* message, 456 void GpuVideoEncodeAccelerator::SendCreateEncoderReply(IPC::Message* message,
458 bool succeeded) { 457 bool succeeded) {
459 GpuCommandBufferMsg_CreateVideoEncoder::WriteReplyParams(message, succeeded); 458 GpuCommandBufferMsg_CreateVideoEncoder::WriteReplyParams(message, succeeded);
460 Send(message); 459 Send(message);
461 } 460 }
462 461
463 } // namespace content 462 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/media/gpu_video_encode_accelerator.h ('k') | content/common/gpu/video_decode_params.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698