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

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

Issue 1552863003: Global conversion of Pass()→std::move(): CrOS edition (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 // The bulk of this file is support code; sorry about that. Here's an overview 5 // The bulk of this file is support code; sorry about that. Here's an overview
6 // to hopefully help readers of this code: 6 // to hopefully help readers of this code:
7 // - RenderingHelper is charged with interacting with X11/{EGL/GLES2,GLX/GL} or 7 // - RenderingHelper is charged with interacting with X11/{EGL/GLES2,GLX/GL} or
8 // Win/EGL. 8 // Win/EGL.
9 // - ClientState is an enum for the state of the decode client used by the test. 9 // - ClientState is an enum for the state of the decode client used by the test.
10 // - ClientStateNotification is a barrier abstraction that allows the test code 10 // - ClientStateNotification is a barrier abstraction that allows the test code
11 // to be written sequentially and wait for the decode client to see certain 11 // to be written sequentially and wait for the decode client to see certain
12 // state transitions. 12 // state transitions.
13 // - GLRenderingVDAClient is a VideoDecodeAccelerator::Client implementation 13 // - GLRenderingVDAClient is a VideoDecodeAccelerator::Client implementation
14 // - Finally actual TEST cases are at the bottom of this file, using the above 14 // - Finally actual TEST cases are at the bottom of this file, using the above
15 // infrastructure. 15 // infrastructure.
16 16
17 #include <fcntl.h> 17 #include <fcntl.h>
18 #include <stddef.h> 18 #include <stddef.h>
19 #include <stdint.h> 19 #include <stdint.h>
20 #include <sys/stat.h> 20 #include <sys/stat.h>
21 #include <sys/types.h> 21 #include <sys/types.h>
22 #include <algorithm> 22 #include <algorithm>
23 #include <deque> 23 #include <deque>
24 #include <map> 24 #include <map>
25 25 #include <utility>
26 // Include gtest.h out of order because <X11/X.h> #define's Bool & None, which
27 // gtest uses as struct names (inside a namespace). This means that
28 // #include'ing gtest after anything that pulls in X.h fails to compile.
29 // This is http://code.google.com/p/googletest/issues/detail?id=371
30 #include "testing/gtest/include/gtest/gtest.h"
31 26
32 #include "base/at_exit.h" 27 #include "base/at_exit.h"
33 #include "base/bind.h" 28 #include "base/bind.h"
34 #include "base/callback_helpers.h" 29 #include "base/callback_helpers.h"
35 #include "base/command_line.h" 30 #include "base/command_line.h"
36 #include "base/files/file.h" 31 #include "base/files/file.h"
37 #include "base/files/file_util.h" 32 #include "base/files/file_util.h"
38 #include "base/format_macros.h" 33 #include "base/format_macros.h"
39 #include "base/macros.h" 34 #include "base/macros.h"
40 #include "base/md5.h" 35 #include "base/md5.h"
41 #include "base/process/process_handle.h" 36 #include "base/process/process_handle.h"
42 #include "base/stl_util.h" 37 #include "base/stl_util.h"
43 #include "base/strings/string_number_conversions.h" 38 #include "base/strings/string_number_conversions.h"
44 #include "base/strings/string_split.h" 39 #include "base/strings/string_split.h"
45 #include "base/strings/stringize_macros.h" 40 #include "base/strings/stringize_macros.h"
46 #include "base/strings/stringprintf.h" 41 #include "base/strings/stringprintf.h"
47 #include "base/strings/utf_string_conversions.h" 42 #include "base/strings/utf_string_conversions.h"
48 #include "base/synchronization/condition_variable.h" 43 #include "base/synchronization/condition_variable.h"
49 #include "base/synchronization/lock.h" 44 #include "base/synchronization/lock.h"
50 #include "base/synchronization/waitable_event.h" 45 #include "base/synchronization/waitable_event.h"
51 #include "base/thread_task_runner_handle.h" 46 #include "base/thread_task_runner_handle.h"
52 #include "base/threading/thread.h" 47 #include "base/threading/thread.h"
53 #include "build/build_config.h" 48 #include "build/build_config.h"
54 #include "content/common/gpu/media/fake_video_decode_accelerator.h" 49 #include "content/common/gpu/media/fake_video_decode_accelerator.h"
55 #include "content/common/gpu/media/rendering_helper.h" 50 #include "content/common/gpu/media/rendering_helper.h"
56 #include "content/common/gpu/media/video_accelerator_unittest_helpers.h" 51 #include "content/common/gpu/media/video_accelerator_unittest_helpers.h"
57 #include "content/public/common/content_switches.h" 52 #include "content/public/common/content_switches.h"
58 #include "media/filters/h264_parser.h" 53 #include "media/filters/h264_parser.h"
54 #include "testing/gtest/include/gtest/gtest.h"
59 #include "ui/gfx/codec/png_codec.h" 55 #include "ui/gfx/codec/png_codec.h"
60 #include "ui/gl/gl_image.h" 56 #include "ui/gl/gl_image.h"
61 57
62 #if defined(OS_WIN) 58 #if defined(OS_WIN)
63 #include "base/win/windows_version.h" 59 #include "base/win/windows_version.h"
64 #include "content/common/gpu/media/dxva_video_decode_accelerator_win.h" 60 #include "content/common/gpu/media/dxva_video_decode_accelerator_win.h"
65 #elif defined(OS_CHROMEOS) 61 #elif defined(OS_CHROMEOS)
66 #if defined(USE_V4L2_CODEC) 62 #if defined(USE_V4L2_CODEC)
67 #include "content/common/gpu/media/v4l2_device.h" 63 #include "content/common/gpu/media/v4l2_device.h"
68 #include "content/common/gpu/media/v4l2_slice_video_decode_accelerator.h" 64 #include "content/common/gpu/media/v4l2_slice_video_decode_accelerator.h"
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 506
511 scoped_ptr<media::VideoDecodeAccelerator> 507 scoped_ptr<media::VideoDecodeAccelerator>
512 GLRenderingVDAClient::CreateFakeVDA() { 508 GLRenderingVDAClient::CreateFakeVDA() {
513 scoped_ptr<media::VideoDecodeAccelerator> decoder; 509 scoped_ptr<media::VideoDecodeAccelerator> decoder;
514 if (fake_decoder_) { 510 if (fake_decoder_) {
515 decoder.reset(new FakeVideoDecodeAccelerator( 511 decoder.reset(new FakeVideoDecodeAccelerator(
516 static_cast<gfx::GLContext*> (rendering_helper_->GetGLContextHandle()), 512 static_cast<gfx::GLContext*> (rendering_helper_->GetGLContextHandle()),
517 frame_size_, 513 frame_size_,
518 base::Bind(&DoNothingReturnTrue))); 514 base::Bind(&DoNothingReturnTrue)));
519 } 515 }
520 return decoder.Pass(); 516 return decoder;
521 } 517 }
522 518
523 scoped_ptr<media::VideoDecodeAccelerator> 519 scoped_ptr<media::VideoDecodeAccelerator>
524 GLRenderingVDAClient::CreateDXVAVDA() { 520 GLRenderingVDAClient::CreateDXVAVDA() {
525 scoped_ptr<media::VideoDecodeAccelerator> decoder; 521 scoped_ptr<media::VideoDecodeAccelerator> decoder;
526 #if defined(OS_WIN) 522 #if defined(OS_WIN)
527 if (base::win::GetVersion() >= base::win::VERSION_WIN7) 523 if (base::win::GetVersion() >= base::win::VERSION_WIN7)
528 decoder.reset( 524 decoder.reset(
529 new DXVAVideoDecodeAccelerator( 525 new DXVAVideoDecodeAccelerator(
530 base::Bind(&DoNothingReturnTrue), 526 base::Bind(&DoNothingReturnTrue),
531 rendering_helper_->GetGLContext().get())); 527 rendering_helper_->GetGLContext().get()));
532 #endif 528 #endif
533 return decoder.Pass(); 529 return decoder;
534 } 530 }
535 531
536 scoped_ptr<media::VideoDecodeAccelerator> 532 scoped_ptr<media::VideoDecodeAccelerator>
537 GLRenderingVDAClient::CreateV4L2VDA() { 533 GLRenderingVDAClient::CreateV4L2VDA() {
538 scoped_ptr<media::VideoDecodeAccelerator> decoder; 534 scoped_ptr<media::VideoDecodeAccelerator> decoder;
539 #if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) 535 #if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC)
540 scoped_refptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder); 536 scoped_refptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder);
541 if (device.get()) { 537 if (device.get()) {
542 base::WeakPtr<VideoDecodeAccelerator::Client> weak_client = AsWeakPtr(); 538 base::WeakPtr<VideoDecodeAccelerator::Client> weak_client = AsWeakPtr();
543 decoder.reset(new V4L2VideoDecodeAccelerator( 539 decoder.reset(new V4L2VideoDecodeAccelerator(
544 static_cast<EGLDisplay>(rendering_helper_->GetGLDisplay()), 540 static_cast<EGLDisplay>(rendering_helper_->GetGLDisplay()),
545 static_cast<EGLContext>(rendering_helper_->GetGLContextHandle()), 541 static_cast<EGLContext>(rendering_helper_->GetGLContextHandle()),
546 weak_client, base::Bind(&DoNothingReturnTrue), device, 542 weak_client, base::Bind(&DoNothingReturnTrue), device,
547 base::ThreadTaskRunnerHandle::Get())); 543 base::ThreadTaskRunnerHandle::Get()));
548 } 544 }
549 #endif 545 #endif
550 return decoder.Pass(); 546 return decoder;
551 } 547 }
552 548
553 scoped_ptr<media::VideoDecodeAccelerator> 549 scoped_ptr<media::VideoDecodeAccelerator>
554 GLRenderingVDAClient::CreateV4L2SliceVDA() { 550 GLRenderingVDAClient::CreateV4L2SliceVDA() {
555 scoped_ptr<media::VideoDecodeAccelerator> decoder; 551 scoped_ptr<media::VideoDecodeAccelerator> decoder;
556 #if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) 552 #if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC)
557 scoped_refptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder); 553 scoped_refptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder);
558 if (device.get()) { 554 if (device.get()) {
559 base::WeakPtr<VideoDecodeAccelerator::Client> weak_client = AsWeakPtr(); 555 base::WeakPtr<VideoDecodeAccelerator::Client> weak_client = AsWeakPtr();
560 decoder.reset(new V4L2SliceVideoDecodeAccelerator( 556 decoder.reset(new V4L2SliceVideoDecodeAccelerator(
561 device, static_cast<EGLDisplay>(rendering_helper_->GetGLDisplay()), 557 device, static_cast<EGLDisplay>(rendering_helper_->GetGLDisplay()),
562 static_cast<EGLContext>(rendering_helper_->GetGLContextHandle()), 558 static_cast<EGLContext>(rendering_helper_->GetGLContextHandle()),
563 weak_client, base::Bind(&DoNothingReturnTrue), 559 weak_client, base::Bind(&DoNothingReturnTrue),
564 base::ThreadTaskRunnerHandle::Get())); 560 base::ThreadTaskRunnerHandle::Get()));
565 } 561 }
566 #endif 562 #endif
567 return decoder.Pass(); 563 return decoder;
568 } 564 }
569 565
570 scoped_ptr<media::VideoDecodeAccelerator> 566 scoped_ptr<media::VideoDecodeAccelerator>
571 GLRenderingVDAClient::CreateVaapiVDA() { 567 GLRenderingVDAClient::CreateVaapiVDA() {
572 scoped_ptr<media::VideoDecodeAccelerator> decoder; 568 scoped_ptr<media::VideoDecodeAccelerator> decoder;
573 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) 569 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
574 decoder.reset(new VaapiVideoDecodeAccelerator( 570 decoder.reset(new VaapiVideoDecodeAccelerator(
575 base::Bind(&DoNothingReturnTrue), 571 base::Bind(&DoNothingReturnTrue),
576 base::Bind(&GLRenderingVDAClient::BindImage, base::Unretained(this)))); 572 base::Bind(&GLRenderingVDAClient::BindImage, base::Unretained(this))));
577 #endif 573 #endif
578 return decoder.Pass(); 574 return decoder;
579 } 575 }
580 576
581 void GLRenderingVDAClient::BindImage(uint32_t client_texture_id, 577 void GLRenderingVDAClient::BindImage(uint32_t client_texture_id,
582 uint32_t texture_target, 578 uint32_t texture_target,
583 scoped_refptr<gl::GLImage> image) {} 579 scoped_refptr<gl::GLImage> image) {}
584 580
585 void GLRenderingVDAClient::CreateAndStartDecoder() { 581 void GLRenderingVDAClient::CreateAndStartDecoder() {
586 LOG_ASSERT(decoder_deleted()); 582 LOG_ASSERT(decoder_deleted());
587 LOG_ASSERT(!decoder_.get()); 583 LOG_ASSERT(!decoder_.get());
588 584
589 VideoDecodeAccelerator::Client* client = this; 585 VideoDecodeAccelerator::Client* client = this;
590 586
591 scoped_ptr<media::VideoDecodeAccelerator> decoders[] = { 587 scoped_ptr<media::VideoDecodeAccelerator> decoders[] = {
592 CreateFakeVDA(), 588 CreateFakeVDA(),
593 CreateDXVAVDA(), 589 CreateDXVAVDA(),
594 CreateV4L2VDA(), 590 CreateV4L2VDA(),
595 CreateV4L2SliceVDA(), 591 CreateV4L2SliceVDA(),
596 CreateVaapiVDA(), 592 CreateVaapiVDA(),
597 }; 593 };
598 594
599 for (size_t i = 0; i < arraysize(decoders); ++i) { 595 for (size_t i = 0; i < arraysize(decoders); ++i) {
600 if (!decoders[i]) 596 if (!decoders[i])
601 continue; 597 continue;
602 decoder_ = decoders[i].Pass(); 598 decoder_ = std::move(decoders[i]);
603 weak_decoder_factory_.reset( 599 weak_decoder_factory_.reset(
604 new base::WeakPtrFactory<VideoDecodeAccelerator>(decoder_.get())); 600 new base::WeakPtrFactory<VideoDecodeAccelerator>(decoder_.get()));
605 if (decoder_->Initialize(profile_, client)) { 601 if (decoder_->Initialize(profile_, client)) {
606 SetState(CS_DECODER_SET); 602 SetState(CS_DECODER_SET);
607 FinishInitialization(); 603 FinishInitialization();
608 return; 604 return;
609 } 605 }
610 } 606 }
611 // Decoders are all initialize failed. 607 // Decoders are all initialize failed.
612 LOG(ERROR) << "VideoDecodeAccelerator::Initialize() failed"; 608 LOG(ERROR) << "VideoDecodeAccelerator::Initialize() failed";
(...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after
1658 content::VaapiWrapper::PreSandboxInitialization(); 1654 content::VaapiWrapper::PreSandboxInitialization();
1659 #endif 1655 #endif
1660 1656
1661 content::g_env = 1657 content::g_env =
1662 reinterpret_cast<content::VideoDecodeAcceleratorTestEnvironment*>( 1658 reinterpret_cast<content::VideoDecodeAcceleratorTestEnvironment*>(
1663 testing::AddGlobalTestEnvironment( 1659 testing::AddGlobalTestEnvironment(
1664 new content::VideoDecodeAcceleratorTestEnvironment())); 1660 new content::VideoDecodeAcceleratorTestEnvironment()));
1665 1661
1666 return RUN_ALL_TESTS(); 1662 return RUN_ALL_TESTS();
1667 } 1663 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698