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" |
11 #include "base/message_loop/message_loop_proxy.h" | 11 #include "base/message_loop/message_loop_proxy.h" |
12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
13 #include "content/common/gpu/gpu_channel.h" | 13 #include "content/common/gpu/gpu_channel.h" |
14 #include "content/common/gpu/gpu_messages.h" | 14 #include "content/common/gpu/gpu_messages.h" |
15 #include "content/public/common/content_switches.h" | 15 #include "content/public/common/content_switches.h" |
16 #include "ipc/ipc_message_macros.h" | 16 #include "ipc/ipc_message_macros.h" |
17 #include "media/base/limits.h" | 17 #include "media/base/limits.h" |
18 #include "media/base/video_frame.h" | 18 #include "media/base/video_frame.h" |
19 | 19 |
20 #if defined(OS_CHROMEOS) | 20 #if defined(OS_CHROMEOS) && defined(USE_X11) |
21 | 21 |
22 #if defined(ARCH_CPU_ARMEL) && defined(USE_X11) | 22 #if defined(ARCH_CPU_ARMEL) |
23 #include "content/common/gpu/media/v4l2_video_encode_accelerator.h" | 23 #include "content/common/gpu/media/v4l2_video_encode_accelerator.h" |
24 #elif defined(ARCH_CPU_X86_FAMILY) | 24 #elif defined(ARCH_CPU_X86_FAMILY) |
25 #include "content/common/gpu/media/vaapi_video_encode_accelerator.h" | 25 #include "content/common/gpu/media/vaapi_video_encode_accelerator.h" |
| 26 #include "ui/gfx/x/x11_types.h" |
26 #endif | 27 #endif |
27 | 28 |
28 #elif defined(OS_ANDROID) && defined(ENABLE_WEBRTC) | 29 #elif defined(OS_ANDROID) && defined(ENABLE_WEBRTC) |
29 #include "content/common/gpu/media/android_video_encode_accelerator.h" | 30 #include "content/common/gpu/media/android_video_encode_accelerator.h" |
30 #endif | 31 #endif |
31 | 32 |
32 namespace content { | 33 namespace content { |
33 | 34 |
34 static bool MakeDecoderContextCurrent( | 35 static bool MakeDecoderContextCurrent( |
35 const base::WeakPtr<GpuCommandBufferStub> stub) { | 36 const base::WeakPtr<GpuCommandBufferStub> stub) { |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 profile.max_framerate_denominator = | 184 profile.max_framerate_denominator = |
184 media_profiles[i].max_framerate_denominator; | 185 media_profiles[i].max_framerate_denominator; |
185 profiles.push_back(profile); | 186 profiles.push_back(profile); |
186 } | 187 } |
187 return profiles; | 188 return profiles; |
188 } | 189 } |
189 | 190 |
190 scoped_ptr<media::VideoEncodeAccelerator> | 191 scoped_ptr<media::VideoEncodeAccelerator> |
191 GpuVideoEncodeAccelerator::CreateEncoder() { | 192 GpuVideoEncodeAccelerator::CreateEncoder() { |
192 scoped_ptr<media::VideoEncodeAccelerator> encoder; | 193 scoped_ptr<media::VideoEncodeAccelerator> encoder; |
193 #if defined(OS_CHROMEOS) | 194 #if defined(OS_CHROMEOS) && defined(USE_X11) |
194 #if defined(ARCH_CPU_ARMEL) && defined(USE_X11) | 195 #if defined(ARCH_CPU_ARMEL) |
195 scoped_ptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kEncoder); | 196 scoped_ptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kEncoder); |
196 if (device) | 197 if (device) |
197 encoder.reset(new V4L2VideoEncodeAccelerator(device.Pass())); | 198 encoder.reset(new V4L2VideoEncodeAccelerator(device.Pass())); |
198 #elif defined(ARCH_CPU_X86_FAMILY) | 199 #elif defined(ARCH_CPU_X86_FAMILY) |
199 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | 200 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
200 if (!cmd_line->HasSwitch(switches::kDisableVaapiAcceleratedVideoEncode)) | 201 if (!cmd_line->HasSwitch(switches::kDisableVaapiAcceleratedVideoEncode)) |
201 encoder.reset(new VaapiVideoEncodeAccelerator()); | 202 encoder.reset(new VaapiVideoEncodeAccelerator(gfx::GetXDisplay())); |
202 #endif | 203 #endif |
203 #elif defined(OS_ANDROID) && defined(ENABLE_WEBRTC) | 204 #elif defined(OS_ANDROID) && defined(ENABLE_WEBRTC) |
204 encoder.reset(new AndroidVideoEncodeAccelerator()); | 205 encoder.reset(new AndroidVideoEncodeAccelerator()); |
205 #endif | 206 #endif |
206 return encoder.Pass(); | 207 return encoder.Pass(); |
207 } | 208 } |
208 | 209 |
209 void GpuVideoEncodeAccelerator::OnEncode(int32 frame_id, | 210 void GpuVideoEncodeAccelerator::OnEncode(int32 frame_id, |
210 base::SharedMemoryHandle buffer_handle, | 211 base::SharedMemoryHandle buffer_handle, |
211 uint32 buffer_size, | 212 uint32 buffer_size, |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 stub_->channel()->Send(message); | 315 stub_->channel()->Send(message); |
315 } | 316 } |
316 | 317 |
317 void GpuVideoEncodeAccelerator::SendCreateEncoderReply(IPC::Message* message, | 318 void GpuVideoEncodeAccelerator::SendCreateEncoderReply(IPC::Message* message, |
318 bool succeeded) { | 319 bool succeeded) { |
319 GpuCommandBufferMsg_CreateVideoEncoder::WriteReplyParams(message, succeeded); | 320 GpuCommandBufferMsg_CreateVideoEncoder::WriteReplyParams(message, succeeded); |
320 Send(message); | 321 Send(message); |
321 } | 322 } |
322 | 323 |
323 } // namespace content | 324 } // namespace content |
OLD | NEW |