OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2008 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2008 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 int kWidth = 800; | 109 int kWidth = 800; |
110 int kHeight = 400; | 110 int kHeight = 400; |
111 int frame_count = 0; | 111 int frame_count = 0; |
112 | 112 |
113 std::vector<cricket::VideoFormat> formats; | 113 std::vector<cricket::VideoFormat> formats; |
114 formats.push_back(cricket::VideoFormat(kWidth, kHeight, | 114 formats.push_back(cricket::VideoFormat(kWidth, kHeight, |
115 cricket::VideoFormat::FpsToInterval(5), | 115 cricket::VideoFormat::FpsToInterval(5), |
116 cricket::FOURCC_I420)); | 116 cricket::FOURCC_I420)); |
117 | 117 |
118 capturer_->ResetSupportedFormats(formats); | 118 capturer_->ResetSupportedFormats(formats); |
| 119 rtc::VideoSinkWants wants; |
| 120 // |capturer_| should compensate rotation. |
| 121 wants.rotation_applied = true; |
| 122 capturer_->AddOrUpdateSink(&renderer_, wants); |
119 | 123 |
120 // capturer_ should compensate rotation as default. | 124 // capturer_ should compensate rotation as default. |
121 EXPECT_EQ(cricket::CS_RUNNING, | 125 EXPECT_EQ(cricket::CS_RUNNING, |
122 capturer_->Start(cricket::VideoFormat( | 126 capturer_->Start(cricket::VideoFormat( |
123 kWidth, kHeight, cricket::VideoFormat::FpsToInterval(30), | 127 kWidth, kHeight, cricket::VideoFormat::FpsToInterval(30), |
124 cricket::FOURCC_I420))); | 128 cricket::FOURCC_I420))); |
125 EXPECT_TRUE(capturer_->IsRunning()); | 129 EXPECT_TRUE(capturer_->IsRunning()); |
126 EXPECT_EQ(0, renderer_.num_rendered_frames()); | 130 EXPECT_EQ(0, renderer_.num_rendered_frames()); |
127 | 131 |
128 // If the frame's rotation is compensated anywhere in the pipeline based on | 132 // If the frame's rotation is compensated anywhere in the pipeline based on |
(...skipping 18 matching lines...) Expand all Loading... |
147 | 151 |
148 capturer_->SetRotation(webrtc::kVideoRotation_180); | 152 capturer_->SetRotation(webrtc::kVideoRotation_180); |
149 EXPECT_TRUE(capturer_->CaptureFrame()); | 153 EXPECT_TRUE(capturer_->CaptureFrame()); |
150 EXPECT_EQ(++frame_count, renderer_.num_rendered_frames()); | 154 EXPECT_EQ(++frame_count, renderer_.num_rendered_frames()); |
151 // Back to normal width and height | 155 // Back to normal width and height |
152 EXPECT_EQ(kWidth, renderer_.width()); | 156 EXPECT_EQ(kWidth, renderer_.width()); |
153 EXPECT_EQ(kHeight, renderer_.height()); | 157 EXPECT_EQ(kHeight, renderer_.height()); |
154 EXPECT_EQ(webrtc::kVideoRotation_0, renderer_.rotation()); | 158 EXPECT_EQ(webrtc::kVideoRotation_0, renderer_.rotation()); |
155 } | 159 } |
156 | 160 |
157 TEST_F(VideoCapturerTest, TestRotationAppliedBySink) { | 161 TEST_F(VideoCapturerTest, TestRotationAppliedBySinkByDefault) { |
158 int kWidth = 800; | 162 int kWidth = 800; |
159 int kHeight = 400; | 163 int kHeight = 400; |
160 | 164 |
161 std::vector<cricket::VideoFormat> formats; | 165 std::vector<cricket::VideoFormat> formats; |
162 formats.push_back(cricket::VideoFormat(kWidth, kHeight, | 166 formats.push_back(cricket::VideoFormat(kWidth, kHeight, |
163 cricket::VideoFormat::FpsToInterval(5), | 167 cricket::VideoFormat::FpsToInterval(5), |
164 cricket::FOURCC_I420)); | 168 cricket::FOURCC_I420)); |
165 | 169 |
166 capturer_->ResetSupportedFormats(formats); | 170 capturer_->ResetSupportedFormats(formats); |
167 rtc::VideoSinkWants wants; | |
168 // capturer_ should not compensate rotation. | |
169 wants.rotation_applied = false; | |
170 capturer_->AddOrUpdateSink(&renderer_, wants); | |
171 | 171 |
172 EXPECT_EQ(cricket::CS_RUNNING, | 172 EXPECT_EQ(cricket::CS_RUNNING, |
173 capturer_->Start(cricket::VideoFormat( | 173 capturer_->Start(cricket::VideoFormat( |
174 kWidth, kHeight, cricket::VideoFormat::FpsToInterval(30), | 174 kWidth, kHeight, cricket::VideoFormat::FpsToInterval(30), |
175 cricket::FOURCC_I420))); | 175 cricket::FOURCC_I420))); |
176 EXPECT_TRUE(capturer_->IsRunning()); | 176 EXPECT_TRUE(capturer_->IsRunning()); |
177 EXPECT_EQ(0, renderer_.num_rendered_frames()); | 177 EXPECT_EQ(0, renderer_.num_rendered_frames()); |
178 | 178 |
179 // If the frame's rotation is compensated anywhere in the pipeline, the frame | 179 // If the frame's rotation is compensated anywhere in the pipeline, the frame |
180 // won't have its original dimension out from capturer. Since the renderer | 180 // won't have its original dimension out from capturer. Since the renderer |
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 capturer_->set_enable_camera_list(true); | 785 capturer_->set_enable_camera_list(true); |
786 capturer_->ConstrainSupportedFormats(vga_format); | 786 capturer_->ConstrainSupportedFormats(vga_format); |
787 EXPECT_EQ(2u, capturer_->GetSupportedFormats()->size()); | 787 EXPECT_EQ(2u, capturer_->GetSupportedFormats()->size()); |
788 // To make sure it's not just the camera list being broken, add in VGA and | 788 // To make sure it's not just the camera list being broken, add in VGA and |
789 // try again. This time, only the VGA format should be there. | 789 // try again. This time, only the VGA format should be there. |
790 supported_formats.push_back(vga_format); | 790 supported_formats.push_back(vga_format); |
791 capturer_->ResetSupportedFormats(supported_formats); | 791 capturer_->ResetSupportedFormats(supported_formats); |
792 ASSERT_EQ(1u, capturer_->GetSupportedFormats()->size()); | 792 ASSERT_EQ(1u, capturer_->GetSupportedFormats()->size()); |
793 EXPECT_EQ(vga_format.height, capturer_->GetSupportedFormats()->at(0).height); | 793 EXPECT_EQ(vga_format.height, capturer_->GetSupportedFormats()->at(0).height); |
794 } | 794 } |
OLD | NEW |