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

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

Issue 356903002: Revert "Revert 279650 "Add VaapiVideoEncodeAccelerator for HW-accelerate..."" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
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/logging.h" 9 #include "base/logging.h"
9 #include "base/memory/shared_memory.h" 10 #include "base/memory/shared_memory.h"
10 #include "base/message_loop/message_loop_proxy.h" 11 #include "base/message_loop/message_loop_proxy.h"
11 #include "build/build_config.h" 12 #include "build/build_config.h"
12 #include "content/common/gpu/gpu_channel.h" 13 #include "content/common/gpu/gpu_channel.h"
13 #include "content/common/gpu/gpu_messages.h" 14 #include "content/common/gpu/gpu_messages.h"
15 #include "content/public/common/content_switches.h"
14 #include "ipc/ipc_message_macros.h" 16 #include "ipc/ipc_message_macros.h"
15 #include "media/base/limits.h" 17 #include "media/base/limits.h"
16 #include "media/base/video_frame.h" 18 #include "media/base/video_frame.h"
17 19
18 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) && defined(USE_X11) 20 #if defined(OS_CHROMEOS) && defined(USE_X11)
21
22 #if defined(ARCH_CPU_ARMEL)
19 #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)
25 #include "content/common/gpu/media/vaapi_video_encode_accelerator.h"
26 #include "ui/gfx/x/x11_types.h"
27 #endif
28
20 #elif defined(OS_ANDROID) && defined(ENABLE_WEBRTC) 29 #elif defined(OS_ANDROID) && defined(ENABLE_WEBRTC)
21 #include "content/common/gpu/media/android_video_encode_accelerator.h" 30 #include "content/common/gpu/media/android_video_encode_accelerator.h"
22 #endif 31 #endif
23 32
24 namespace content { 33 namespace content {
25 34
26 static bool MakeDecoderContextCurrent( 35 static bool MakeDecoderContextCurrent(
27 const base::WeakPtr<GpuCommandBufferStub> stub) { 36 const base::WeakPtr<GpuCommandBufferStub> stub) {
28 if (!stub) { 37 if (!stub) {
29 DLOG(ERROR) << "Stub is gone; won't MakeCurrent()."; 38 DLOG(ERROR) << "Stub is gone; won't MakeCurrent().";
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 stub_->RemoveDestructionObserver(this); 160 stub_->RemoveDestructionObserver(this);
152 encoder_.reset(); 161 encoder_.reset();
153 delete this; 162 delete this;
154 } 163 }
155 164
156 // static 165 // static
157 std::vector<media::VideoEncodeAccelerator::SupportedProfile> 166 std::vector<media::VideoEncodeAccelerator::SupportedProfile>
158 GpuVideoEncodeAccelerator::GetSupportedProfiles() { 167 GpuVideoEncodeAccelerator::GetSupportedProfiles() {
159 std::vector<media::VideoEncodeAccelerator::SupportedProfile> profiles; 168 std::vector<media::VideoEncodeAccelerator::SupportedProfile> profiles;
160 169
161 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) && defined(USE_X11) 170 #if defined(OS_CHROMEOS) && defined(USE_X11)
171 #if defined(ARCH_CPU_ARMEL)
162 profiles = V4L2VideoEncodeAccelerator::GetSupportedProfiles(); 172 profiles = V4L2VideoEncodeAccelerator::GetSupportedProfiles();
173 #elif defined(ARCH_CPU_X86_FAMILY)
174 profiles = VaapiVideoEncodeAccelerator::GetSupportedProfiles();
175 #endif
163 #elif defined(OS_ANDROID) && defined(ENABLE_WEBRTC) 176 #elif defined(OS_ANDROID) && defined(ENABLE_WEBRTC)
164 profiles = AndroidVideoEncodeAccelerator::GetSupportedProfiles(); 177 profiles = AndroidVideoEncodeAccelerator::GetSupportedProfiles();
165 #endif 178 #endif
166 179
167 // TODO(sheu): return platform-specific profiles. 180 // TODO(sheu): return platform-specific profiles.
168 return profiles; 181 return profiles;
169 } 182 }
170 183
171 void GpuVideoEncodeAccelerator::CreateEncoder() { 184 void GpuVideoEncodeAccelerator::CreateEncoder() {
172 DCHECK(!encoder_); 185 DCHECK(!encoder_);
173 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) && defined(USE_X11) 186 #if defined(OS_CHROMEOS) && defined(USE_X11)
187 #if defined(ARCH_CPU_ARMEL)
174 scoped_ptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kEncoder); 188 scoped_ptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kEncoder);
175 if (!device.get()) 189 if (!device.get())
176 return; 190 return;
177 191
178 encoder_.reset(new V4L2VideoEncodeAccelerator(device.Pass())); 192 encoder_.reset(new V4L2VideoEncodeAccelerator(device.Pass()));
193 #elif defined(ARCH_CPU_X86_FAMILY)
194 const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
195 if (cmd_line->HasSwitch(switches::kEnableVaapiAcceleratedVideoEncode))
196 encoder_.reset(new VaapiVideoEncodeAccelerator(gfx::GetXDisplay()));
197 #endif
179 #elif defined(OS_ANDROID) && defined(ENABLE_WEBRTC) 198 #elif defined(OS_ANDROID) && defined(ENABLE_WEBRTC)
180 encoder_.reset(new AndroidVideoEncodeAccelerator()); 199 encoder_.reset(new AndroidVideoEncodeAccelerator());
181 #endif 200 #endif
182 } 201 }
183 202
184 void GpuVideoEncodeAccelerator::OnEncode(int32 frame_id, 203 void GpuVideoEncodeAccelerator::OnEncode(int32 frame_id,
185 base::SharedMemoryHandle buffer_handle, 204 base::SharedMemoryHandle buffer_handle,
186 uint32 buffer_size, 205 uint32 buffer_size,
187 bool force_keyframe) { 206 bool force_keyframe) {
188 DVLOG(3) << "GpuVideoEncodeAccelerator::OnEncode(): frame_id=" << frame_id 207 DVLOG(3) << "GpuVideoEncodeAccelerator::OnEncode(): frame_id=" << frame_id
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 stub_->channel()->Send(message); 308 stub_->channel()->Send(message);
290 } 309 }
291 310
292 void GpuVideoEncodeAccelerator::SendCreateEncoderReply(IPC::Message* message, 311 void GpuVideoEncodeAccelerator::SendCreateEncoderReply(IPC::Message* message,
293 bool succeeded) { 312 bool succeeded) {
294 GpuCommandBufferMsg_CreateVideoEncoder::WriteReplyParams(message, succeeded); 313 GpuCommandBufferMsg_CreateVideoEncoder::WriteReplyParams(message, succeeded);
295 Send(message); 314 Send(message);
296 } 315 }
297 316
298 } // namespace content 317 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.cc ('k') | content/common/gpu/media/h264_dpb.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698