| 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 17 matching lines...) Expand all Loading... |
| 28 const int kMinHdHeight = 720; | 28 const int kMinHdHeight = 720; |
| 29 const uint32_t kTimeout = 5000U; | 29 const uint32_t kTimeout = 5000U; |
| 30 | 30 |
| 31 } // namespace | 31 } // namespace |
| 32 | 32 |
| 33 class VideoCapturerTest | 33 class VideoCapturerTest |
| 34 : public sigslot::has_slots<>, | 34 : public sigslot::has_slots<>, |
| 35 public testing::Test { | 35 public testing::Test { |
| 36 public: | 36 public: |
| 37 VideoCapturerTest() | 37 VideoCapturerTest() |
| 38 : capture_state_(cricket::CS_STOPPED), | 38 : capture_state_(cricket::CS_STOPPED), num_state_changes_(0) { |
| 39 num_state_changes_(0), | |
| 40 video_frames_received_(0), | |
| 41 expects_rotation_applied_(true) { | |
| 42 capturer_.SignalVideoFrame.connect(this, &VideoCapturerTest::OnVideoFrame); | |
| 43 capturer_.SignalStateChange.connect(this, | 39 capturer_.SignalStateChange.connect(this, |
| 44 &VideoCapturerTest::OnStateChange); | 40 &VideoCapturerTest::OnStateChange); |
| 45 } | 41 capturer_.AddOrUpdateSink(&renderer_, rtc::VideoWants()); |
| 46 | |
| 47 void set_expected_compensation(bool compensation) { | |
| 48 expects_rotation_applied_ = compensation; | |
| 49 } | 42 } |
| 50 | 43 |
| 51 protected: | 44 protected: |
| 52 void OnVideoFrame(cricket::VideoCapturer*, const cricket::VideoFrame* frame) { | |
| 53 ++video_frames_received_; | |
| 54 if (expects_rotation_applied_) { | |
| 55 EXPECT_EQ(webrtc::kVideoRotation_0, frame->GetRotation()); | |
| 56 } else { | |
| 57 EXPECT_EQ(capturer_.GetRotation(), frame->GetRotation()); | |
| 58 } | |
| 59 renderer_.RenderFrame(frame); | |
| 60 } | |
| 61 void OnStateChange(cricket::VideoCapturer*, | 45 void OnStateChange(cricket::VideoCapturer*, |
| 62 cricket::CaptureState capture_state) { | 46 cricket::CaptureState capture_state) { |
| 63 capture_state_ = capture_state; | 47 capture_state_ = capture_state; |
| 64 ++num_state_changes_; | 48 ++num_state_changes_; |
| 65 } | 49 } |
| 66 cricket::CaptureState capture_state() { return capture_state_; } | 50 cricket::CaptureState capture_state() { return capture_state_; } |
| 67 int num_state_changes() { return num_state_changes_; } | 51 int num_state_changes() { return num_state_changes_; } |
| 68 int video_frames_received() const { | |
| 69 return video_frames_received_; | |
| 70 } | |
| 71 | 52 |
| 72 cricket::FakeVideoCapturer capturer_; | 53 cricket::FakeVideoCapturer capturer_; |
| 73 cricket::CaptureState capture_state_; | 54 cricket::CaptureState capture_state_; |
| 74 int num_state_changes_; | 55 int num_state_changes_; |
| 75 int video_frames_received_; | |
| 76 cricket::FakeVideoRenderer renderer_; | 56 cricket::FakeVideoRenderer renderer_; |
| 77 bool expects_rotation_applied_; | 57 bool expects_rotation_applied_; |
| 78 }; | 58 }; |
| 79 | 59 |
| 80 TEST_F(VideoCapturerTest, CaptureState) { | 60 TEST_F(VideoCapturerTest, CaptureState) { |
| 81 EXPECT_TRUE(capturer_.enable_video_adapter()); | 61 EXPECT_TRUE(capturer_.enable_video_adapter()); |
| 82 EXPECT_EQ(cricket::CS_RUNNING, capturer_.Start(cricket::VideoFormat( | 62 EXPECT_EQ(cricket::CS_RUNNING, capturer_.Start(cricket::VideoFormat( |
| 83 640, | 63 640, |
| 84 480, | 64 480, |
| 85 cricket::VideoFormat::FpsToInterval(30), | 65 cricket::VideoFormat::FpsToInterval(30), |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 EXPECT_EQ(1, num_state_changes()); | 122 EXPECT_EQ(1, num_state_changes()); |
| 143 } | 123 } |
| 144 | 124 |
| 145 TEST_F(VideoCapturerTest, CameraOffOnMute) { | 125 TEST_F(VideoCapturerTest, CameraOffOnMute) { |
| 146 EXPECT_EQ(cricket::CS_RUNNING, capturer_.Start(cricket::VideoFormat( | 126 EXPECT_EQ(cricket::CS_RUNNING, capturer_.Start(cricket::VideoFormat( |
| 147 640, | 127 640, |
| 148 480, | 128 480, |
| 149 cricket::VideoFormat::FpsToInterval(30), | 129 cricket::VideoFormat::FpsToInterval(30), |
| 150 cricket::FOURCC_I420))); | 130 cricket::FOURCC_I420))); |
| 151 EXPECT_TRUE(capturer_.IsRunning()); | 131 EXPECT_TRUE(capturer_.IsRunning()); |
| 152 EXPECT_EQ(0, video_frames_received()); | 132 EXPECT_EQ(0, renderer_.num_rendered_frames()); |
| 153 EXPECT_TRUE(capturer_.CaptureFrame()); | 133 EXPECT_TRUE(capturer_.CaptureFrame()); |
| 154 EXPECT_EQ(1, video_frames_received()); | 134 EXPECT_EQ(1, renderer_.num_rendered_frames()); |
| 155 EXPECT_FALSE(capturer_.IsMuted()); | 135 EXPECT_FALSE(capturer_.IsMuted()); |
| 156 | 136 |
| 157 // Mute the camera and expect black output frame. | 137 // Mute the camera and expect black output frame. |
| 158 capturer_.MuteToBlackThenPause(true); | 138 capturer_.MuteToBlackThenPause(true); |
| 159 EXPECT_TRUE(capturer_.IsMuted()); | 139 EXPECT_TRUE(capturer_.IsMuted()); |
| 160 for (int i = 0; i < 31; ++i) { | 140 for (int i = 0; i < 31; ++i) { |
| 161 EXPECT_TRUE(capturer_.CaptureFrame()); | 141 EXPECT_TRUE(capturer_.CaptureFrame()); |
| 162 EXPECT_TRUE(renderer_.black_frame()); | 142 EXPECT_TRUE(renderer_.black_frame()); |
| 163 } | 143 } |
| 164 EXPECT_EQ(32, video_frames_received()); | 144 EXPECT_EQ(32, renderer_.num_rendered_frames()); |
| 165 EXPECT_EQ_WAIT(cricket::CS_PAUSED, | 145 EXPECT_EQ_WAIT(cricket::CS_PAUSED, |
| 166 capturer_.capture_state(), kTimeout); | 146 capturer_.capture_state(), kTimeout); |
| 167 | 147 |
| 168 // Verify that the camera is off. | 148 // Verify that the camera is off. |
| 169 EXPECT_FALSE(capturer_.CaptureFrame()); | 149 EXPECT_FALSE(capturer_.CaptureFrame()); |
| 170 EXPECT_EQ(32, video_frames_received()); | 150 EXPECT_EQ(32, renderer_.num_rendered_frames()); |
| 171 | 151 |
| 172 // Unmute the camera and expect non-black output frame. | 152 // Unmute the camera and expect non-black output frame. |
| 173 capturer_.MuteToBlackThenPause(false); | 153 capturer_.MuteToBlackThenPause(false); |
| 174 EXPECT_FALSE(capturer_.IsMuted()); | 154 EXPECT_FALSE(capturer_.IsMuted()); |
| 175 EXPECT_EQ_WAIT(cricket::CS_RUNNING, | 155 EXPECT_EQ_WAIT(cricket::CS_RUNNING, |
| 176 capturer_.capture_state(), kTimeout); | 156 capturer_.capture_state(), kTimeout); |
| 177 EXPECT_TRUE(capturer_.CaptureFrame()); | 157 EXPECT_TRUE(capturer_.CaptureFrame()); |
| 178 EXPECT_FALSE(renderer_.black_frame()); | 158 EXPECT_FALSE(renderer_.black_frame()); |
| 179 EXPECT_EQ(33, video_frames_received()); | 159 EXPECT_EQ(33, renderer_.num_rendered_frames()); |
| 180 } | 160 } |
| 181 | 161 |
| 182 TEST_F(VideoCapturerTest, ScreencastScaledOddWidth) { | 162 TEST_F(VideoCapturerTest, ScreencastScaledOddWidth) { |
| 183 capturer_.SetScreencast(true); | 163 capturer_.SetScreencast(true); |
| 184 | 164 |
| 185 int kWidth = 1281; | 165 int kWidth = 1281; |
| 186 int kHeight = 720; | 166 int kHeight = 720; |
| 187 | 167 |
| 188 std::vector<cricket::VideoFormat> formats; | 168 std::vector<cricket::VideoFormat> formats; |
| 189 formats.push_back(cricket::VideoFormat(kWidth, kHeight, | 169 formats.push_back(cricket::VideoFormat(kWidth, kHeight, |
| 190 cricket::VideoFormat::FpsToInterval(5), cricket::FOURCC_ARGB)); | 170 cricket::VideoFormat::FpsToInterval(5), cricket::FOURCC_ARGB)); |
| 191 capturer_.ResetSupportedFormats(formats); | 171 capturer_.ResetSupportedFormats(formats); |
| 192 | 172 |
| 193 EXPECT_EQ(cricket::CS_RUNNING, capturer_.Start(cricket::VideoFormat( | 173 EXPECT_EQ(cricket::CS_RUNNING, capturer_.Start(cricket::VideoFormat( |
| 194 kWidth, | 174 kWidth, |
| 195 kHeight, | 175 kHeight, |
| 196 cricket::VideoFormat::FpsToInterval(30), | 176 cricket::VideoFormat::FpsToInterval(30), |
| 197 cricket::FOURCC_ARGB))); | 177 cricket::FOURCC_ARGB))); |
| 198 EXPECT_TRUE(capturer_.IsRunning()); | 178 EXPECT_TRUE(capturer_.IsRunning()); |
| 199 EXPECT_EQ(0, renderer_.num_rendered_frames()); | 179 EXPECT_EQ(0, renderer_.num_rendered_frames()); |
| 200 EXPECT_TRUE(capturer_.CaptureFrame()); | 180 EXPECT_TRUE(capturer_.CaptureFrame()); |
| 201 EXPECT_EQ(1, renderer_.num_rendered_frames()); | 181 EXPECT_EQ(1, renderer_.num_rendered_frames()); |
| 202 EXPECT_EQ(kWidth, renderer_.width()); | 182 EXPECT_EQ(kWidth, renderer_.width()); |
| 203 EXPECT_EQ(kHeight, renderer_.height()); | 183 EXPECT_EQ(kHeight, renderer_.height()); |
| 204 } | 184 } |
| 205 | 185 |
| 206 TEST_F(VideoCapturerTest, TestRotationPending) { | 186 TEST_F(VideoCapturerTest, TestRotationAppliedBySource) { |
| 207 int kWidth = 800; | 187 int kWidth = 800; |
| 208 int kHeight = 400; | 188 int kHeight = 400; |
| 209 int frame_count = 0; | 189 int frame_count = 0; |
| 210 | 190 |
| 211 std::vector<cricket::VideoFormat> formats; | 191 std::vector<cricket::VideoFormat> formats; |
| 212 formats.push_back(cricket::VideoFormat(kWidth, kHeight, | 192 formats.push_back(cricket::VideoFormat(kWidth, kHeight, |
| 213 cricket::VideoFormat::FpsToInterval(5), | 193 cricket::VideoFormat::FpsToInterval(5), |
| 214 cricket::FOURCC_I420)); | 194 cricket::FOURCC_I420)); |
| 215 | 195 |
| 216 capturer_.ResetSupportedFormats(formats); | 196 capturer_.ResetSupportedFormats(formats); |
| 197 |
| 217 // capturer_ should compensate rotation as default. | 198 // capturer_ should compensate rotation as default. |
| 218 capturer_.UpdateAspectRatio(400, 200); | 199 capturer_.UpdateAspectRatio(400, 200); |
| 219 | 200 |
| 220 EXPECT_EQ(cricket::CS_RUNNING, | 201 EXPECT_EQ(cricket::CS_RUNNING, |
| 221 capturer_.Start(cricket::VideoFormat( | 202 capturer_.Start(cricket::VideoFormat( |
| 222 kWidth, kHeight, cricket::VideoFormat::FpsToInterval(30), | 203 kWidth, kHeight, cricket::VideoFormat::FpsToInterval(30), |
| 223 cricket::FOURCC_I420))); | 204 cricket::FOURCC_I420))); |
| 224 EXPECT_TRUE(capturer_.IsRunning()); | 205 EXPECT_TRUE(capturer_.IsRunning()); |
| 225 EXPECT_EQ(0, renderer_.num_rendered_frames()); | 206 EXPECT_EQ(0, renderer_.num_rendered_frames()); |
| 226 | 207 |
| 227 // If the frame's rotation is compensated anywhere in the pipeline based on | 208 // If the frame's rotation is compensated anywhere in the pipeline based on |
| 228 // the rotation information, the renderer should be given the right dimension | 209 // the rotation information, the renderer should be given the right dimension |
| 229 // such that the frame could be rendered. | 210 // such that the frame could be rendered. |
| 230 | 211 |
| 231 capturer_.SetRotation(webrtc::kVideoRotation_90); | 212 capturer_.SetRotation(webrtc::kVideoRotation_90); |
| 232 EXPECT_TRUE(capturer_.CaptureFrame()); | 213 EXPECT_TRUE(capturer_.CaptureFrame()); |
| 233 EXPECT_EQ(++frame_count, renderer_.num_rendered_frames()); | 214 EXPECT_EQ(++frame_count, renderer_.num_rendered_frames()); |
| 234 // Swapped width and height | 215 // Swapped width and height |
| 235 EXPECT_EQ(kWidth, renderer_.height()); | 216 EXPECT_EQ(kWidth, renderer_.height()); |
| 236 EXPECT_EQ(kHeight, renderer_.width()); | 217 EXPECT_EQ(kHeight, renderer_.width()); |
| 218 EXPECT_EQ(webrtc::kVideoRotation_0, renderer_.rotation()); |
| 237 | 219 |
| 238 capturer_.SetRotation(webrtc::kVideoRotation_270); | 220 capturer_.SetRotation(webrtc::kVideoRotation_270); |
| 239 EXPECT_TRUE(capturer_.CaptureFrame()); | 221 EXPECT_TRUE(capturer_.CaptureFrame()); |
| 240 EXPECT_EQ(++frame_count, renderer_.num_rendered_frames()); | 222 EXPECT_EQ(++frame_count, renderer_.num_rendered_frames()); |
| 241 // Swapped width and height | 223 // Swapped width and height |
| 242 EXPECT_EQ(kWidth, renderer_.height()); | 224 EXPECT_EQ(kWidth, renderer_.height()); |
| 243 EXPECT_EQ(kHeight, renderer_.width()); | 225 EXPECT_EQ(kHeight, renderer_.width()); |
| 226 EXPECT_EQ(webrtc::kVideoRotation_0, renderer_.rotation()); |
| 244 | 227 |
| 245 capturer_.SetRotation(webrtc::kVideoRotation_180); | 228 capturer_.SetRotation(webrtc::kVideoRotation_180); |
| 246 EXPECT_TRUE(capturer_.CaptureFrame()); | 229 EXPECT_TRUE(capturer_.CaptureFrame()); |
| 247 EXPECT_EQ(++frame_count, renderer_.num_rendered_frames()); | 230 EXPECT_EQ(++frame_count, renderer_.num_rendered_frames()); |
| 248 // Back to normal width and height | 231 // Back to normal width and height |
| 249 EXPECT_EQ(kWidth, renderer_.width()); | 232 EXPECT_EQ(kWidth, renderer_.width()); |
| 250 EXPECT_EQ(kHeight, renderer_.height()); | 233 EXPECT_EQ(kHeight, renderer_.height()); |
| 234 EXPECT_EQ(webrtc::kVideoRotation_0, renderer_.rotation()); |
| 251 } | 235 } |
| 252 | 236 |
| 253 TEST_F(VideoCapturerTest, TestRotationApplied) { | 237 TEST_F(VideoCapturerTest, TestRotationAppliedBySink) { |
| 254 int kWidth = 800; | 238 int kWidth = 800; |
| 255 int kHeight = 400; | 239 int kHeight = 400; |
| 256 | 240 |
| 257 std::vector<cricket::VideoFormat> formats; | 241 std::vector<cricket::VideoFormat> formats; |
| 258 formats.push_back(cricket::VideoFormat(kWidth, kHeight, | 242 formats.push_back(cricket::VideoFormat(kWidth, kHeight, |
| 259 cricket::VideoFormat::FpsToInterval(5), | 243 cricket::VideoFormat::FpsToInterval(5), |
| 260 cricket::FOURCC_I420)); | 244 cricket::FOURCC_I420)); |
| 261 | 245 |
| 262 capturer_.ResetSupportedFormats(formats); | 246 capturer_.ResetSupportedFormats(formats); |
| 247 rtc::VideoWants wants; |
| 263 // capturer_ should not compensate rotation. | 248 // capturer_ should not compensate rotation. |
| 264 capturer_.SetApplyRotation(false); | 249 wants.rotation_applied = false; |
| 250 capturer_.AddOrUpdateSink(&renderer_, wants); |
| 251 |
| 265 capturer_.UpdateAspectRatio(400, 200); | 252 capturer_.UpdateAspectRatio(400, 200); |
| 266 set_expected_compensation(false); | |
| 267 | 253 |
| 268 EXPECT_EQ(cricket::CS_RUNNING, | 254 EXPECT_EQ(cricket::CS_RUNNING, |
| 269 capturer_.Start(cricket::VideoFormat( | 255 capturer_.Start(cricket::VideoFormat( |
| 270 kWidth, kHeight, cricket::VideoFormat::FpsToInterval(30), | 256 kWidth, kHeight, cricket::VideoFormat::FpsToInterval(30), |
| 271 cricket::FOURCC_I420))); | 257 cricket::FOURCC_I420))); |
| 272 EXPECT_TRUE(capturer_.IsRunning()); | 258 EXPECT_TRUE(capturer_.IsRunning()); |
| 273 EXPECT_EQ(0, renderer_.num_rendered_frames()); | 259 EXPECT_EQ(0, renderer_.num_rendered_frames()); |
| 274 | 260 |
| 275 // If the frame's rotation is compensated anywhere in the pipeline, the frame | 261 // If the frame's rotation is compensated anywhere in the pipeline, the frame |
| 276 // won't have its original dimension out from capturer. Since the renderer | 262 // won't have its original dimension out from capturer. Since the renderer |
| 277 // here has the same dimension as the capturer, it will skip that frame as the | 263 // here has the same dimension as the capturer, it will skip that frame as the |
| 278 // resolution won't match anymore. | 264 // resolution won't match anymore. |
| 279 | 265 |
| 280 int frame_count = 0; | 266 int frame_count = 0; |
| 281 capturer_.SetRotation(webrtc::kVideoRotation_0); | 267 capturer_.SetRotation(webrtc::kVideoRotation_0); |
| 282 EXPECT_TRUE(capturer_.CaptureFrame()); | 268 EXPECT_TRUE(capturer_.CaptureFrame()); |
| 283 EXPECT_EQ(++frame_count, renderer_.num_rendered_frames()); | 269 EXPECT_EQ(++frame_count, renderer_.num_rendered_frames()); |
| 270 EXPECT_EQ(capturer_.GetRotation(), renderer_.rotation()); |
| 284 | 271 |
| 285 capturer_.SetRotation(webrtc::kVideoRotation_90); | 272 capturer_.SetRotation(webrtc::kVideoRotation_90); |
| 286 EXPECT_TRUE(capturer_.CaptureFrame()); | 273 EXPECT_TRUE(capturer_.CaptureFrame()); |
| 287 EXPECT_EQ(++frame_count, renderer_.num_rendered_frames()); | 274 EXPECT_EQ(++frame_count, renderer_.num_rendered_frames()); |
| 275 EXPECT_EQ(capturer_.GetRotation(), renderer_.rotation()); |
| 288 | 276 |
| 289 capturer_.SetRotation(webrtc::kVideoRotation_180); | 277 capturer_.SetRotation(webrtc::kVideoRotation_180); |
| 290 EXPECT_TRUE(capturer_.CaptureFrame()); | 278 EXPECT_TRUE(capturer_.CaptureFrame()); |
| 291 EXPECT_EQ(++frame_count, renderer_.num_rendered_frames()); | 279 EXPECT_EQ(++frame_count, renderer_.num_rendered_frames()); |
| 280 EXPECT_EQ(capturer_.GetRotation(), renderer_.rotation()); |
| 292 | 281 |
| 293 capturer_.SetRotation(webrtc::kVideoRotation_270); | 282 capturer_.SetRotation(webrtc::kVideoRotation_270); |
| 294 EXPECT_TRUE(capturer_.CaptureFrame()); | 283 EXPECT_TRUE(capturer_.CaptureFrame()); |
| 295 EXPECT_EQ(++frame_count, renderer_.num_rendered_frames()); | 284 EXPECT_EQ(++frame_count, renderer_.num_rendered_frames()); |
| 285 EXPECT_EQ(capturer_.GetRotation(), renderer_.rotation()); |
| 286 } |
| 287 |
| 288 TEST_F(VideoCapturerTest, TestRotationAppliedBySourceWhenDifferentWants) { |
| 289 int kWidth = 800; |
| 290 int kHeight = 400; |
| 291 |
| 292 std::vector<cricket::VideoFormat> formats; |
| 293 formats.push_back(cricket::VideoFormat(kWidth, kHeight, |
| 294 cricket::VideoFormat::FpsToInterval(5), |
| 295 cricket::FOURCC_I420)); |
| 296 |
| 297 capturer_.ResetSupportedFormats(formats); |
| 298 rtc::VideoWants wants; |
| 299 // capturer_ should not compensate rotation. |
| 300 wants.rotation_applied = false; |
| 301 capturer_.AddOrUpdateSink(&renderer_, wants); |
| 302 |
| 303 capturer_.UpdateAspectRatio(400, 200); |
| 304 |
| 305 EXPECT_EQ(cricket::CS_RUNNING, |
| 306 capturer_.Start(cricket::VideoFormat( |
| 307 kWidth, kHeight, cricket::VideoFormat::FpsToInterval(30), |
| 308 cricket::FOURCC_I420))); |
| 309 EXPECT_TRUE(capturer_.IsRunning()); |
| 310 EXPECT_EQ(0, renderer_.num_rendered_frames()); |
| 311 |
| 312 int frame_count = 0; |
| 313 capturer_.SetRotation(webrtc::kVideoRotation_90); |
| 314 EXPECT_TRUE(capturer_.CaptureFrame()); |
| 315 EXPECT_EQ(++frame_count, renderer_.num_rendered_frames()); |
| 316 EXPECT_EQ(capturer_.GetRotation(), renderer_.rotation()); |
| 317 |
| 318 // Add another sink that wants frames to be rotated. |
| 319 cricket::FakeVideoRenderer renderer2; |
| 320 wants.rotation_applied = true; |
| 321 capturer_.AddOrUpdateSink(&renderer2, wants); |
| 322 |
| 323 EXPECT_TRUE(capturer_.CaptureFrame()); |
| 324 EXPECT_EQ(++frame_count, renderer_.num_rendered_frames()); |
| 325 EXPECT_EQ(1, renderer2.num_rendered_frames()); |
| 326 EXPECT_EQ(webrtc::kVideoRotation_0, renderer_.rotation()); |
| 327 EXPECT_EQ(webrtc::kVideoRotation_0, renderer2.rotation()); |
| 296 } | 328 } |
| 297 | 329 |
| 298 TEST_F(VideoCapturerTest, ScreencastScaledSuperLarge) { | 330 TEST_F(VideoCapturerTest, ScreencastScaledSuperLarge) { |
| 299 capturer_.SetScreencast(true); | 331 capturer_.SetScreencast(true); |
| 300 | 332 |
| 301 const int kMaxWidth = 4096; | 333 const int kMaxWidth = 4096; |
| 302 const int kMaxHeight = 3072; | 334 const int kMaxHeight = 3072; |
| 303 int kWidth = kMaxWidth + 4; | 335 int kWidth = kMaxWidth + 4; |
| 304 int kHeight = kMaxHeight + 4; | 336 int kHeight = kMaxHeight + 4; |
| 305 | 337 |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 EXPECT_EQ(required_formats[i].width, best.width); | 740 EXPECT_EQ(required_formats[i].width, best.width); |
| 709 EXPECT_EQ(required_formats[i].height, best.height); | 741 EXPECT_EQ(required_formats[i].height, best.height); |
| 710 } | 742 } |
| 711 | 743 |
| 712 // Expect 16x9 for 16x9 request. | 744 // Expect 16x9 for 16x9 request. |
| 713 EXPECT_TRUE(capturer_.GetBestCaptureFormat(required_formats[2], &best)); | 745 EXPECT_TRUE(capturer_.GetBestCaptureFormat(required_formats[2], &best)); |
| 714 EXPECT_EQ(640, best.width); | 746 EXPECT_EQ(640, best.width); |
| 715 EXPECT_EQ(360, best.height); | 747 EXPECT_EQ(360, best.height); |
| 716 } | 748 } |
| 717 | 749 |
| 718 // If HAVE_WEBRTC_VIDEO is not defined the video capturer will not be able to | |
| 719 // provide OnVideoFrame-callbacks since they require cricket::CapturedFrame to | |
| 720 // be decoded as a cricket::VideoFrame (i.e. an I420 frame). This functionality | |
| 721 // only exist if HAVE_WEBRTC_VIDEO is defined below. I420 frames are also a | |
| 722 // requirement for the VideoProcessors so they will not be called either. | |
| 723 #if defined(HAVE_WEBRTC_VIDEO) | |
| 724 TEST_F(VideoCapturerTest, VideoFrame) { | |
| 725 EXPECT_EQ(cricket::CS_RUNNING, capturer_.Start(cricket::VideoFormat( | |
| 726 640, | |
| 727 480, | |
| 728 cricket::VideoFormat::FpsToInterval(30), | |
| 729 cricket::FOURCC_I420))); | |
| 730 EXPECT_TRUE(capturer_.IsRunning()); | |
| 731 EXPECT_EQ(0, video_frames_received()); | |
| 732 EXPECT_TRUE(capturer_.CaptureFrame()); | |
| 733 EXPECT_EQ(1, video_frames_received()); | |
| 734 } | |
| 735 #endif // HAVE_WEBRTC_VIDEO | |
| 736 | |
| 737 bool HdFormatInList(const std::vector<cricket::VideoFormat>& formats) { | 750 bool HdFormatInList(const std::vector<cricket::VideoFormat>& formats) { |
| 738 for (std::vector<cricket::VideoFormat>::const_iterator found = | 751 for (std::vector<cricket::VideoFormat>::const_iterator found = |
| 739 formats.begin(); found != formats.end(); ++found) { | 752 formats.begin(); found != formats.end(); ++found) { |
| 740 if (found->height >= kMinHdHeight) { | 753 if (found->height >= kMinHdHeight) { |
| 741 return true; | 754 return true; |
| 742 } | 755 } |
| 743 } | 756 } |
| 744 return false; | 757 return false; |
| 745 } | 758 } |
| 746 | 759 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 791 capturer_.set_enable_camera_list(true); | 804 capturer_.set_enable_camera_list(true); |
| 792 capturer_.ConstrainSupportedFormats(vga_format); | 805 capturer_.ConstrainSupportedFormats(vga_format); |
| 793 EXPECT_EQ(2u, capturer_.GetSupportedFormats()->size()); | 806 EXPECT_EQ(2u, capturer_.GetSupportedFormats()->size()); |
| 794 // To make sure it's not just the camera list being broken, add in VGA and | 807 // To make sure it's not just the camera list being broken, add in VGA and |
| 795 // try again. This time, only the VGA format should be there. | 808 // try again. This time, only the VGA format should be there. |
| 796 supported_formats.push_back(vga_format); | 809 supported_formats.push_back(vga_format); |
| 797 capturer_.ResetSupportedFormats(supported_formats); | 810 capturer_.ResetSupportedFormats(supported_formats); |
| 798 ASSERT_EQ(1u, capturer_.GetSupportedFormats()->size()); | 811 ASSERT_EQ(1u, capturer_.GetSupportedFormats()->size()); |
| 799 EXPECT_EQ(vga_format.height, capturer_.GetSupportedFormats()->at(0).height); | 812 EXPECT_EQ(vga_format.height, capturer_.GetSupportedFormats()->at(0).height); |
| 800 } | 813 } |
| OLD | NEW |