| 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); | |
| 123 | 119 |
| 124 // capturer_ should compensate rotation as default. | 120 // capturer_ should compensate rotation as default. |
| 125 EXPECT_EQ(cricket::CS_RUNNING, | 121 EXPECT_EQ(cricket::CS_RUNNING, |
| 126 capturer_->Start(cricket::VideoFormat( | 122 capturer_->Start(cricket::VideoFormat( |
| 127 kWidth, kHeight, cricket::VideoFormat::FpsToInterval(30), | 123 kWidth, kHeight, cricket::VideoFormat::FpsToInterval(30), |
| 128 cricket::FOURCC_I420))); | 124 cricket::FOURCC_I420))); |
| 129 EXPECT_TRUE(capturer_->IsRunning()); | 125 EXPECT_TRUE(capturer_->IsRunning()); |
| 130 EXPECT_EQ(0, renderer_.num_rendered_frames()); | 126 EXPECT_EQ(0, renderer_.num_rendered_frames()); |
| 131 | 127 |
| 132 // If the frame's rotation is compensated anywhere in the pipeline based on | 128 // If the frame's rotation is compensated anywhere in the pipeline based on |
| (...skipping 18 matching lines...) Expand all Loading... |
| 151 | 147 |
| 152 capturer_->SetRotation(webrtc::kVideoRotation_180); | 148 capturer_->SetRotation(webrtc::kVideoRotation_180); |
| 153 EXPECT_TRUE(capturer_->CaptureFrame()); | 149 EXPECT_TRUE(capturer_->CaptureFrame()); |
| 154 EXPECT_EQ(++frame_count, renderer_.num_rendered_frames()); | 150 EXPECT_EQ(++frame_count, renderer_.num_rendered_frames()); |
| 155 // Back to normal width and height | 151 // Back to normal width and height |
| 156 EXPECT_EQ(kWidth, renderer_.width()); | 152 EXPECT_EQ(kWidth, renderer_.width()); |
| 157 EXPECT_EQ(kHeight, renderer_.height()); | 153 EXPECT_EQ(kHeight, renderer_.height()); |
| 158 EXPECT_EQ(webrtc::kVideoRotation_0, renderer_.rotation()); | 154 EXPECT_EQ(webrtc::kVideoRotation_0, renderer_.rotation()); |
| 159 } | 155 } |
| 160 | 156 |
| 161 TEST_F(VideoCapturerTest, TestRotationAppliedBySinkByDefault) { | 157 TEST_F(VideoCapturerTest, TestRotationAppliedBySink) { |
| 162 int kWidth = 800; | 158 int kWidth = 800; |
| 163 int kHeight = 400; | 159 int kHeight = 400; |
| 164 | 160 |
| 165 std::vector<cricket::VideoFormat> formats; | 161 std::vector<cricket::VideoFormat> formats; |
| 166 formats.push_back(cricket::VideoFormat(kWidth, kHeight, | 162 formats.push_back(cricket::VideoFormat(kWidth, kHeight, |
| 167 cricket::VideoFormat::FpsToInterval(5), | 163 cricket::VideoFormat::FpsToInterval(5), |
| 168 cricket::FOURCC_I420)); | 164 cricket::FOURCC_I420)); |
| 169 | 165 |
| 170 capturer_->ResetSupportedFormats(formats); | 166 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 |