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

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

Issue 817023005: Reland: Refactor Vaapi video decoder/encoder in preparation of Freon support (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Remove refcounting on VaapiWrapper Created 6 years 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
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/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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 profile.max_framerate_denominator = 183 profile.max_framerate_denominator =
185 media_profiles[i].max_framerate_denominator; 184 media_profiles[i].max_framerate_denominator;
186 profiles.push_back(profile); 185 profiles.push_back(profile);
187 } 186 }
188 return profiles; 187 return profiles;
189 } 188 }
190 189
191 scoped_ptr<media::VideoEncodeAccelerator> 190 scoped_ptr<media::VideoEncodeAccelerator>
192 GpuVideoEncodeAccelerator::CreateEncoder() { 191 GpuVideoEncodeAccelerator::CreateEncoder() {
193 scoped_ptr<media::VideoEncodeAccelerator> encoder; 192 scoped_ptr<media::VideoEncodeAccelerator> encoder;
194 #if defined(OS_CHROMEOS) && defined(USE_X11) 193 #if defined(OS_CHROMEOS)
195 #if defined(ARCH_CPU_ARMEL) 194 #if defined(ARCH_CPU_ARMEL) && defined(USE_X11)
196 scoped_ptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kEncoder); 195 scoped_ptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kEncoder);
197 if (device) 196 if (device)
198 encoder.reset(new V4L2VideoEncodeAccelerator(device.Pass())); 197 encoder.reset(new V4L2VideoEncodeAccelerator(device.Pass()));
199 #elif defined(ARCH_CPU_X86_FAMILY) 198 #elif defined(ARCH_CPU_X86_FAMILY)
200 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); 199 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess();
201 if (!cmd_line->HasSwitch(switches::kDisableVaapiAcceleratedVideoEncode)) 200 if (!cmd_line->HasSwitch(switches::kDisableVaapiAcceleratedVideoEncode))
202 encoder.reset(new VaapiVideoEncodeAccelerator(gfx::GetXDisplay())); 201 encoder.reset(new VaapiVideoEncodeAccelerator());
203 #endif 202 #endif
204 #elif defined(OS_ANDROID) && defined(ENABLE_WEBRTC) 203 #elif defined(OS_ANDROID) && defined(ENABLE_WEBRTC)
205 encoder.reset(new AndroidVideoEncodeAccelerator()); 204 encoder.reset(new AndroidVideoEncodeAccelerator());
206 #endif 205 #endif
207 return encoder.Pass(); 206 return encoder.Pass();
208 } 207 }
209 208
210 void GpuVideoEncodeAccelerator::OnEncode(int32 frame_id, 209 void GpuVideoEncodeAccelerator::OnEncode(int32 frame_id,
211 base::SharedMemoryHandle buffer_handle, 210 base::SharedMemoryHandle buffer_handle,
212 uint32 buffer_size, 211 uint32 buffer_size,
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 stub_->channel()->Send(message); 314 stub_->channel()->Send(message);
316 } 315 }
317 316
318 void GpuVideoEncodeAccelerator::SendCreateEncoderReply(IPC::Message* message, 317 void GpuVideoEncodeAccelerator::SendCreateEncoderReply(IPC::Message* message,
319 bool succeeded) { 318 bool succeeded) {
320 GpuCommandBufferMsg_CreateVideoEncoder::WriteReplyParams(message, succeeded); 319 GpuCommandBufferMsg_CreateVideoEncoder::WriteReplyParams(message, succeeded);
321 Send(message); 320 Send(message);
322 } 321 }
323 322
324 } // namespace content 323 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/media/gpu_video_decode_accelerator.cc ('k') | content/common/gpu/media/rendering_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698