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

Side by Side Diff: ppapi/tests/test_video_decoder.cc

Issue 6961018: Pepper Video Decoder API tester plugin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase & compilation fixes related to it. Created 9 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « ppapi/tests/test_video_decoder.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "ppapi/tests/test_video_decoder.h" 5 #include "ppapi/tests/test_video_decoder.h"
6 6
7 #include "ppapi/c/dev/ppb_video_decoder_dev.h" 7 #include <vector>
8
9 #include "ppapi/c/pp_errors.h"
8 #include "ppapi/c/dev/ppb_testing_dev.h" 10 #include "ppapi/c/dev/ppb_testing_dev.h"
9 #include "ppapi/c/ppb_var.h" 11 #include "ppapi/tests/test_utils.h"
10 #include "ppapi/tests/testing_instance.h" 12 #include "ppapi/tests/testing_instance.h"
11 13
12 REGISTER_TEST_CASE(VideoDecoder); 14 REGISTER_TEST_CASE(VideoDecoder);
13 15
14 bool TestVideoDecoder::Init() { 16 bool TestVideoDecoder::Init() {
15 video_decoder_interface_ = reinterpret_cast<PPB_VideoDecoder_Dev const*>( 17 return InitTestingInterface();
16 pp::Module::Get()->GetBrowserInterface(PPB_VIDEODECODER_DEV_INTERFACE));
17 var_interface_ = reinterpret_cast<PPB_Var const*>(
18 pp::Module::Get()->GetBrowserInterface(PPB_VAR_INTERFACE));
19 return video_decoder_interface_ && var_interface_ && InitTestingInterface();
20 } 18 }
21 19
22 void TestVideoDecoder::RunTest() { 20 void TestVideoDecoder::RunTest() {
23 instance_->LogTest("Create", TestCreate()); 21 instance_->LogTest("H264", TestH264());
24 } 22 }
25 23
26 void TestVideoDecoder::QuitMessageLoop() { 24 void TestVideoDecoder::QuitMessageLoop() {
27 testing_interface_->QuitMessageLoop(instance_->pp_instance()); 25 testing_interface_->QuitMessageLoop(instance_->pp_instance());
28 } 26 }
29 27
30 std::string TestVideoDecoder::TestCreate() { 28 std::string TestVideoDecoder::TestH264() {
31 PP_Resource decoder = video_decoder_interface_->Create( 29 test_result_ = 0;
32 instance_->pp_instance(), NULL, PP_MakeCompletionCallback(NULL, NULL)); 30 test_completed_ = false;
33 if (decoder == 0) { 31 // Set-up the local video bitstream source.
34 return "Error creating the decoder"; 32 video_bitstream_source_ = new LocalVideoBitstreamSource("test-25fps.264");
33 if (!video_bitstream_source_) {
34 return "Failed to create local video bitstream source";
35 }
36
37 // Set up the display.
38 PP_Size surface_size = { 320, 240 };
39 GLES2Display* display = new GLES2Display(instance_, surface_size);
40 if (!display || !display->Initialize()) {
41 return "Failed to initialize GLES2Display";
42 }
43 display_interface_ = display;
44
45 // Create and initialize the video decoding engine.
46 video_decoder_session_ = new VideoDecoderSession(
47 instance_, this, video_bitstream_source_, display_interface_);
48 PP_VideoConfigElement decoder_cfg[] = {
49 PP_VIDEOATTR_BITSTREAMFORMATKEY_FOURCC, PP_VIDEOCODECFOURCC_H264,
50 PP_VIDEOATTR_BITSTREAMFORMATKEY_WIDTH, 320,
51 PP_VIDEOATTR_BITSTREAMFORMATKEY_HEIGHT, 240,
52 // TODO(vmr): Correct colorformat once the CL lands.
53 PP_VIDEOATTR_COLORFORMAT_RGBA, 0,
54 PP_VIDEOATTR_DICTIONARY_TERMINATOR
55 };
56 if (!video_decoder_session_ ||
57 !video_decoder_session_->Initialize(
58 decoder_cfg,
59 cb_factory_.NewCallback(&TestVideoDecoder::OnInitializeCompleted))) {
60 return "Failed to initialize VideoDecoderSession";
61 }
62
63 // Wait the test to complete. By assigning the TestCompletionCallback into
64 // pp::CompletionCallback we are registering completion callback which waits
65 // until the latter is initiated.
66 int32_t result = WaitForCompletion();
67 if (result) {
68 return "Test failed during the decoding process with result: " + result;
35 } 69 }
36 PASS(); 70 PASS();
37 } 71 }
72
73 // Wait for the completion of test.
74 int32_t TestVideoDecoder::WaitForCompletion() {
75 // TODO(vmr): Get rid of ugly busy-loop in platform independent,
76 // Pepper-compatible manner for synchronization.
77 while (!test_completed_);
78 return test_result_;
79 }
80
81 void TestVideoDecoder::OnSessionCompleted(int32_t result) {
82 test_result_ = result;
83 test_completed_ = true;
84 }
85
86 void TestVideoDecoder::OnInitializeCompleted(int32_t result) {
87 if (result != PP_OK) {
88 OnSessionCompleted(result);
89 }
90 video_decoder_session_->Run(
91 cb_factory_.NewCallback(&TestVideoDecoder::OnRunCompleted));
92 }
93
94 void TestVideoDecoder::OnRunCompleted(int32_t result) {
95 if (result != PP_OK) {
96 OnSessionCompleted(result);
97 }
98 // No action needed, just let the session continue until it runs out.
99 }
100
101 void TestVideoDecoder::OnStopCompleted(int32_t result) {
102 if (result != PP_OK) {
103 OnSessionCompleted(result);
104 }
105 video_decoder_session_->Teardown(
106 cb_factory_.NewCallback(&TestVideoDecoder::OnTeardownCompleted));
107 }
108
109 void TestVideoDecoder::OnFlushCompleted(int32_t result) {
110 if (result != PP_OK) {
111 OnSessionCompleted(result);
112 }
113 // No action needed, just let the session continue.
114 }
115
116 void TestVideoDecoder::OnTeardownCompleted(int32_t result) {
117 OnSessionCompleted(result);
118 }
119
OLDNEW
« no previous file with comments | « ppapi/tests/test_video_decoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698