| OLD | NEW |
| 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" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 #if defined(OS_CHROMEOS) | 25 #if defined(OS_CHROMEOS) |
| 26 #if defined(USE_V4L2_CODEC) | 26 #if defined(USE_V4L2_CODEC) |
| 27 #include "content/common/gpu/media/v4l2_video_encode_accelerator.h" | 27 #include "content/common/gpu/media/v4l2_video_encode_accelerator.h" |
| 28 #endif | 28 #endif |
| 29 #if defined(ARCH_CPU_X86_FAMILY) | 29 #if defined(ARCH_CPU_X86_FAMILY) |
| 30 #include "content/common/gpu/media/vaapi_video_encode_accelerator.h" | 30 #include "content/common/gpu/media/vaapi_video_encode_accelerator.h" |
| 31 #endif | 31 #endif |
| 32 #elif defined(OS_ANDROID) && defined(ENABLE_WEBRTC) | 32 #elif defined(OS_ANDROID) && defined(ENABLE_WEBRTC) |
| 33 #include "content/common/gpu/media/android_video_encode_accelerator.h" | 33 #include "content/common/gpu/media/android_video_encode_accelerator.h" |
| 34 #elif defined(OS_MACOSX) |
| 35 #include "content/common/gpu/media/vt_video_encode_accelerator_mac.h" |
| 34 #endif | 36 #endif |
| 35 | 37 |
| 36 namespace content { | 38 namespace content { |
| 37 | 39 |
| 38 namespace { | 40 namespace { |
| 39 | 41 |
| 40 // Allocation and destruction of buffer are done on the Browser process, so we | 42 // Allocation and destruction of buffer are done on the Browser process, so we |
| 41 // don't need to handle synchronization here. | 43 // don't need to handle synchronization here. |
| 42 void DestroyGpuMemoryBuffer(const gpu::SyncToken& sync_token) {} | 44 void DestroyGpuMemoryBuffer(const gpu::SyncToken& sync_token) {} |
| 43 | 45 |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 create_vea_fps.push_back(&GpuVideoEncodeAccelerator::CreateV4L2VEA); | 206 create_vea_fps.push_back(&GpuVideoEncodeAccelerator::CreateV4L2VEA); |
| 205 #endif | 207 #endif |
| 206 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) | 208 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) |
| 207 if (!gpu_preferences.disable_vaapi_accelerated_video_encode) | 209 if (!gpu_preferences.disable_vaapi_accelerated_video_encode) |
| 208 create_vea_fps.push_back(&GpuVideoEncodeAccelerator::CreateVaapiVEA); | 210 create_vea_fps.push_back(&GpuVideoEncodeAccelerator::CreateVaapiVEA); |
| 209 #endif | 211 #endif |
| 210 #if defined(OS_ANDROID) && defined(ENABLE_WEBRTC) | 212 #if defined(OS_ANDROID) && defined(ENABLE_WEBRTC) |
| 211 if (!gpu_preferences.disable_web_rtc_hw_encoding) | 213 if (!gpu_preferences.disable_web_rtc_hw_encoding) |
| 212 create_vea_fps.push_back(&GpuVideoEncodeAccelerator::CreateAndroidVEA); | 214 create_vea_fps.push_back(&GpuVideoEncodeAccelerator::CreateAndroidVEA); |
| 213 #endif | 215 #endif |
| 216 #if defined(OS_MACOSX) |
| 217 create_vea_fps.push_back(&GpuVideoEncodeAccelerator::CreateVTVEA); |
| 218 #endif |
| 214 return create_vea_fps; | 219 return create_vea_fps; |
| 215 } | 220 } |
| 216 | 221 |
| 217 #if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) | 222 #if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) |
| 218 // static | 223 // static |
| 219 scoped_ptr<media::VideoEncodeAccelerator> | 224 scoped_ptr<media::VideoEncodeAccelerator> |
| 220 GpuVideoEncodeAccelerator::CreateV4L2VEA() { | 225 GpuVideoEncodeAccelerator::CreateV4L2VEA() { |
| 221 scoped_ptr<media::VideoEncodeAccelerator> encoder; | 226 scoped_ptr<media::VideoEncodeAccelerator> encoder; |
| 222 scoped_refptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kEncoder); | 227 scoped_refptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kEncoder); |
| 223 if (device) | 228 if (device) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 237 | 242 |
| 238 #if defined(OS_ANDROID) && defined(ENABLE_WEBRTC) | 243 #if defined(OS_ANDROID) && defined(ENABLE_WEBRTC) |
| 239 // static | 244 // static |
| 240 scoped_ptr<media::VideoEncodeAccelerator> | 245 scoped_ptr<media::VideoEncodeAccelerator> |
| 241 GpuVideoEncodeAccelerator::CreateAndroidVEA() { | 246 GpuVideoEncodeAccelerator::CreateAndroidVEA() { |
| 242 return make_scoped_ptr<media::VideoEncodeAccelerator>( | 247 return make_scoped_ptr<media::VideoEncodeAccelerator>( |
| 243 new AndroidVideoEncodeAccelerator()); | 248 new AndroidVideoEncodeAccelerator()); |
| 244 } | 249 } |
| 245 #endif | 250 #endif |
| 246 | 251 |
| 252 #if defined(OS_MACOSX) |
| 253 // static |
| 254 scoped_ptr<media::VideoEncodeAccelerator> |
| 255 GpuVideoEncodeAccelerator::CreateVTVEA() { |
| 256 return make_scoped_ptr<media::VideoEncodeAccelerator>( |
| 257 new VTVideoEncodeAccelerator()); |
| 258 } |
| 259 #endif |
| 260 |
| 247 void GpuVideoEncodeAccelerator::OnEncode( | 261 void GpuVideoEncodeAccelerator::OnEncode( |
| 248 const AcceleratedVideoEncoderMsg_Encode_Params& params) { | 262 const AcceleratedVideoEncoderMsg_Encode_Params& params) { |
| 249 DVLOG(3) << "GpuVideoEncodeAccelerator::OnEncode: frame_id = " | 263 DVLOG(3) << "GpuVideoEncodeAccelerator::OnEncode: frame_id = " |
| 250 << params.frame_id << ", buffer_size=" << params.buffer_size | 264 << params.frame_id << ", buffer_size=" << params.buffer_size |
| 251 << ", force_keyframe=" << params.force_keyframe; | 265 << ", force_keyframe=" << params.force_keyframe; |
| 252 DCHECK_EQ(media::PIXEL_FORMAT_I420, input_format_); | 266 DCHECK_EQ(media::PIXEL_FORMAT_I420, input_format_); |
| 253 | 267 |
| 254 // Wrap into a SharedMemory in the beginning, so that |params.buffer_handle| | 268 // Wrap into a SharedMemory in the beginning, so that |params.buffer_handle| |
| 255 // is cleaned properly in case of an early return. | 269 // is cleaned properly in case of an early return. |
| 256 scoped_ptr<base::SharedMemory> shm( | 270 scoped_ptr<base::SharedMemory> shm( |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 Send(new AcceleratedVideoEncoderHostMsg_NotifyInputDone(host_route_id_, | 468 Send(new AcceleratedVideoEncoderHostMsg_NotifyInputDone(host_route_id_, |
| 455 frame_id)); | 469 frame_id)); |
| 456 // Just let |buffers| fall out of scope. | 470 // Just let |buffers| fall out of scope. |
| 457 } | 471 } |
| 458 | 472 |
| 459 void GpuVideoEncodeAccelerator::Send(IPC::Message* message) { | 473 void GpuVideoEncodeAccelerator::Send(IPC::Message* message) { |
| 460 stub_->channel()->Send(message); | 474 stub_->channel()->Send(message); |
| 461 } | 475 } |
| 462 | 476 |
| 463 } // namespace content | 477 } // namespace content |
| OLD | NEW |