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