| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 TEST_WEBRTCVIDEOFRAME(ConvertFromI400BufferInverted) | 238 TEST_WEBRTCVIDEOFRAME(ConvertFromI400BufferInverted) |
| 239 TEST_WEBRTCVIDEOFRAME(ConvertFromYUY2Buffer) | 239 TEST_WEBRTCVIDEOFRAME(ConvertFromYUY2Buffer) |
| 240 TEST_WEBRTCVIDEOFRAME(ConvertFromYUY2BufferStride) | 240 TEST_WEBRTCVIDEOFRAME(ConvertFromYUY2BufferStride) |
| 241 TEST_WEBRTCVIDEOFRAME(ConvertFromYUY2BufferInverted) | 241 TEST_WEBRTCVIDEOFRAME(ConvertFromYUY2BufferInverted) |
| 242 TEST_WEBRTCVIDEOFRAME(ConvertFromUYVYBuffer) | 242 TEST_WEBRTCVIDEOFRAME(ConvertFromUYVYBuffer) |
| 243 TEST_WEBRTCVIDEOFRAME(ConvertFromUYVYBufferStride) | 243 TEST_WEBRTCVIDEOFRAME(ConvertFromUYVYBufferStride) |
| 244 TEST_WEBRTCVIDEOFRAME(ConvertFromUYVYBufferInverted) | 244 TEST_WEBRTCVIDEOFRAME(ConvertFromUYVYBufferInverted) |
| 245 // TEST_WEBRTCVIDEOFRAME(ConvertToI422Buffer) | 245 // TEST_WEBRTCVIDEOFRAME(ConvertToI422Buffer) |
| 246 // TEST_WEBRTCVIDEOFRAME(ConstructARGBBlackWhitePixel) | 246 // TEST_WEBRTCVIDEOFRAME(ConstructARGBBlackWhitePixel) |
| 247 | 247 |
| 248 TEST_WEBRTCVIDEOFRAME(Copy) |
| 249 TEST_WEBRTCVIDEOFRAME(CopyIsRef) |
| 250 |
| 248 // These functions test implementation-specific details. | 251 // These functions test implementation-specific details. |
| 249 // Tests the Init function with different cropped size. | 252 // Tests the Init function with different cropped size. |
| 250 TEST_F(WebRtcVideoFrameTest, InitEvenSize) { | 253 TEST_F(WebRtcVideoFrameTest, InitEvenSize) { |
| 251 TestInit(640, 360, webrtc::kVideoRotation_0, true); | 254 TestInit(640, 360, webrtc::kVideoRotation_0, true); |
| 252 } | 255 } |
| 253 | 256 |
| 254 TEST_F(WebRtcVideoFrameTest, InitOddWidth) { | 257 TEST_F(WebRtcVideoFrameTest, InitOddWidth) { |
| 255 TestInit(601, 480, webrtc::kVideoRotation_0, true); | 258 TestInit(601, 480, webrtc::kVideoRotation_0, true); |
| 256 } | 259 } |
| 257 | 260 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 282 EXPECT_EQ(dummy_handle, frame.video_frame_buffer()->native_handle()); | 285 EXPECT_EQ(dummy_handle, frame.video_frame_buffer()->native_handle()); |
| 283 EXPECT_EQ(640, frame.width()); | 286 EXPECT_EQ(640, frame.width()); |
| 284 EXPECT_EQ(480, frame.height()); | 287 EXPECT_EQ(480, frame.height()); |
| 285 EXPECT_EQ(20000, frame.GetTimeStamp()); | 288 EXPECT_EQ(20000, frame.GetTimeStamp()); |
| 286 EXPECT_EQ(20, frame.timestamp_us()); | 289 EXPECT_EQ(20, frame.timestamp_us()); |
| 287 frame.set_timestamp_us(40); | 290 frame.set_timestamp_us(40); |
| 288 EXPECT_EQ(40000, frame.GetTimeStamp()); | 291 EXPECT_EQ(40000, frame.GetTimeStamp()); |
| 289 EXPECT_EQ(40, frame.timestamp_us()); | 292 EXPECT_EQ(40, frame.timestamp_us()); |
| 290 } | 293 } |
| 291 | 294 |
| 295 TEST_F(WebRtcVideoFrameTest, CopyTextureFrame) { |
| 296 webrtc::test::FakeNativeHandle* dummy_handle = |
| 297 new webrtc::test::FakeNativeHandle(); |
| 298 webrtc::NativeHandleBuffer* buffer = |
| 299 new rtc::RefCountedObject<webrtc::test::FakeNativeHandleBuffer>( |
| 300 dummy_handle, 640, 480); |
| 301 // Timestamp is converted from ns to us, so last three digits are lost. |
| 302 cricket::WebRtcVideoFrame frame1(buffer, 20000, webrtc::kVideoRotation_0); |
| 303 cricket::VideoFrame* frame2 = frame1.Copy(); |
| 304 EXPECT_EQ(frame1.video_frame_buffer()->native_handle(), |
| 305 frame2->video_frame_buffer()->native_handle()); |
| 306 EXPECT_EQ(frame1.width(), frame2->width()); |
| 307 EXPECT_EQ(frame1.height(), frame2->height()); |
| 308 EXPECT_EQ(frame1.GetTimeStamp(), frame2->GetTimeStamp()); |
| 309 EXPECT_EQ(frame1.timestamp_us(), frame2->timestamp_us()); |
| 310 delete frame2; |
| 311 } |
| 312 |
| 292 TEST_F(WebRtcVideoFrameTest, ApplyRotationToFrame) { | 313 TEST_F(WebRtcVideoFrameTest, ApplyRotationToFrame) { |
| 293 WebRtcVideoTestFrame applied0; | 314 WebRtcVideoTestFrame applied0; |
| 294 EXPECT_TRUE(IsNull(applied0)); | 315 EXPECT_TRUE(IsNull(applied0)); |
| 295 EXPECT_TRUE(LoadFrame(CreateYuvSample(kWidth, kHeight, 12).get(), | 316 EXPECT_TRUE(LoadFrame(CreateYuvSample(kWidth, kHeight, 12).get(), |
| 296 cricket::FOURCC_I420, kWidth, kHeight, &applied0)); | 317 cricket::FOURCC_I420, kWidth, kHeight, &applied0)); |
| 297 | 318 |
| 298 // Claim that this frame needs to be rotated for 90 degree. | 319 // Claim that this frame needs to be rotated for 90 degree. |
| 299 applied0.set_rotation(webrtc::kVideoRotation_90); | 320 applied0.set_rotation(webrtc::kVideoRotation_90); |
| 300 | 321 |
| 301 // Apply rotation on frame 1. Output should be different from frame 1. | 322 // Apply rotation on frame 1. Output should be different from frame 1. |
| 302 WebRtcVideoTestFrame* applied90 = const_cast<WebRtcVideoTestFrame*>( | 323 WebRtcVideoTestFrame* applied90 = const_cast<WebRtcVideoTestFrame*>( |
| 303 static_cast<const WebRtcVideoTestFrame*>( | 324 static_cast<const WebRtcVideoTestFrame*>( |
| 304 applied0.GetCopyWithRotationApplied())); | 325 applied0.GetCopyWithRotationApplied())); |
| 305 EXPECT_TRUE(applied90); | 326 EXPECT_TRUE(applied90); |
| 306 EXPECT_EQ(applied90->rotation(), webrtc::kVideoRotation_0); | 327 EXPECT_EQ(applied90->rotation(), webrtc::kVideoRotation_0); |
| 307 EXPECT_FALSE(IsEqual(applied0, *applied90, 0)); | 328 EXPECT_FALSE(IsEqual(applied0, *applied90, 0)); |
| 308 | 329 |
| 309 // Claim the frame 2 needs to be rotated for another 270 degree. The output | 330 // Claim the frame 2 needs to be rotated for another 270 degree. The output |
| 310 // from frame 2 rotation should be the same as frame 1. | 331 // from frame 2 rotation should be the same as frame 1. |
| 311 applied90->set_rotation(webrtc::kVideoRotation_270); | 332 applied90->set_rotation(webrtc::kVideoRotation_270); |
| 312 const cricket::VideoFrame* applied360 = | 333 const cricket::VideoFrame* applied360 = |
| 313 applied90->GetCopyWithRotationApplied(); | 334 applied90->GetCopyWithRotationApplied(); |
| 314 EXPECT_TRUE(applied360); | 335 EXPECT_TRUE(applied360); |
| 315 EXPECT_EQ(applied360->rotation(), webrtc::kVideoRotation_0); | 336 EXPECT_EQ(applied360->rotation(), webrtc::kVideoRotation_0); |
| 316 EXPECT_TRUE(IsEqual(applied0, *applied360, 0)); | 337 EXPECT_TRUE(IsEqual(applied0, *applied360, 0)); |
| 317 } | 338 } |
| OLD | NEW |