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

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

Issue 2698203003: Update sink wants with ranges for both pixel count and frame rate.
Patch Set: Slightly updated sink wants merging in videobroadcaster Created 3 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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 EXPECT_EQ(0, renderer_.num_rendered_frames()); 259 EXPECT_EQ(0, renderer_.num_rendered_frames());
260 EXPECT_TRUE(capturer_->CaptureFrame()); 260 EXPECT_TRUE(capturer_->CaptureFrame());
261 EXPECT_EQ(1, renderer_.num_rendered_frames()); 261 EXPECT_EQ(1, renderer_.num_rendered_frames());
262 EXPECT_EQ(1280, renderer_.width()); 262 EXPECT_EQ(1280, renderer_.width());
263 EXPECT_EQ(720, renderer_.height()); 263 EXPECT_EQ(720, renderer_.height());
264 264
265 // Request a lower resolution. The output resolution will have a resolution 265 // Request a lower resolution. The output resolution will have a resolution
266 // with less than or equal to |wants.max_pixel_count| depending on how the 266 // with less than or equal to |wants.max_pixel_count| depending on how the
267 // capturer can scale the input frame size. 267 // capturer can scale the input frame size.
268 rtc::VideoSinkWants wants; 268 rtc::VideoSinkWants wants;
269 wants.max_pixel_count = rtc::Optional<int>(1280 * 720 * 3 / 5); 269 wants.pixel_count.emplace(
270 rtc::VideoSinkWants::Range(0, 1280 * 720 * 3 / 5, 1280 * 720 - 1));
270 capturer_->AddOrUpdateSink(&renderer_, wants); 271 capturer_->AddOrUpdateSink(&renderer_, wants);
271 EXPECT_TRUE(capturer_->CaptureFrame()); 272 EXPECT_TRUE(capturer_->CaptureFrame());
272 EXPECT_EQ(2, renderer_.num_rendered_frames()); 273 EXPECT_EQ(2, renderer_.num_rendered_frames());
273 EXPECT_EQ(960, renderer_.width()); 274 EXPECT_EQ(960, renderer_.width());
274 EXPECT_EQ(540, renderer_.height()); 275 EXPECT_EQ(540, renderer_.height());
275 276
276 // Request a lower resolution. 277 // Request a lower resolution.
277 wants.max_pixel_count = 278 wants.pixel_count.emplace(rtc::VideoSinkWants::Range(
278 rtc::Optional<int>((renderer_.width() * renderer_.height() * 3) / 5); 279 0, (renderer_.width() * renderer_.height() * 3) / 5,
280 renderer_.width() * renderer_.height() - 1));
279 capturer_->AddOrUpdateSink(&renderer_, wants); 281 capturer_->AddOrUpdateSink(&renderer_, wants);
280 EXPECT_TRUE(capturer_->CaptureFrame()); 282 EXPECT_TRUE(capturer_->CaptureFrame());
281 EXPECT_EQ(3, renderer_.num_rendered_frames()); 283 EXPECT_EQ(3, renderer_.num_rendered_frames());
282 EXPECT_EQ(640, renderer_.width()); 284 EXPECT_EQ(640, renderer_.width());
283 EXPECT_EQ(360, renderer_.height()); 285 EXPECT_EQ(360, renderer_.height());
284 286
285 // Adding a new renderer should not affect resolution. 287 // Adding a new renderer should not affect resolution.
286 cricket::FakeVideoRenderer renderer2; 288 cricket::FakeVideoRenderer renderer2;
287 capturer_->AddOrUpdateSink(&renderer2, rtc::VideoSinkWants()); 289 capturer_->AddOrUpdateSink(&renderer2, rtc::VideoSinkWants());
288 EXPECT_TRUE(capturer_->CaptureFrame()); 290 EXPECT_TRUE(capturer_->CaptureFrame());
289 EXPECT_EQ(4, renderer_.num_rendered_frames()); 291 EXPECT_EQ(4, renderer_.num_rendered_frames());
290 EXPECT_EQ(640, renderer_.width()); 292 EXPECT_EQ(640, renderer_.width());
291 EXPECT_EQ(360, renderer_.height()); 293 EXPECT_EQ(360, renderer_.height());
292 EXPECT_EQ(1, renderer2.num_rendered_frames()); 294 EXPECT_EQ(1, renderer2.num_rendered_frames());
293 EXPECT_EQ(640, renderer2.width()); 295 EXPECT_EQ(640, renderer2.width());
294 EXPECT_EQ(360, renderer2.height()); 296 EXPECT_EQ(360, renderer2.height());
295 297
296 // Request higher resolution. 298 // Request higher resolution.
297 wants.target_pixel_count.emplace((*wants.max_pixel_count * 5) / 3); 299 wants.pixel_count.emplace(rtc::VideoSinkWants::Range(
298 wants.max_pixel_count.emplace(*wants.max_pixel_count * 4); 300 0, (renderer_.width() * renderer_.height() * 5) / 3,
301 renderer_.width() * renderer_.height() * 4));
299 capturer_->AddOrUpdateSink(&renderer_, wants); 302 capturer_->AddOrUpdateSink(&renderer_, wants);
300 EXPECT_TRUE(capturer_->CaptureFrame()); 303 EXPECT_TRUE(capturer_->CaptureFrame());
301 EXPECT_EQ(5, renderer_.num_rendered_frames()); 304 EXPECT_EQ(5, renderer_.num_rendered_frames());
302 EXPECT_EQ(960, renderer_.width()); 305 EXPECT_EQ(960, renderer_.width());
303 EXPECT_EQ(540, renderer_.height()); 306 EXPECT_EQ(540, renderer_.height());
304 EXPECT_EQ(2, renderer2.num_rendered_frames()); 307 EXPECT_EQ(2, renderer2.num_rendered_frames());
305 EXPECT_EQ(960, renderer2.width()); 308 EXPECT_EQ(960, renderer2.width());
306 EXPECT_EQ(540, renderer2.height()); 309 EXPECT_EQ(540, renderer2.height());
307 310
308 // Updating with no wants should not affect resolution. 311 // Updating with no wants should not affect resolution.
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 capturer_->set_enable_camera_list(true); 781 capturer_->set_enable_camera_list(true);
779 capturer_->ConstrainSupportedFormats(vga_format); 782 capturer_->ConstrainSupportedFormats(vga_format);
780 EXPECT_EQ(2u, capturer_->GetSupportedFormats()->size()); 783 EXPECT_EQ(2u, capturer_->GetSupportedFormats()->size());
781 // To make sure it's not just the camera list being broken, add in VGA and 784 // To make sure it's not just the camera list being broken, add in VGA and
782 // try again. This time, only the VGA format should be there. 785 // try again. This time, only the VGA format should be there.
783 supported_formats.push_back(vga_format); 786 supported_formats.push_back(vga_format);
784 capturer_->ResetSupportedFormats(supported_formats); 787 capturer_->ResetSupportedFormats(supported_formats);
785 ASSERT_EQ(1u, capturer_->GetSupportedFormats()->size()); 788 ASSERT_EQ(1u, capturer_->GetSupportedFormats()->size());
786 EXPECT_EQ(vga_format.height, capturer_->GetSupportedFormats()->at(0).height); 789 EXPECT_EQ(vga_format.height, capturer_->GetSupportedFormats()->at(0).height);
787 } 790 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698