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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 TEST_WEBRTCVIDEOFRAME(ConvertFromI400BufferInverted) | 216 TEST_WEBRTCVIDEOFRAME(ConvertFromI400BufferInverted) |
217 TEST_WEBRTCVIDEOFRAME(ConvertFromYUY2Buffer) | 217 TEST_WEBRTCVIDEOFRAME(ConvertFromYUY2Buffer) |
218 TEST_WEBRTCVIDEOFRAME(ConvertFromYUY2BufferStride) | 218 TEST_WEBRTCVIDEOFRAME(ConvertFromYUY2BufferStride) |
219 TEST_WEBRTCVIDEOFRAME(ConvertFromYUY2BufferInverted) | 219 TEST_WEBRTCVIDEOFRAME(ConvertFromYUY2BufferInverted) |
220 TEST_WEBRTCVIDEOFRAME(ConvertFromUYVYBuffer) | 220 TEST_WEBRTCVIDEOFRAME(ConvertFromUYVYBuffer) |
221 TEST_WEBRTCVIDEOFRAME(ConvertFromUYVYBufferStride) | 221 TEST_WEBRTCVIDEOFRAME(ConvertFromUYVYBufferStride) |
222 TEST_WEBRTCVIDEOFRAME(ConvertFromUYVYBufferInverted) | 222 TEST_WEBRTCVIDEOFRAME(ConvertFromUYVYBufferInverted) |
223 // TEST_WEBRTCVIDEOFRAME(ConvertToI422Buffer) | 223 // TEST_WEBRTCVIDEOFRAME(ConvertToI422Buffer) |
224 // TEST_WEBRTCVIDEOFRAME(ConstructARGBBlackWhitePixel) | 224 // TEST_WEBRTCVIDEOFRAME(ConstructARGBBlackWhitePixel) |
225 | 225 |
| 226 TEST_WEBRTCVIDEOFRAME(Copy) |
| 227 TEST_WEBRTCVIDEOFRAME(CopyIsRef) |
| 228 |
226 // These functions test implementation-specific details. | 229 // These functions test implementation-specific details. |
227 // Tests the Init function with different cropped size. | 230 // Tests the Init function with different cropped size. |
228 TEST_F(WebRtcVideoFrameTest, InitEvenSize) { | 231 TEST_F(WebRtcVideoFrameTest, InitEvenSize) { |
229 TestInit(640, 360, webrtc::kVideoRotation_0, true); | 232 TestInit(640, 360, webrtc::kVideoRotation_0, true); |
230 } | 233 } |
231 | 234 |
232 TEST_F(WebRtcVideoFrameTest, InitOddWidth) { | 235 TEST_F(WebRtcVideoFrameTest, InitOddWidth) { |
233 TestInit(601, 480, webrtc::kVideoRotation_0, true); | 236 TestInit(601, 480, webrtc::kVideoRotation_0, true); |
234 } | 237 } |
235 | 238 |
(...skipping 24 matching lines...) Expand all Loading... |
260 EXPECT_EQ(dummy_handle, frame.video_frame_buffer()->native_handle()); | 263 EXPECT_EQ(dummy_handle, frame.video_frame_buffer()->native_handle()); |
261 EXPECT_EQ(640, frame.width()); | 264 EXPECT_EQ(640, frame.width()); |
262 EXPECT_EQ(480, frame.height()); | 265 EXPECT_EQ(480, frame.height()); |
263 EXPECT_EQ(20000, frame.GetTimeStamp()); | 266 EXPECT_EQ(20000, frame.GetTimeStamp()); |
264 EXPECT_EQ(20, frame.timestamp_us()); | 267 EXPECT_EQ(20, frame.timestamp_us()); |
265 frame.set_timestamp_us(40); | 268 frame.set_timestamp_us(40); |
266 EXPECT_EQ(40000, frame.GetTimeStamp()); | 269 EXPECT_EQ(40000, frame.GetTimeStamp()); |
267 EXPECT_EQ(40, frame.timestamp_us()); | 270 EXPECT_EQ(40, frame.timestamp_us()); |
268 } | 271 } |
269 | 272 |
| 273 TEST_F(WebRtcVideoFrameTest, CopyTextureFrame) { |
| 274 webrtc::test::FakeNativeHandle* dummy_handle = |
| 275 new webrtc::test::FakeNativeHandle(); |
| 276 webrtc::NativeHandleBuffer* buffer = |
| 277 new rtc::RefCountedObject<webrtc::test::FakeNativeHandleBuffer>( |
| 278 dummy_handle, 640, 480); |
| 279 // Timestamp is converted from ns to us, so last three digits are lost. |
| 280 WebRtcVideoFrame frame1(buffer, 20000, webrtc::kVideoRotation_0); |
| 281 VideoFrame* frame2 = frame1.Copy(); |
| 282 EXPECT_EQ(frame1.video_frame_buffer()->native_handle(), |
| 283 frame2->video_frame_buffer()->native_handle()); |
| 284 EXPECT_EQ(frame1.width(), frame2->width()); |
| 285 EXPECT_EQ(frame1.height(), frame2->height()); |
| 286 EXPECT_EQ(frame1.GetTimeStamp(), frame2->GetTimeStamp()); |
| 287 EXPECT_EQ(frame1.timestamp_us(), frame2->timestamp_us()); |
| 288 delete frame2; |
| 289 } |
| 290 |
270 TEST_F(WebRtcVideoFrameTest, ApplyRotationToFrame) { | 291 TEST_F(WebRtcVideoFrameTest, ApplyRotationToFrame) { |
271 WebRtcVideoFrame applied0; | 292 WebRtcVideoFrame applied0; |
272 EXPECT_TRUE(IsNull(applied0)); | 293 EXPECT_TRUE(IsNull(applied0)); |
273 EXPECT_TRUE(LoadFrame(CreateYuvSample(kWidth, kHeight, 12).get(), FOURCC_I420, | 294 EXPECT_TRUE(LoadFrame(CreateYuvSample(kWidth, kHeight, 12).get(), FOURCC_I420, |
274 kWidth, kHeight, &applied0)); | 295 kWidth, kHeight, &applied0)); |
275 | 296 |
276 // Claim that this frame needs to be rotated for 90 degree. | 297 // Claim that this frame needs to be rotated for 90 degree. |
277 SetFrameRotation(&applied0, webrtc::kVideoRotation_90); | 298 SetFrameRotation(&applied0, webrtc::kVideoRotation_90); |
278 | 299 |
279 // Apply rotation on frame 1. Output should be different from frame 1. | 300 // Apply rotation on frame 1. Output should be different from frame 1. |
280 WebRtcVideoFrame* applied90 = | 301 WebRtcVideoFrame* applied90 = |
281 const_cast<WebRtcVideoFrame*>(static_cast<const WebRtcVideoFrame*>( | 302 const_cast<WebRtcVideoFrame*>(static_cast<const WebRtcVideoFrame*>( |
282 applied0.GetCopyWithRotationApplied())); | 303 applied0.GetCopyWithRotationApplied())); |
283 EXPECT_TRUE(applied90); | 304 EXPECT_TRUE(applied90); |
284 EXPECT_EQ(applied90->rotation(), webrtc::kVideoRotation_0); | 305 EXPECT_EQ(applied90->rotation(), webrtc::kVideoRotation_0); |
285 EXPECT_FALSE(IsEqual(applied0, *applied90, 0)); | 306 EXPECT_FALSE(IsEqual(applied0, *applied90, 0)); |
286 | 307 |
287 // Claim the frame 2 needs to be rotated for another 270 degree. The output | 308 // Claim the frame 2 needs to be rotated for another 270 degree. The output |
288 // from frame 2 rotation should be the same as frame 1. | 309 // from frame 2 rotation should be the same as frame 1. |
289 SetFrameRotation(applied90, webrtc::kVideoRotation_270); | 310 SetFrameRotation(applied90, webrtc::kVideoRotation_270); |
290 const VideoFrame* applied360 = applied90->GetCopyWithRotationApplied(); | 311 const VideoFrame* applied360 = applied90->GetCopyWithRotationApplied(); |
291 EXPECT_TRUE(applied360); | 312 EXPECT_TRUE(applied360); |
292 EXPECT_EQ(applied360->rotation(), webrtc::kVideoRotation_0); | 313 EXPECT_EQ(applied360->rotation(), webrtc::kVideoRotation_0); |
293 EXPECT_TRUE(IsEqual(applied0, *applied360, 0)); | 314 EXPECT_TRUE(IsEqual(applied0, *applied360, 0)); |
294 } | 315 } |
295 | 316 |
296 } // namespace cricket | 317 } // namespace cricket |
OLD | NEW |