OLD | NEW |
---|---|
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2008 Google Inc. | 3 * Copyright 2008 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
49 | 49 |
50 class VideoCapturerTest | 50 class VideoCapturerTest |
51 : public sigslot::has_slots<>, | 51 : public sigslot::has_slots<>, |
52 public testing::Test { | 52 public testing::Test { |
53 public: | 53 public: |
54 VideoCapturerTest() | 54 VideoCapturerTest() |
55 : capture_state_(cricket::CS_STOPPED), | 55 : capture_state_(cricket::CS_STOPPED), |
56 num_state_changes_(0), | 56 num_state_changes_(0), |
57 video_frames_received_(0), | 57 video_frames_received_(0), |
58 expects_rotation_applied_(true) { | 58 expects_rotation_applied_(true) { |
59 capturer_.SignalVideoFrame.connect(this, &VideoCapturerTest::OnVideoFrame); | 59 renderer_.SignalRenderFrame.connect(this, &VideoCapturerTest::OnVideoFrame); |
60 capturer_.SignalStateChange.connect(this, | 60 capturer_.SignalStateChange.connect(this, |
61 &VideoCapturerTest::OnStateChange); | 61 &VideoCapturerTest::OnStateChange); |
62 rtc::VideoSinkCapabilities sink_capabilities; | |
63 sink_capabilities.can_apply_rotation = !expects_rotation_applied_; | |
nisse-webrtc
2016/02/03 09:16:34
Is it possible to name these flags in some differe
perkj_webrtc
2016/02/08 14:32:00
ptal
| |
64 capturer_.AddSink(&renderer_, sink_capabilities); | |
62 } | 65 } |
63 | 66 |
64 void set_expected_compensation(bool compensation) { | 67 void set_expected_compensation(bool compensation) { |
65 expects_rotation_applied_ = compensation; | 68 expects_rotation_applied_ = compensation; |
69 capturer_.RemoveSink(&renderer_); | |
70 rtc::VideoSinkCapabilities sink_capabilities; | |
71 sink_capabilities.can_apply_rotation = !expects_rotation_applied_; | |
72 capturer_.AddSink(&renderer_, sink_capabilities); | |
66 } | 73 } |
67 | 74 |
68 protected: | 75 protected: |
69 void OnVideoFrame(cricket::VideoCapturer*, const cricket::VideoFrame* frame) { | 76 void OnVideoFrame(const cricket::VideoFrame* frame) { |
70 ++video_frames_received_; | 77 ++video_frames_received_; |
71 if (expects_rotation_applied_) { | 78 if (expects_rotation_applied_) { |
72 EXPECT_EQ(webrtc::kVideoRotation_0, frame->GetRotation()); | 79 EXPECT_EQ(webrtc::kVideoRotation_0, frame->GetRotation()); |
73 } else { | 80 } else { |
74 EXPECT_EQ(capturer_.GetRotation(), frame->GetRotation()); | 81 EXPECT_EQ(capturer_.GetRotation(), frame->GetRotation()); |
75 } | 82 } |
76 renderer_.RenderFrame(frame); | |
77 } | 83 } |
78 void OnStateChange(cricket::VideoCapturer*, | 84 void OnStateChange(cricket::VideoCapturer*, |
79 cricket::CaptureState capture_state) { | 85 cricket::CaptureState capture_state) { |
80 capture_state_ = capture_state; | 86 capture_state_ = capture_state; |
81 ++num_state_changes_; | 87 ++num_state_changes_; |
82 } | 88 } |
83 cricket::CaptureState capture_state() { return capture_state_; } | 89 cricket::CaptureState capture_state() { return capture_state_; } |
84 int num_state_changes() { return num_state_changes_; } | 90 int num_state_changes() { return num_state_changes_; } |
85 int video_frames_received() const { | 91 int video_frames_received() const { |
86 return video_frames_received_; | 92 return video_frames_received_; |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
271 int kWidth = 800; | 277 int kWidth = 800; |
272 int kHeight = 400; | 278 int kHeight = 400; |
273 | 279 |
274 std::vector<cricket::VideoFormat> formats; | 280 std::vector<cricket::VideoFormat> formats; |
275 formats.push_back(cricket::VideoFormat(kWidth, kHeight, | 281 formats.push_back(cricket::VideoFormat(kWidth, kHeight, |
276 cricket::VideoFormat::FpsToInterval(5), | 282 cricket::VideoFormat::FpsToInterval(5), |
277 cricket::FOURCC_I420)); | 283 cricket::FOURCC_I420)); |
278 | 284 |
279 capturer_.ResetSupportedFormats(formats); | 285 capturer_.ResetSupportedFormats(formats); |
280 // capturer_ should not compensate rotation. | 286 // capturer_ should not compensate rotation. |
281 capturer_.SetApplyRotation(false); | 287 set_expected_compensation(false); |
282 capturer_.UpdateAspectRatio(400, 200); | 288 capturer_.UpdateAspectRatio(400, 200); |
283 set_expected_compensation(false); | |
284 | 289 |
285 EXPECT_EQ(cricket::CS_RUNNING, | 290 EXPECT_EQ(cricket::CS_RUNNING, |
286 capturer_.Start(cricket::VideoFormat( | 291 capturer_.Start(cricket::VideoFormat( |
287 kWidth, kHeight, cricket::VideoFormat::FpsToInterval(30), | 292 kWidth, kHeight, cricket::VideoFormat::FpsToInterval(30), |
288 cricket::FOURCC_I420))); | 293 cricket::FOURCC_I420))); |
289 EXPECT_TRUE(capturer_.IsRunning()); | 294 EXPECT_TRUE(capturer_.IsRunning()); |
290 EXPECT_EQ(0, renderer_.num_rendered_frames()); | 295 EXPECT_EQ(0, renderer_.num_rendered_frames()); |
291 | 296 |
292 // If the frame's rotation is compensated anywhere in the pipeline, the frame | 297 // If the frame's rotation is compensated anywhere in the pipeline, the frame |
293 // won't have its original dimension out from capturer. Since the renderer | 298 // won't have its original dimension out from capturer. Since the renderer |
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
808 capturer_.set_enable_camera_list(true); | 813 capturer_.set_enable_camera_list(true); |
809 capturer_.ConstrainSupportedFormats(vga_format); | 814 capturer_.ConstrainSupportedFormats(vga_format); |
810 EXPECT_EQ(2u, capturer_.GetSupportedFormats()->size()); | 815 EXPECT_EQ(2u, capturer_.GetSupportedFormats()->size()); |
811 // To make sure it's not just the camera list being broken, add in VGA and | 816 // To make sure it's not just the camera list being broken, add in VGA and |
812 // try again. This time, only the VGA format should be there. | 817 // try again. This time, only the VGA format should be there. |
813 supported_formats.push_back(vga_format); | 818 supported_formats.push_back(vga_format); |
814 capturer_.ResetSupportedFormats(supported_formats); | 819 capturer_.ResetSupportedFormats(supported_formats); |
815 ASSERT_EQ(1u, capturer_.GetSupportedFormats()->size()); | 820 ASSERT_EQ(1u, capturer_.GetSupportedFormats()->size()); |
816 EXPECT_EQ(vga_format.height, capturer_.GetSupportedFormats()->at(0).height); | 821 EXPECT_EQ(vga_format.height, capturer_.GetSupportedFormats()->at(0).height); |
817 } | 822 } |
OLD | NEW |