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" |
(...skipping 28 matching lines...) Expand all Loading... |
39 #include "content/common/gpu/media/v4l2_slice_video_decode_accelerator.h" | 39 #include "content/common/gpu/media/v4l2_slice_video_decode_accelerator.h" |
40 #include "content/common/gpu/media/v4l2_video_decode_accelerator.h" | 40 #include "content/common/gpu/media/v4l2_video_decode_accelerator.h" |
41 #endif | 41 #endif |
42 #if defined(ARCH_CPU_X86_FAMILY) | 42 #if defined(ARCH_CPU_X86_FAMILY) |
43 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h" | 43 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h" |
44 #include "ui/gl/gl_implementation.h" | 44 #include "ui/gl/gl_implementation.h" |
45 #endif | 45 #endif |
46 #elif defined(USE_OZONE) | 46 #elif defined(USE_OZONE) |
47 #include "media/ozone/media_ozone_platform.h" | 47 #include "media/ozone/media_ozone_platform.h" |
48 #elif defined(OS_ANDROID) | 48 #elif defined(OS_ANDROID) |
49 #include "content/common/gpu/media/android_copying_backing_strategy.h" | |
50 #include "content/common/gpu/media/android_deferred_rendering_backing_strategy.h
" | |
51 #include "content/common/gpu/media/android_video_decode_accelerator.h" | 49 #include "content/common/gpu/media/android_video_decode_accelerator.h" |
52 #endif | 50 #endif |
53 | 51 |
54 #include "ui/gfx/geometry/size.h" | 52 #include "ui/gfx/geometry/size.h" |
55 | 53 |
56 namespace content { | 54 namespace content { |
57 | 55 |
58 static bool MakeDecoderContextCurrent( | 56 static bool MakeDecoderContextCurrent( |
59 const base::WeakPtr<GpuCommandBufferStub> stub) { | 57 const base::WeakPtr<GpuCommandBufferStub> stub) { |
60 if (!stub) { | 58 if (!stub) { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 base::Bind(&MakeDecoderContextCurrent, stub_->AsWeakPtr()); | 143 base::Bind(&MakeDecoderContextCurrent, stub_->AsWeakPtr()); |
146 } | 144 } |
147 | 145 |
148 GpuVideoDecodeAccelerator::~GpuVideoDecodeAccelerator() { | 146 GpuVideoDecodeAccelerator::~GpuVideoDecodeAccelerator() { |
149 // This class can only be self-deleted from OnWillDestroyStub(), which means | 147 // This class can only be self-deleted from OnWillDestroyStub(), which means |
150 // the VDA has already been destroyed in there. | 148 // the VDA has already been destroyed in there. |
151 DCHECK(!video_decode_accelerator_); | 149 DCHECK(!video_decode_accelerator_); |
152 } | 150 } |
153 | 151 |
154 // static | 152 // static |
155 gpu::VideoDecodeAcceleratorSupportedProfiles | 153 gpu::VideoDecodeAcceleratorCapabilities |
156 GpuVideoDecodeAccelerator::GetSupportedProfiles() { | 154 GpuVideoDecodeAccelerator::GetCapabilities() { |
157 media::VideoDecodeAccelerator::SupportedProfiles profiles; | 155 media::VideoDecodeAccelerator::Capabilities capabilities; |
158 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | 156 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
159 if (cmd_line->HasSwitch(switches::kDisableAcceleratedVideoDecode)) | 157 if (cmd_line->HasSwitch(switches::kDisableAcceleratedVideoDecode)) |
160 return gpu::VideoDecodeAcceleratorSupportedProfiles(); | 158 return gpu::VideoDecodeAcceleratorCapabilities(); |
161 | 159 |
162 // Query supported profiles for each VDA. The order of querying VDAs should | 160 // Query supported profiles for each VDA. The order of querying VDAs should |
163 // be the same as the order of initializing VDAs. Then the returned profile | 161 // be the same as the order of initializing VDAs. Then the returned profile |
164 // can be initialized by corresponding VDA successfully. | 162 // can be initialized by corresponding VDA successfully. |
165 #if defined(OS_WIN) | 163 #if defined(OS_WIN) |
166 profiles = DXVAVideoDecodeAccelerator::GetSupportedProfiles(); | 164 capabilities.supported_profiles = |
| 165 DXVAVideoDecodeAccelerator::GetSupportedProfiles(); |
167 #elif defined(OS_CHROMEOS) | 166 #elif defined(OS_CHROMEOS) |
168 media::VideoDecodeAccelerator::SupportedProfiles vda_profiles; | 167 media::VideoDecodeAccelerator::SupportedProfiles vda_profiles; |
169 #if defined(USE_V4L2_CODEC) | 168 #if defined(USE_V4L2_CODEC) |
170 vda_profiles = V4L2VideoDecodeAccelerator::GetSupportedProfiles(); | 169 vda_profiles = V4L2VideoDecodeAccelerator::GetSupportedProfiles(); |
171 GpuVideoAcceleratorUtil::InsertUniqueDecodeProfiles(vda_profiles, &profiles); | 170 GpuVideoAcceleratorUtil::InsertUniqueDecodeProfiles( |
| 171 vda_profiles, &capabilities.supported_profiles); |
172 vda_profiles = V4L2SliceVideoDecodeAccelerator::GetSupportedProfiles(); | 172 vda_profiles = V4L2SliceVideoDecodeAccelerator::GetSupportedProfiles(); |
173 GpuVideoAcceleratorUtil::InsertUniqueDecodeProfiles(vda_profiles, &profiles); | 173 GpuVideoAcceleratorUtil::InsertUniqueDecodeProfiles( |
| 174 vda_profiles, &capabilities.supported_profiles); |
174 #endif | 175 #endif |
175 #if defined(ARCH_CPU_X86_FAMILY) | 176 #if defined(ARCH_CPU_X86_FAMILY) |
176 vda_profiles = VaapiVideoDecodeAccelerator::GetSupportedProfiles(); | 177 vda_profiles = VaapiVideoDecodeAccelerator::GetSupportedProfiles(); |
177 GpuVideoAcceleratorUtil::InsertUniqueDecodeProfiles(vda_profiles, &profiles); | 178 GpuVideoAcceleratorUtil::InsertUniqueDecodeProfiles( |
| 179 vda_profiles, &capabilities.supported_profiles); |
178 #endif | 180 #endif |
179 #elif defined(OS_MACOSX) | 181 #elif defined(OS_MACOSX) |
180 profiles = VTVideoDecodeAccelerator::GetSupportedProfiles(); | 182 capabilities.supported_profiles = |
| 183 VTVideoDecodeAccelerator::GetSupportedProfiles(); |
181 #elif defined(OS_ANDROID) | 184 #elif defined(OS_ANDROID) |
182 profiles = AndroidVideoDecodeAccelerator::GetSupportedProfiles(); | 185 capabilities = AndroidVideoDecodeAccelerator::GetCapabilities(); |
183 #endif | 186 #endif |
184 return GpuVideoAcceleratorUtil::ConvertMediaToGpuDecodeProfiles(profiles); | 187 return GpuVideoAcceleratorUtil::ConvertMediaToGpuDecodeCapabilities( |
| 188 capabilities); |
185 } | 189 } |
186 | 190 |
187 bool GpuVideoDecodeAccelerator::OnMessageReceived(const IPC::Message& msg) { | 191 bool GpuVideoDecodeAccelerator::OnMessageReceived(const IPC::Message& msg) { |
188 if (!video_decode_accelerator_) | 192 if (!video_decode_accelerator_) |
189 return false; | 193 return false; |
190 | 194 |
191 bool handled = true; | 195 bool handled = true; |
192 IPC_BEGIN_MESSAGE_MAP(GpuVideoDecodeAccelerator, msg) | 196 IPC_BEGIN_MESSAGE_MAP(GpuVideoDecodeAccelerator, msg) |
193 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderMsg_SetCdm, OnSetCdm) | 197 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderMsg_SetCdm, OnSetCdm) |
194 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderMsg_Decode, OnDecode) | 198 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderMsg_Decode, OnDecode) |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 media::MediaOzonePlatform::GetInstance(); | 470 media::MediaOzonePlatform::GetInstance(); |
467 decoder.reset(platform->CreateVideoDecodeAccelerator(make_context_current_)); | 471 decoder.reset(platform->CreateVideoDecodeAccelerator(make_context_current_)); |
468 #endif | 472 #endif |
469 return decoder.Pass(); | 473 return decoder.Pass(); |
470 } | 474 } |
471 | 475 |
472 scoped_ptr<media::VideoDecodeAccelerator> | 476 scoped_ptr<media::VideoDecodeAccelerator> |
473 GpuVideoDecodeAccelerator::CreateAndroidVDA() { | 477 GpuVideoDecodeAccelerator::CreateAndroidVDA() { |
474 scoped_ptr<media::VideoDecodeAccelerator> decoder; | 478 scoped_ptr<media::VideoDecodeAccelerator> decoder; |
475 #if defined(OS_ANDROID) | 479 #if defined(OS_ANDROID) |
476 decoder.reset(new AndroidVideoDecodeAccelerator( | 480 decoder.reset(new AndroidVideoDecodeAccelerator(stub_->decoder()->AsWeakPtr(), |
477 stub_->decoder()->AsWeakPtr(), make_context_current_, | 481 make_context_current_)); |
478 make_scoped_ptr( | |
479 #if defined(ENABLE_MEDIA_PIPELINE_ON_ANDROID) | |
480 new AndroidDeferredRenderingBackingStrategy() | |
481 #else | |
482 new AndroidCopyingBackingStrategy() | |
483 #endif | |
484 ))); | |
485 #endif | 482 #endif |
486 return decoder.Pass(); | 483 return decoder.Pass(); |
487 } | 484 } |
488 | 485 |
489 void GpuVideoDecodeAccelerator::OnSetCdm(int cdm_id) { | 486 void GpuVideoDecodeAccelerator::OnSetCdm(int cdm_id) { |
490 DCHECK(video_decode_accelerator_); | 487 DCHECK(video_decode_accelerator_); |
491 video_decode_accelerator_->SetCdm(cdm_id); | 488 video_decode_accelerator_->SetCdm(cdm_id); |
492 } | 489 } |
493 | 490 |
494 // Runs on IO thread if video_decode_accelerator_->CanDecodeOnIOThread() is | 491 // Runs on IO thread if video_decode_accelerator_->CanDecodeOnIOThread() is |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 uncleared_textures_.erase(it); | 636 uncleared_textures_.erase(it); |
640 } | 637 } |
641 | 638 |
642 void GpuVideoDecodeAccelerator::SendCreateDecoderReply(IPC::Message* message, | 639 void GpuVideoDecodeAccelerator::SendCreateDecoderReply(IPC::Message* message, |
643 bool succeeded) { | 640 bool succeeded) { |
644 GpuCommandBufferMsg_CreateVideoDecoder::WriteReplyParams(message, succeeded); | 641 GpuCommandBufferMsg_CreateVideoDecoder::WriteReplyParams(message, succeeded); |
645 Send(message); | 642 Send(message); |
646 } | 643 } |
647 | 644 |
648 } // namespace content | 645 } // namespace content |
OLD | NEW |