| 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 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 #if defined(OS_CHROMEOS) | 24 #if defined(OS_CHROMEOS) |
| 25 #if defined(USE_V4L2_CODEC) | 25 #if defined(USE_V4L2_CODEC) |
| 26 #include "content/common/gpu/media/v4l2_video_encode_accelerator.h" | 26 #include "content/common/gpu/media/v4l2_video_encode_accelerator.h" |
| 27 #endif | 27 #endif |
| 28 #if defined(ARCH_CPU_X86_FAMILY) | 28 #if defined(ARCH_CPU_X86_FAMILY) |
| 29 #include "content/common/gpu/media/vaapi_video_encode_accelerator.h" | 29 #include "content/common/gpu/media/vaapi_video_encode_accelerator.h" |
| 30 #endif | 30 #endif |
| 31 #elif defined(OS_ANDROID) && defined(ENABLE_WEBRTC) | 31 #elif defined(OS_ANDROID) && defined(ENABLE_WEBRTC) |
| 32 #include "content/common/gpu/media/android_video_encode_accelerator.h" | 32 #include "content/common/gpu/media/android_video_encode_accelerator.h" |
| 33 #elif defined(OS_MACOSX) |
| 34 #include "content/common/gpu/media/vt_video_encode_accelerator_mac.h" |
| 33 #endif | 35 #endif |
| 34 | 36 |
| 35 namespace content { | 37 namespace content { |
| 36 | 38 |
| 37 namespace { | 39 namespace { |
| 38 | 40 |
| 39 // Allocation and destruction of buffer are done on the Browser process, so we | 41 // Allocation and destruction of buffer are done on the Browser process, so we |
| 40 // don't need to handle synchronization here. | 42 // don't need to handle synchronization here. |
| 41 void DestroyGpuMemoryBuffer(const gpu::SyncToken& sync_token) {} | 43 void DestroyGpuMemoryBuffer(const gpu::SyncToken& sync_token) {} |
| 42 | 44 |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 return GpuVideoAcceleratorUtil::ConvertMediaToGpuEncodeProfiles(profiles); | 196 return GpuVideoAcceleratorUtil::ConvertMediaToGpuEncodeProfiles(profiles); |
| 195 } | 197 } |
| 196 | 198 |
| 197 // static | 199 // static |
| 198 std::vector<GpuVideoEncodeAccelerator::CreateVEAFp> | 200 std::vector<GpuVideoEncodeAccelerator::CreateVEAFp> |
| 199 GpuVideoEncodeAccelerator::CreateVEAFps() { | 201 GpuVideoEncodeAccelerator::CreateVEAFps() { |
| 200 std::vector<GpuVideoEncodeAccelerator::CreateVEAFp> create_vea_fps; | 202 std::vector<GpuVideoEncodeAccelerator::CreateVEAFp> create_vea_fps; |
| 201 create_vea_fps.push_back(&GpuVideoEncodeAccelerator::CreateV4L2VEA); | 203 create_vea_fps.push_back(&GpuVideoEncodeAccelerator::CreateV4L2VEA); |
| 202 create_vea_fps.push_back(&GpuVideoEncodeAccelerator::CreateVaapiVEA); | 204 create_vea_fps.push_back(&GpuVideoEncodeAccelerator::CreateVaapiVEA); |
| 203 create_vea_fps.push_back(&GpuVideoEncodeAccelerator::CreateAndroidVEA); | 205 create_vea_fps.push_back(&GpuVideoEncodeAccelerator::CreateAndroidVEA); |
| 206 create_vea_fps.push_back(&GpuVideoEncodeAccelerator::CreateVTVEA); |
| 204 return create_vea_fps; | 207 return create_vea_fps; |
| 205 } | 208 } |
| 206 | 209 |
| 207 // static | 210 // static |
| 208 scoped_ptr<media::VideoEncodeAccelerator> | 211 scoped_ptr<media::VideoEncodeAccelerator> |
| 209 GpuVideoEncodeAccelerator::CreateV4L2VEA() { | 212 GpuVideoEncodeAccelerator::CreateV4L2VEA() { |
| 210 scoped_ptr<media::VideoEncodeAccelerator> encoder; | 213 scoped_ptr<media::VideoEncodeAccelerator> encoder; |
| 211 #if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) | 214 #if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) |
| 212 scoped_refptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kEncoder); | 215 scoped_refptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kEncoder); |
| 213 if (device) | 216 if (device) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 231 // static | 234 // static |
| 232 scoped_ptr<media::VideoEncodeAccelerator> | 235 scoped_ptr<media::VideoEncodeAccelerator> |
| 233 GpuVideoEncodeAccelerator::CreateAndroidVEA() { | 236 GpuVideoEncodeAccelerator::CreateAndroidVEA() { |
| 234 scoped_ptr<media::VideoEncodeAccelerator> encoder; | 237 scoped_ptr<media::VideoEncodeAccelerator> encoder; |
| 235 #if defined(OS_ANDROID) && defined(ENABLE_WEBRTC) | 238 #if defined(OS_ANDROID) && defined(ENABLE_WEBRTC) |
| 236 encoder.reset(new AndroidVideoEncodeAccelerator()); | 239 encoder.reset(new AndroidVideoEncodeAccelerator()); |
| 237 #endif | 240 #endif |
| 238 return encoder; | 241 return encoder; |
| 239 } | 242 } |
| 240 | 243 |
| 244 // static |
| 245 scoped_ptr<media::VideoEncodeAccelerator> |
| 246 GpuVideoEncodeAccelerator::CreateVTVEA() { |
| 247 scoped_ptr<media::VideoEncodeAccelerator> encoder; |
| 248 #if defined(OS_MACOSX) |
| 249 encoder.reset(new VTVideoEncodeAccelerator()); |
| 250 #endif // defined(OS_MACOSX) |
| 251 return encoder; |
| 252 } |
| 253 |
| 241 void GpuVideoEncodeAccelerator::OnEncode( | 254 void GpuVideoEncodeAccelerator::OnEncode( |
| 242 const AcceleratedVideoEncoderMsg_Encode_Params& params) { | 255 const AcceleratedVideoEncoderMsg_Encode_Params& params) { |
| 243 DVLOG(3) << "GpuVideoEncodeAccelerator::OnEncode: frame_id = " | 256 DVLOG(3) << "GpuVideoEncodeAccelerator::OnEncode: frame_id = " |
| 244 << params.frame_id << ", buffer_size=" << params.buffer_size | 257 << params.frame_id << ", buffer_size=" << params.buffer_size |
| 245 << ", force_keyframe=" << params.force_keyframe; | 258 << ", force_keyframe=" << params.force_keyframe; |
| 246 DCHECK_EQ(media::PIXEL_FORMAT_I420, input_format_); | 259 DCHECK_EQ(media::PIXEL_FORMAT_I420, input_format_); |
| 247 | 260 |
| 248 // Wrap into a SharedMemory in the beginning, so that |params.buffer_handle| | 261 // Wrap into a SharedMemory in the beginning, so that |params.buffer_handle| |
| 249 // is cleaned properly in case of an early return. | 262 // is cleaned properly in case of an early return. |
| 250 scoped_ptr<base::SharedMemory> shm( | 263 scoped_ptr<base::SharedMemory> shm( |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 stub_->channel()->Send(message); | 467 stub_->channel()->Send(message); |
| 455 } | 468 } |
| 456 | 469 |
| 457 void GpuVideoEncodeAccelerator::SendCreateEncoderReply(IPC::Message* message, | 470 void GpuVideoEncodeAccelerator::SendCreateEncoderReply(IPC::Message* message, |
| 458 bool succeeded) { | 471 bool succeeded) { |
| 459 GpuCommandBufferMsg_CreateVideoEncoder::WriteReplyParams(message, succeeded); | 472 GpuCommandBufferMsg_CreateVideoEncoder::WriteReplyParams(message, succeeded); |
| 460 Send(message); | 473 Send(message); |
| 461 } | 474 } |
| 462 | 475 |
| 463 } // namespace content | 476 } // namespace content |
| OLD | NEW |