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

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

Issue 2262443003: Delete VideoFrameFactory, CapturedFrame, and related code. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Update apply_rotation_ comment. 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/webrtcvideoframefactory.cc ('k') | webrtc/media/media.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include <string.h>
12
13 #include <memory>
14
15 #include "webrtc/base/gunit.h"
16 #include "webrtc/media/base/videocapturer.h"
17 #include "webrtc/media/engine/webrtcvideoframe.h"
18 #include "webrtc/media/engine/webrtcvideoframefactory.h"
19
20 class WebRtcVideoFrameFactoryTest : public testing::Test {
21 public:
22 WebRtcVideoFrameFactoryTest() {}
23
24 void InitFrame(webrtc::VideoRotation frame_rotation) {
25 const int frame_width = 1920;
26 const int frame_height = 1080;
27
28 // Build the CapturedFrame.
29 captured_frame_.fourcc = cricket::FOURCC_I420;
30 captured_frame_.pixel_width = 1;
31 captured_frame_.pixel_height = 1;
32 captured_frame_.time_stamp = rtc::TimeNanos();
33 captured_frame_.rotation = frame_rotation;
34 captured_frame_.width = frame_width;
35 captured_frame_.height = frame_height;
36 captured_frame_.data_size =
37 (frame_width * frame_height) +
38 ((frame_width + 1) / 2) * ((frame_height + 1) / 2) * 2;
39 captured_frame_buffer_.reset(new uint8_t[captured_frame_.data_size]);
40 // Initialize memory to satisfy DrMemory tests.
41 memset(captured_frame_buffer_.get(), 0, captured_frame_.data_size);
42 captured_frame_.data = captured_frame_buffer_.get();
43 }
44
45 void VerifyFrame(cricket::VideoFrame* dest_frame,
46 webrtc::VideoRotation src_rotation,
47 int src_width,
48 int src_height,
49 bool apply_rotation) {
50 if (!apply_rotation) {
51 EXPECT_EQ(dest_frame->rotation(), src_rotation);
52 EXPECT_EQ(dest_frame->width(), src_width);
53 EXPECT_EQ(dest_frame->height(), src_height);
54 } else {
55 EXPECT_EQ(dest_frame->rotation(), webrtc::kVideoRotation_0);
56 if (src_rotation == webrtc::kVideoRotation_90 ||
57 src_rotation == webrtc::kVideoRotation_270) {
58 EXPECT_EQ(dest_frame->width(), src_height);
59 EXPECT_EQ(dest_frame->height(), src_width);
60 } else {
61 EXPECT_EQ(dest_frame->width(), src_width);
62 EXPECT_EQ(dest_frame->height(), src_height);
63 }
64 }
65 }
66
67 void TestCreateAliasedFrame(bool apply_rotation) {
68 cricket::VideoFrameFactory& factory = factory_;
69 factory.SetApplyRotation(apply_rotation);
70 InitFrame(webrtc::kVideoRotation_270);
71 const cricket::CapturedFrame& captured_frame = get_captured_frame();
72 // Create the new frame from the CapturedFrame.
73 std::unique_ptr<cricket::VideoFrame> frame;
74 int new_width = captured_frame.width / 2;
75 int new_height = captured_frame.height / 2;
76 frame.reset(factory.CreateAliasedFrame(&captured_frame, new_width,
77 new_height, new_width, new_height));
78 VerifyFrame(frame.get(), webrtc::kVideoRotation_270, new_width, new_height,
79 apply_rotation);
80
81 frame.reset(factory.CreateAliasedFrame(
82 &captured_frame, new_width, new_height, new_width / 2, new_height / 2));
83 VerifyFrame(frame.get(), webrtc::kVideoRotation_270, new_width / 2,
84 new_height / 2, apply_rotation);
85
86 // Reset the frame first so it's exclusive hence we could go through the
87 // StretchToFrame code path in CreateAliasedFrame.
88 frame.reset();
89 frame.reset(factory.CreateAliasedFrame(
90 &captured_frame, new_width, new_height, new_width / 2, new_height / 2));
91 VerifyFrame(frame.get(), webrtc::kVideoRotation_270, new_width / 2,
92 new_height / 2, apply_rotation);
93 }
94
95 const cricket::CapturedFrame& get_captured_frame() { return captured_frame_; }
96
97 private:
98 cricket::CapturedFrame captured_frame_;
99 std::unique_ptr<uint8_t[]> captured_frame_buffer_;
100 cricket::WebRtcVideoFrameFactory factory_;
101 };
102
103 TEST_F(WebRtcVideoFrameFactoryTest, NoApplyRotation) {
104 TestCreateAliasedFrame(false);
105 }
106
107 TEST_F(WebRtcVideoFrameFactoryTest, ApplyRotation) {
108 TestCreateAliasedFrame(true);
109 }
OLDNEW
« no previous file with comments | « webrtc/media/engine/webrtcvideoframefactory.cc ('k') | webrtc/media/media.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698