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) && defined(USE_X11) | 20 #if defined(OS_CHROMEOS) |
21 | 21 |
22 #if defined(ARCH_CPU_ARMEL) | 22 #if defined(ARCH_CPU_ARMEL) && defined(USE_X11) |
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" | |
27 #endif | 26 #endif |
28 | 27 |
29 #elif defined(OS_ANDROID) && defined(ENABLE_WEBRTC) | 28 #elif defined(OS_ANDROID) && defined(ENABLE_WEBRTC) |
30 #include "content/common/gpu/media/android_video_encode_accelerator.h" | 29 #include "content/common/gpu/media/android_video_encode_accelerator.h" |
31 #endif | 30 #endif |
32 | 31 |
33 namespace content { | 32 namespace content { |
34 | 33 |
35 static bool MakeDecoderContextCurrent( | 34 static bool MakeDecoderContextCurrent( |
36 const base::WeakPtr<GpuCommandBufferStub> stub) { | 35 const base::WeakPtr<GpuCommandBufferStub> stub) { |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
160 stub_->RemoveDestructionObserver(this); | 159 stub_->RemoveDestructionObserver(this); |
161 encoder_.reset(); | 160 encoder_.reset(); |
162 delete this; | 161 delete this; |
163 } | 162 } |
164 | 163 |
165 // static | 164 // static |
166 std::vector<media::VideoEncodeAccelerator::SupportedProfile> | 165 std::vector<media::VideoEncodeAccelerator::SupportedProfile> |
167 GpuVideoEncodeAccelerator::GetSupportedProfiles() { | 166 GpuVideoEncodeAccelerator::GetSupportedProfiles() { |
168 std::vector<media::VideoEncodeAccelerator::SupportedProfile> profiles; | 167 std::vector<media::VideoEncodeAccelerator::SupportedProfile> profiles; |
169 | 168 |
170 #if defined(OS_CHROMEOS) && defined(USE_X11) | 169 #if defined(OS_CHROMEOS) |
171 #if defined(ARCH_CPU_ARMEL) | 170 #if defined(ARCH_CPU_ARMEL) && defined(USE_X11) |
172 profiles = V4L2VideoEncodeAccelerator::GetSupportedProfiles(); | 171 profiles = V4L2VideoEncodeAccelerator::GetSupportedProfiles(); |
173 #elif defined(ARCH_CPU_X86_FAMILY) | 172 #elif defined(ARCH_CPU_X86_FAMILY) |
174 profiles = VaapiVideoEncodeAccelerator::GetSupportedProfiles(); | 173 profiles = VaapiVideoEncodeAccelerator::GetSupportedProfiles(); |
175 #endif | 174 #endif |
176 #elif defined(OS_ANDROID) && defined(ENABLE_WEBRTC) | 175 #elif defined(OS_ANDROID) && defined(ENABLE_WEBRTC) |
177 profiles = AndroidVideoEncodeAccelerator::GetSupportedProfiles(); | 176 profiles = AndroidVideoEncodeAccelerator::GetSupportedProfiles(); |
178 #endif | 177 #endif |
179 | 178 |
180 // TODO(sheu): return platform-specific profiles. | 179 // TODO(sheu): return platform-specific profiles. |
181 return profiles; | 180 return profiles; |
182 } | 181 } |
183 | 182 |
184 void GpuVideoEncodeAccelerator::CreateEncoder() { | 183 void GpuVideoEncodeAccelerator::CreateEncoder() { |
185 DCHECK(!encoder_); | 184 DCHECK(!encoder_); |
186 #if defined(OS_CHROMEOS) && defined(USE_X11) | 185 #if defined(OS_CHROMEOS) |
187 #if defined(ARCH_CPU_ARMEL) | 186 #if defined(ARCH_CPU_ARMEL) && defined(USE_X11) |
188 scoped_ptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kEncoder); | 187 scoped_ptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kEncoder); |
189 if (!device.get()) | 188 if (!device.get()) |
190 return; | 189 return; |
191 | 190 |
192 encoder_.reset(new V4L2VideoEncodeAccelerator(device.Pass())); | 191 encoder_.reset(new V4L2VideoEncodeAccelerator(device.Pass())); |
193 #elif defined(ARCH_CPU_X86_FAMILY) | 192 #elif defined(ARCH_CPU_X86_FAMILY) |
194 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | 193 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
Pawel Osciak
2014/09/24 11:27:10
Please don't remove base::.
| |
195 if (!cmd_line->HasSwitch(switches::kDisableVaapiAcceleratedVideoEncode)) | 194 if (!cmd_line->HasSwitch(switches::kDisableVaapiAcceleratedVideoEncode)) |
196 encoder_.reset(new VaapiVideoEncodeAccelerator(gfx::GetXDisplay())); | 195 encoder_.reset(new VaapiVideoEncodeAccelerator()); |
197 #endif | 196 #endif |
198 #elif defined(OS_ANDROID) && defined(ENABLE_WEBRTC) | 197 #elif defined(OS_ANDROID) && defined(ENABLE_WEBRTC) |
199 encoder_.reset(new AndroidVideoEncodeAccelerator()); | 198 encoder_.reset(new AndroidVideoEncodeAccelerator()); |
200 #endif | 199 #endif |
201 } | 200 } |
202 | 201 |
203 void GpuVideoEncodeAccelerator::OnEncode(int32 frame_id, | 202 void GpuVideoEncodeAccelerator::OnEncode(int32 frame_id, |
204 base::SharedMemoryHandle buffer_handle, | 203 base::SharedMemoryHandle buffer_handle, |
205 uint32 buffer_size, | 204 uint32 buffer_size, |
206 bool force_keyframe) { | 205 bool force_keyframe) { |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
308 stub_->channel()->Send(message); | 307 stub_->channel()->Send(message); |
309 } | 308 } |
310 | 309 |
311 void GpuVideoEncodeAccelerator::SendCreateEncoderReply(IPC::Message* message, | 310 void GpuVideoEncodeAccelerator::SendCreateEncoderReply(IPC::Message* message, |
312 bool succeeded) { | 311 bool succeeded) { |
313 GpuCommandBufferMsg_CreateVideoEncoder::WriteReplyParams(message, succeeded); | 312 GpuCommandBufferMsg_CreateVideoEncoder::WriteReplyParams(message, succeeded); |
314 Send(message); | 313 Send(message); |
315 } | 314 } |
316 | 315 |
317 } // namespace content | 316 } // namespace content |
OLD | NEW |