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

Unified Diff: webrtc/media/engine/webrtcvideoframe_unittest.cc

Issue 2091983002: Revert of Cleanups in cricket::VideoFrame and cricket::WebRtcVideoFrame. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/media/engine/webrtcvideoframe.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/media/engine/webrtcvideoframe_unittest.cc
diff --git a/webrtc/media/engine/webrtcvideoframe_unittest.cc b/webrtc/media/engine/webrtcvideoframe_unittest.cc
index fbb7ebd6257609d031027d1233aa8384bf7dafe9..abfd0aea3cdfe43ea36c86c42d40fed1cbea29bb 100644
--- a/webrtc/media/engine/webrtcvideoframe_unittest.cc
+++ b/webrtc/media/engine/webrtcvideoframe_unittest.cc
@@ -16,11 +16,37 @@
#include "webrtc/media/engine/webrtcvideoframe.h"
#include "webrtc/test/fake_texture_frame.h"
-namespace cricket {
-
-class WebRtcVideoFrameTest : public VideoFrameTest<WebRtcVideoFrame> {
+namespace {
+
+class WebRtcVideoTestFrame : public cricket::WebRtcVideoFrame {
public:
- WebRtcVideoFrameTest() {}
+ WebRtcVideoTestFrame() {}
+ WebRtcVideoTestFrame(
+ const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer,
+ int64_t time_stamp_ns,
+ webrtc::VideoRotation rotation)
+ : WebRtcVideoFrame(buffer, time_stamp_ns, rotation) {}
+
+ // The ApplyRotationToFrame test needs this as a public method.
+ using cricket::WebRtcVideoFrame::set_rotation;
+
+ virtual VideoFrame* CreateEmptyFrame(int w,
+ int h,
+ int64_t time_stamp) const override {
+ rtc::scoped_refptr<webrtc::I420Buffer> buffer(
+ new rtc::RefCountedObject<webrtc::I420Buffer>(w, h));
+ buffer->SetToBlack();
+ return new WebRtcVideoTestFrame(
+ buffer, time_stamp, webrtc::kVideoRotation_0);
+ }
+};
+
+} // namespace
+
+class WebRtcVideoFrameTest : public VideoFrameTest<cricket::WebRtcVideoFrame> {
+ public:
+ WebRtcVideoFrameTest() {
+ }
void TestInit(int cropped_width, int cropped_height,
webrtc::VideoRotation frame_rotation,
@@ -29,8 +55,8 @@
const int frame_height = 1080;
// Build the CapturedFrame.
- CapturedFrame captured_frame;
- captured_frame.fourcc = FOURCC_I420;
+ cricket::CapturedFrame captured_frame;
+ captured_frame.fourcc = cricket::FOURCC_I420;
captured_frame.time_stamp = rtc::TimeNanos();
captured_frame.rotation = frame_rotation;
captured_frame.width = frame_width;
@@ -44,7 +70,7 @@
captured_frame.data = captured_frame_buffer.get();
// Create the new frame from the CapturedFrame.
- WebRtcVideoFrame frame;
+ cricket::WebRtcVideoFrame frame;
EXPECT_TRUE(
frame.Init(&captured_frame, cropped_width, cropped_height,
apply_rotation));
@@ -69,8 +95,9 @@
}
};
-#define TEST_WEBRTCVIDEOFRAME(X) \
- TEST_F(WebRtcVideoFrameTest, X) { VideoFrameTest<WebRtcVideoFrame>::X(); }
+#define TEST_WEBRTCVIDEOFRAME(X) TEST_F(WebRtcVideoFrameTest, X) { \
+ VideoFrameTest<cricket::WebRtcVideoFrame>::X(); \
+}
TEST_WEBRTCVIDEOFRAME(ConstructI420)
TEST_WEBRTCVIDEOFRAME(ConstructI422)
@@ -254,7 +281,7 @@
new rtc::RefCountedObject<webrtc::test::FakeNativeHandleBuffer>(
dummy_handle, 640, 480);
// Timestamp is converted from ns to us, so last three digits are lost.
- WebRtcVideoFrame frame(buffer, 20000, webrtc::kVideoRotation_0);
+ cricket::WebRtcVideoFrame frame(buffer, 20000, webrtc::kVideoRotation_0);
EXPECT_EQ(dummy_handle, frame.video_frame_buffer()->native_handle());
EXPECT_EQ(640, frame.width());
EXPECT_EQ(480, frame.height());
@@ -272,8 +299,8 @@
new rtc::RefCountedObject<webrtc::test::FakeNativeHandleBuffer>(
dummy_handle, 640, 480);
// Timestamp is converted from ns to us, so last three digits are lost.
- WebRtcVideoFrame frame1(buffer, 20000, webrtc::kVideoRotation_0);
- VideoFrame* frame2 = frame1.Copy();
+ cricket::WebRtcVideoFrame frame1(buffer, 20000, webrtc::kVideoRotation_0);
+ cricket::VideoFrame* frame2 = frame1.Copy();
EXPECT_EQ(frame1.video_frame_buffer()->native_handle(),
frame2->video_frame_buffer()->native_handle());
EXPECT_EQ(frame1.width(), frame2->width());
@@ -284,17 +311,17 @@
}
TEST_F(WebRtcVideoFrameTest, ApplyRotationToFrame) {
- WebRtcVideoFrame applied0;
+ WebRtcVideoTestFrame applied0;
EXPECT_TRUE(IsNull(applied0));
- EXPECT_TRUE(LoadFrame(CreateYuvSample(kWidth, kHeight, 12).get(), FOURCC_I420,
- kWidth, kHeight, &applied0));
+ EXPECT_TRUE(LoadFrame(CreateYuvSample(kWidth, kHeight, 12).get(),
+ cricket::FOURCC_I420, kWidth, kHeight, &applied0));
// Claim that this frame needs to be rotated for 90 degree.
- applied0.rotation_ = webrtc::kVideoRotation_90;
+ applied0.set_rotation(webrtc::kVideoRotation_90);
// Apply rotation on frame 1. Output should be different from frame 1.
- WebRtcVideoFrame* applied90 =
- const_cast<WebRtcVideoFrame*>(static_cast<const WebRtcVideoFrame*>(
+ WebRtcVideoTestFrame* applied90 = const_cast<WebRtcVideoTestFrame*>(
+ static_cast<const WebRtcVideoTestFrame*>(
applied0.GetCopyWithRotationApplied()));
EXPECT_TRUE(applied90);
EXPECT_EQ(applied90->rotation(), webrtc::kVideoRotation_0);
@@ -302,11 +329,10 @@
// Claim the frame 2 needs to be rotated for another 270 degree. The output
// from frame 2 rotation should be the same as frame 1.
- applied90->rotation_ = webrtc::kVideoRotation_270;
- const VideoFrame* applied360 = applied90->GetCopyWithRotationApplied();
+ applied90->set_rotation(webrtc::kVideoRotation_270);
+ const cricket::VideoFrame* applied360 =
+ applied90->GetCopyWithRotationApplied();
EXPECT_TRUE(applied360);
EXPECT_EQ(applied360->rotation(), webrtc::kVideoRotation_0);
EXPECT_TRUE(IsEqual(applied0, *applied360, 0));
}
-
-} // namespace cricket
« 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