OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_encoder.h" | 5 #include "ppapi/tests/test_video_encoder.h" |
6 | 6 |
7 #include "ppapi/c/pp_codecs.h" | 7 #include "ppapi/c/pp_codecs.h" |
8 #include "ppapi/c/pp_errors.h" | 8 #include "ppapi/c/pp_errors.h" |
9 #include "ppapi/cpp/video_encoder.h" | 9 #include "ppapi/cpp/video_encoder.h" |
10 #include "ppapi/tests/testing_instance.h" | 10 #include "ppapi/tests/testing_instance.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 // Test that we get results for supported formats. | 25 // Test that we get results for supported formats. |
26 { | 26 { |
27 pp::VideoEncoder video_encoder(instance_); | 27 pp::VideoEncoder video_encoder(instance_); |
28 ASSERT_FALSE(video_encoder.is_null()); | 28 ASSERT_FALSE(video_encoder.is_null()); |
29 | 29 |
30 TestCompletionCallbackWithOutput<std::vector<PP_VideoProfileDescription> > | 30 TestCompletionCallbackWithOutput<std::vector<PP_VideoProfileDescription> > |
31 callback(instance_->pp_instance(), false); | 31 callback(instance_->pp_instance(), false); |
32 callback.WaitForResult( | 32 callback.WaitForResult( |
33 video_encoder.GetSupportedProfiles(callback.GetCallback())); | 33 video_encoder.GetSupportedProfiles(callback.GetCallback())); |
34 | 34 |
35 ASSERT_GE(callback.output().size(), 0U); | 35 ASSERT_EQ(PP_OK, callback.result()); |
| 36 ASSERT_GE(callback.output().size(), 1U); |
| 37 |
| 38 bool found_vp8 = false; |
| 39 for (uint32_t i = 0; i < callback.output().size(); ++i) { |
| 40 const PP_VideoProfileDescription& description = callback.output()[i]; |
| 41 if (description.profile == PP_VIDEOPROFILE_VP8_ANY) |
| 42 found_vp8 = true; |
| 43 } |
| 44 ASSERT_TRUE(found_vp8); |
36 } | 45 } |
37 // TODO(llandwerlin): add more tests once software video encode is | 46 // Test that initializing the encoder with incorrect size fails. |
38 // available. | 47 { |
| 48 pp::VideoEncoder video_encoder(instance_); |
| 49 ASSERT_FALSE(video_encoder.is_null()); |
| 50 pp::Size video_size(0, 0); |
| 51 |
| 52 TestCompletionCallback callback(instance_->pp_instance(), false); |
| 53 callback.WaitForResult( |
| 54 video_encoder.Initialize(PP_VIDEOFRAME_FORMAT_I420, |
| 55 video_size, |
| 56 PP_VIDEOPROFILE_VP8_ANY, |
| 57 1000000, |
| 58 PP_HARDWAREACCELERATION_WITHFALLBACK, |
| 59 callback.GetCallback())); |
| 60 |
| 61 ASSERT_EQ(PP_ERROR_BADARGUMENT, callback.result()); |
| 62 } |
| 63 // Test that initializing the encoder with software VP8 succeeds. |
| 64 { |
| 65 pp::VideoEncoder video_encoder(instance_); |
| 66 ASSERT_FALSE(video_encoder.is_null()); |
| 67 pp::Size video_size(640, 480); |
| 68 |
| 69 TestCompletionCallback callback(instance_->pp_instance(), false); |
| 70 callback.WaitForResult( |
| 71 video_encoder.Initialize(PP_VIDEOFRAME_FORMAT_I420, |
| 72 video_size, |
| 73 PP_VIDEOPROFILE_VP8_ANY, |
| 74 1000000, |
| 75 PP_HARDWAREACCELERATION_WITHFALLBACK, |
| 76 callback.GetCallback())); |
| 77 |
| 78 ASSERT_EQ(PP_OK, callback.result()); |
| 79 |
| 80 pp::Size coded_size; |
| 81 ASSERT_EQ(PP_OK, video_encoder.GetFrameCodedSize(&coded_size)); |
| 82 ASSERT_GE(coded_size.GetArea(), video_size.GetArea()); |
| 83 ASSERT_GE(video_encoder.GetFramesRequired(), 1); |
| 84 } |
39 | 85 |
40 PASS(); | 86 PASS(); |
41 } | 87 } |
OLD | NEW |