| OLD | NEW |
| 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" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/message_loop/message_loop_proxy.h" | 13 #include "base/message_loop/message_loop_proxy.h" |
| 14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
| 15 | 15 |
| 16 #include "content/common/gpu/gpu_channel.h" | 16 #include "content/common/gpu/gpu_channel.h" |
| 17 #include "content/common/gpu/gpu_messages.h" | 17 #include "content/common/gpu/gpu_messages.h" |
| 18 #include "content/common/gpu/media/gpu_video_accelerator_util.h" |
| 18 #include "content/public/common/content_switches.h" | 19 #include "content/public/common/content_switches.h" |
| 19 #include "gpu/command_buffer/common/command_buffer.h" | 20 #include "gpu/command_buffer/common/command_buffer.h" |
| 20 #include "ipc/ipc_message_macros.h" | 21 #include "ipc/ipc_message_macros.h" |
| 21 #include "ipc/ipc_message_utils.h" | 22 #include "ipc/ipc_message_utils.h" |
| 22 #include "ipc/message_filter.h" | 23 #include "ipc/message_filter.h" |
| 23 #include "media/base/limits.h" | 24 #include "media/base/limits.h" |
| 24 #include "ui/gl/gl_context.h" | 25 #include "ui/gl/gl_context.h" |
| 25 #include "ui/gl/gl_image.h" | 26 #include "ui/gl/gl_image.h" |
| 26 #include "ui/gl/gl_surface_egl.h" | 27 #include "ui/gl/gl_surface_egl.h" |
| 27 | 28 |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 #if !defined(OS_WIN) | 243 #if !defined(OS_WIN) |
| 243 // Ensure we will be able to get a GL context at all before initializing | 244 // Ensure we will be able to get a GL context at all before initializing |
| 244 // non-Windows VDAs. | 245 // non-Windows VDAs. |
| 245 if (!make_context_current_.Run()) { | 246 if (!make_context_current_.Run()) { |
| 246 SendCreateDecoderReply(init_done_msg, false); | 247 SendCreateDecoderReply(init_done_msg, false); |
| 247 return; | 248 return; |
| 248 } | 249 } |
| 249 #endif | 250 #endif |
| 250 | 251 |
| 251 // Array of Create..VDA() function pointers, maybe applicable to the current | 252 // Array of Create..VDA() function pointers, maybe applicable to the current |
| 252 // platform. This list is ordered by priority of use. | 253 // platform. This list is ordered by priority of use and it should be the |
| 254 // same as the order of querying supported profiles of VDAs. |
| 253 const GpuVideoDecodeAccelerator::CreateVDAFp create_vda_fps[] = { | 255 const GpuVideoDecodeAccelerator::CreateVDAFp create_vda_fps[] = { |
| 254 &GpuVideoDecodeAccelerator::CreateDXVAVDA, | 256 &GpuVideoDecodeAccelerator::CreateDXVAVDA, |
| 255 &GpuVideoDecodeAccelerator::CreateV4L2VDA, | 257 &GpuVideoDecodeAccelerator::CreateV4L2VDA, |
| 256 &GpuVideoDecodeAccelerator::CreateV4L2SliceVDA, | 258 &GpuVideoDecodeAccelerator::CreateV4L2SliceVDA, |
| 257 &GpuVideoDecodeAccelerator::CreateVaapiVDA, | 259 &GpuVideoDecodeAccelerator::CreateVaapiVDA, |
| 258 &GpuVideoDecodeAccelerator::CreateVTVDA, | 260 &GpuVideoDecodeAccelerator::CreateVTVDA, |
| 259 &GpuVideoDecodeAccelerator::CreateOzoneVDA, | 261 &GpuVideoDecodeAccelerator::CreateOzoneVDA, |
| 260 &GpuVideoDecodeAccelerator::CreateAndroidVDA}; | 262 &GpuVideoDecodeAccelerator::CreateAndroidVDA}; |
| 261 | 263 |
| 262 for (const auto& create_vda_function : create_vda_fps) { | 264 for (const auto& create_vda_function : create_vda_fps) { |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 GpuVideoDecodeAccelerator::CreateAndroidVDA() { | 378 GpuVideoDecodeAccelerator::CreateAndroidVDA() { |
| 377 scoped_ptr<media::VideoDecodeAccelerator> decoder; | 379 scoped_ptr<media::VideoDecodeAccelerator> decoder; |
| 378 #if defined(OS_ANDROID) | 380 #if defined(OS_ANDROID) |
| 379 decoder.reset(new AndroidVideoDecodeAccelerator( | 381 decoder.reset(new AndroidVideoDecodeAccelerator( |
| 380 stub_->decoder()->AsWeakPtr(), | 382 stub_->decoder()->AsWeakPtr(), |
| 381 make_context_current_)); | 383 make_context_current_)); |
| 382 #endif | 384 #endif |
| 383 return decoder.Pass(); | 385 return decoder.Pass(); |
| 384 } | 386 } |
| 385 | 387 |
| 388 // static |
| 389 gpu::VideoDecodeAcceleratorSupportedProfiles |
| 390 GpuVideoDecodeAccelerator::GetSupportedProfiles() { |
| 391 media::VideoDecodeAccelerator::SupportedProfiles profiles; |
| 392 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
| 393 if (cmd_line->HasSwitch(switches::kDisableAcceleratedVideoDecode)) |
| 394 return gpu::VideoDecodeAcceleratorSupportedProfiles(); |
| 395 |
| 396 // Query supported profiles for each VDA. The order of querying VDAs should |
| 397 // be the same as the order of initializing VDAs. Then the returned profile |
| 398 // can be initialized by corresponding VDA successfully. |
| 399 #if defined(OS_WIN) |
| 400 profiles = DXVAVideoDecodeAccelerator::GetSupportedProfiles(); |
| 401 #elif defined(OS_CHROMEOS) |
| 402 #if defined(USE_V4L2_CODEC) |
| 403 media::VideoDecodeAccelerator::SupportedProfiles vda_profiles; |
| 404 vda_profiles = V4L2VideoDecodeAccelerator::GetSupportedProfiles(); |
| 405 GpuVideoAcceleratorUtil::InsertUniqueDecodeProfiles(vda_profiles, &profiles); |
| 406 vda_profiles = V4L2SliceVideoDecodeAccelerator::GetSupportedProfiles(); |
| 407 GpuVideoAcceleratorUtil::InsertUniqueDecodeProfiles(vda_profiles, &profiles); |
| 408 #endif |
| 409 #if defined(ARCH_CPU_X86_FAMILY) |
| 410 vda_profiles = VaapiVideoDecodeAccelerator::GetSupportedProfiles(); |
| 411 GpuVideoAcceleratorUtil::InsertUniqueDecodeProfiles(vda_profiles, &profiles); |
| 412 #endif |
| 413 #elif defined(OS_MACOSX) |
| 414 profiles = VTVideoDecodeAccelerator::GetSupportedProfiles(); |
| 415 #elif defined(OS_ANDROID) |
| 416 profiles = AndroidVideoDecodeAccelerator::GetSupportedProfiles(); |
| 417 #endif |
| 418 return GpuVideoAcceleratorUtil::ConvertMediaToGpuDecodeProfiles(profiles); |
| 419 } |
| 420 |
| 386 // Runs on IO thread if video_decode_accelerator_->CanDecodeOnIOThread() is | 421 // Runs on IO thread if video_decode_accelerator_->CanDecodeOnIOThread() is |
| 387 // true, otherwise on the main thread. | 422 // true, otherwise on the main thread. |
| 388 void GpuVideoDecodeAccelerator::OnDecode( | 423 void GpuVideoDecodeAccelerator::OnDecode( |
| 389 base::SharedMemoryHandle handle, int32 id, uint32 size) { | 424 base::SharedMemoryHandle handle, int32 id, uint32 size) { |
| 390 DCHECK(video_decode_accelerator_.get()); | 425 DCHECK(video_decode_accelerator_.get()); |
| 391 if (id < 0) { | 426 if (id < 0) { |
| 392 DLOG(ERROR) << "BitstreamBuffer id " << id << " out of range"; | 427 DLOG(ERROR) << "BitstreamBuffer id " << id << " out of range"; |
| 393 if (child_message_loop_->BelongsToCurrentThread()) { | 428 if (child_message_loop_->BelongsToCurrentThread()) { |
| 394 NotifyError(media::VideoDecodeAccelerator::INVALID_ARGUMENT); | 429 NotifyError(media::VideoDecodeAccelerator::INVALID_ARGUMENT); |
| 395 } else { | 430 } else { |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 return stub_->channel()->Send(message); | 611 return stub_->channel()->Send(message); |
| 577 } | 612 } |
| 578 | 613 |
| 579 void GpuVideoDecodeAccelerator::SendCreateDecoderReply(IPC::Message* message, | 614 void GpuVideoDecodeAccelerator::SendCreateDecoderReply(IPC::Message* message, |
| 580 bool succeeded) { | 615 bool succeeded) { |
| 581 GpuCommandBufferMsg_CreateVideoDecoder::WriteReplyParams(message, succeeded); | 616 GpuCommandBufferMsg_CreateVideoDecoder::WriteReplyParams(message, succeeded); |
| 582 Send(message); | 617 Send(message); |
| 583 } | 618 } |
| 584 | 619 |
| 585 } // namespace content | 620 } // namespace content |
| OLD | NEW |