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

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: More implementation meat and clearing things all around. 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
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_c[] = {
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 std::vector<uint32_t> decoder_config(
57 decoder_cfg_c,
58 decoder_cfg_c + sizeof(decoder_cfg_c) / sizeof(decoder_cfg_c[0]));
59 if (!video_decoder_session_ ||
60 !video_decoder_session_->Initialize(
61 decoder_config,
62 cb_factory_.NewCallback(&TestVideoDecoder::OnInitializeCompleted))) {
63 return "Failed to initialize VideoDecoderSession";
64 }
65
66 // Wait the test to complete. By assigning the TestCompletionCallback into
67 // pp::CompletionCallback we are registering completion callback which waits
68 // until the latter is initiated.
69 int32_t result = WaitForCompletion();
70 if (result) {
71 return "Test failed during the decoding process with result: " + result;
35 } 72 }
36 PASS(); 73 PASS();
37 } 74 }
75
76 // Wait for the completion of test.
77 int32_t TestVideoDecoder::WaitForCompletion() {
78 // TODO(vmr): Get rid of ugly busy-loop in platform independent,
79 // Pepper-compatible manner for synchronization.
80 while (!test_completed_);
81 return test_result_;
82 }
83
84 void TestVideoDecoder::OnSessionCompleted(int32_t result) {
85 test_result_ = result;
86 test_completed_ = true;
87 }
88
89 void TestVideoDecoder::OnInitializeCompleted(int32_t result) {
90 if (result != PP_OK) {
91 OnSessionCompleted(result);
92 }
93 video_decoder_session_->Run(
94 cb_factory_.NewCallback(&TestVideoDecoder::OnRunCompleted));
95 }
96
97 void TestVideoDecoder::OnRunCompleted(int32_t result) {
98 if (result != PP_OK) {
99 OnSessionCompleted(result);
100 }
101 // No action needed, just let the session continue until it runs out.
102 }
103
104 void TestVideoDecoder::OnStopCompleted(int32_t result) {
105 if (result != PP_OK) {
106 OnSessionCompleted(result);
107 }
108 video_decoder_session_->Teardown(
109 cb_factory_.NewCallback(&TestVideoDecoder::OnTeardownCompleted));
110 }
111
112 void TestVideoDecoder::OnFlushCompleted(int32_t result) {
113 if (result != PP_OK) {
114 OnSessionCompleted(result);
115 }
116 // No action needed, just let the session continue.
117 }
118
119 void TestVideoDecoder::OnTeardownCompleted(int32_t result) {
120 OnSessionCompleted(result);
121 }
122
OLDNEW
« ppapi/examples/video_decoder/video_decoder_session.cc ('K') | « ppapi/tests/test_video_decoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698