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 |
11 #include <string.h> | 11 #include <string.h> |
12 | 12 |
13 #include <memory> | 13 #include <memory> |
14 | 14 |
15 #include "webrtc/media/base/videoframe_unittest.h" | 15 #include "webrtc/media/base/videoframe_unittest.h" |
16 #include "webrtc/media/engine/webrtcvideoframe.h" | 16 #include "webrtc/media/engine/webrtcvideoframe.h" |
17 #include "webrtc/test/fake_texture_frame.h" | 17 #include "webrtc/test/fake_texture_frame.h" |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 class WebRtcVideoTestFrame : public cricket::WebRtcVideoFrame { | 21 class WebRtcVideoTestFrame : public cricket::WebRtcVideoFrame { |
22 public: | 22 public: |
23 WebRtcVideoTestFrame() {} | |
24 WebRtcVideoTestFrame( | |
25 const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer, | |
26 int64_t time_stamp_ns, | |
27 webrtc::VideoRotation rotation) | |
28 : WebRtcVideoFrame(buffer, time_stamp_ns, rotation) {} | |
29 | |
30 // The ApplyRotationToFrame test needs this as a public method. | 23 // The ApplyRotationToFrame test needs this as a public method. |
31 using cricket::WebRtcVideoFrame::set_rotation; | 24 using cricket::WebRtcVideoFrame::set_rotation; |
32 | 25 |
33 virtual VideoFrame* CreateEmptyFrame(int w, | 26 virtual VideoFrame* CreateEmptyFrame(int w, |
34 int h, | 27 int h, |
35 int64_t time_stamp) const override { | 28 int64_t time_stamp) const override { |
36 rtc::scoped_refptr<webrtc::I420Buffer> buffer( | 29 WebRtcVideoTestFrame* frame = new WebRtcVideoTestFrame(); |
37 new rtc::RefCountedObject<webrtc::I420Buffer>(w, h)); | 30 frame->InitToBlack(w, h, time_stamp); |
38 buffer->SetToBlack(); | 31 return frame; |
39 return new WebRtcVideoTestFrame( | |
40 buffer, time_stamp, webrtc::kVideoRotation_0); | |
41 } | 32 } |
42 }; | 33 }; |
43 | 34 |
44 } // namespace | 35 } // namespace |
45 | 36 |
46 class WebRtcVideoFrameTest : public VideoFrameTest<cricket::WebRtcVideoFrame> { | 37 class WebRtcVideoFrameTest : public VideoFrameTest<cricket::WebRtcVideoFrame> { |
47 public: | 38 public: |
48 WebRtcVideoFrameTest() { | 39 WebRtcVideoFrameTest() { |
49 } | 40 } |
50 | 41 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 TEST_WEBRTCVIDEOFRAME(ConstructI4201Pixel) | 138 TEST_WEBRTCVIDEOFRAME(ConstructI4201Pixel) |
148 TEST_WEBRTCVIDEOFRAME(ConstructI4205Pixel) | 139 TEST_WEBRTCVIDEOFRAME(ConstructI4205Pixel) |
149 // TODO(juberti): WebRtcVideoFrame does not support horizontal crop. | 140 // TODO(juberti): WebRtcVideoFrame does not support horizontal crop. |
150 // Re-evaluate once it supports 3 independent planes, since we might want to | 141 // Re-evaluate once it supports 3 independent planes, since we might want to |
151 // just Init normally and then crop by adjusting pointers. | 142 // just Init normally and then crop by adjusting pointers. |
152 // TEST_WEBRTCVIDEOFRAME(ConstructI420CropHorizontal) | 143 // TEST_WEBRTCVIDEOFRAME(ConstructI420CropHorizontal) |
153 TEST_WEBRTCVIDEOFRAME(ConstructI420CropVertical) | 144 TEST_WEBRTCVIDEOFRAME(ConstructI420CropVertical) |
154 // TODO(juberti): WebRtcVideoFrame is not currently refcounted. | 145 // TODO(juberti): WebRtcVideoFrame is not currently refcounted. |
155 // TEST_WEBRTCVIDEOFRAME(ConstructCopy) | 146 // TEST_WEBRTCVIDEOFRAME(ConstructCopy) |
156 // TEST_WEBRTCVIDEOFRAME(ConstructCopyIsRef) | 147 // TEST_WEBRTCVIDEOFRAME(ConstructCopyIsRef) |
| 148 TEST_WEBRTCVIDEOFRAME(ConstructBlack) |
157 // TODO(fbarchard): Implement Jpeg | 149 // TODO(fbarchard): Implement Jpeg |
158 // TEST_WEBRTCVIDEOFRAME(ConstructMjpgI420) | 150 // TEST_WEBRTCVIDEOFRAME(ConstructMjpgI420) |
159 TEST_WEBRTCVIDEOFRAME(ConstructMjpgI422) | 151 TEST_WEBRTCVIDEOFRAME(ConstructMjpgI422) |
160 // TEST_WEBRTCVIDEOFRAME(ConstructMjpgI444) | 152 // TEST_WEBRTCVIDEOFRAME(ConstructMjpgI444) |
161 // TEST_WEBRTCVIDEOFRAME(ConstructMjpgI411) | 153 // TEST_WEBRTCVIDEOFRAME(ConstructMjpgI411) |
162 // TEST_WEBRTCVIDEOFRAME(ConstructMjpgI400) | 154 // TEST_WEBRTCVIDEOFRAME(ConstructMjpgI400) |
163 // TEST_WEBRTCVIDEOFRAME(ValidateMjpgI420) | 155 // TEST_WEBRTCVIDEOFRAME(ValidateMjpgI420) |
164 // TEST_WEBRTCVIDEOFRAME(ValidateMjpgI422) | 156 // TEST_WEBRTCVIDEOFRAME(ValidateMjpgI422) |
165 // TEST_WEBRTCVIDEOFRAME(ValidateMjpgI444) | 157 // TEST_WEBRTCVIDEOFRAME(ValidateMjpgI444) |
166 // TEST_WEBRTCVIDEOFRAME(ValidateMjpgI411) | 158 // TEST_WEBRTCVIDEOFRAME(ValidateMjpgI411) |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 | 323 |
332 // Claim the frame 2 needs to be rotated for another 270 degree. The output | 324 // Claim the frame 2 needs to be rotated for another 270 degree. The output |
333 // from frame 2 rotation should be the same as frame 1. | 325 // from frame 2 rotation should be the same as frame 1. |
334 applied90->set_rotation(webrtc::kVideoRotation_270); | 326 applied90->set_rotation(webrtc::kVideoRotation_270); |
335 const cricket::VideoFrame* applied360 = | 327 const cricket::VideoFrame* applied360 = |
336 applied90->GetCopyWithRotationApplied(); | 328 applied90->GetCopyWithRotationApplied(); |
337 EXPECT_TRUE(applied360); | 329 EXPECT_TRUE(applied360); |
338 EXPECT_EQ(applied360->rotation(), webrtc::kVideoRotation_0); | 330 EXPECT_EQ(applied360->rotation(), webrtc::kVideoRotation_0); |
339 EXPECT_TRUE(IsEqual(applied0, *applied360, 0)); | 331 EXPECT_TRUE(IsEqual(applied0, *applied360, 0)); |
340 } | 332 } |
OLD | NEW |