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

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

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

Powered by Google App Engine
This is Rietveld 408576698