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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 media::MediaOzonePlatform::GetInstance(); | 469 media::MediaOzonePlatform::GetInstance(); |
466 decoder.reset(platform->CreateVideoDecodeAccelerator(make_context_current_)); | 470 decoder.reset(platform->CreateVideoDecodeAccelerator(make_context_current_)); |
467 #endif | 471 #endif |
468 return decoder.Pass(); | 472 return decoder.Pass(); |
469 } | 473 } |
470 | 474 |
471 scoped_ptr<media::VideoDecodeAccelerator> | 475 scoped_ptr<media::VideoDecodeAccelerator> |
472 GpuVideoDecodeAccelerator::CreateAndroidVDA() { | 476 GpuVideoDecodeAccelerator::CreateAndroidVDA() { |
473 scoped_ptr<media::VideoDecodeAccelerator> decoder; | 477 scoped_ptr<media::VideoDecodeAccelerator> decoder; |
474 #if defined(OS_ANDROID) | 478 #if defined(OS_ANDROID) |
475 decoder.reset(new AndroidVideoDecodeAccelerator( | 479 decoder.reset(new AndroidVideoDecodeAccelerator(stub_->decoder()->AsWeakPtr(), |
476 stub_->decoder()->AsWeakPtr(), make_context_current_, | 480 make_context_current_)); |
477 make_scoped_ptr( | |
478 #if defined(ENABLE_MEDIA_PIPELINE_ON_ANDROID) | |
479 new AndroidDeferredRenderingBackingStrategy() | |
480 #else | |
481 new AndroidCopyingBackingStrategy() | |
482 #endif | |
483 ))); | |
484 #endif | 481 #endif |
485 return decoder.Pass(); | 482 return decoder.Pass(); |
486 } | 483 } |
487 | 484 |
488 void GpuVideoDecodeAccelerator::OnSetCdm(int cdm_id) { | 485 void GpuVideoDecodeAccelerator::OnSetCdm(int cdm_id) { |
489 DCHECK(video_decode_accelerator_); | 486 DCHECK(video_decode_accelerator_); |
490 video_decode_accelerator_->SetCdm(cdm_id); | 487 video_decode_accelerator_->SetCdm(cdm_id); |
491 } | 488 } |
492 | 489 |
493 // Runs on IO thread if video_decode_accelerator_->CanDecodeOnIOThread() is | 490 // Runs on IO thread if video_decode_accelerator_->CanDecodeOnIOThread() is |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 uncleared_textures_.erase(it); | 635 uncleared_textures_.erase(it); |
639 } | 636 } |
640 | 637 |
641 void GpuVideoDecodeAccelerator::SendCreateDecoderReply(IPC::Message* message, | 638 void GpuVideoDecodeAccelerator::SendCreateDecoderReply(IPC::Message* message, |
642 bool succeeded) { | 639 bool succeeded) { |
643 GpuCommandBufferMsg_CreateVideoDecoder::WriteReplyParams(message, succeeded); | 640 GpuCommandBufferMsg_CreateVideoDecoder::WriteReplyParams(message, succeeded); |
644 Send(message); | 641 Send(message); |
645 } | 642 } |
646 | 643 |
647 } // namespace content | 644 } // namespace content |
OLD | NEW |