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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 return; | 267 return; |
267 } | 268 } |
268 video_decode_accelerator_.reset(); | 269 video_decode_accelerator_.reset(); |
269 NOTIMPLEMENTED() << "HW video decode acceleration not available."; | 270 NOTIMPLEMENTED() << "HW video decode acceleration not available."; |
270 SendCreateDecoderReply(init_done_msg, false); | 271 SendCreateDecoderReply(init_done_msg, false); |
271 } | 272 } |
272 | 273 |
273 std::vector<GpuVideoDecodeAccelerator::CreateVDAFp> | 274 std::vector<GpuVideoDecodeAccelerator::CreateVDAFp> |
274 GpuVideoDecodeAccelerator::CreateVDAFps() { | 275 GpuVideoDecodeAccelerator::CreateVDAFps() { |
275 std::vector<GpuVideoDecodeAccelerator::CreateVDAFp> create_vda_fps; | 276 std::vector<GpuVideoDecodeAccelerator::CreateVDAFp> create_vda_fps; |
| 277 // The order of initializing VDAs should be the same as the order of querying |
| 278 // supported profiles of VDAs. |
276 create_vda_fps.push_back(&GpuVideoDecodeAccelerator::CreateDXVAVDA); | 279 create_vda_fps.push_back(&GpuVideoDecodeAccelerator::CreateDXVAVDA); |
277 create_vda_fps.push_back(&GpuVideoDecodeAccelerator::CreateV4L2VDA); | 280 create_vda_fps.push_back(&GpuVideoDecodeAccelerator::CreateV4L2VDA); |
278 create_vda_fps.push_back(&GpuVideoDecodeAccelerator::CreateV4L2SliceVDA); | 281 create_vda_fps.push_back(&GpuVideoDecodeAccelerator::CreateV4L2SliceVDA); |
279 create_vda_fps.push_back(&GpuVideoDecodeAccelerator::CreateVaapiVDA); | 282 create_vda_fps.push_back(&GpuVideoDecodeAccelerator::CreateVaapiVDA); |
280 create_vda_fps.push_back(&GpuVideoDecodeAccelerator::CreateVTVDA); | 283 create_vda_fps.push_back(&GpuVideoDecodeAccelerator::CreateVTVDA); |
281 create_vda_fps.push_back(&GpuVideoDecodeAccelerator::CreateOzoneVDA); | 284 create_vda_fps.push_back(&GpuVideoDecodeAccelerator::CreateOzoneVDA); |
282 create_vda_fps.push_back(&GpuVideoDecodeAccelerator::CreateAndroidVDA); | 285 create_vda_fps.push_back(&GpuVideoDecodeAccelerator::CreateAndroidVDA); |
283 return create_vda_fps; | 286 return create_vda_fps; |
284 } | 287 } |
285 | 288 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 GpuVideoDecodeAccelerator::CreateAndroidVDA() { | 385 GpuVideoDecodeAccelerator::CreateAndroidVDA() { |
383 scoped_ptr<media::VideoDecodeAccelerator> decoder; | 386 scoped_ptr<media::VideoDecodeAccelerator> decoder; |
384 #if defined(OS_ANDROID) | 387 #if defined(OS_ANDROID) |
385 decoder.reset(new AndroidVideoDecodeAccelerator( | 388 decoder.reset(new AndroidVideoDecodeAccelerator( |
386 stub_->decoder()->AsWeakPtr(), | 389 stub_->decoder()->AsWeakPtr(), |
387 make_context_current_)); | 390 make_context_current_)); |
388 #endif | 391 #endif |
389 return decoder.Pass(); | 392 return decoder.Pass(); |
390 } | 393 } |
391 | 394 |
| 395 // static |
| 396 bool GpuVideoDecodeAccelerator::GetSupportedProfiles( |
| 397 std::vector<gpu::VideoDecodeAcceleratorSupportedProfile>* |
| 398 supported_profiles) { |
| 399 std::vector<media::VideoDecodeAccelerator::SupportedProfile> profiles; |
| 400 bool support_query_profile = false; |
| 401 #if defined(OS_CHROMEOS) |
| 402 std::vector<media::VideoDecodeAccelerator::SupportedProfile> vda_profiles; |
| 403 support_query_profile = true; |
| 404 // Query supported profiles for each VDA. The order of querying VDAs should |
| 405 // be the same as the order of initializing VDAs. Then the returned profile |
| 406 // can be initialized by corresponding VDA successfully. |
| 407 #if defined(USE_V4L2_CODEC) |
| 408 vda_profiles = V4L2VideoDecodeAccelerator::GetSupportedProfiles(); |
| 409 GpuVideoAcceleratorUtil::UniqueInsertDecodeProfiles(&profiles, vda_profiles); |
| 410 vda_profiles = V4L2SliceVideoDecodeAccelerator::GetSupportedProfiles(); |
| 411 GpuVideoAcceleratorUtil::UniqueInsertDecodeProfiles(&profiles, vda_profiles); |
| 412 #endif |
| 413 #if defined(ARCH_CPU_X86_FAMILY) |
| 414 vda_profiles = VaapiVideoDecodeAccelerator::GetSupportedProfiles(); |
| 415 GpuVideoAcceleratorUtil::UniqueInsertDecodeProfiles(&profiles, vda_profiles); |
| 416 #endif |
| 417 *supported_profiles = |
| 418 GpuVideoAcceleratorUtil::ConvertMediaToGpuDecodeProfiles(profiles); |
| 419 #endif // defined(OS_CHROMEOS) |
| 420 return support_query_profile; |
| 421 } |
| 422 |
392 // Runs on IO thread if video_decode_accelerator_->CanDecodeOnIOThread() is | 423 // Runs on IO thread if video_decode_accelerator_->CanDecodeOnIOThread() is |
393 // true, otherwise on the main thread. | 424 // true, otherwise on the main thread. |
394 void GpuVideoDecodeAccelerator::OnDecode( | 425 void GpuVideoDecodeAccelerator::OnDecode( |
395 base::SharedMemoryHandle handle, int32 id, uint32 size) { | 426 base::SharedMemoryHandle handle, int32 id, uint32 size) { |
396 DCHECK(video_decode_accelerator_.get()); | 427 DCHECK(video_decode_accelerator_.get()); |
397 if (id < 0) { | 428 if (id < 0) { |
398 DLOG(ERROR) << "BitstreamBuffer id " << id << " out of range"; | 429 DLOG(ERROR) << "BitstreamBuffer id " << id << " out of range"; |
399 if (child_message_loop_->BelongsToCurrentThread()) { | 430 if (child_message_loop_->BelongsToCurrentThread()) { |
400 NotifyError(media::VideoDecodeAccelerator::INVALID_ARGUMENT); | 431 NotifyError(media::VideoDecodeAccelerator::INVALID_ARGUMENT); |
401 } else { | 432 } else { |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 return stub_->channel()->Send(message); | 613 return stub_->channel()->Send(message); |
583 } | 614 } |
584 | 615 |
585 void GpuVideoDecodeAccelerator::SendCreateDecoderReply(IPC::Message* message, | 616 void GpuVideoDecodeAccelerator::SendCreateDecoderReply(IPC::Message* message, |
586 bool succeeded) { | 617 bool succeeded) { |
587 GpuCommandBufferMsg_CreateVideoDecoder::WriteReplyParams(message, succeeded); | 618 GpuCommandBufferMsg_CreateVideoDecoder::WriteReplyParams(message, succeeded); |
588 Send(message); | 619 Send(message); |
589 } | 620 } |
590 | 621 |
591 } // namespace content | 622 } // namespace content |
OLD | NEW |