Chromium Code Reviews| 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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 265 SendCreateDecoderReply(init_done_msg, true); | 266 SendCreateDecoderReply(init_done_msg, true); |
| 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; |
|
wuchengli
2015/03/19 06:19:25
Add comment to say the insert order here must be t
henryhsu
2015/03/19 10:00:32
Done.
| |
| 276 create_vda_fps.push_back(&GpuVideoDecodeAccelerator::CreateDXVAVDA); | 277 create_vda_fps.push_back(&GpuVideoDecodeAccelerator::CreateDXVAVDA); |
| 277 create_vda_fps.push_back(&GpuVideoDecodeAccelerator::CreateV4L2VDA); | 278 create_vda_fps.push_back(&GpuVideoDecodeAccelerator::CreateV4L2VDA); |
| 278 create_vda_fps.push_back(&GpuVideoDecodeAccelerator::CreateV4L2SliceVDA); | 279 create_vda_fps.push_back(&GpuVideoDecodeAccelerator::CreateV4L2SliceVDA); |
| 279 create_vda_fps.push_back(&GpuVideoDecodeAccelerator::CreateVaapiVDA); | 280 create_vda_fps.push_back(&GpuVideoDecodeAccelerator::CreateVaapiVDA); |
| 280 create_vda_fps.push_back(&GpuVideoDecodeAccelerator::CreateVTVDA); | 281 create_vda_fps.push_back(&GpuVideoDecodeAccelerator::CreateVTVDA); |
| 281 create_vda_fps.push_back(&GpuVideoDecodeAccelerator::CreateOzoneVDA); | 282 create_vda_fps.push_back(&GpuVideoDecodeAccelerator::CreateOzoneVDA); |
| 282 create_vda_fps.push_back(&GpuVideoDecodeAccelerator::CreateAndroidVDA); | 283 create_vda_fps.push_back(&GpuVideoDecodeAccelerator::CreateAndroidVDA); |
| 283 return create_vda_fps; | 284 return create_vda_fps; |
| 284 } | 285 } |
| 285 | 286 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 382 GpuVideoDecodeAccelerator::CreateAndroidVDA() { | 383 GpuVideoDecodeAccelerator::CreateAndroidVDA() { |
| 383 scoped_ptr<media::VideoDecodeAccelerator> decoder; | 384 scoped_ptr<media::VideoDecodeAccelerator> decoder; |
| 384 #if defined(OS_ANDROID) | 385 #if defined(OS_ANDROID) |
| 385 decoder.reset(new AndroidVideoDecodeAccelerator( | 386 decoder.reset(new AndroidVideoDecodeAccelerator( |
| 386 stub_->decoder()->AsWeakPtr(), | 387 stub_->decoder()->AsWeakPtr(), |
| 387 make_context_current_)); | 388 make_context_current_)); |
| 388 #endif | 389 #endif |
| 389 return decoder.Pass(); | 390 return decoder.Pass(); |
| 390 } | 391 } |
| 391 | 392 |
| 393 // static | |
| 394 bool GpuVideoDecodeAccelerator::GetSupportedProfiles( | |
| 395 std::vector<gpu::VideoDecodeAcceleratorSupportedProfile>* | |
| 396 supported_profiles) { | |
| 397 std::vector<media::VideoDecodeAccelerator::SupportedProfile> profiles; | |
| 398 bool support_query_profile = false; | |
| 399 #if defined(OS_CHROMEOS) | |
| 400 std::vector<media::VideoDecodeAccelerator::SupportedProfile> vda_profiles; | |
| 401 support_query_profile = true; | |
|
wuchengli
2015/03/19 06:19:25
Add comment to say the insert order here must be t
henryhsu
2015/03/19 10:00:32
Done.
| |
| 402 #if defined(USE_V4L2_CODEC) | |
| 403 vda_profiles = V4L2VideoDecodeAccelerator::GetSupportedProfiles(); | |
| 404 profiles.insert(profiles.end(), vda_profiles.begin(), vda_profiles.end()); | |
| 405 vda_profiles = V4L2SliceVideoDecodeAccelerator::GetSupportedProfiles(); | |
| 406 profiles.insert(profiles.end(), vda_profiles.begin(), vda_profiles.end()); | |
| 407 #endif | |
| 408 #if defined(ARCH_CPU_X86_FAMILY) | |
| 409 vda_profiles = VaapiVideoDecodeAccelerator::GetSupportedProfiles(); | |
| 410 profiles.insert(profiles.end(), vda_profiles.begin(), vda_profiles.end()); | |
| 411 #endif | |
| 412 #endif // defined(OS_CHROMEOS) | |
| 413 *supported_profiles = | |
| 414 GpuVideoAcceleratorUtil::ConvertMediaToGpuDecodeProfiles(profiles); | |
|
wuchengli
2015/03/19 06:19:24
We shouldn't touch |supported_profiles| if this fu
henryhsu
2015/03/19 10:00:32
Done.
| |
| 415 return support_query_profile; | |
| 416 } | |
| 417 | |
| 392 // Runs on IO thread if video_decode_accelerator_->CanDecodeOnIOThread() is | 418 // Runs on IO thread if video_decode_accelerator_->CanDecodeOnIOThread() is |
| 393 // true, otherwise on the main thread. | 419 // true, otherwise on the main thread. |
| 394 void GpuVideoDecodeAccelerator::OnDecode( | 420 void GpuVideoDecodeAccelerator::OnDecode( |
| 395 base::SharedMemoryHandle handle, int32 id, uint32 size) { | 421 base::SharedMemoryHandle handle, int32 id, uint32 size) { |
| 396 DCHECK(video_decode_accelerator_.get()); | 422 DCHECK(video_decode_accelerator_.get()); |
| 397 if (id < 0) { | 423 if (id < 0) { |
| 398 DLOG(ERROR) << "BitstreamBuffer id " << id << " out of range"; | 424 DLOG(ERROR) << "BitstreamBuffer id " << id << " out of range"; |
| 399 if (child_message_loop_->BelongsToCurrentThread()) { | 425 if (child_message_loop_->BelongsToCurrentThread()) { |
| 400 NotifyError(media::VideoDecodeAccelerator::INVALID_ARGUMENT); | 426 NotifyError(media::VideoDecodeAccelerator::INVALID_ARGUMENT); |
| 401 } else { | 427 } else { |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 582 return stub_->channel()->Send(message); | 608 return stub_->channel()->Send(message); |
| 583 } | 609 } |
| 584 | 610 |
| 585 void GpuVideoDecodeAccelerator::SendCreateDecoderReply(IPC::Message* message, | 611 void GpuVideoDecodeAccelerator::SendCreateDecoderReply(IPC::Message* message, |
| 586 bool succeeded) { | 612 bool succeeded) { |
| 587 GpuCommandBufferMsg_CreateVideoDecoder::WriteReplyParams(message, succeeded); | 613 GpuCommandBufferMsg_CreateVideoDecoder::WriteReplyParams(message, succeeded); |
| 588 Send(message); | 614 Send(message); |
| 589 } | 615 } |
| 590 | 616 |
| 591 } // namespace content | 617 } // namespace content |
| OLD | NEW |