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

Side by Side Diff: webrtc/media/engine/webrtcvideoframe_unittest.cc

Issue 2275243002: Reland of Delete method cricket::VideoFrame::Copy. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Update peerconnection_jni.cc (file moved since the revert). Created 4 years, 3 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
« no previous file with comments | « webrtc/media/engine/webrtcvideoframe.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
229 // These functions test implementation-specific details. 226 // These functions test implementation-specific details.
230 // Tests the Init function with different cropped size. 227 // Tests the Init function with different cropped size.
231 TEST_F(WebRtcVideoFrameTest, InitEvenSize) { 228 TEST_F(WebRtcVideoFrameTest, InitEvenSize) {
232 TestInit(640, 360, webrtc::kVideoRotation_0, true); 229 TestInit(640, 360, webrtc::kVideoRotation_0, true);
233 } 230 }
234 231
235 TEST_F(WebRtcVideoFrameTest, InitOddWidth) { 232 TEST_F(WebRtcVideoFrameTest, InitOddWidth) {
236 TestInit(601, 480, webrtc::kVideoRotation_0, true); 233 TestInit(601, 480, webrtc::kVideoRotation_0, true);
237 } 234 }
238 235
(...skipping 24 matching lines...) Expand all
263 EXPECT_EQ(dummy_handle, frame.video_frame_buffer()->native_handle()); 260 EXPECT_EQ(dummy_handle, frame.video_frame_buffer()->native_handle());
264 EXPECT_EQ(640, frame.width()); 261 EXPECT_EQ(640, frame.width());
265 EXPECT_EQ(480, frame.height()); 262 EXPECT_EQ(480, frame.height());
266 EXPECT_EQ(20000, frame.GetTimeStamp()); 263 EXPECT_EQ(20000, frame.GetTimeStamp());
267 EXPECT_EQ(20, frame.timestamp_us()); 264 EXPECT_EQ(20, frame.timestamp_us());
268 frame.set_timestamp_us(40); 265 frame.set_timestamp_us(40);
269 EXPECT_EQ(40000, frame.GetTimeStamp()); 266 EXPECT_EQ(40000, frame.GetTimeStamp());
270 EXPECT_EQ(40, frame.timestamp_us()); 267 EXPECT_EQ(40, frame.timestamp_us());
271 } 268 }
272 269
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
291 TEST_F(WebRtcVideoFrameTest, ApplyRotationToFrame) { 270 TEST_F(WebRtcVideoFrameTest, ApplyRotationToFrame) {
292 WebRtcVideoFrame applied0; 271 WebRtcVideoFrame applied0;
293 EXPECT_TRUE(IsNull(applied0)); 272 EXPECT_TRUE(IsNull(applied0));
294 EXPECT_TRUE(LoadFrame(CreateYuvSample(kWidth, kHeight, 12).get(), FOURCC_I420, 273 EXPECT_TRUE(LoadFrame(CreateYuvSample(kWidth, kHeight, 12).get(), FOURCC_I420,
295 kWidth, kHeight, &applied0)); 274 kWidth, kHeight, &applied0));
296 275
297 // Claim that this frame needs to be rotated for 90 degree. 276 // Claim that this frame needs to be rotated for 90 degree.
298 SetFrameRotation(&applied0, webrtc::kVideoRotation_90); 277 SetFrameRotation(&applied0, webrtc::kVideoRotation_90);
299 278
300 // Apply rotation on frame 1. Output should be different from frame 1. 279 // Apply rotation on frame 1. Output should be different from frame 1.
301 WebRtcVideoFrame* applied90 = 280 WebRtcVideoFrame* applied90 =
302 const_cast<WebRtcVideoFrame*>(static_cast<const WebRtcVideoFrame*>( 281 const_cast<WebRtcVideoFrame*>(static_cast<const WebRtcVideoFrame*>(
303 applied0.GetCopyWithRotationApplied())); 282 applied0.GetCopyWithRotationApplied()));
304 EXPECT_TRUE(applied90); 283 EXPECT_TRUE(applied90);
305 EXPECT_EQ(applied90->rotation(), webrtc::kVideoRotation_0); 284 EXPECT_EQ(applied90->rotation(), webrtc::kVideoRotation_0);
306 EXPECT_FALSE(IsEqual(applied0, *applied90, 0)); 285 EXPECT_FALSE(IsEqual(applied0, *applied90, 0));
307 286
308 // Claim the frame 2 needs to be rotated for another 270 degree. The output 287 // Claim the frame 2 needs to be rotated for another 270 degree. The output
309 // from frame 2 rotation should be the same as frame 1. 288 // from frame 2 rotation should be the same as frame 1.
310 SetFrameRotation(applied90, webrtc::kVideoRotation_270); 289 SetFrameRotation(applied90, webrtc::kVideoRotation_270);
311 const VideoFrame* applied360 = applied90->GetCopyWithRotationApplied(); 290 const VideoFrame* applied360 = applied90->GetCopyWithRotationApplied();
312 EXPECT_TRUE(applied360); 291 EXPECT_TRUE(applied360);
313 EXPECT_EQ(applied360->rotation(), webrtc::kVideoRotation_0); 292 EXPECT_EQ(applied360->rotation(), webrtc::kVideoRotation_0);
314 EXPECT_TRUE(IsEqual(applied0, *applied360, 0)); 293 EXPECT_TRUE(IsEqual(applied0, *applied360, 0));
315 } 294 }
316 295
317 } // namespace cricket 296 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/media/engine/webrtcvideoframe.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698