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/message_loop/message_loop_proxy.h" | 12 #include "base/message_loop/message_loop_proxy.h" |
| 13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
| 14 | 14 |
| 15 #include "content/common/gpu/gpu_channel.h" | 15 #include "content/common/gpu/gpu_channel.h" |
| 16 #include "content/common/gpu/gpu_messages.h" | 16 #include "content/common/gpu/gpu_messages.h" |
| 17 #include "content/public/common/content_switches.h" | 17 #include "content/public/common/content_switches.h" |
| 18 #include "gpu/command_buffer/common/command_buffer.h" | 18 #include "gpu/command_buffer/common/command_buffer.h" |
| 19 #include "ipc/ipc_message_macros.h" | 19 #include "ipc/ipc_message_macros.h" |
| 20 #include "ipc/ipc_message_utils.h" | 20 #include "ipc/ipc_message_utils.h" |
| 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 "media/base/media_switches.h" | |
| 23 #include "ui/gl/gl_context.h" | 24 #include "ui/gl/gl_context.h" |
| 24 #include "ui/gl/gl_surface_egl.h" | 25 #include "ui/gl/gl_surface_egl.h" |
| 25 | 26 |
| 26 #if defined(OS_WIN) | 27 #if defined(OS_WIN) |
| 27 #include "base/win/windows_version.h" | 28 #include "base/win/windows_version.h" |
| 28 #include "content/common/gpu/media/dxva_video_decode_accelerator.h" | 29 #include "content/common/gpu/media/dxva_video_decode_accelerator.h" |
| 29 #elif defined(OS_MACOSX) | 30 #elif defined(OS_MACOSX) |
| 30 #include "content/common/gpu/media/vt_video_decode_accelerator.h" | 31 #include "content/common/gpu/media/vt_video_decode_accelerator.h" |
| 31 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) && defined(USE_X11) | 32 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) && defined(USE_X11) |
| 32 #include "content/common/gpu/media/v4l2_video_decode_accelerator.h" | 33 #include "content/common/gpu/media/v4l2_video_decode_accelerator.h" |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 308 } | 309 } |
| 309 | 310 |
| 310 if (!video_decode_accelerator_->Initialize(profile, this)) { | 311 if (!video_decode_accelerator_->Initialize(profile, this)) { |
| 311 SendCreateDecoderReply(init_done_msg, false); | 312 SendCreateDecoderReply(init_done_msg, false); |
| 312 return; | 313 return; |
| 313 } | 314 } |
| 314 | 315 |
| 315 SendCreateDecoderReply(init_done_msg, true); | 316 SendCreateDecoderReply(init_done_msg, true); |
| 316 } | 317 } |
| 317 | 318 |
| 319 // static | |
| 320 std::vector<gpu::VideoDecodeAcceleratorSupportedProfile> | |
| 321 GpuVideoDecodeAccelerator::GetSupportedProfiles() { | |
| 322 std::vector<media::VideoDecodeAccelerator::SupportedProfile> profiles; | |
| 323 media::VideoDecodeAccelerator::SupportedProfile profile; | |
| 324 profile.profile = media::VIDEO_CODEC_PROFILE_UNKNOWN; | |
|
wuchengli
2014/12/19 03:35:18
We shouldn't return unknown. Find the right profil
| |
| 325 | |
| 326 #if defined(OS_WIN) | |
| 327 // Windows Media Foundation H.264 decoding does not support decoding videos | |
| 328 // with any dimension smaller than 48 pixels: | |
| 329 // http://msdn.microsoft.com/en-us/library/windows/desktop/dd797815 | |
| 330 profile.min_resolution.SetSize(48, 48); | |
| 331 profile.max_resolution.SetSize(1920, 1088); | |
| 332 profiles.push_back(profile); | |
|
wuchengli
2014/12/19 03:35:18
We cannot return unknown.
| |
| 333 #else | |
| 334 #if defined(OS_CHROMEOS) && defined(USE_X11) | |
| 335 #if defined(ARCH_CPU_ARMEL) | |
| 336 profiles = V4L2VideoDecodeAccelerator::GetSupportedProfiles(); | |
| 337 #elif defined(ARCH_CPU_X86_FAMILY) | |
| 338 profiles = VaapiVideoDecodeAccelerator::GetSupportedProfiles(); | |
| 339 #endif | |
| 340 #elif defined(OS_ANDROID) && defined(ENABLE_WEBRTC) | |
| 341 profiles = AndroidVideoDecodeAccelerator::GetSupportedProfiles(); | |
| 342 #endif | |
| 343 #endif | |
| 344 return ConvertMediaToGpuProfiles(profiles); | |
| 345 } | |
| 346 | |
| 347 // static | |
| 348 std::vector<gpu::VideoDecodeAcceleratorSupportedProfile> | |
| 349 GpuVideoDecodeAccelerator::ConvertMediaToGpuProfiles(const std::vector< | |
| 350 media::VideoDecodeAccelerator::SupportedProfile>& media_profiles) { | |
| 351 std::vector<gpu::VideoDecodeAcceleratorSupportedProfile> profiles; | |
| 352 for (size_t i = 0; i < media_profiles.size(); i++) { | |
| 353 gpu::VideoDecodeAcceleratorSupportedProfile profile; | |
| 354 profile.profile = | |
| 355 static_cast<gpu::VideoCodecProfile>(media_profiles[i].profile); | |
|
wuchengli
2014/12/19 03:35:18
This can also go to gpu_video_accelerator_unit.h/.
| |
| 356 profile.max_resolution = media_profiles[i].max_resolution; | |
| 357 profile.min_resolution = media_profiles[i].min_resolution; | |
| 358 profiles.push_back(profile); | |
| 359 } | |
| 360 return profiles; | |
| 361 } | |
| 362 | |
| 318 // Runs on IO thread if video_decode_accelerator_->CanDecodeOnIOThread() is | 363 // Runs on IO thread if video_decode_accelerator_->CanDecodeOnIOThread() is |
| 319 // true, otherwise on the main thread. | 364 // true, otherwise on the main thread. |
| 320 void GpuVideoDecodeAccelerator::OnDecode( | 365 void GpuVideoDecodeAccelerator::OnDecode( |
| 321 base::SharedMemoryHandle handle, int32 id, uint32 size) { | 366 base::SharedMemoryHandle handle, int32 id, uint32 size) { |
| 322 DCHECK(video_decode_accelerator_.get()); | 367 DCHECK(video_decode_accelerator_.get()); |
| 323 if (id < 0) { | 368 if (id < 0) { |
| 324 DLOG(ERROR) << "BitstreamBuffer id " << id << " out of range"; | 369 DLOG(ERROR) << "BitstreamBuffer id " << id << " out of range"; |
| 325 if (child_message_loop_->BelongsToCurrentThread()) { | 370 if (child_message_loop_->BelongsToCurrentThread()) { |
| 326 NotifyError(media::VideoDecodeAccelerator::INVALID_ARGUMENT); | 371 NotifyError(media::VideoDecodeAccelerator::INVALID_ARGUMENT); |
| 327 } else { | 372 } else { |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 514 return stub_->channel()->Send(message); | 559 return stub_->channel()->Send(message); |
| 515 } | 560 } |
| 516 | 561 |
| 517 void GpuVideoDecodeAccelerator::SendCreateDecoderReply(IPC::Message* message, | 562 void GpuVideoDecodeAccelerator::SendCreateDecoderReply(IPC::Message* message, |
| 518 bool succeeded) { | 563 bool succeeded) { |
| 519 GpuCommandBufferMsg_CreateVideoDecoder::WriteReplyParams(message, succeeded); | 564 GpuCommandBufferMsg_CreateVideoDecoder::WriteReplyParams(message, succeeded); |
| 520 Send(message); | 565 Send(message); |
| 521 } | 566 } |
| 522 | 567 |
| 523 } // namespace content | 568 } // namespace content |
| OLD | NEW |