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

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

Issue 1728503002: Replace scoped_ptr with unique_ptr in webrtc/media/ (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@up1
Patch Set: Created 4 years, 10 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.h ('k') | webrtc/media/engine/webrtcvideoframefactory.cc » ('j') | 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
11 #include <string.h> 11 #include <string.h>
12 12
13 #include <memory>
14
13 #include "webrtc/media/base/videoframe_unittest.h" 15 #include "webrtc/media/base/videoframe_unittest.h"
14 #include "webrtc/media/engine/webrtcvideoframe.h" 16 #include "webrtc/media/engine/webrtcvideoframe.h"
15 #include "webrtc/test/fake_texture_frame.h" 17 #include "webrtc/test/fake_texture_frame.h"
16 18
17 namespace { 19 namespace {
18 20
19 class WebRtcVideoTestFrame : public cricket::WebRtcVideoFrame { 21 class WebRtcVideoTestFrame : public cricket::WebRtcVideoFrame {
20 public: 22 public:
21 using cricket::WebRtcVideoFrame::SetRotation; 23 using cricket::WebRtcVideoFrame::SetRotation;
22 24
(...skipping 21 matching lines...) Expand all
44 46
45 // Build the CapturedFrame. 47 // Build the CapturedFrame.
46 cricket::CapturedFrame captured_frame; 48 cricket::CapturedFrame captured_frame;
47 captured_frame.fourcc = cricket::FOURCC_I420; 49 captured_frame.fourcc = cricket::FOURCC_I420;
48 captured_frame.time_stamp = 5678; 50 captured_frame.time_stamp = 5678;
49 captured_frame.rotation = frame_rotation; 51 captured_frame.rotation = frame_rotation;
50 captured_frame.width = frame_width; 52 captured_frame.width = frame_width;
51 captured_frame.height = frame_height; 53 captured_frame.height = frame_height;
52 captured_frame.data_size = (frame_width * frame_height) + 54 captured_frame.data_size = (frame_width * frame_height) +
53 ((frame_width + 1) / 2) * ((frame_height + 1) / 2) * 2; 55 ((frame_width + 1) / 2) * ((frame_height + 1) / 2) * 2;
54 rtc::scoped_ptr<uint8_t[]> captured_frame_buffer( 56 std::unique_ptr<uint8_t[]> captured_frame_buffer(
55 new uint8_t[captured_frame.data_size]); 57 new uint8_t[captured_frame.data_size]);
56 // Initialize memory to satisfy DrMemory tests. 58 // Initialize memory to satisfy DrMemory tests.
57 memset(captured_frame_buffer.get(), 0, captured_frame.data_size); 59 memset(captured_frame_buffer.get(), 0, captured_frame.data_size);
58 captured_frame.data = captured_frame_buffer.get(); 60 captured_frame.data = captured_frame_buffer.get();
59 61
60 // Create the new frame from the CapturedFrame. 62 // Create the new frame from the CapturedFrame.
61 cricket::WebRtcVideoFrame frame; 63 cricket::WebRtcVideoFrame frame;
62 EXPECT_TRUE( 64 EXPECT_TRUE(
63 frame.Init(&captured_frame, cropped_width, cropped_height, 65 frame.Init(&captured_frame, cropped_width, cropped_height,
64 apply_rotation)); 66 apply_rotation));
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 EXPECT_EQ(frame1.GetNativeHandle(), frame2->GetNativeHandle()); 295 EXPECT_EQ(frame1.GetNativeHandle(), frame2->GetNativeHandle());
294 EXPECT_EQ(frame1.GetWidth(), frame2->GetWidth()); 296 EXPECT_EQ(frame1.GetWidth(), frame2->GetWidth());
295 EXPECT_EQ(frame1.GetHeight(), frame2->GetHeight()); 297 EXPECT_EQ(frame1.GetHeight(), frame2->GetHeight());
296 EXPECT_EQ(frame1.GetTimeStamp(), frame2->GetTimeStamp()); 298 EXPECT_EQ(frame1.GetTimeStamp(), frame2->GetTimeStamp());
297 delete frame2; 299 delete frame2;
298 } 300 }
299 301
300 TEST_F(WebRtcVideoFrameTest, ApplyRotationToFrame) { 302 TEST_F(WebRtcVideoFrameTest, ApplyRotationToFrame) {
301 WebRtcVideoTestFrame applied0; 303 WebRtcVideoTestFrame applied0;
302 EXPECT_TRUE(IsNull(applied0)); 304 EXPECT_TRUE(IsNull(applied0));
303 rtc::scoped_ptr<rtc::MemoryStream> ms(CreateYuvSample(kWidth, kHeight, 12)); 305 std::unique_ptr<rtc::MemoryStream> ms(CreateYuvSample(kWidth, kHeight, 12));
304 EXPECT_TRUE( 306 EXPECT_TRUE(
305 LoadFrame(ms.get(), cricket::FOURCC_I420, kWidth, kHeight, &applied0)); 307 LoadFrame(ms.get(), cricket::FOURCC_I420, kWidth, kHeight, &applied0));
306 308
307 // Claim that this frame needs to be rotated for 90 degree. 309 // Claim that this frame needs to be rotated for 90 degree.
308 applied0.SetRotation(webrtc::kVideoRotation_90); 310 applied0.SetRotation(webrtc::kVideoRotation_90);
309 311
310 // Apply rotation on frame 1. Output should be different from frame 1. 312 // Apply rotation on frame 1. Output should be different from frame 1.
311 WebRtcVideoTestFrame* applied90 = const_cast<WebRtcVideoTestFrame*>( 313 WebRtcVideoTestFrame* applied90 = const_cast<WebRtcVideoTestFrame*>(
312 static_cast<const WebRtcVideoTestFrame*>( 314 static_cast<const WebRtcVideoTestFrame*>(
313 applied0.GetCopyWithRotationApplied())); 315 applied0.GetCopyWithRotationApplied()));
314 EXPECT_TRUE(applied90); 316 EXPECT_TRUE(applied90);
315 EXPECT_EQ(applied90->GetVideoRotation(), webrtc::kVideoRotation_0); 317 EXPECT_EQ(applied90->GetVideoRotation(), webrtc::kVideoRotation_0);
316 EXPECT_FALSE(IsEqual(applied0, *applied90, 0)); 318 EXPECT_FALSE(IsEqual(applied0, *applied90, 0));
317 319
318 // Claim the frame 2 needs to be rotated for another 270 degree. The output 320 // Claim the frame 2 needs to be rotated for another 270 degree. The output
319 // from frame 2 rotation should be the same as frame 1. 321 // from frame 2 rotation should be the same as frame 1.
320 applied90->SetRotation(webrtc::kVideoRotation_270); 322 applied90->SetRotation(webrtc::kVideoRotation_270);
321 const cricket::VideoFrame* applied360 = 323 const cricket::VideoFrame* applied360 =
322 applied90->GetCopyWithRotationApplied(); 324 applied90->GetCopyWithRotationApplied();
323 EXPECT_TRUE(applied360); 325 EXPECT_TRUE(applied360);
324 EXPECT_EQ(applied360->GetVideoRotation(), webrtc::kVideoRotation_0); 326 EXPECT_EQ(applied360->GetVideoRotation(), webrtc::kVideoRotation_0);
325 EXPECT_TRUE(IsEqual(applied0, *applied360, 0)); 327 EXPECT_TRUE(IsEqual(applied0, *applied360, 0));
326 } 328 }
OLDNEW
« no previous file with comments | « webrtc/media/engine/webrtcvideoframe.h ('k') | webrtc/media/engine/webrtcvideoframefactory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698