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

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

Issue 333253002: Add VaapiVideoEncodeAccelerator for HW-accelerated video encode. (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/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/shared_memory.h" 9 #include "base/memory/shared_memory.h"
10 #include "base/message_loop/message_loop_proxy.h" 10 #include "base/message_loop/message_loop_proxy.h"
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 #include "content/common/gpu/gpu_channel.h" 12 #include "content/common/gpu/gpu_channel.h"
13 #include "content/common/gpu/gpu_messages.h" 13 #include "content/common/gpu/gpu_messages.h"
14 #include "ipc/ipc_message_macros.h" 14 #include "ipc/ipc_message_macros.h"
15 #include "media/base/limits.h" 15 #include "media/base/limits.h"
16 #include "media/base/video_frame.h" 16 #include "media/base/video_frame.h"
17 17
18 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) && defined(USE_X11) 18 #if defined(OS_CHROMEOS) && defined(USE_X11)
19
20 #if defined(ARCH_CPU_ARMEL)
19 #include "content/common/gpu/media/v4l2_video_encode_accelerator.h" 21 #include "content/common/gpu/media/v4l2_video_encode_accelerator.h"
22 #elif defined(ARCH_CPU_X86_FAMILY)
23 #include "content/common/gpu/media/vaapi_video_encode_accelerator.h"
24 #include "ui/gfx/x/x11_types.h"
25 #endif
26
20 #elif defined(OS_ANDROID) && defined(ENABLE_WEBRTC) 27 #elif defined(OS_ANDROID) && defined(ENABLE_WEBRTC)
21 #include "content/common/gpu/media/android_video_encode_accelerator.h" 28 #include "content/common/gpu/media/android_video_encode_accelerator.h"
22 #endif 29 #endif
23 30
24 namespace content { 31 namespace content {
25 32
26 static bool MakeDecoderContextCurrent( 33 static bool MakeDecoderContextCurrent(
27 const base::WeakPtr<GpuCommandBufferStub> stub) { 34 const base::WeakPtr<GpuCommandBufferStub> stub) {
28 if (!stub) { 35 if (!stub) {
29 DLOG(ERROR) << "Stub is gone; won't MakeCurrent()."; 36 DLOG(ERROR) << "Stub is gone; won't MakeCurrent().";
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 stub_->RemoveDestructionObserver(this); 158 stub_->RemoveDestructionObserver(this);
152 encoder_.reset(); 159 encoder_.reset();
153 delete this; 160 delete this;
154 } 161 }
155 162
156 // static 163 // static
157 std::vector<media::VideoEncodeAccelerator::SupportedProfile> 164 std::vector<media::VideoEncodeAccelerator::SupportedProfile>
158 GpuVideoEncodeAccelerator::GetSupportedProfiles() { 165 GpuVideoEncodeAccelerator::GetSupportedProfiles() {
159 std::vector<media::VideoEncodeAccelerator::SupportedProfile> profiles; 166 std::vector<media::VideoEncodeAccelerator::SupportedProfile> profiles;
160 167
161 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) && defined(USE_X11) 168 #if defined(OS_CHROMEOS) && defined(USE_X11)
169 #if defined(ARCH_CPU_ARMEL)
162 profiles = V4L2VideoEncodeAccelerator::GetSupportedProfiles(); 170 profiles = V4L2VideoEncodeAccelerator::GetSupportedProfiles();
171 #elif defined(ARCH_CPU_X86_FAMILY)
172 profiles = VaapiVideoEncodeAccelerator::GetSupportedProfiles();
173 #endif
163 #elif defined(OS_ANDROID) && defined(ENABLE_WEBRTC) 174 #elif defined(OS_ANDROID) && defined(ENABLE_WEBRTC)
164 profiles = AndroidVideoEncodeAccelerator::GetSupportedProfiles(); 175 profiles = AndroidVideoEncodeAccelerator::GetSupportedProfiles();
165 #endif 176 #endif
166 177
167 // TODO(sheu): return platform-specific profiles. 178 // TODO(sheu): return platform-specific profiles.
168 return profiles; 179 return profiles;
169 } 180 }
170 181
171 void GpuVideoEncodeAccelerator::CreateEncoder() { 182 void GpuVideoEncodeAccelerator::CreateEncoder() {
172 DCHECK(!encoder_); 183 DCHECK(!encoder_);
173 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) && defined(USE_X11) 184 #if defined(OS_CHROMEOS) && defined(USE_X11)
185 #if defined(ARCH_CPU_ARMEL)
174 scoped_ptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kEncoder); 186 scoped_ptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kEncoder);
175 if (!device.get()) 187 if (!device.get())
176 return; 188 return;
177 189
178 encoder_.reset(new V4L2VideoEncodeAccelerator(device.Pass())); 190 encoder_.reset(new V4L2VideoEncodeAccelerator(device.Pass()));
191 #elif defined(ARCH_CPU_X86_FAMILY)
192 encoder_.reset(new VaapiVideoEncodeAccelerator(gfx::GetXDisplay()));
193 #endif
piman 2014/06/20 17:10:22 Should this be gated on the flag? Rationale: don't
Pawel Osciak 2014/06/20 22:28:11 It actually is, just in a convoluted way. As I men
piman 2014/06/21 01:27:06 The idea is that the gpu process is privileged, it
Pawel Osciak 2014/06/21 03:13:12 Good point. Done. This makes we want to do the sam
179 #elif defined(OS_ANDROID) && defined(ENABLE_WEBRTC) 194 #elif defined(OS_ANDROID) && defined(ENABLE_WEBRTC)
180 encoder_.reset(new AndroidVideoEncodeAccelerator()); 195 encoder_.reset(new AndroidVideoEncodeAccelerator());
181 #endif 196 #endif
182 } 197 }
183 198
184 void GpuVideoEncodeAccelerator::OnEncode(int32 frame_id, 199 void GpuVideoEncodeAccelerator::OnEncode(int32 frame_id,
185 base::SharedMemoryHandle buffer_handle, 200 base::SharedMemoryHandle buffer_handle,
186 uint32 buffer_size, 201 uint32 buffer_size,
187 bool force_keyframe) { 202 bool force_keyframe) {
188 DVLOG(3) << "GpuVideoEncodeAccelerator::OnEncode(): frame_id=" << frame_id 203 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); 304 stub_->channel()->Send(message);
290 } 305 }
291 306
292 void GpuVideoEncodeAccelerator::SendCreateEncoderReply(IPC::Message* message, 307 void GpuVideoEncodeAccelerator::SendCreateEncoderReply(IPC::Message* message,
293 bool succeeded) { 308 bool succeeded) {
294 GpuCommandBufferMsg_CreateVideoEncoder::WriteReplyParams(message, succeeded); 309 GpuCommandBufferMsg_CreateVideoEncoder::WriteReplyParams(message, succeeded);
295 Send(message); 310 Send(message);
296 } 311 }
297 312
298 } // namespace content 313 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698