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

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

Issue 832383004: Revert of Support multiple video decoders and encoders (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_decode_accelerator.h" 5 #include "content/common/gpu/media/gpu_video_decode_accelerator.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 10 matching lines...) Expand all
21 #include "ipc/message_filter.h" 21 #include "ipc/message_filter.h"
22 #include "media/base/limits.h" 22 #include "media/base/limits.h"
23 #include "ui/gl/gl_context.h" 23 #include "ui/gl/gl_context.h"
24 #include "ui/gl/gl_surface_egl.h" 24 #include "ui/gl/gl_surface_egl.h"
25 25
26 #if defined(OS_WIN) 26 #if defined(OS_WIN)
27 #include "base/win/windows_version.h" 27 #include "base/win/windows_version.h"
28 #include "content/common/gpu/media/dxva_video_decode_accelerator.h" 28 #include "content/common/gpu/media/dxva_video_decode_accelerator.h"
29 #elif defined(OS_MACOSX) 29 #elif defined(OS_MACOSX)
30 #include "content/common/gpu/media/vt_video_decode_accelerator.h" 30 #include "content/common/gpu/media/vt_video_decode_accelerator.h"
31 #elif defined(OS_CHROMEOS) 31 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) && defined(USE_X11)
32 #if defined(USE_OZONE) || defined(ARCH_CPU_ARMEL)
33 #include "content/common/gpu/media/v4l2_video_decode_accelerator.h" 32 #include "content/common/gpu/media/v4l2_video_decode_accelerator.h"
34 #include "content/common/gpu/media/v4l2_video_device.h" 33 #include "content/common/gpu/media/v4l2_video_device.h"
35 #endif // defined(USE_OZONE) || defined(ARCH_CPU_ARMEL) 34 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
36 #if defined(ARCH_CPU_X86_FAMILY)
37 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h" 35 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h"
38 #include "ui/gl/gl_implementation.h" 36 #include "ui/gl/gl_implementation.h"
39 #endif // defined(ARCH_CPU_X86_FAMILY)
40 #elif defined(USE_OZONE) 37 #elif defined(USE_OZONE)
41 #include "media/ozone/media_ozone_platform.h" 38 #include "media/ozone/media_ozone_platform.h"
42 #elif defined(OS_ANDROID) 39 #elif defined(OS_ANDROID)
43 #include "content/common/gpu/media/android_video_decode_accelerator.h" 40 #include "content/common/gpu/media/android_video_decode_accelerator.h"
44 #endif 41 #endif
45 42
46 #include "ui/gfx/size.h" 43 #include "ui/gfx/size.h"
47 44
48 namespace content { 45 namespace content {
49 46
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 237
241 #if !defined(OS_WIN) 238 #if !defined(OS_WIN)
242 // Ensure we will be able to get a GL context at all before initializing 239 // Ensure we will be able to get a GL context at all before initializing
243 // non-Windows VDAs. 240 // non-Windows VDAs.
244 if (!make_context_current_.Run()) { 241 if (!make_context_current_.Run()) {
245 SendCreateDecoderReply(init_done_msg, false); 242 SendCreateDecoderReply(init_done_msg, false);
246 return; 243 return;
247 } 244 }
248 #endif 245 #endif
249 246
250 std::vector<GpuVideoDecodeAccelerator::CreateVDAFp> 247 #if defined(OS_WIN)
251 create_vda_fps = CreateVDAFps(); 248 if (base::win::GetVersion() < base::win::VERSION_WIN7) {
252 249 NOTIMPLEMENTED() << "HW video decode acceleration not available.";
253 for (size_t i = 0; i < create_vda_fps.size(); ++i) { 250 SendCreateDecoderReply(init_done_msg, false);
254 video_decode_accelerator_ = (this->*create_vda_fps[i])();
255 if (!video_decode_accelerator_ ||
256 !video_decode_accelerator_->Initialize(profile, this))
257 continue;
258
259 if (video_decode_accelerator_->CanDecodeOnIOThread()) {
260 filter_ = new MessageFilter(this, host_route_id_);
261 stub_->channel()->AddFilter(filter_.get());
262 }
263 SendCreateDecoderReply(init_done_msg, true);
264 return; 251 return;
265 } 252 }
266 video_decode_accelerator_.reset(); 253 DVLOG(0) << "Initializing DXVA HW decoder for windows.";
254 video_decode_accelerator_.reset(
255 new DXVAVideoDecodeAccelerator(make_context_current_));
256 #elif defined(OS_MACOSX)
257 video_decode_accelerator_.reset(new VTVideoDecodeAccelerator(
258 static_cast<CGLContextObj>(
259 stub_->decoder()->GetGLContext()->GetHandle()),
260 make_context_current_));
261 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) && defined(USE_X11)
262 scoped_ptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder);
263 if (!device.get()) {
264 SendCreateDecoderReply(init_done_msg, false);
265 return;
266 }
267 video_decode_accelerator_.reset(new V4L2VideoDecodeAccelerator(
268 gfx::GLSurfaceEGL::GetHardwareDisplay(),
269 stub_->decoder()->GetGLContext()->GetHandle(),
270 weak_factory_for_io_.GetWeakPtr(),
271 make_context_current_,
272 device.Pass(),
273 io_message_loop_));
274 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
275 video_decode_accelerator_.reset(
276 new VaapiVideoDecodeAccelerator(make_context_current_));
277 #elif defined(USE_OZONE)
278 media::MediaOzonePlatform* platform =
279 media::MediaOzonePlatform::GetInstance();
280 video_decode_accelerator_.reset(platform->CreateVideoDecodeAccelerator(
281 make_context_current_));
282 if (!video_decode_accelerator_) {
283 SendCreateDecoderReply(init_done_msg, false);
284 return;
285 }
286 #elif defined(OS_ANDROID)
287 video_decode_accelerator_.reset(new AndroidVideoDecodeAccelerator(
288 stub_->decoder()->AsWeakPtr(),
289 make_context_current_));
290 #else
267 NOTIMPLEMENTED() << "HW video decode acceleration not available."; 291 NOTIMPLEMENTED() << "HW video decode acceleration not available.";
268 SendCreateDecoderReply(init_done_msg, false); 292 SendCreateDecoderReply(init_done_msg, false);
269 } 293 return;
294 #endif
270 295
271 std::vector<GpuVideoDecodeAccelerator::CreateVDAFp> 296 if (video_decode_accelerator_->CanDecodeOnIOThread()) {
272 GpuVideoDecodeAccelerator::CreateVDAFps() { 297 filter_ = new MessageFilter(this, host_route_id_);
273 std::vector<GpuVideoDecodeAccelerator::CreateVDAFp> create_vda_fps; 298 stub_->channel()->AddFilter(filter_.get());
274 create_vda_fps.push_back(&GpuVideoDecodeAccelerator::CreateDXVAVDA); 299 }
275 create_vda_fps.push_back(&GpuVideoDecodeAccelerator::CreateV4L2VDA);
276 create_vda_fps.push_back(&GpuVideoDecodeAccelerator::CreateVaapiVDA);
277 create_vda_fps.push_back(&GpuVideoDecodeAccelerator::CreateVTVDA);
278 create_vda_fps.push_back(&GpuVideoDecodeAccelerator::CreateOzoneVDA);
279 create_vda_fps.push_back(&GpuVideoDecodeAccelerator::CreateAndroidVDA);
280 return create_vda_fps;
281 }
282 300
283 scoped_ptr<media::VideoDecodeAccelerator> 301 if (!video_decode_accelerator_->Initialize(profile, this)) {
284 GpuVideoDecodeAccelerator::CreateDXVAVDA() { 302 SendCreateDecoderReply(init_done_msg, false);
285 scoped_ptr<media::VideoDecodeAccelerator> decoder; 303 return;
286 #if defined(OS_WIN)
287 if (base::win::GetVersion() >= base::win::VERSION_WIN7) {
288 DVLOG(0) << "Initializing DXVA HW decoder for windows.";
289 decoder.reset(new DXVAVideoDecodeAccelerator(make_context_current_));
290 } else {
291 NOTIMPLEMENTED() << "HW video decode acceleration not available.";
292 } 304 }
293 #endif
294 return decoder.Pass();
295 }
296 305
297 scoped_ptr<media::VideoDecodeAccelerator> 306 SendCreateDecoderReply(init_done_msg, true);
298 GpuVideoDecodeAccelerator::CreateV4L2VDA() {
299 scoped_ptr<media::VideoDecodeAccelerator> decoder;
300 #if defined(OS_CHROMEOS) && (defined(USE_OZONE) || defined(ARCH_CPU_ARMEL))
301 scoped_ptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder);
302 if (device.get()) {
303 decoder.reset(new V4L2VideoDecodeAccelerator(
304 gfx::GLSurfaceEGL::GetHardwareDisplay(),
305 stub_->decoder()->GetGLContext()->GetHandle(),
306 weak_factory_for_io_.GetWeakPtr(),
307 make_context_current_,
308 device.Pass(),
309 io_message_loop_));
310 }
311 #endif
312 return decoder.Pass();
313 }
314
315 scoped_ptr<media::VideoDecodeAccelerator>
316 GpuVideoDecodeAccelerator::CreateVaapiVDA() {
317 scoped_ptr<media::VideoDecodeAccelerator> decoder;
318 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
319 decoder.reset(new VaapiVideoDecodeAccelerator(make_context_current_));
320 #endif
321 return decoder.Pass();
322 }
323
324 scoped_ptr<media::VideoDecodeAccelerator>
325 GpuVideoDecodeAccelerator::CreateVTVDA() {
326 scoped_ptr<media::VideoDecodeAccelerator> decoder;
327 #if defined(OS_MACOSX)
328 decoder.reset(new VTVideoDecodeAccelerator(
329 static_cast<CGLContextObj>(stub_->decoder()->GetGLContext()->GetHandle()),
330 make_context_current_));
331 #endif
332 return decoder.Pass();
333 }
334
335 scoped_ptr<media::VideoDecodeAccelerator>
336 GpuVideoDecodeAccelerator::CreateOzoneVDA() {
337 scoped_ptr<media::VideoDecodeAccelerator> decoder;
338 #if !defined(OS_CHROMEOS) && defined(USE_OZONE)
339 media::MediaOzonePlatform* platform =
340 media::MediaOzonePlatform::GetInstance();
341 decoder.reset(platform->CreateVideoDecodeAccelerator(make_context_current_));
342 #endif
343 return decoder.Pass();
344 }
345
346 scoped_ptr<media::VideoDecodeAccelerator>
347 GpuVideoDecodeAccelerator::CreateAndroidVDA() {
348 scoped_ptr<media::VideoDecodeAccelerator> decoder;
349 #if defined(OS_ANDROID)
350 decoder.reset(new AndroidVideoDecodeAccelerator(
351 stub_->decoder()->AsWeakPtr(),
352 make_context_current_));
353 #endif
354 return decoder.Pass();
355 } 307 }
356 308
357 // Runs on IO thread if video_decode_accelerator_->CanDecodeOnIOThread() is 309 // Runs on IO thread if video_decode_accelerator_->CanDecodeOnIOThread() is
358 // true, otherwise on the main thread. 310 // true, otherwise on the main thread.
359 void GpuVideoDecodeAccelerator::OnDecode( 311 void GpuVideoDecodeAccelerator::OnDecode(
360 base::SharedMemoryHandle handle, int32 id, uint32 size) { 312 base::SharedMemoryHandle handle, int32 id, uint32 size) {
361 DCHECK(video_decode_accelerator_.get()); 313 DCHECK(video_decode_accelerator_.get());
362 if (id < 0) { 314 if (id < 0) {
363 DLOG(ERROR) << "BitstreamBuffer id " << id << " out of range"; 315 DLOG(ERROR) << "BitstreamBuffer id " << id << " out of range";
364 if (child_message_loop_->BelongsToCurrentThread()) { 316 if (child_message_loop_->BelongsToCurrentThread()) {
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 return stub_->channel()->Send(message); 505 return stub_->channel()->Send(message);
554 } 506 }
555 507
556 void GpuVideoDecodeAccelerator::SendCreateDecoderReply(IPC::Message* message, 508 void GpuVideoDecodeAccelerator::SendCreateDecoderReply(IPC::Message* message,
557 bool succeeded) { 509 bool succeeded) {
558 GpuCommandBufferMsg_CreateVideoDecoder::WriteReplyParams(message, succeeded); 510 GpuCommandBufferMsg_CreateVideoDecoder::WriteReplyParams(message, succeeded);
559 Send(message); 511 Send(message);
560 } 512 }
561 513
562 } // namespace content 514 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/media/gpu_video_decode_accelerator.h ('k') | content/common/gpu/media/gpu_video_encode_accelerator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698