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 std::vector<gpu::VideoDecodeAcceleratorSupportedProfile> | |
390 GpuVideoDecodeAccelerator::GetSupportedProfiles() { | |
391 std::vector<media::VideoDecodeAccelerator::SupportedProfile> profiles; | |
392 std::vector<media::VideoDecodeAccelerator::SupportedProfile> vda_profiles; | |
393 // Query supported profiles for each VDA. The order of querying VDAs should | |
394 // be the same as the order of initializing VDAs. Then the returned profile | |
395 // can be initialized by corresponding VDA successfully. | |
396 #if defined(OS_WIN) | |
397 vda_profiles = DXVAVideoDecodeAccelerator::GetSupportedProfiles(); | |
398 profiles.insert(profiles.end(), vda_profiles.begin(), vda_profiles.end()); | |
piman
2015/03/23 20:29:30
nit: you can do profiles = DXVAVideoDecodeAccelera
henryhsu
2015/03/24 10:02:44
Done.
| |
399 #elif defined(OS_CHROMEOS) | |
400 #if defined(USE_V4L2_CODEC) | |
401 vda_profiles = V4L2VideoDecodeAccelerator::GetSupportedProfiles(); | |
402 GpuVideoAcceleratorUtil::InsertUniqueDecodeProfiles(vda_profiles, &profiles); | |
403 vda_profiles = V4L2SliceVideoDecodeAccelerator::GetSupportedProfiles(); | |
404 GpuVideoAcceleratorUtil::InsertUniqueDecodeProfiles(vda_profiles, &profiles); | |
405 #endif | |
406 #if defined(ARCH_CPU_X86_FAMILY) | |
407 vda_profiles = VaapiVideoDecodeAccelerator::GetSupportedProfiles(); | |
408 GpuVideoAcceleratorUtil::InsertUniqueDecodeProfiles(vda_profiles, &profiles); | |
409 #endif | |
410 #elif defined(OS_MACOSX) | |
411 vda_profiles = VTVideoDecodeAccelerator::GetSupportedProfiles(); | |
412 profiles.insert(profiles.end(), vda_profiles.begin(), vda_profiles.end()); | |
413 #elif defined(OS_ANDROID) | |
414 vda_profiles = AndroidVideoDecodeAccelerator::GetSupportedProfiles(); | |
415 profiles.insert(profiles.end(), vda_profiles.begin(), vda_profiles.end()); | |
416 #endif // defined(OS_CHROMEOS) | |
wuchengli
2015/03/23 14:42:06
Remove "// defined(OS_CHROMEOS)" comment
henryhsu
2015/03/24 10:02:44
Done.
| |
417 return GpuVideoAcceleratorUtil::ConvertMediaToGpuDecodeProfiles(profiles); | |
418 } | |
419 | |
386 // Runs on IO thread if video_decode_accelerator_->CanDecodeOnIOThread() is | 420 // Runs on IO thread if video_decode_accelerator_->CanDecodeOnIOThread() is |
387 // true, otherwise on the main thread. | 421 // true, otherwise on the main thread. |
388 void GpuVideoDecodeAccelerator::OnDecode( | 422 void GpuVideoDecodeAccelerator::OnDecode( |
389 base::SharedMemoryHandle handle, int32 id, uint32 size) { | 423 base::SharedMemoryHandle handle, int32 id, uint32 size) { |
390 DCHECK(video_decode_accelerator_.get()); | 424 DCHECK(video_decode_accelerator_.get()); |
391 if (id < 0) { | 425 if (id < 0) { |
392 DLOG(ERROR) << "BitstreamBuffer id " << id << " out of range"; | 426 DLOG(ERROR) << "BitstreamBuffer id " << id << " out of range"; |
393 if (child_message_loop_->BelongsToCurrentThread()) { | 427 if (child_message_loop_->BelongsToCurrentThread()) { |
394 NotifyError(media::VideoDecodeAccelerator::INVALID_ARGUMENT); | 428 NotifyError(media::VideoDecodeAccelerator::INVALID_ARGUMENT); |
395 } else { | 429 } else { |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
576 return stub_->channel()->Send(message); | 610 return stub_->channel()->Send(message); |
577 } | 611 } |
578 | 612 |
579 void GpuVideoDecodeAccelerator::SendCreateDecoderReply(IPC::Message* message, | 613 void GpuVideoDecodeAccelerator::SendCreateDecoderReply(IPC::Message* message, |
580 bool succeeded) { | 614 bool succeeded) { |
581 GpuCommandBufferMsg_CreateVideoDecoder::WriteReplyParams(message, succeeded); | 615 GpuCommandBufferMsg_CreateVideoDecoder::WriteReplyParams(message, succeeded); |
582 Send(message); | 616 Send(message); |
583 } | 617 } |
584 | 618 |
585 } // namespace content | 619 } // namespace content |
OLD | NEW |