Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(339)

Side by Side Diff: webrtc/media/base/videocapturer_unittest.cc

Issue 1655793003: Make cricket::VideoCapturer implement VideoSourceInterface (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Addressed comments. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 21 matching lines...) Expand all
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),
39 num_state_changes_(0), 39 num_state_changes_(0),
40 video_frames_received_(0), 40 video_frames_received_(0),
41 expects_rotation_applied_(true) { 41 expects_rotation_applied_(true) {
42 capturer_.SignalVideoFrame.connect(this, &VideoCapturerTest::OnVideoFrame); 42 renderer_.SignalRenderFrame.connect(this, &VideoCapturerTest::OnVideoFrame);
43 capturer_.SignalStateChange.connect(this, 43 capturer_.SignalStateChange.connect(this,
44 &VideoCapturerTest::OnStateChange); 44 &VideoCapturerTest::OnStateChange);
45 capturer_.AddSink(&renderer_);
45 } 46 }
46 47
47 void set_expected_compensation(bool compensation) { 48 void set_expected_compensation(bool compensation) {
48 expects_rotation_applied_ = compensation; 49 expects_rotation_applied_ = compensation;
49 } 50 }
50 51
51 protected: 52 protected:
52 void OnVideoFrame(cricket::VideoCapturer*, const cricket::VideoFrame* frame) { 53 void OnVideoFrame(const cricket::VideoFrame* frame) {
53 ++video_frames_received_; 54 ++video_frames_received_;
54 if (expects_rotation_applied_) { 55 if (expects_rotation_applied_) {
55 EXPECT_EQ(webrtc::kVideoRotation_0, frame->GetRotation()); 56 EXPECT_EQ(webrtc::kVideoRotation_0, frame->GetRotation());
56 } else { 57 } else {
57 EXPECT_EQ(capturer_.GetRotation(), frame->GetRotation()); 58 EXPECT_EQ(capturer_.GetRotation(), frame->GetRotation());
58 } 59 }
59 renderer_.RenderFrame(frame);
60 } 60 }
61 void OnStateChange(cricket::VideoCapturer*, 61 void OnStateChange(cricket::VideoCapturer*,
62 cricket::CaptureState capture_state) { 62 cricket::CaptureState capture_state) {
63 capture_state_ = capture_state; 63 capture_state_ = capture_state;
64 ++num_state_changes_; 64 ++num_state_changes_;
65 } 65 }
66 cricket::CaptureState capture_state() { return capture_state_; } 66 cricket::CaptureState capture_state() { return capture_state_; }
67 int num_state_changes() { return num_state_changes_; } 67 int num_state_changes() { return num_state_changes_; }
68 int video_frames_received() const { 68 int video_frames_received() const {
69 return video_frames_received_; 69 return video_frames_received_;
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 int kWidth = 800; 207 int kWidth = 800;
208 int kHeight = 400; 208 int kHeight = 400;
209 int frame_count = 0; 209 int frame_count = 0;
210 210
211 std::vector<cricket::VideoFormat> formats; 211 std::vector<cricket::VideoFormat> formats;
212 formats.push_back(cricket::VideoFormat(kWidth, kHeight, 212 formats.push_back(cricket::VideoFormat(kWidth, kHeight,
213 cricket::VideoFormat::FpsToInterval(5), 213 cricket::VideoFormat::FpsToInterval(5),
214 cricket::FOURCC_I420)); 214 cricket::FOURCC_I420));
215 215
216 capturer_.ResetSupportedFormats(formats); 216 capturer_.ResetSupportedFormats(formats);
217
217 // capturer_ should compensate rotation as default. 218 // capturer_ should compensate rotation as default.
218 capturer_.UpdateAspectRatio(400, 200); 219 capturer_.UpdateAspectRatio(400, 200);
219 220
220 EXPECT_EQ(cricket::CS_RUNNING, 221 EXPECT_EQ(cricket::CS_RUNNING,
221 capturer_.Start(cricket::VideoFormat( 222 capturer_.Start(cricket::VideoFormat(
222 kWidth, kHeight, cricket::VideoFormat::FpsToInterval(30), 223 kWidth, kHeight, cricket::VideoFormat::FpsToInterval(30),
223 cricket::FOURCC_I420))); 224 cricket::FOURCC_I420)));
224 EXPECT_TRUE(capturer_.IsRunning()); 225 EXPECT_TRUE(capturer_.IsRunning());
225 EXPECT_EQ(0, renderer_.num_rendered_frames()); 226 EXPECT_EQ(0, renderer_.num_rendered_frames());
226 227
(...skipping 27 matching lines...) Expand all
254 int kWidth = 800; 255 int kWidth = 800;
255 int kHeight = 400; 256 int kHeight = 400;
256 257
257 std::vector<cricket::VideoFormat> formats; 258 std::vector<cricket::VideoFormat> formats;
258 formats.push_back(cricket::VideoFormat(kWidth, kHeight, 259 formats.push_back(cricket::VideoFormat(kWidth, kHeight,
259 cricket::VideoFormat::FpsToInterval(5), 260 cricket::VideoFormat::FpsToInterval(5),
260 cricket::FOURCC_I420)); 261 cricket::FOURCC_I420));
261 262
262 capturer_.ResetSupportedFormats(formats); 263 capturer_.ResetSupportedFormats(formats);
263 // capturer_ should not compensate rotation. 264 // capturer_ should not compensate rotation.
264 capturer_.SetApplyRotation(false); 265 set_expected_compensation(false);
266 rtc::VideoSinkHints hints;
267 hints.can_apply_rotation = true;
268 capturer_.AddOrUpdateSink(&renderer_, hints);
269
265 capturer_.UpdateAspectRatio(400, 200); 270 capturer_.UpdateAspectRatio(400, 200);
266 set_expected_compensation(false);
267 271
268 EXPECT_EQ(cricket::CS_RUNNING, 272 EXPECT_EQ(cricket::CS_RUNNING,
269 capturer_.Start(cricket::VideoFormat( 273 capturer_.Start(cricket::VideoFormat(
270 kWidth, kHeight, cricket::VideoFormat::FpsToInterval(30), 274 kWidth, kHeight, cricket::VideoFormat::FpsToInterval(30),
271 cricket::FOURCC_I420))); 275 cricket::FOURCC_I420)));
272 EXPECT_TRUE(capturer_.IsRunning()); 276 EXPECT_TRUE(capturer_.IsRunning());
273 EXPECT_EQ(0, renderer_.num_rendered_frames()); 277 EXPECT_EQ(0, renderer_.num_rendered_frames());
274 278
275 // If the frame's rotation is compensated anywhere in the pipeline, the frame 279 // 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 280 // won't have its original dimension out from capturer. Since the renderer
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 capturer_.set_enable_camera_list(true); 795 capturer_.set_enable_camera_list(true);
792 capturer_.ConstrainSupportedFormats(vga_format); 796 capturer_.ConstrainSupportedFormats(vga_format);
793 EXPECT_EQ(2u, capturer_.GetSupportedFormats()->size()); 797 EXPECT_EQ(2u, capturer_.GetSupportedFormats()->size());
794 // To make sure it's not just the camera list being broken, add in VGA and 798 // 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. 799 // try again. This time, only the VGA format should be there.
796 supported_formats.push_back(vga_format); 800 supported_formats.push_back(vga_format);
797 capturer_.ResetSupportedFormats(supported_formats); 801 capturer_.ResetSupportedFormats(supported_formats);
798 ASSERT_EQ(1u, capturer_.GetSupportedFormats()->size()); 802 ASSERT_EQ(1u, capturer_.GetSupportedFormats()->size());
799 EXPECT_EQ(vga_format.height, capturer_.GetSupportedFormats()->at(0).height); 803 EXPECT_EQ(vga_format.height, capturer_.GetSupportedFormats()->at(0).height);
800 } 804 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698