| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // Tests PPB_MediaStreamVideoTrack interface. | 5 // Tests PPB_MediaStreamVideoTrack interface. |
| 6 | 6 |
| 7 #include "ppapi/tests/test_media_stream_video_track.h" | 7 #include "ppapi/tests/test_media_stream_video_track.h" |
| 8 | 8 |
| 9 #include "ppapi/c/private/ppb_testing_private.h" | 9 #include "ppapi/c/private/ppb_testing_private.h" |
| 10 #include "ppapi/cpp/completion_callback.h" | 10 #include "ppapi/cpp/completion_callback.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 PP_TimeDelta timestamp = 0.0; | 91 PP_TimeDelta timestamp = 0.0; |
| 92 | 92 |
| 93 // Get |kTimes| frames. | 93 // Get |kTimes| frames. |
| 94 for (int i = 0; i < kTimes; ++i) { | 94 for (int i = 0; i < kTimes; ++i) { |
| 95 TestCompletionCallbackWithOutput<pp::VideoFrame> cc( | 95 TestCompletionCallbackWithOutput<pp::VideoFrame> cc( |
| 96 instance_->pp_instance(), false); | 96 instance_->pp_instance(), false); |
| 97 cc.WaitForResult(video_track_.GetFrame(cc.GetCallback())); | 97 cc.WaitForResult(video_track_.GetFrame(cc.GetCallback())); |
| 98 ASSERT_EQ(PP_OK, cc.result()); | 98 ASSERT_EQ(PP_OK, cc.result()); |
| 99 pp::VideoFrame frame = cc.output(); | 99 pp::VideoFrame frame = cc.output(); |
| 100 ASSERT_FALSE(frame.is_null()); | 100 ASSERT_FALSE(frame.is_null()); |
| 101 ASSERT_EQ(frame.GetFormat(), PP_VIDEOFRAME_FORMAT_YV12); | 101 ASSERT_TRUE(frame.GetFormat() == PP_VIDEOFRAME_FORMAT_YV12 || |
| 102 frame.GetFormat() == PP_VIDEOFRAME_FORMAT_I420); |
| 102 | 103 |
| 103 pp::Size size; | 104 pp::Size size; |
| 104 ASSERT_TRUE(frame.GetSize(&size)); | 105 ASSERT_TRUE(frame.GetSize(&size)); |
| 105 ASSERT_EQ(size.width(), kDefaultWidth); | 106 ASSERT_EQ(size.width(), kDefaultWidth); |
| 106 ASSERT_EQ(size.height(), kDefaultHeight); | 107 ASSERT_EQ(size.height(), kDefaultHeight); |
| 107 | 108 |
| 108 ASSERT_GE(frame.GetTimestamp(), timestamp); | 109 ASSERT_GE(frame.GetTimestamp(), timestamp); |
| 109 timestamp = frame.GetTimestamp(); | 110 timestamp = frame.GetTimestamp(); |
| 110 | 111 |
| 111 ASSERT_GT(frame.GetDataBufferSize(), 0U); | 112 ASSERT_GT(frame.GetDataBufferSize(), 0U); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 cc1.WaitForResult(video_track_.Configure(attrib_list, cc1.GetCallback())); | 158 cc1.WaitForResult(video_track_.Configure(attrib_list, cc1.GetCallback())); |
| 158 ASSERT_EQ(PP_OK, cc1.result()); | 159 ASSERT_EQ(PP_OK, cc1.result()); |
| 159 | 160 |
| 160 for (int j = 0; j < kTimes; ++j) { | 161 for (int j = 0; j < kTimes; ++j) { |
| 161 TestCompletionCallbackWithOutput<pp::VideoFrame> cc2( | 162 TestCompletionCallbackWithOutput<pp::VideoFrame> cc2( |
| 162 instance_->pp_instance(), false); | 163 instance_->pp_instance(), false); |
| 163 cc2.WaitForResult(video_track_.GetFrame(cc2.GetCallback())); | 164 cc2.WaitForResult(video_track_.GetFrame(cc2.GetCallback())); |
| 164 ASSERT_EQ(PP_OK, cc2.result()); | 165 ASSERT_EQ(PP_OK, cc2.result()); |
| 165 pp::VideoFrame frame = cc2.output(); | 166 pp::VideoFrame frame = cc2.output(); |
| 166 ASSERT_FALSE(frame.is_null()); | 167 ASSERT_FALSE(frame.is_null()); |
| 167 ASSERT_EQ(frame.GetFormat(), formats[i].expected_format); | 168 if (formats[i].format != PP_VIDEOFRAME_FORMAT_UNKNOWN) { |
| 169 ASSERT_EQ(frame.GetFormat(), formats[i].expected_format); |
| 170 } else { |
| 171 // Both YV12 and I420 are acceptable as default YUV formats. |
| 172 ASSERT_TRUE(frame.GetFormat() == PP_VIDEOFRAME_FORMAT_YV12 || |
| 173 frame.GetFormat() == PP_VIDEOFRAME_FORMAT_I420); |
| 174 } |
| 168 | 175 |
| 169 pp::Size size; | 176 pp::Size size; |
| 170 ASSERT_TRUE(frame.GetSize(&size)); | 177 ASSERT_TRUE(frame.GetSize(&size)); |
| 171 ASSERT_EQ(size.width(), kDefaultWidth); | 178 ASSERT_EQ(size.width(), kDefaultWidth); |
| 172 ASSERT_EQ(size.height(), kDefaultHeight); | 179 ASSERT_EQ(size.height(), kDefaultHeight); |
| 173 | 180 |
| 174 ASSERT_GT(frame.GetDataBufferSize(), 0U); | 181 ASSERT_GT(frame.GetDataBufferSize(), 0U); |
| 175 ASSERT_TRUE(frame.GetDataBuffer() != NULL); | 182 ASSERT_TRUE(frame.GetDataBuffer() != NULL); |
| 176 | 183 |
| 177 video_track_.RecycleFrame(frame); | 184 video_track_.RecycleFrame(frame); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 199 cc1.WaitForResult(video_track_.Configure(attrib_list, cc1.GetCallback())); | 206 cc1.WaitForResult(video_track_.Configure(attrib_list, cc1.GetCallback())); |
| 200 ASSERT_EQ(PP_OK, cc1.result()); | 207 ASSERT_EQ(PP_OK, cc1.result()); |
| 201 | 208 |
| 202 for (int j = 0; j < kTimes; ++j) { | 209 for (int j = 0; j < kTimes; ++j) { |
| 203 TestCompletionCallbackWithOutput<pp::VideoFrame> cc2( | 210 TestCompletionCallbackWithOutput<pp::VideoFrame> cc2( |
| 204 instance_->pp_instance(), false); | 211 instance_->pp_instance(), false); |
| 205 cc2.WaitForResult(video_track_.GetFrame(cc2.GetCallback())); | 212 cc2.WaitForResult(video_track_.GetFrame(cc2.GetCallback())); |
| 206 ASSERT_EQ(PP_OK, cc2.result()); | 213 ASSERT_EQ(PP_OK, cc2.result()); |
| 207 pp::VideoFrame frame = cc2.output(); | 214 pp::VideoFrame frame = cc2.output(); |
| 208 ASSERT_FALSE(frame.is_null()); | 215 ASSERT_FALSE(frame.is_null()); |
| 209 ASSERT_EQ(frame.GetFormat(), PP_VIDEOFRAME_FORMAT_YV12); | 216 ASSERT_TRUE(frame.GetFormat() == PP_VIDEOFRAME_FORMAT_YV12 || |
| 217 frame.GetFormat() == PP_VIDEOFRAME_FORMAT_I420); |
| 210 | 218 |
| 211 pp::Size size; | 219 pp::Size size; |
| 212 ASSERT_TRUE(frame.GetSize(&size)); | 220 ASSERT_TRUE(frame.GetSize(&size)); |
| 213 ASSERT_EQ(size.width(), sizes[i].expect_width); | 221 ASSERT_EQ(size.width(), sizes[i].expect_width); |
| 214 ASSERT_EQ(size.height(), sizes[i].expect_height); | 222 ASSERT_EQ(size.height(), sizes[i].expect_height); |
| 215 | 223 |
| 216 ASSERT_GT(frame.GetDataBufferSize(), 0U); | 224 ASSERT_GT(frame.GetDataBufferSize(), 0U); |
| 217 ASSERT_TRUE(frame.GetDataBuffer() != NULL); | 225 ASSERT_TRUE(frame.GetDataBuffer() != NULL); |
| 218 | 226 |
| 219 video_track_.RecycleFrame(frame); | 227 video_track_.RecycleFrame(frame); |
| 220 } | 228 } |
| 221 } | 229 } |
| 222 | 230 |
| 223 // Close the track. | 231 // Close the track. |
| 224 video_track_.Close(); | 232 video_track_.Close(); |
| 225 ASSERT_TRUE(video_track_.HasEnded()); | 233 ASSERT_TRUE(video_track_.HasEnded()); |
| 226 video_track_ = pp::MediaStreamVideoTrack(); | 234 video_track_ = pp::MediaStreamVideoTrack(); |
| 227 PASS(); | 235 PASS(); |
| 228 } | 236 } |
| OLD | NEW |