Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(372)

Side by Side Diff: content/common/gpu/media/gpu_video_decode_accelerator.cc

Issue 826663002: Support multiple video decoders and encoders (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 16 matching lines...) Expand all
27 #include "base/win/windows_version.h" 27 #include "base/win/windows_version.h"
28 #include "content/common/gpu/media/dxva_video_decode_accelerator.h" 28 #include "content/common/gpu/media/dxva_video_decode_accelerator.h"
29 #elif defined(OS_MACOSX) 29 #elif defined(OS_MACOSX)
30 #include "content/common/gpu/media/vt_video_decode_accelerator.h" 30 #include "content/common/gpu/media/vt_video_decode_accelerator.h"
31 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) && defined(USE_X11) 31 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) && defined(USE_X11)
32 #include "content/common/gpu/media/v4l2_video_decode_accelerator.h" 32 #include "content/common/gpu/media/v4l2_video_decode_accelerator.h"
33 #include "content/common/gpu/media/v4l2_video_device.h" 33 #include "content/common/gpu/media/v4l2_video_device.h"
34 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) 34 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
35 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h" 35 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h"
36 #include "ui/gl/gl_implementation.h" 36 #include "ui/gl/gl_implementation.h"
37 #if defined(USE_X11)
38 #include "content/common/gpu/media/v4l2_video_decode_accelerator.h"
39 #include "content/common/gpu/media/v4l2_video_device.h"
40 #endif
37 #elif defined(USE_OZONE) 41 #elif defined(USE_OZONE)
38 #include "media/ozone/media_ozone_platform.h" 42 #include "media/ozone/media_ozone_platform.h"
39 #elif defined(OS_ANDROID) 43 #elif defined(OS_ANDROID)
40 #include "content/common/gpu/media/android_video_decode_accelerator.h" 44 #include "content/common/gpu/media/android_video_decode_accelerator.h"
41 #endif 45 #endif
42 46
43 #include "ui/gfx/size.h" 47 #include "ui/gfx/size.h"
44 48
45 namespace content { 49 namespace content {
46 50
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 241
238 #if !defined(OS_WIN) 242 #if !defined(OS_WIN)
239 // Ensure we will be able to get a GL context at all before initializing 243 // Ensure we will be able to get a GL context at all before initializing
240 // non-Windows VDAs. 244 // non-Windows VDAs.
241 if (!make_context_current_.Run()) { 245 if (!make_context_current_.Run()) {
242 SendCreateDecoderReply(init_done_msg, false); 246 SendCreateDecoderReply(init_done_msg, false);
243 return; 247 return;
244 } 248 }
245 #endif 249 #endif
246 250
247 #if defined(OS_WIN) 251 std::vector<GpuVideoDecodeAccelerator::CreateVDACb>
248 if (base::win::GetVersion() < base::win::VERSION_WIN7) { 252 create_vda_cbs = CreateVDACbs();
249 NOTIMPLEMENTED() << "HW video decode acceleration not available."; 253
250 SendCreateDecoderReply(init_done_msg, false); 254 for (size_t i = 0; i < create_vda_cbs.size(); ++i) {
255 video_decode_accelerator_ = create_vda_cbs[i].Run();
256 if (!video_decode_accelerator_ ||
257 !video_decode_accelerator_->Initialize(profile, this))
258 continue;
259
260 if (video_decode_accelerator_->CanDecodeOnIOThread()) {
261 filter_ = new MessageFilter(this, host_route_id_);
262 stub_->channel()->AddFilter(filter_.get());
263 }
264 SendCreateDecoderReply(init_done_msg, true);
251 return; 265 return;
252 } 266 }
253 DVLOG(0) << "Initializing DXVA HW decoder for windows."; 267 video_decode_accelerator_.reset();
254 video_decode_accelerator_.reset( 268 NOTIMPLEMENTED() << "HW video decode acceleration not available.";
255 new DXVAVideoDecodeAccelerator(make_context_current_)); 269 SendCreateDecoderReply(init_done_msg, false);
256 #elif defined(OS_MACOSX) 270 }
257 video_decode_accelerator_.reset(new VTVideoDecodeAccelerator( 271
258 static_cast<CGLContextObj>( 272 std::vector<GpuVideoDecodeAccelerator::CreateVDACb>
259 stub_->decoder()->GetGLContext()->GetHandle()), 273 GpuVideoDecodeAccelerator::CreateVDACbs() {
274 std::vector<GpuVideoDecodeAccelerator::CreateVDACb> create_vda_cbs;
275 create_vda_cbs.push_back(base::Bind(
276 &GpuVideoDecodeAccelerator::CreateDXVAVDA, base::Unretained(this)));
277 create_vda_cbs.push_back(base::Bind(
278 &GpuVideoDecodeAccelerator::CreateV4L2VDA, base::Unretained(this)));
279 create_vda_cbs.push_back(base::Bind(
280 &GpuVideoDecodeAccelerator::CreateVaapiVDA, base::Unretained(this)));
281 create_vda_cbs.push_back(base::Bind(
282 &GpuVideoDecodeAccelerator::CreateVTVDA, base::Unretained(this)));
283 create_vda_cbs.push_back(base::Bind(
284 &GpuVideoDecodeAccelerator::CreateAndroidVDA,
285 base::Unretained(this)));
286 create_vda_cbs.push_back(base::Bind(
287 &GpuVideoDecodeAccelerator::CreateOzoneVDA, base::Unretained(this)));
288 return create_vda_cbs;
289 }
290
291 scoped_ptr<media::VideoDecodeAccelerator>
292 GpuVideoDecodeAccelerator::CreateDXVAVDA() {
293 scoped_ptr<media::VideoDecodeAccelerator> decoder;
294 #if defined(OS_WIN)
295 if (base::win::GetVersion() >= base::win::VERSION_WIN7) {
296 DVLOG(0) << "Initializing DXVA HW decoder for windows.";
297 decoder.reset(new DXVAVideoDecodeAccelerator(make_context_current_));
298 } else {
299 NOTIMPLEMENTED() << "HW video decode acceleration not available.";
300 }
301 #endif
302 return decoder.Pass();
303 }
304
305 scoped_ptr<media::VideoDecodeAccelerator>
306 GpuVideoDecodeAccelerator::CreateV4L2VDA() {
307 scoped_ptr<media::VideoDecodeAccelerator> decoder;
308 #if defined(OS_CHROMEOS) && defined(USE_X11) && \
309 (defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARMEL))
310 scoped_ptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder);
311 if (device.get()) {
312 decoder.reset(new V4L2VideoDecodeAccelerator(
313 gfx::GLSurfaceEGL::GetHardwareDisplay(),
314 stub_->decoder()->GetGLContext()->GetHandle(),
315 weak_factory_for_io_.GetWeakPtr(),
316 make_context_current_,
317 device.Pass(),
318 io_message_loop_));
319 }
320 #endif
321 return decoder.Pass();
322 }
323
324 scoped_ptr<media::VideoDecodeAccelerator>
325 GpuVideoDecodeAccelerator::CreateVaapiVDA() {
326 scoped_ptr<media::VideoDecodeAccelerator> decoder;
327 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
328 decoder.reset(new VaapiVideoDecodeAccelerator(make_context_current_));
329 #endif
330 return decoder.Pass();
331 }
332
333 scoped_ptr<media::VideoDecodeAccelerator>
334 GpuVideoDecodeAccelerator::CreateVTVDA() {
335 scoped_ptr<media::VideoDecodeAccelerator> decoder;
336 #if defined(OS_MACOSX)
337 decoder.reset(new VTVideoDecodeAccelerator(
338 static_cast<CGLContextObj>(stub_->decoder()->GetGLContext()->GetHandle()),
260 make_context_current_)); 339 make_context_current_));
261 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) && defined(USE_X11) 340 #endif
262 scoped_ptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder); 341 return decoder.Pass();
263 if (!device.get()) { 342 }
264 SendCreateDecoderReply(init_done_msg, false); 343
265 return; 344 scoped_ptr<media::VideoDecodeAccelerator>
266 } 345 GpuVideoDecodeAccelerator::CreateAndroidVDA() {
267 video_decode_accelerator_.reset(new V4L2VideoDecodeAccelerator( 346 scoped_ptr<media::VideoDecodeAccelerator> decoder;
268 gfx::GLSurfaceEGL::GetHardwareDisplay(), 347 #if defined(OS_ANDROID)
269 stub_->decoder()->GetGLContext()->GetHandle(), 348 decoder.reset(new AndroidVideoDecodeAccelerator(
270 weak_factory_for_io_.GetWeakPtr(), 349 stub_->decoder()->AsWeakPtr(),
271 make_context_current_, 350 make_context_current_));
272 device.Pass(), 351 #endif
273 io_message_loop_)); 352 return decoder.Pass();
274 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) 353 }
275 video_decode_accelerator_.reset( 354
276 new VaapiVideoDecodeAccelerator(make_context_current_)); 355 scoped_ptr<media::VideoDecodeAccelerator>
277 #elif defined(USE_OZONE) 356 GpuVideoDecodeAccelerator::CreateOzoneVDA() {
357 scoped_ptr<media::VideoDecodeAccelerator> decoder;
358 #if defined(USE_OZONE)
Pawel Osciak 2015/01/02 05:46:24 This fails on freon boards. It should be: #if !de
278 media::MediaOzonePlatform* platform = 359 media::MediaOzonePlatform* platform =
279 media::MediaOzonePlatform::GetInstance(); 360 media::MediaOzonePlatform::GetInstance();
280 video_decode_accelerator_.reset(platform->CreateVideoDecodeAccelerator( 361 decoder.reset(platform->CreateVideoDecodeAccelerator(make_context_current_));
281 make_context_current_));
282 if (!video_decode_accelerator_) {
283 SendCreateDecoderReply(init_done_msg, false);
284 return;
285 }
286 #elif defined(OS_ANDROID)
287 video_decode_accelerator_.reset(new AndroidVideoDecodeAccelerator(
288 stub_->decoder()->AsWeakPtr(),
289 make_context_current_));
290 #else
291 NOTIMPLEMENTED() << "HW video decode acceleration not available.";
292 SendCreateDecoderReply(init_done_msg, false);
293 return;
294 #endif 362 #endif
295 363 return decoder.Pass();
296 if (video_decode_accelerator_->CanDecodeOnIOThread()) {
297 filter_ = new MessageFilter(this, host_route_id_);
298 stub_->channel()->AddFilter(filter_.get());
299 }
300
301 if (!video_decode_accelerator_->Initialize(profile, this)) {
302 SendCreateDecoderReply(init_done_msg, false);
303 return;
304 }
305
306 SendCreateDecoderReply(init_done_msg, true);
307 } 364 }
308 365
309 // Runs on IO thread if video_decode_accelerator_->CanDecodeOnIOThread() is 366 // Runs on IO thread if video_decode_accelerator_->CanDecodeOnIOThread() is
310 // true, otherwise on the main thread. 367 // true, otherwise on the main thread.
311 void GpuVideoDecodeAccelerator::OnDecode( 368 void GpuVideoDecodeAccelerator::OnDecode(
312 base::SharedMemoryHandle handle, int32 id, uint32 size) { 369 base::SharedMemoryHandle handle, int32 id, uint32 size) {
313 DCHECK(video_decode_accelerator_.get()); 370 DCHECK(video_decode_accelerator_.get());
314 if (id < 0) { 371 if (id < 0) {
315 DLOG(ERROR) << "BitstreamBuffer id " << id << " out of range"; 372 DLOG(ERROR) << "BitstreamBuffer id " << id << " out of range";
316 if (child_message_loop_->BelongsToCurrentThread()) { 373 if (child_message_loop_->BelongsToCurrentThread()) {
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 return stub_->channel()->Send(message); 562 return stub_->channel()->Send(message);
506 } 563 }
507 564
508 void GpuVideoDecodeAccelerator::SendCreateDecoderReply(IPC::Message* message, 565 void GpuVideoDecodeAccelerator::SendCreateDecoderReply(IPC::Message* message,
509 bool succeeded) { 566 bool succeeded) {
510 GpuCommandBufferMsg_CreateVideoDecoder::WriteReplyParams(message, succeeded); 567 GpuCommandBufferMsg_CreateVideoDecoder::WriteReplyParams(message, succeeded);
511 Send(message); 568 Send(message);
512 } 569 }
513 570
514 } // namespace content 571 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/media/gpu_video_decode_accelerator.h ('k') | content/common/gpu/media/gpu_video_encode_accelerator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698