| Index: content/renderer/media/media_stream_constraints_util_video_device_unittest.cc
|
| diff --git a/content/renderer/media/media_stream_constraints_util_video_source_unittest.cc b/content/renderer/media/media_stream_constraints_util_video_device_unittest.cc
|
| similarity index 67%
|
| rename from content/renderer/media/media_stream_constraints_util_video_source_unittest.cc
|
| rename to content/renderer/media/media_stream_constraints_util_video_device_unittest.cc
|
| index cc92442fc08e3c78e8b32bb4932e925c3f2d8958..5247f396be50e83bfb11c6fb551560075d9df152 100644
|
| --- a/content/renderer/media/media_stream_constraints_util_video_source_unittest.cc
|
| +++ b/content/renderer/media/media_stream_constraints_util_video_device_unittest.cc
|
| @@ -2,7 +2,7 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "content/renderer/media/media_stream_constraints_util_video_source.h"
|
| +#include "content/renderer/media/media_stream_constraints_util_video_device.h"
|
|
|
| #include <algorithm>
|
| #include <utility>
|
| @@ -23,7 +23,7 @@ const char kDeviceID3[] = "fake_device_3";
|
| const char kDeviceID4[] = "fake_device_4";
|
| }
|
|
|
| -class MediaStreamConstraintsUtilVideoSourceTest : public testing::Test {
|
| +class MediaStreamConstraintsUtilVideoDeviceTest : public testing::Test {
|
| public:
|
| void SetUp() override {
|
| // Default device. It is default because it is the first in the enumeration.
|
| @@ -110,13 +110,13 @@ class MediaStreamConstraintsUtilVideoSourceTest : public testing::Test {
|
| }
|
|
|
| protected:
|
| - VideoCaptureSourceSelectionResult SelectSettings() {
|
| + VideoDeviceCaptureSourceSelectionResult SelectSettings() {
|
| blink::WebMediaConstraints constraints =
|
| constraint_factory_.CreateWebMediaConstraints();
|
| - return SelectVideoCaptureSourceSettings(capabilities_, constraints);
|
| + return SelectVideoDeviceCaptureSourceSettings(capabilities_, constraints);
|
| }
|
|
|
| - VideoCaptureCapabilities capabilities_;
|
| + VideoDeviceCaptureCapabilities capabilities_;
|
| const mojom::VideoInputDeviceCapabilities* default_device_;
|
| const mojom::VideoInputDeviceCapabilities* low_res_device_;
|
| const mojom::VideoInputDeviceCapabilities* high_res_device_;
|
| @@ -130,109 +130,109 @@ class MediaStreamConstraintsUtilVideoSourceTest : public testing::Test {
|
| };
|
|
|
| // The Unconstrained test checks the default selection criteria.
|
| -TEST_F(MediaStreamConstraintsUtilVideoSourceTest, Unconstrained) {
|
| +TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, Unconstrained) {
|
| constraint_factory_.Reset();
|
| auto result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| + EXPECT_TRUE(result.HasValue());
|
| // Should select the default device with closest-to-default settings.
|
| - EXPECT_EQ(default_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(default_device_->facing_mode, result.settings.facing_mode());
|
| - EXPECT_EQ(*default_closest_format_, result.settings.format());
|
| + EXPECT_EQ(default_device_->device_id, result.device_id);
|
| + EXPECT_EQ(default_device_->facing_mode, result.facing_mode);
|
| + EXPECT_EQ(*default_closest_format_, result.Format());
|
| }
|
|
|
| // The "Overconstrained" tests verify that failure of any single required
|
| // constraint results in failure to select a candidate.
|
| -TEST_F(MediaStreamConstraintsUtilVideoSourceTest, OverconstrainedOnDeviceID) {
|
| +TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, OverconstrainedOnDeviceID) {
|
| constraint_factory_.Reset();
|
| constraint_factory_.basic().deviceId.setExact(
|
| blink::WebString::fromASCII("NONEXISTING"));
|
| auto result = SelectSettings();
|
| - EXPECT_FALSE(result.has_value());
|
| + EXPECT_FALSE(result.HasValue());
|
| EXPECT_EQ(constraint_factory_.basic().deviceId.name(),
|
| result.failed_constraint_name);
|
| }
|
|
|
| -TEST_F(MediaStreamConstraintsUtilVideoSourceTest, OverconstrainedOnFacingMode) {
|
| +TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, OverconstrainedOnFacingMode) {
|
| constraint_factory_.Reset();
|
| // No device in |capabilities_| has facing mode equal to LEFT.
|
| constraint_factory_.basic().facingMode.setExact(
|
| blink::WebString::fromASCII("left"));
|
| auto result = SelectSettings();
|
| - EXPECT_FALSE(result.has_value());
|
| + EXPECT_FALSE(result.HasValue());
|
| EXPECT_EQ(constraint_factory_.basic().facingMode.name(),
|
| result.failed_constraint_name);
|
| }
|
|
|
| -TEST_F(MediaStreamConstraintsUtilVideoSourceTest, OverconstrainedOnVideoKind) {
|
| +TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, OverconstrainedOnVideoKind) {
|
| constraint_factory_.Reset();
|
| // No device in |capabilities_| has video kind infrared.
|
| constraint_factory_.basic().videoKind.setExact(
|
| blink::WebString::fromASCII("infrared"));
|
| auto result = SelectSettings();
|
| - EXPECT_FALSE(result.has_value());
|
| + EXPECT_FALSE(result.HasValue());
|
| EXPECT_EQ(constraint_factory_.basic().videoKind.name(),
|
| result.failed_constraint_name);
|
| }
|
|
|
| -TEST_F(MediaStreamConstraintsUtilVideoSourceTest, OverconstrainedOnHeight) {
|
| +TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, OverconstrainedOnHeight) {
|
| constraint_factory_.Reset();
|
| constraint_factory_.basic().height.setExact(123467890);
|
| auto result = SelectSettings();
|
| - EXPECT_FALSE(result.has_value());
|
| + EXPECT_FALSE(result.HasValue());
|
| EXPECT_EQ(constraint_factory_.basic().height.name(),
|
| result.failed_constraint_name);
|
|
|
| constraint_factory_.Reset();
|
| constraint_factory_.basic().height.setMin(123467890);
|
| result = SelectSettings();
|
| - EXPECT_FALSE(result.has_value());
|
| + EXPECT_FALSE(result.HasValue());
|
| EXPECT_EQ(constraint_factory_.basic().height.name(),
|
| result.failed_constraint_name);
|
|
|
| constraint_factory_.Reset();
|
| constraint_factory_.basic().height.setMax(0);
|
| result = SelectSettings();
|
| - EXPECT_FALSE(result.has_value());
|
| + EXPECT_FALSE(result.HasValue());
|
| EXPECT_EQ(constraint_factory_.basic().height.name(),
|
| result.failed_constraint_name);
|
| }
|
|
|
| -TEST_F(MediaStreamConstraintsUtilVideoSourceTest, OverconstrainedOnWidth) {
|
| +TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, OverconstrainedOnWidth) {
|
| constraint_factory_.Reset();
|
| constraint_factory_.basic().width.setExact(123467890);
|
| auto result = SelectSettings();
|
| - EXPECT_FALSE(result.has_value());
|
| + EXPECT_FALSE(result.HasValue());
|
| EXPECT_EQ(constraint_factory_.basic().width.name(),
|
| result.failed_constraint_name);
|
|
|
| constraint_factory_.Reset();
|
| constraint_factory_.basic().width.setMin(123467890);
|
| result = SelectSettings();
|
| - EXPECT_FALSE(result.has_value());
|
| + EXPECT_FALSE(result.HasValue());
|
| EXPECT_EQ(constraint_factory_.basic().width.name(),
|
| result.failed_constraint_name);
|
|
|
| constraint_factory_.Reset();
|
| constraint_factory_.basic().width.setMax(0);
|
| result = SelectSettings();
|
| - EXPECT_FALSE(result.has_value());
|
| + EXPECT_FALSE(result.HasValue());
|
| EXPECT_EQ(constraint_factory_.basic().width.name(),
|
| result.failed_constraint_name);
|
| }
|
|
|
| -TEST_F(MediaStreamConstraintsUtilVideoSourceTest,
|
| +TEST_F(MediaStreamConstraintsUtilVideoDeviceTest,
|
| OverconstrainedOnAspectRatio) {
|
| constraint_factory_.Reset();
|
| constraint_factory_.basic().aspectRatio.setExact(123467890.0);
|
| auto result = SelectSettings();
|
| - EXPECT_FALSE(result.has_value());
|
| + EXPECT_FALSE(result.HasValue());
|
| EXPECT_EQ(constraint_factory_.basic().aspectRatio.name(),
|
| result.failed_constraint_name);
|
|
|
| constraint_factory_.Reset();
|
| constraint_factory_.basic().aspectRatio.setMin(123467890.0);
|
| result = SelectSettings();
|
| - EXPECT_FALSE(result.has_value());
|
| + EXPECT_FALSE(result.HasValue());
|
| EXPECT_EQ(constraint_factory_.basic().aspectRatio.name(),
|
| result.failed_constraint_name);
|
|
|
| @@ -241,132 +241,132 @@ TEST_F(MediaStreamConstraintsUtilVideoSourceTest,
|
| double kLowAspectRatio = 0.01;
|
| constraint_factory_.basic().aspectRatio.setMax(kLowAspectRatio);
|
| result = SelectSettings();
|
| - EXPECT_FALSE(result.has_value());
|
| + EXPECT_FALSE(result.HasValue());
|
| EXPECT_EQ(constraint_factory_.basic().aspectRatio.name(),
|
| result.failed_constraint_name);
|
| }
|
|
|
| -TEST_F(MediaStreamConstraintsUtilVideoSourceTest, OverconstrainedOnFrameRate) {
|
| +TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, OverconstrainedOnFrameRate) {
|
| constraint_factory_.Reset();
|
| constraint_factory_.basic().frameRate.setExact(123467890.0);
|
| auto result = SelectSettings();
|
| - EXPECT_FALSE(result.has_value());
|
| + EXPECT_FALSE(result.HasValue());
|
| EXPECT_EQ(constraint_factory_.basic().frameRate.name(),
|
| result.failed_constraint_name);
|
|
|
| constraint_factory_.Reset();
|
| constraint_factory_.basic().frameRate.setMin(123467890.0);
|
| result = SelectSettings();
|
| - EXPECT_FALSE(result.has_value());
|
| + EXPECT_FALSE(result.HasValue());
|
| EXPECT_EQ(constraint_factory_.basic().frameRate.name(),
|
| result.failed_constraint_name);
|
|
|
| constraint_factory_.Reset();
|
| constraint_factory_.basic().frameRate.setMax(0.0);
|
| result = SelectSettings();
|
| - EXPECT_FALSE(result.has_value());
|
| + EXPECT_FALSE(result.HasValue());
|
| EXPECT_EQ(constraint_factory_.basic().frameRate.name(),
|
| result.failed_constraint_name);
|
| }
|
|
|
| -TEST_F(MediaStreamConstraintsUtilVideoSourceTest,
|
| +TEST_F(MediaStreamConstraintsUtilVideoDeviceTest,
|
| OverconstrainedOnPowerLineFrequency) {
|
| constraint_factory_.Reset();
|
| constraint_factory_.basic().googPowerLineFrequency.setExact(123467890);
|
| auto result = SelectSettings();
|
| - EXPECT_FALSE(result.has_value());
|
| + EXPECT_FALSE(result.HasValue());
|
| EXPECT_EQ(constraint_factory_.basic().googPowerLineFrequency.name(),
|
| result.failed_constraint_name);
|
|
|
| constraint_factory_.Reset();
|
| constraint_factory_.basic().googPowerLineFrequency.setMin(123467890);
|
| result = SelectSettings();
|
| - EXPECT_FALSE(result.has_value());
|
| + EXPECT_FALSE(result.HasValue());
|
| EXPECT_EQ(constraint_factory_.basic().googPowerLineFrequency.name(),
|
| result.failed_constraint_name);
|
|
|
| constraint_factory_.Reset();
|
| constraint_factory_.basic().googPowerLineFrequency.setMax(-1);
|
| result = SelectSettings();
|
| - EXPECT_FALSE(result.has_value());
|
| + EXPECT_FALSE(result.HasValue());
|
| EXPECT_EQ(constraint_factory_.basic().googPowerLineFrequency.name(),
|
| result.failed_constraint_name);
|
| }
|
|
|
| // The "Mandatory" and "Ideal" tests check that various selection criteria work
|
| // for each individual constraint in the basic constraint set.
|
| -TEST_F(MediaStreamConstraintsUtilVideoSourceTest, MandatoryDeviceID) {
|
| +TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryDeviceID) {
|
| constraint_factory_.Reset();
|
| constraint_factory_.basic().deviceId.setExact(
|
| blink::WebString::fromASCII(default_device_->device_id));
|
| auto result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| - EXPECT_EQ(default_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(*default_closest_format_, result.settings.format());
|
| + EXPECT_TRUE(result.HasValue());
|
| + EXPECT_EQ(default_device_->device_id, result.device_id);
|
| + EXPECT_EQ(*default_closest_format_, result.Format());
|
| EXPECT_EQ(media::PowerLineFrequency::FREQUENCY_DEFAULT,
|
| - result.settings.power_line_frequency());
|
| + result.PowerLineFrequency());
|
|
|
| constraint_factory_.basic().deviceId.setExact(
|
| blink::WebString::fromASCII(low_res_device_->device_id));
|
| result = SelectSettings();
|
| - EXPECT_EQ(low_res_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(*low_res_closest_format_, result.settings.format());
|
| + EXPECT_EQ(low_res_device_->device_id, result.device_id);
|
| + EXPECT_EQ(*low_res_closest_format_, result.Format());
|
| EXPECT_EQ(media::PowerLineFrequency::FREQUENCY_DEFAULT,
|
| - result.settings.power_line_frequency());
|
| + result.PowerLineFrequency());
|
|
|
| constraint_factory_.basic().deviceId.setExact(
|
| blink::WebString::fromASCII(high_res_device_->device_id));
|
| result = SelectSettings();
|
| - EXPECT_EQ(high_res_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(*high_res_closest_format_, result.settings.format());
|
| + EXPECT_EQ(high_res_device_->device_id, result.device_id);
|
| + EXPECT_EQ(*high_res_closest_format_, result.Format());
|
| EXPECT_EQ(media::PowerLineFrequency::FREQUENCY_DEFAULT,
|
| - result.settings.power_line_frequency());
|
| + result.PowerLineFrequency());
|
| }
|
|
|
| -TEST_F(MediaStreamConstraintsUtilVideoSourceTest, MandatoryFacingMode) {
|
| +TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryFacingMode) {
|
| constraint_factory_.Reset();
|
| constraint_factory_.basic().facingMode.setExact(
|
| blink::WebString::fromASCII("environment"));
|
| auto result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| - EXPECT_EQ(::mojom::FacingMode::ENVIRONMENT, result.settings.facing_mode());
|
| + EXPECT_TRUE(result.HasValue());
|
| + EXPECT_EQ(::mojom::FacingMode::ENVIRONMENT, result.facing_mode);
|
| // Only the low-res device supports environment facing mode. Should select
|
| // default settings for everything else.
|
| - EXPECT_EQ(low_res_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(*low_res_closest_format_, result.settings.format());
|
| + EXPECT_EQ(low_res_device_->device_id, result.device_id);
|
| + EXPECT_EQ(*low_res_closest_format_, result.Format());
|
| EXPECT_EQ(media::PowerLineFrequency::FREQUENCY_DEFAULT,
|
| - result.settings.power_line_frequency());
|
| + result.PowerLineFrequency());
|
|
|
| constraint_factory_.basic().facingMode.setExact(
|
| blink::WebString::fromASCII("user"));
|
| result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| - EXPECT_EQ(::mojom::FacingMode::USER, result.settings.facing_mode());
|
| + EXPECT_TRUE(result.HasValue());
|
| + EXPECT_EQ(::mojom::FacingMode::USER, result.facing_mode);
|
| // Only the high-res device supports user facing mode. Should select default
|
| // settings for everything else.
|
| - EXPECT_EQ(high_res_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(*high_res_closest_format_, result.settings.format());
|
| + EXPECT_EQ(high_res_device_->device_id, result.device_id);
|
| + EXPECT_EQ(*high_res_closest_format_, result.Format());
|
| EXPECT_EQ(media::PowerLineFrequency::FREQUENCY_DEFAULT,
|
| - result.settings.power_line_frequency());
|
| + result.PowerLineFrequency());
|
| }
|
|
|
| -TEST_F(MediaStreamConstraintsUtilVideoSourceTest, MandatoryVideoKind) {
|
| +TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryVideoKind) {
|
| constraint_factory_.Reset();
|
| constraint_factory_.basic().videoKind.setExact(
|
| blink::WebString::fromASCII("depth"));
|
| auto result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| - EXPECT_EQ(kDeviceID4, result.settings.device_id());
|
| - EXPECT_EQ(media::PIXEL_FORMAT_Y16, result.settings.format().pixel_format);
|
| + EXPECT_TRUE(result.HasValue());
|
| + EXPECT_EQ(kDeviceID4, result.device_id);
|
| + EXPECT_EQ(media::PIXEL_FORMAT_Y16, result.Format().pixel_format);
|
|
|
| constraint_factory_.basic().videoKind.setExact(
|
| blink::WebString::fromASCII("color"));
|
| result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| - EXPECT_EQ(default_device_->device_id, result.settings.device_id());
|
| + EXPECT_TRUE(result.HasValue());
|
| + EXPECT_EQ(default_device_->device_id, result.device_id);
|
| }
|
|
|
| -TEST_F(MediaStreamConstraintsUtilVideoSourceTest, MandatoryPowerLineFrequency) {
|
| +TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryPowerLineFrequency) {
|
| constraint_factory_.Reset();
|
| const media::PowerLineFrequency kPowerLineFrequencies[] = {
|
| media::PowerLineFrequency::FREQUENCY_50HZ,
|
| @@ -375,73 +375,73 @@ TEST_F(MediaStreamConstraintsUtilVideoSourceTest, MandatoryPowerLineFrequency) {
|
| constraint_factory_.basic().googPowerLineFrequency.setExact(
|
| static_cast<long>(power_line_frequency));
|
| auto result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| - EXPECT_EQ(power_line_frequency, result.settings.power_line_frequency());
|
| + EXPECT_TRUE(result.HasValue());
|
| + EXPECT_EQ(power_line_frequency, result.PowerLineFrequency());
|
| // The default device and settings closest to the default should be
|
| // selected.
|
| - EXPECT_EQ(default_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(default_device_->facing_mode, result.settings.facing_mode());
|
| - EXPECT_EQ(*default_closest_format_, result.settings.format());
|
| + EXPECT_EQ(default_device_->device_id, result.device_id);
|
| + EXPECT_EQ(default_device_->facing_mode, result.facing_mode);
|
| + EXPECT_EQ(*default_closest_format_, result.Format());
|
| }
|
| }
|
|
|
| -TEST_F(MediaStreamConstraintsUtilVideoSourceTest, MandatoryExactHeight) {
|
| +TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryExactHeight) {
|
| constraint_factory_.Reset();
|
| const int kHeight = MediaStreamVideoSource::kDefaultHeight;
|
| constraint_factory_.basic().height.setExact(kHeight);
|
| auto result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| + EXPECT_TRUE(result.HasValue());
|
| // All devices in |capabilities_| support the requested height. The algorithm
|
| // should prefer the first device that supports the requested height natively,
|
| // which is the low-res device.
|
| - EXPECT_EQ(low_res_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(kHeight, result.settings.GetHeight());
|
| + EXPECT_EQ(low_res_device_->device_id, result.device_id);
|
| + EXPECT_EQ(kHeight, result.Height());
|
|
|
| const int kLargeHeight = 1500;
|
| constraint_factory_.basic().height.setExact(kLargeHeight);
|
| result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| + EXPECT_TRUE(result.HasValue());
|
| // Only the high-res device at the highest resolution supports the requested
|
| // height, even if not natively.
|
| - EXPECT_EQ(high_res_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(*high_res_highest_format_, result.settings.format());
|
| + EXPECT_EQ(high_res_device_->device_id, result.device_id);
|
| + EXPECT_EQ(*high_res_highest_format_, result.Format());
|
| }
|
|
|
| -TEST_F(MediaStreamConstraintsUtilVideoSourceTest, MandatoryMinHeight) {
|
| +TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryMinHeight) {
|
| constraint_factory_.Reset();
|
| const int kHeight = MediaStreamVideoSource::kDefaultHeight;
|
| constraint_factory_.basic().height.setMin(kHeight);
|
| auto result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| + EXPECT_TRUE(result.HasValue());
|
| // All devices in |capabilities_| support the requested height range. The
|
| // algorithm should prefer the default device.
|
| - EXPECT_EQ(default_device_->device_id, result.settings.device_id());
|
| - EXPECT_LE(kHeight, result.settings.GetHeight());
|
| + EXPECT_EQ(default_device_->device_id, result.device_id);
|
| + EXPECT_LE(kHeight, result.Height());
|
|
|
| const int kLargeHeight = 1500;
|
| constraint_factory_.basic().height.setMin(kLargeHeight);
|
| result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| + EXPECT_TRUE(result.HasValue());
|
| // Only the high-res device at the highest resolution supports the requested
|
| // height range.
|
| - EXPECT_EQ(high_res_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(*high_res_highest_format_, result.settings.format());
|
| + EXPECT_EQ(high_res_device_->device_id, result.device_id);
|
| + EXPECT_EQ(*high_res_highest_format_, result.Format());
|
| }
|
|
|
| -TEST_F(MediaStreamConstraintsUtilVideoSourceTest, MandatoryMaxHeight) {
|
| +TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryMaxHeight) {
|
| constraint_factory_.Reset();
|
| const int kLowHeight = 20;
|
| constraint_factory_.basic().height.setMax(kLowHeight);
|
| auto result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| + EXPECT_TRUE(result.HasValue());
|
| // All devices in |capabilities_| support the requested height range. The
|
| // algorithm should prefer the settings that natively exceed the requested
|
| // maximum by the lowest amount. In this case it is the low-res device.
|
| - EXPECT_EQ(low_res_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(low_res_device_->formats[0], result.settings.format());
|
| + EXPECT_EQ(low_res_device_->device_id, result.device_id);
|
| + EXPECT_EQ(low_res_device_->formats[0], result.Format());
|
| }
|
|
|
| -TEST_F(MediaStreamConstraintsUtilVideoSourceTest, MandatoryHeightRange) {
|
| +TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryHeightRange) {
|
| constraint_factory_.Reset();
|
| {
|
| const int kMinHeight = 480;
|
| @@ -449,15 +449,15 @@ TEST_F(MediaStreamConstraintsUtilVideoSourceTest, MandatoryHeightRange) {
|
| constraint_factory_.basic().height.setMin(kMinHeight);
|
| constraint_factory_.basic().height.setMax(kMaxHeight);
|
| auto result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| - EXPECT_GE(result.settings.GetHeight(), kMinHeight);
|
| - EXPECT_LE(result.settings.GetHeight(), kMaxHeight);
|
| + EXPECT_TRUE(result.HasValue());
|
| + EXPECT_GE(result.Height(), kMinHeight);
|
| + EXPECT_LE(result.Height(), kMaxHeight);
|
| // All devices in |capabilities_| support the constraint range. The
|
| // algorithm should prefer the default device since it has at least one
|
| // native format (the closest-to-default format) included in the requested
|
| // range.
|
| - EXPECT_EQ(default_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(*default_closest_format_, result.settings.format());
|
| + EXPECT_EQ(default_device_->device_id, result.device_id);
|
| + EXPECT_EQ(*default_closest_format_, result.Format());
|
| }
|
|
|
| {
|
| @@ -466,15 +466,15 @@ TEST_F(MediaStreamConstraintsUtilVideoSourceTest, MandatoryHeightRange) {
|
| constraint_factory_.basic().height.setMin(kMinHeight);
|
| constraint_factory_.basic().height.setMax(kMaxHeight);
|
| auto result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| - EXPECT_GE(result.settings.GetHeight(), kMinHeight);
|
| - EXPECT_LE(result.settings.GetHeight(), kMaxHeight);
|
| + EXPECT_TRUE(result.HasValue());
|
| + EXPECT_GE(result.Height(), kMinHeight);
|
| + EXPECT_LE(result.Height(), kMaxHeight);
|
| // In this case, the algorithm should prefer the low-res device since it is
|
| // the first device with a native format (800x600) included in the requested
|
| // range.
|
| - EXPECT_EQ(low_res_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(800, result.settings.GetWidth());
|
| - EXPECT_EQ(600, result.settings.GetHeight());
|
| + EXPECT_EQ(low_res_device_->device_id, result.device_id);
|
| + EXPECT_EQ(800, result.Width());
|
| + EXPECT_EQ(600, result.Height());
|
| }
|
|
|
| {
|
| @@ -483,132 +483,132 @@ TEST_F(MediaStreamConstraintsUtilVideoSourceTest, MandatoryHeightRange) {
|
| constraint_factory_.basic().height.setMin(kMinHeight);
|
| constraint_factory_.basic().height.setMax(kMaxHeight);
|
| auto result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| - EXPECT_GE(result.settings.GetHeight(), kMinHeight);
|
| - EXPECT_LE(result.settings.GetHeight(), kMaxHeight);
|
| + EXPECT_TRUE(result.HasValue());
|
| + EXPECT_GE(result.Height(), kMinHeight);
|
| + EXPECT_LE(result.Height(), kMaxHeight);
|
| // In this case, the algorithm should prefer the high-res device since it is
|
| // the only device with a native format (1280x720) included in the requested
|
| // range.
|
| - EXPECT_EQ(high_res_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(1280, result.settings.GetWidth());
|
| - EXPECT_EQ(720, result.settings.GetHeight());
|
| + EXPECT_EQ(high_res_device_->device_id, result.device_id);
|
| + EXPECT_EQ(1280, result.Width());
|
| + EXPECT_EQ(720, result.Height());
|
| }
|
| }
|
|
|
| -TEST_F(MediaStreamConstraintsUtilVideoSourceTest, IdealHeight) {
|
| +TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, IdealHeight) {
|
| constraint_factory_.Reset();
|
| {
|
| const int kIdealHeight = 480;
|
| constraint_factory_.basic().height.setIdeal(kIdealHeight);
|
| auto result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| + EXPECT_TRUE(result.HasValue());
|
| // The algorithm should select the first device that supports the ideal
|
| // height natively.
|
| - EXPECT_EQ(low_res_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(kIdealHeight, result.settings.GetHeight());
|
| + EXPECT_EQ(low_res_device_->device_id, result.device_id);
|
| + EXPECT_EQ(kIdealHeight, result.Height());
|
| }
|
|
|
| {
|
| const int kIdealHeight = 481;
|
| constraint_factory_.basic().height.setIdeal(kIdealHeight);
|
| auto result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| + EXPECT_TRUE(result.HasValue());
|
| // In this case, the default device is selected because it can satisfy the
|
| // ideal at a lower cost than the other devices (500 vs 600 or 720).
|
| // Note that a native resolution of 480 is further from the ideal than
|
| // 500 cropped to 480.
|
| - EXPECT_EQ(default_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(*default_closest_format_, result.settings.format());
|
| + EXPECT_EQ(default_device_->device_id, result.device_id);
|
| + EXPECT_EQ(*default_closest_format_, result.Format());
|
| }
|
|
|
| {
|
| const int kIdealHeight = 1079;
|
| constraint_factory_.basic().height.setIdeal(kIdealHeight);
|
| auto result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| + EXPECT_TRUE(result.HasValue());
|
| // In this case, the high-res device has two configurations that satisfy
|
| // the ideal value (1920x1080 and 2304x1536). Select the one with shortest
|
| // native distance to the ideal value (1920x1080).
|
| - EXPECT_EQ(high_res_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(1920, result.settings.GetWidth());
|
| - EXPECT_EQ(1080, result.settings.GetHeight());
|
| + EXPECT_EQ(high_res_device_->device_id, result.device_id);
|
| + EXPECT_EQ(1920, result.Width());
|
| + EXPECT_EQ(1080, result.Height());
|
| }
|
|
|
| {
|
| const int kIdealHeight = 1200;
|
| constraint_factory_.basic().height.setIdeal(kIdealHeight);
|
| auto result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| + EXPECT_TRUE(result.HasValue());
|
| // The algorithm must the select the only device that can satisfy the ideal,
|
| // which is the high-res device at the highest resolution.
|
| - EXPECT_EQ(high_res_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(*high_res_highest_format_, result.settings.format());
|
| + EXPECT_EQ(high_res_device_->device_id, result.device_id);
|
| + EXPECT_EQ(*high_res_highest_format_, result.Format());
|
| }
|
| }
|
|
|
| -TEST_F(MediaStreamConstraintsUtilVideoSourceTest, MandatoryExactWidth) {
|
| +TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryExactWidth) {
|
| constraint_factory_.Reset();
|
| const int kWidth = 640;
|
| constraint_factory_.basic().width.setExact(kWidth);
|
| auto result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| + EXPECT_TRUE(result.HasValue());
|
| // All devices in |capabilities_| support the requested width. The algorithm
|
| // should prefer the first device that supports the requested width natively,
|
| // which is the low-res device.
|
| - EXPECT_EQ(low_res_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(kWidth, result.settings.GetWidth());
|
| + EXPECT_EQ(low_res_device_->device_id, result.device_id);
|
| + EXPECT_EQ(kWidth, result.Width());
|
|
|
| const int kLargeWidth = 2000;
|
| constraint_factory_.basic().width.setExact(kLargeWidth);
|
| result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| - EXPECT_LE(kLargeWidth, result.settings.GetWidth());
|
| + EXPECT_TRUE(result.HasValue());
|
| + EXPECT_LE(kLargeWidth, result.Width());
|
| // Only the high-res device at the highest resolution supports the requested
|
| // width, even if not natively.
|
| - EXPECT_EQ(high_res_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(*high_res_highest_format_, result.settings.format());
|
| + EXPECT_EQ(high_res_device_->device_id, result.device_id);
|
| + EXPECT_EQ(*high_res_highest_format_, result.Format());
|
| }
|
|
|
| -TEST_F(MediaStreamConstraintsUtilVideoSourceTest, MandatoryMinWidth) {
|
| +TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryMinWidth) {
|
| constraint_factory_.Reset();
|
| const int kWidth = 640;
|
| constraint_factory_.basic().width.setMin(kWidth);
|
| auto result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| + EXPECT_TRUE(result.HasValue());
|
| // All devices in |capabilities_| support the requested width range. The
|
| // algorithm should prefer the default device at 1000x1000, which is the
|
| // first configuration that satisfies the minimum width.
|
| - EXPECT_EQ(default_device_->device_id, result.settings.device_id());
|
| - EXPECT_LE(kWidth, result.settings.GetWidth());
|
| - EXPECT_EQ(1000, result.settings.GetWidth());
|
| - EXPECT_EQ(1000, result.settings.GetHeight());
|
| + EXPECT_EQ(default_device_->device_id, result.device_id);
|
| + EXPECT_LE(kWidth, result.Width());
|
| + EXPECT_EQ(1000, result.Width());
|
| + EXPECT_EQ(1000, result.Height());
|
|
|
| const int kLargeWidth = 2000;
|
| constraint_factory_.basic().width.setMin(kLargeWidth);
|
| result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| + EXPECT_TRUE(result.HasValue());
|
| // Only the high-res device at the highest resolution supports the requested
|
| // minimum width.
|
| - EXPECT_EQ(high_res_device_->device_id, result.settings.device_id());
|
| - EXPECT_LE(kLargeWidth, result.settings.GetWidth());
|
| - EXPECT_EQ(*high_res_highest_format_, result.settings.format());
|
| + EXPECT_EQ(high_res_device_->device_id, result.device_id);
|
| + EXPECT_LE(kLargeWidth, result.Width());
|
| + EXPECT_EQ(*high_res_highest_format_, result.Format());
|
| }
|
|
|
| -TEST_F(MediaStreamConstraintsUtilVideoSourceTest, MandatoryMaxWidth) {
|
| +TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryMaxWidth) {
|
| constraint_factory_.Reset();
|
| const int kLowWidth = 30;
|
| constraint_factory_.basic().width.setMax(kLowWidth);
|
| auto result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| + EXPECT_TRUE(result.HasValue());
|
| // All devices in |capabilities_| support the requested width range. The
|
| // algorithm should prefer the settings that natively exceed the requested
|
| // maximum by the lowest amount. In this case it is the low-res device at its
|
| // lowest resolution.
|
| - EXPECT_EQ(low_res_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(low_res_device_->formats[0], result.settings.format());
|
| + EXPECT_EQ(low_res_device_->device_id, result.device_id);
|
| + EXPECT_EQ(low_res_device_->formats[0], result.Format());
|
| }
|
|
|
| -TEST_F(MediaStreamConstraintsUtilVideoSourceTest, MandatoryWidthRange) {
|
| +TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryWidthRange) {
|
| constraint_factory_.Reset();
|
| {
|
| const int kMinWidth = 640;
|
| @@ -616,15 +616,15 @@ TEST_F(MediaStreamConstraintsUtilVideoSourceTest, MandatoryWidthRange) {
|
| constraint_factory_.basic().width.setMin(kMinWidth);
|
| constraint_factory_.basic().width.setMax(kMaxWidth);
|
| auto result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| - EXPECT_GE(result.settings.GetWidth(), kMinWidth);
|
| - EXPECT_LE(result.settings.GetWidth(), kMaxWidth);
|
| + EXPECT_TRUE(result.HasValue());
|
| + EXPECT_GE(result.Width(), kMinWidth);
|
| + EXPECT_LE(result.Width(), kMaxWidth);
|
| // All devices in |capabilities_| support the constraint range. The
|
| // algorithm should prefer the default device since it has at least one
|
| // native format (1000x1000) included in the requested range.
|
| - EXPECT_EQ(default_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(1000, result.settings.GetWidth());
|
| - EXPECT_EQ(1000, result.settings.GetHeight());
|
| + EXPECT_EQ(default_device_->device_id, result.device_id);
|
| + EXPECT_EQ(1000, result.Width());
|
| + EXPECT_EQ(1000, result.Height());
|
| }
|
|
|
| {
|
| @@ -633,15 +633,15 @@ TEST_F(MediaStreamConstraintsUtilVideoSourceTest, MandatoryWidthRange) {
|
| constraint_factory_.basic().width.setMin(kMinWidth);
|
| constraint_factory_.basic().width.setMax(kMaxWidth);
|
| auto result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| - EXPECT_GE(result.settings.GetWidth(), kMinWidth);
|
| - EXPECT_LE(result.settings.GetWidth(), kMaxWidth);
|
| + EXPECT_TRUE(result.HasValue());
|
| + EXPECT_GE(result.Width(), kMinWidth);
|
| + EXPECT_LE(result.Width(), kMaxWidth);
|
| // In this case, the algorithm should prefer the low-res device since it is
|
| // the first device with a native format (800x600) included in the requested
|
| // range.
|
| - EXPECT_EQ(low_res_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(800, result.settings.GetWidth());
|
| - EXPECT_EQ(600, result.settings.GetHeight());
|
| + EXPECT_EQ(low_res_device_->device_id, result.device_id);
|
| + EXPECT_EQ(800, result.Width());
|
| + EXPECT_EQ(600, result.Height());
|
| }
|
|
|
| {
|
| @@ -650,135 +650,134 @@ TEST_F(MediaStreamConstraintsUtilVideoSourceTest, MandatoryWidthRange) {
|
| constraint_factory_.basic().width.setMin(kMinWidth);
|
| constraint_factory_.basic().width.setMax(kMaxWidth);
|
| auto result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| - EXPECT_GE(result.settings.GetWidth(), kMinWidth);
|
| - EXPECT_LE(result.settings.GetWidth(), kMaxWidth);
|
| + EXPECT_TRUE(result.HasValue());
|
| + EXPECT_GE(result.Width(), kMinWidth);
|
| + EXPECT_LE(result.Width(), kMaxWidth);
|
| // In this case, the algorithm should prefer the high-res device since it is
|
| // the only device with a native format (1920x1080) included in the
|
| // requested range.
|
| - EXPECT_EQ(high_res_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(1920, result.settings.GetWidth());
|
| - EXPECT_EQ(1080, result.settings.GetHeight());
|
| + EXPECT_EQ(high_res_device_->device_id, result.device_id);
|
| + EXPECT_EQ(1920, result.Width());
|
| + EXPECT_EQ(1080, result.Height());
|
| }
|
| }
|
|
|
| -TEST_F(MediaStreamConstraintsUtilVideoSourceTest, IdealWidth) {
|
| +TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, IdealWidth) {
|
| constraint_factory_.Reset();
|
| {
|
| const int kIdealWidth = 320;
|
| constraint_factory_.basic().width.setIdeal(kIdealWidth);
|
| auto result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| + EXPECT_TRUE(result.HasValue());
|
| // The algorithm should select the first device that supports the ideal
|
| // width natively, which is the low-res device at 320x240.
|
| - EXPECT_EQ(low_res_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(kIdealWidth, result.settings.GetWidth());
|
| + EXPECT_EQ(low_res_device_->device_id, result.device_id);
|
| + EXPECT_EQ(kIdealWidth, result.Width());
|
| }
|
|
|
| {
|
| const int kIdealWidth = 321;
|
| constraint_factory_.basic().width.setIdeal(kIdealWidth);
|
| auto result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| + EXPECT_TRUE(result.HasValue());
|
| // In this case, the default device is selected because it can satisfy the
|
| // ideal at a lower cost than the other devices (500 vs 640).
|
| // Note that a native resolution of 320 is further from the ideal value of
|
| // 321 than 500 cropped to 321.
|
| - EXPECT_EQ(default_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(*default_closest_format_, result.settings.format());
|
| + EXPECT_EQ(default_device_->device_id, result.device_id);
|
| + EXPECT_EQ(*default_closest_format_, result.Format());
|
| }
|
|
|
| {
|
| const int kIdealWidth = 2000;
|
| constraint_factory_.basic().width.setIdeal(kIdealWidth);
|
| auto result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| + EXPECT_TRUE(result.HasValue());
|
| // The algorithm must the select the only device that can satisfy the ideal.
|
| - EXPECT_EQ(high_res_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(*high_res_highest_format_, result.settings.format());
|
| + EXPECT_EQ(high_res_device_->device_id, result.device_id);
|
| + EXPECT_EQ(*high_res_highest_format_, result.Format());
|
| }
|
|
|
| {
|
| const int kIdealWidth = 3000;
|
| constraint_factory_.basic().width.setIdeal(kIdealWidth);
|
| auto result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| + EXPECT_TRUE(result.HasValue());
|
| // The algorithm must the select the device and setting with less distance
|
| // to the ideal.
|
| - EXPECT_EQ(high_res_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(*high_res_highest_format_, result.settings.format());
|
| + EXPECT_EQ(high_res_device_->device_id, result.device_id);
|
| + EXPECT_EQ(*high_res_highest_format_, result.Format());
|
| }
|
| }
|
|
|
| -TEST_F(MediaStreamConstraintsUtilVideoSourceTest, MandatoryExactFrameRate) {
|
| +TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryExactFrameRate) {
|
| constraint_factory_.Reset();
|
| const double kFrameRate = MediaStreamVideoSource::kDefaultFrameRate;
|
| constraint_factory_.basic().frameRate.setExact(kFrameRate);
|
| auto result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| + EXPECT_TRUE(result.HasValue());
|
| // All devices in |capabilities_| support the requested frame rate. The
|
| // algorithm should prefer the first device that supports the requested frame
|
| // rate natively, which is the low-res device at 640x480x30Hz.
|
| - EXPECT_EQ(low_res_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(kFrameRate, result.settings.GetFrameRate());
|
| - EXPECT_EQ(640, result.settings.GetWidth());
|
| - EXPECT_EQ(480, result.settings.GetHeight());
|
| + EXPECT_EQ(low_res_device_->device_id, result.device_id);
|
| + EXPECT_EQ(kFrameRate, result.FrameRate());
|
| + EXPECT_EQ(640, result.Width());
|
| + EXPECT_EQ(480, result.Height());
|
|
|
| const double kLargeFrameRate = 50;
|
| constraint_factory_.basic().frameRate.setExact(kLargeFrameRate);
|
| result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| + EXPECT_TRUE(result.HasValue());
|
| // Only the high-res device supports the requested frame rate, even if not
|
| // natively. The least expensive configuration that supports the requested
|
| // frame rate is 1280x720x60Hz.
|
| - EXPECT_EQ(high_res_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(60.0, result.settings.GetFrameRate());
|
| - EXPECT_EQ(1280, result.settings.GetWidth());
|
| - EXPECT_EQ(720, result.settings.GetHeight());
|
| + EXPECT_EQ(high_res_device_->device_id, result.device_id);
|
| + EXPECT_EQ(60.0, result.FrameRate());
|
| + EXPECT_EQ(1280, result.Width());
|
| + EXPECT_EQ(720, result.Height());
|
| }
|
|
|
| -TEST_F(MediaStreamConstraintsUtilVideoSourceTest, MandatoryMinFrameRate) {
|
| +TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryMinFrameRate) {
|
| constraint_factory_.Reset();
|
| const double kFrameRate = MediaStreamVideoSource::kDefaultFrameRate;
|
| constraint_factory_.basic().frameRate.setMin(kFrameRate);
|
| auto result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| + EXPECT_TRUE(result.HasValue());
|
| // All devices in |capabilities_| support the requested frame-rate range. The
|
| // algorithm should prefer the default device.
|
| - EXPECT_EQ(default_device_->device_id, result.settings.device_id());
|
| + EXPECT_EQ(default_device_->device_id, result.device_id);
|
| // The format closest to the default satisfies the constraint.
|
| - EXPECT_EQ(*default_closest_format_, result.settings.format());
|
| + EXPECT_EQ(*default_closest_format_, result.Format());
|
|
|
| const double kLargeFrameRate = 50;
|
| constraint_factory_.basic().frameRate.setMin(kLargeFrameRate);
|
| result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| + EXPECT_TRUE(result.HasValue());
|
| // Only the high-res device supports the requested frame-rate range.
|
| // The least expensive configuration is 1280x720x60Hz.
|
| - EXPECT_EQ(high_res_device_->device_id, result.settings.device_id());
|
| - EXPECT_LE(kLargeFrameRate, result.settings.GetFrameRate());
|
| - EXPECT_EQ(1280, result.settings.GetWidth());
|
| - EXPECT_EQ(720, result.settings.GetHeight());
|
| + EXPECT_EQ(high_res_device_->device_id, result.device_id);
|
| + EXPECT_LE(kLargeFrameRate, result.FrameRate());
|
| + EXPECT_EQ(1280, result.Width());
|
| + EXPECT_EQ(720, result.Height());
|
| }
|
|
|
| -TEST_F(MediaStreamConstraintsUtilVideoSourceTest, MandatoryMaxFrameRate) {
|
| +TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryMaxFrameRate) {
|
| constraint_factory_.Reset();
|
| const double kLowFrameRate = 10;
|
| constraint_factory_.basic().frameRate.setMax(kLowFrameRate);
|
| auto result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| + EXPECT_TRUE(result.HasValue());
|
| // All devices in |capabilities_| support the requested frame-rate range. The
|
| // algorithm should prefer the settings that natively exceed the requested
|
| // maximum by the lowest amount. In this case it is the high-res device with
|
| // default resolution .
|
| - EXPECT_EQ(high_res_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(kLowFrameRate, result.settings.GetFrameRate());
|
| - EXPECT_EQ(MediaStreamVideoSource::kDefaultHeight,
|
| - result.settings.GetHeight());
|
| - EXPECT_EQ(MediaStreamVideoSource::kDefaultWidth, result.settings.GetWidth());
|
| + EXPECT_EQ(high_res_device_->device_id, result.device_id);
|
| + EXPECT_EQ(kLowFrameRate, result.FrameRate());
|
| + EXPECT_EQ(MediaStreamVideoSource::kDefaultHeight, result.Height());
|
| + EXPECT_EQ(MediaStreamVideoSource::kDefaultWidth, result.Width());
|
| }
|
|
|
| -TEST_F(MediaStreamConstraintsUtilVideoSourceTest, MandatoryFrameRateRange) {
|
| +TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryFrameRateRange) {
|
| constraint_factory_.Reset();
|
| {
|
| const double kMinFrameRate = 10;
|
| @@ -786,14 +785,14 @@ TEST_F(MediaStreamConstraintsUtilVideoSourceTest, MandatoryFrameRateRange) {
|
| constraint_factory_.basic().frameRate.setMin(kMinFrameRate);
|
| constraint_factory_.basic().frameRate.setMax(kMaxFrameRate);
|
| auto result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| - EXPECT_LE(kMinFrameRate, result.settings.GetFrameRate());
|
| - EXPECT_GE(kMaxFrameRate, result.settings.GetFrameRate());
|
| + EXPECT_TRUE(result.HasValue());
|
| + EXPECT_LE(kMinFrameRate, result.FrameRate());
|
| + EXPECT_GE(kMaxFrameRate, result.FrameRate());
|
| // All devices in |capabilities_| support the constraint range. The
|
| // algorithm should prefer the default device since its closest-to-default
|
| // format has a frame rate included in the requested range.
|
| - EXPECT_EQ(default_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(*default_closest_format_, result.settings.format());
|
| + EXPECT_EQ(default_device_->device_id, result.device_id);
|
| + EXPECT_EQ(*default_closest_format_, result.Format());
|
| }
|
|
|
| {
|
| @@ -802,14 +801,14 @@ TEST_F(MediaStreamConstraintsUtilVideoSourceTest, MandatoryFrameRateRange) {
|
| constraint_factory_.basic().frameRate.setMin(kMinFrameRate);
|
| constraint_factory_.basic().frameRate.setMax(kMaxFrameRate);
|
| auto result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| - EXPECT_GE(result.settings.GetFrameRate(), kMinFrameRate);
|
| - EXPECT_LE(result.settings.GetFrameRate(), kMaxFrameRate);
|
| + EXPECT_TRUE(result.HasValue());
|
| + EXPECT_GE(result.FrameRate(), kMinFrameRate);
|
| + EXPECT_LE(result.FrameRate(), kMaxFrameRate);
|
| // In this case, the algorithm should prefer the low-res device since it is
|
| // the first device with a native frame rate included in the requested
|
| // range. The default resolution should be preferred as secondary criterion.
|
| - EXPECT_EQ(low_res_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(*low_res_closest_format_, result.settings.format());
|
| + EXPECT_EQ(low_res_device_->device_id, result.device_id);
|
| + EXPECT_EQ(*low_res_closest_format_, result.Format());
|
| }
|
|
|
| {
|
| @@ -818,86 +817,86 @@ TEST_F(MediaStreamConstraintsUtilVideoSourceTest, MandatoryFrameRateRange) {
|
| constraint_factory_.basic().frameRate.setMin(kMinFrameRate);
|
| constraint_factory_.basic().frameRate.setMax(kMaxFrameRate);
|
| auto result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| - EXPECT_GE(result.settings.GetFrameRate(), kMinFrameRate);
|
| - EXPECT_LE(result.settings.GetFrameRate(), kMaxFrameRate);
|
| + EXPECT_TRUE(result.HasValue());
|
| + EXPECT_GE(result.FrameRate(), kMinFrameRate);
|
| + EXPECT_LE(result.FrameRate(), kMaxFrameRate);
|
| // In this case, the algorithm should prefer the high-res device since it is
|
| // the only device with a native format included in the requested range.
|
| // The 1280x720 resolution should be selected due to closeness to default
|
| // settings, which is the second tie-breaker criterion that applies.
|
| - EXPECT_EQ(high_res_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(1280, result.settings.GetWidth());
|
| - EXPECT_EQ(720, result.settings.GetHeight());
|
| + EXPECT_EQ(high_res_device_->device_id, result.device_id);
|
| + EXPECT_EQ(1280, result.Width());
|
| + EXPECT_EQ(720, result.Height());
|
| }
|
| }
|
|
|
| -TEST_F(MediaStreamConstraintsUtilVideoSourceTest, IdealFrameRate) {
|
| +TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, IdealFrameRate) {
|
| constraint_factory_.Reset();
|
| {
|
| const double kIdealFrameRate = MediaStreamVideoSource::kDefaultFrameRate;
|
| constraint_factory_.basic().frameRate.setIdeal(kIdealFrameRate);
|
| auto result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| + EXPECT_TRUE(result.HasValue());
|
| // The algorithm should select the first configuration that supports the
|
| // ideal frame rate natively, which is the low-res device. Default
|
| // resolution should be selected as secondary criterion.
|
| - EXPECT_EQ(low_res_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(*low_res_closest_format_, result.settings.format());
|
| + EXPECT_EQ(low_res_device_->device_id, result.device_id);
|
| + EXPECT_EQ(*low_res_closest_format_, result.Format());
|
| }
|
|
|
| {
|
| const double kIdealFrameRate = 31;
|
| constraint_factory_.basic().frameRate.setIdeal(kIdealFrameRate);
|
| auto result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| + EXPECT_TRUE(result.HasValue());
|
| // In this case, the default device is selected because it can satisfy the
|
| // ideal at a lower cost than the other devices (40 vs 60).
|
| // Note that a native frame rate of 30 is further from the ideal than
|
| // 31 adjusted to 30.
|
| - EXPECT_EQ(default_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(*default_closest_format_, result.settings.format());
|
| + EXPECT_EQ(default_device_->device_id, result.device_id);
|
| + EXPECT_EQ(*default_closest_format_, result.Format());
|
| }
|
|
|
| {
|
| const double kIdealFrameRate = 55;
|
| constraint_factory_.basic().frameRate.setIdeal(kIdealFrameRate);
|
| auto result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| + EXPECT_TRUE(result.HasValue());
|
| // The high-res device format 1280x720x60.0 must be selected because its
|
| // frame rate can satisfy the ideal frame rate and has resolution closest
|
| // to the default.
|
| - EXPECT_EQ(high_res_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(1280, result.settings.GetWidth());
|
| - EXPECT_EQ(720, result.settings.GetHeight());
|
| - EXPECT_EQ(60, result.settings.GetFrameRate());
|
| + EXPECT_EQ(high_res_device_->device_id, result.device_id);
|
| + EXPECT_EQ(1280, result.Width());
|
| + EXPECT_EQ(720, result.Height());
|
| + EXPECT_EQ(60, result.FrameRate());
|
| }
|
|
|
| {
|
| const double kIdealFrameRate = 100;
|
| constraint_factory_.basic().frameRate.setIdeal(kIdealFrameRate);
|
| auto result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| + EXPECT_TRUE(result.HasValue());
|
| // The algorithm must select settings with frame rate closest to the ideal.
|
| // The high-res device format 1280x720x60.0 must be selected because its
|
| // frame rate it closest to the ideal value and it has resolution closest to
|
| // the default.
|
| - EXPECT_EQ(high_res_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(1280, result.settings.GetWidth());
|
| - EXPECT_EQ(720, result.settings.GetHeight());
|
| - EXPECT_EQ(60, result.settings.GetFrameRate());
|
| + EXPECT_EQ(high_res_device_->device_id, result.device_id);
|
| + EXPECT_EQ(1280, result.Width());
|
| + EXPECT_EQ(720, result.Height());
|
| + EXPECT_EQ(60, result.FrameRate());
|
| }
|
| }
|
|
|
| -TEST_F(MediaStreamConstraintsUtilVideoSourceTest, MandatoryExactAspectRatio) {
|
| +TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryExactAspectRatio) {
|
| constraint_factory_.Reset();
|
| const double kAspectRatio = 4.0 / 3.0;
|
| constraint_factory_.basic().aspectRatio.setExact(kAspectRatio);
|
| auto result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| + EXPECT_TRUE(result.HasValue());
|
| double min_width = 1.0;
|
| - double max_width = result.settings.GetWidth();
|
| + double max_width = result.Width();
|
| double min_height = 1.0;
|
| - double max_height = result.settings.GetHeight();
|
| + double max_height = result.Height();
|
| double min_aspect_ratio = min_width / max_height;
|
| double max_aspect_ratio = max_width / min_height;
|
| // The requested aspect ratio must be within the supported range.
|
| @@ -906,22 +905,22 @@ TEST_F(MediaStreamConstraintsUtilVideoSourceTest, MandatoryExactAspectRatio) {
|
| // All devices in |capabilities_| support the requested aspect ratio.
|
| // The algorithm should prefer the first device that supports the requested
|
| // aspect ratio.
|
| - EXPECT_EQ(default_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(*default_closest_format_, result.settings.format());
|
| + EXPECT_EQ(default_device_->device_id, result.device_id);
|
| + EXPECT_EQ(*default_closest_format_, result.Format());
|
|
|
| - const long kMinWidth = 500;
|
| - const long kMaxWidth = 1000;
|
| - const long kMaxHeight = 500;
|
| + const int kMinWidth = 500;
|
| + const int kMaxWidth = 1000;
|
| + const int kMaxHeight = 500;
|
| constraint_factory_.basic().height.setMax(kMaxHeight);
|
| constraint_factory_.basic().width.setMin(kMinWidth);
|
| constraint_factory_.basic().width.setMax(kMaxWidth);
|
| constraint_factory_.basic().aspectRatio.setExact(kAspectRatio);
|
| result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| - min_width = std::max(1L, kMinWidth);
|
| - max_width = std::min(result.settings.GetWidth(), kMaxWidth);
|
| + EXPECT_TRUE(result.HasValue());
|
| + min_width = std::max(1, kMinWidth);
|
| + max_width = std::min(result.Width(), kMaxWidth);
|
| min_height = 1.0;
|
| - max_height = std::min(result.settings.GetHeight(), kMaxHeight);
|
| + max_height = std::min(result.Height(), kMaxHeight);
|
| min_aspect_ratio = min_width / max_height;
|
| max_aspect_ratio = max_width / min_height;
|
| // The requested aspect ratio must be within the supported range.
|
| @@ -929,21 +928,21 @@ TEST_F(MediaStreamConstraintsUtilVideoSourceTest, MandatoryExactAspectRatio) {
|
| EXPECT_LE(kAspectRatio, max_aspect_ratio);
|
| // The default device can support the requested aspect ratio with the default
|
| // settings (500x500) using cropping.
|
| - EXPECT_EQ(default_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(*default_closest_format_, result.settings.format());
|
| + EXPECT_EQ(default_device_->device_id, result.device_id);
|
| + EXPECT_EQ(*default_closest_format_, result.Format());
|
|
|
| - const long kMinHeight = 480;
|
| + const int kMinHeight = 480;
|
| constraint_factory_.basic().height.setMin(kMinHeight);
|
| constraint_factory_.basic().height.setMax(kMaxHeight);
|
| constraint_factory_.basic().width.setMin(kMinWidth);
|
| constraint_factory_.basic().width.setMax(kMaxWidth);
|
| constraint_factory_.basic().aspectRatio.setExact(kAspectRatio);
|
| result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| - min_width = std::max(1L, kMinWidth);
|
| - max_width = std::min(result.settings.GetWidth(), kMaxWidth);
|
| - min_height = std::max(1L, kMinHeight);
|
| - max_height = std::min(result.settings.GetHeight(), kMaxHeight);
|
| + EXPECT_TRUE(result.HasValue());
|
| + min_width = std::max(1, kMinWidth);
|
| + max_width = std::min(result.Width(), kMaxWidth);
|
| + min_height = std::max(1, kMinHeight);
|
| + max_height = std::min(result.Height(), kMaxHeight);
|
| min_aspect_ratio = min_width / max_height;
|
| max_aspect_ratio = max_width / min_height;
|
| // The requested aspect ratio must be within the supported range.
|
| @@ -955,17 +954,17 @@ TEST_F(MediaStreamConstraintsUtilVideoSourceTest, MandatoryExactAspectRatio) {
|
| // resolution of 640x480. Higher resolutions for the default device are more
|
| // penalized by the constraints than the default native resolution of the
|
| // low-res device.
|
| - EXPECT_EQ(low_res_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(*low_res_closest_format_, result.settings.format());
|
| + EXPECT_EQ(low_res_device_->device_id, result.device_id);
|
| + EXPECT_EQ(*low_res_closest_format_, result.Format());
|
| }
|
|
|
| -TEST_F(MediaStreamConstraintsUtilVideoSourceTest, MandatoryMinAspectRatio) {
|
| +TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryMinAspectRatio) {
|
| constraint_factory_.Reset();
|
| const double kAspectRatio = 4.0 / 3.0;
|
| constraint_factory_.basic().aspectRatio.setMin(kAspectRatio);
|
| auto result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| - double max_width = result.settings.GetWidth();
|
| + EXPECT_TRUE(result.HasValue());
|
| + double max_width = result.Width();
|
| double min_height = 1.0;
|
| double max_aspect_ratio = max_width / min_height;
|
| // Minimum constraint aspect ratio must be less than or equal to the maximum
|
| @@ -974,22 +973,22 @@ TEST_F(MediaStreamConstraintsUtilVideoSourceTest, MandatoryMinAspectRatio) {
|
| // All devices in |capabilities_| support the requested aspect-ratio range.
|
| // The algorithm should prefer the first device that supports the requested
|
| // aspect-ratio range, which in this case is the default device.
|
| - EXPECT_EQ(default_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(*default_closest_format_, result.settings.format());
|
| + EXPECT_EQ(default_device_->device_id, result.device_id);
|
| + EXPECT_EQ(*default_closest_format_, result.Format());
|
|
|
| - const long kMinWidth = 500;
|
| - const long kMaxWidth = 1000;
|
| - const long kMinHeight = 480;
|
| - const long kMaxHeight = 500;
|
| + const int kMinWidth = 500;
|
| + const int kMaxWidth = 1000;
|
| + const int kMinHeight = 480;
|
| + const int kMaxHeight = 500;
|
| constraint_factory_.basic().width.setMin(kMinWidth);
|
| constraint_factory_.basic().width.setMax(kMaxWidth);
|
| constraint_factory_.basic().height.setMin(kMinHeight);
|
| constraint_factory_.basic().height.setMax(kMaxHeight);
|
| constraint_factory_.basic().aspectRatio.setMin(kAspectRatio);
|
| result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| - max_width = std::min(result.settings.GetWidth(), kMaxWidth);
|
| - min_height = std::max(1L, kMinHeight);
|
| + EXPECT_TRUE(result.HasValue());
|
| + max_width = std::min(result.Width(), kMaxWidth);
|
| + min_height = std::max(1, kMinHeight);
|
| max_aspect_ratio = max_width / min_height;
|
| // Minimum constraint aspect ratio must be less than or equal to the minimum
|
| // supported by the source.
|
| @@ -1000,18 +999,18 @@ TEST_F(MediaStreamConstraintsUtilVideoSourceTest, MandatoryMinAspectRatio) {
|
| // resolution of 640x480.
|
| // Higher resolutions for the default device are more penalized by the
|
| // constraints than the default native resolution of the low-res device.
|
| - EXPECT_EQ(low_res_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(*low_res_closest_format_, result.settings.format());
|
| + EXPECT_EQ(low_res_device_->device_id, result.device_id);
|
| + EXPECT_EQ(*low_res_closest_format_, result.Format());
|
| }
|
|
|
| -TEST_F(MediaStreamConstraintsUtilVideoSourceTest, MandatoryMaxAspectRatio) {
|
| +TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryMaxAspectRatio) {
|
| constraint_factory_.Reset();
|
| const double kAspectRatio = 0.5;
|
| constraint_factory_.basic().aspectRatio.setMax(kAspectRatio);
|
| auto result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| + EXPECT_TRUE(result.HasValue());
|
| double min_width = 1.0;
|
| - double max_height = result.settings.GetHeight();
|
| + double max_height = result.Height();
|
| double min_aspect_ratio = min_width / max_height;
|
| // Minimum constraint aspect ratio must be less than or equal to the maximum
|
| // supported by the source.
|
| @@ -1019,20 +1018,20 @@ TEST_F(MediaStreamConstraintsUtilVideoSourceTest, MandatoryMaxAspectRatio) {
|
| // All devices in |capabilities_| support the requested aspect-ratio range.
|
| // The algorithm should prefer the first device that supports the requested
|
| // aspect-ratio range, which in this case is the default device.
|
| - EXPECT_EQ(default_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(*default_closest_format_, result.settings.format());
|
| + EXPECT_EQ(default_device_->device_id, result.device_id);
|
| + EXPECT_EQ(*default_closest_format_, result.Format());
|
|
|
| - const long kExactWidth = 360;
|
| - const long kMinHeight = 360;
|
| - const long kMaxHeight = 720;
|
| + const int kExactWidth = 360;
|
| + const int kMinHeight = 360;
|
| + const int kMaxHeight = 720;
|
| constraint_factory_.basic().width.setExact(kExactWidth);
|
| constraint_factory_.basic().height.setMin(kMinHeight);
|
| constraint_factory_.basic().height.setMax(kMaxHeight);
|
| constraint_factory_.basic().aspectRatio.setMax(kAspectRatio);
|
| result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| - min_width = std::max(1L, kExactWidth);
|
| - max_height = std::min(result.settings.GetHeight(), kMaxHeight);
|
| + EXPECT_TRUE(result.HasValue());
|
| + min_width = std::max(1, kExactWidth);
|
| + max_height = std::min(result.Height(), kMaxHeight);
|
| min_aspect_ratio = min_width / max_height;
|
| // Minimum constraint aspect ratio must be less than or equal to the minimum
|
| // supported by the source.
|
| @@ -1043,12 +1042,12 @@ TEST_F(MediaStreamConstraintsUtilVideoSourceTest, MandatoryMaxAspectRatio) {
|
| // The high-res device with a native resolution of 1280x720 can support
|
| // 360x720 with cropping with less penalty than the default device at
|
| // 1000x1000.
|
| - EXPECT_EQ(high_res_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(1280, result.settings.GetWidth());
|
| - EXPECT_EQ(720, result.settings.GetHeight());
|
| + EXPECT_EQ(high_res_device_->device_id, result.device_id);
|
| + EXPECT_EQ(1280, result.Width());
|
| + EXPECT_EQ(720, result.Height());
|
| }
|
|
|
| -TEST_F(MediaStreamConstraintsUtilVideoSourceTest, MandatoryAspectRatioRange) {
|
| +TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, MandatoryAspectRatioRange) {
|
| constraint_factory_.Reset();
|
| {
|
| const double kMinAspectRatio = 0.5;
|
| @@ -1057,11 +1056,11 @@ TEST_F(MediaStreamConstraintsUtilVideoSourceTest, MandatoryAspectRatioRange) {
|
| constraint_factory_.basic().aspectRatio.setMin(kMinAspectRatio);
|
| constraint_factory_.basic().aspectRatio.setMax(kMaxAspectRatio);
|
| auto result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| + EXPECT_TRUE(result.HasValue());
|
| double min_width = 1.0;
|
| - double max_width = result.settings.GetWidth();
|
| + double max_width = result.Width();
|
| double min_height = 1.0;
|
| - double max_height = result.settings.GetHeight();
|
| + double max_height = result.Height();
|
| double min_aspect_ratio = min_width / max_height;
|
| double max_aspect_ratio = max_width / min_height;
|
| // Constraint aspect-ratio range must have nonempty intersection with
|
| @@ -1071,8 +1070,8 @@ TEST_F(MediaStreamConstraintsUtilVideoSourceTest, MandatoryAspectRatioRange) {
|
| // All devices in |capabilities_| support the requested aspect-ratio range.
|
| // The algorithm should prefer the first device that supports the requested
|
| // aspect-ratio range, which in this case is the default device.
|
| - EXPECT_EQ(default_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(*default_closest_format_, result.settings.format());
|
| + EXPECT_EQ(default_device_->device_id, result.device_id);
|
| + EXPECT_EQ(*default_closest_format_, result.Format());
|
| }
|
|
|
| {
|
| @@ -1085,11 +1084,11 @@ TEST_F(MediaStreamConstraintsUtilVideoSourceTest, MandatoryAspectRatioRange) {
|
| constraint_factory_.basic().aspectRatio.setMin(kMinAspectRatio);
|
| constraint_factory_.basic().aspectRatio.setMax(kMaxAspectRatio);
|
| auto result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| + EXPECT_TRUE(result.HasValue());
|
| double min_width = 1.0;
|
| - double max_width = result.settings.GetWidth();
|
| + double max_width = result.Width();
|
| double min_height = 1.0;
|
| - double max_height = result.settings.GetHeight();
|
| + double max_height = result.Height();
|
| double min_aspect_ratio = min_width / max_height;
|
| double max_aspect_ratio = max_width / min_height;
|
| // Constraint aspect-ratio range must have nonempty intersection with
|
| @@ -1098,23 +1097,23 @@ TEST_F(MediaStreamConstraintsUtilVideoSourceTest, MandatoryAspectRatioRange) {
|
| EXPECT_GE(kMaxAspectRatio, min_aspect_ratio);
|
| // The only device that supports the resolution and aspect ratio constraint
|
| // is the high-res device. The 1920x1080 is the least expensive format.
|
| - EXPECT_EQ(high_res_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(1920, result.settings.GetWidth());
|
| - EXPECT_EQ(1080, result.settings.GetHeight());
|
| + EXPECT_EQ(high_res_device_->device_id, result.device_id);
|
| + EXPECT_EQ(1920, result.Width());
|
| + EXPECT_EQ(1080, result.Height());
|
| }
|
| }
|
|
|
| -TEST_F(MediaStreamConstraintsUtilVideoSourceTest, IdealAspectRatio) {
|
| +TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, IdealAspectRatio) {
|
| constraint_factory_.Reset();
|
| {
|
| const double kIdealAspectRatio = 0.5;
|
| constraint_factory_.basic().aspectRatio.setIdeal(kIdealAspectRatio);
|
| auto result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| + EXPECT_TRUE(result.HasValue());
|
| double min_width = 1.0;
|
| - double max_width = result.settings.GetWidth();
|
| + double max_width = result.Width();
|
| double min_height = 1.0;
|
| - double max_height = result.settings.GetHeight();
|
| + double max_height = result.Height();
|
| double min_aspect_ratio = min_width / max_height;
|
| double max_aspect_ratio = max_width / min_height;
|
| // All devices in |capabilities_| support the ideal aspect-ratio.
|
| @@ -1122,43 +1121,43 @@ TEST_F(MediaStreamConstraintsUtilVideoSourceTest, IdealAspectRatio) {
|
| // settings.
|
| EXPECT_LE(kIdealAspectRatio, max_aspect_ratio);
|
| EXPECT_GE(kIdealAspectRatio, min_aspect_ratio);
|
| - EXPECT_EQ(default_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(*default_closest_format_, result.settings.format());
|
| + EXPECT_EQ(default_device_->device_id, result.device_id);
|
| + EXPECT_EQ(*default_closest_format_, result.Format());
|
| }
|
|
|
| {
|
| const double kIdealAspectRatio = 1500.0;
|
| constraint_factory_.basic().aspectRatio.setIdeal(kIdealAspectRatio);
|
| auto result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| + EXPECT_TRUE(result.HasValue());
|
| // The only device that supports the ideal aspect ratio is the high-res
|
| // device. The least expensive way to support it with the 1920x1080 format
|
| // cropped to 1500x1.
|
| - EXPECT_EQ(high_res_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(1920, result.settings.GetWidth());
|
| - EXPECT_EQ(1080, result.settings.GetHeight());
|
| + EXPECT_EQ(high_res_device_->device_id, result.device_id);
|
| + EXPECT_EQ(1920, result.Width());
|
| + EXPECT_EQ(1080, result.Height());
|
| }
|
|
|
| {
|
| const double kIdealAspectRatio = 2000.0;
|
| constraint_factory_.basic().aspectRatio.setIdeal(kIdealAspectRatio);
|
| auto result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| + EXPECT_TRUE(result.HasValue());
|
| // The only device that supports the ideal aspect ratio is the high-res
|
| // device with its highest resolution, cropped to 2000x1.
|
| - EXPECT_EQ(high_res_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(*high_res_highest_format_, result.settings.format());
|
| + EXPECT_EQ(high_res_device_->device_id, result.device_id);
|
| + EXPECT_EQ(*high_res_highest_format_, result.Format());
|
| }
|
|
|
| {
|
| const double kIdealAspectRatio = 4000.0;
|
| constraint_factory_.basic().aspectRatio.setIdeal(kIdealAspectRatio);
|
| auto result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| + EXPECT_TRUE(result.HasValue());
|
| // The configuration closest to the ideal aspect ratio is is the high-res
|
| // device with its highest resolution, cropped to 2304x1.
|
| - EXPECT_EQ(high_res_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(*high_res_highest_format_, result.settings.format());
|
| + EXPECT_EQ(high_res_device_->device_id, result.device_id);
|
| + EXPECT_EQ(*high_res_highest_format_, result.Format());
|
| }
|
|
|
| {
|
| @@ -1166,13 +1165,13 @@ TEST_F(MediaStreamConstraintsUtilVideoSourceTest, IdealAspectRatio) {
|
| constraint_factory_.basic().aspectRatio.setIdeal(kIdealAspectRatio);
|
| constraint_factory_.basic().height.setExact(400);
|
| auto result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| + EXPECT_TRUE(result.HasValue());
|
| // The first device to support the ideal aspect ratio and the resolution
|
| // constraint is the low-res device. The 800x600 format cropped to 800x400
|
| // is the lest expensive way to achieve it.
|
| - EXPECT_EQ(low_res_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(800, result.settings.GetWidth());
|
| - EXPECT_EQ(600, result.settings.GetHeight());
|
| + EXPECT_EQ(low_res_device_->device_id, result.device_id);
|
| + EXPECT_EQ(800, result.Width());
|
| + EXPECT_EQ(600, result.Height());
|
| }
|
|
|
| {
|
| @@ -1180,19 +1179,19 @@ TEST_F(MediaStreamConstraintsUtilVideoSourceTest, IdealAspectRatio) {
|
| constraint_factory_.basic().aspectRatio.setIdeal(kIdealAspectRatio);
|
| constraint_factory_.basic().height.setExact(400);
|
| auto result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| + EXPECT_TRUE(result.HasValue());
|
| // The only device that supports the ideal aspect ratio and the resolution
|
| // constraint is the high-res device. The 1280x720 cropped to 1200x400 is
|
| // the lest expensive way to achieve it.
|
| - EXPECT_EQ(high_res_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(1280, result.settings.GetWidth());
|
| - EXPECT_EQ(720, result.settings.GetHeight());
|
| + EXPECT_EQ(high_res_device_->device_id, result.device_id);
|
| + EXPECT_EQ(1280, result.Width());
|
| + EXPECT_EQ(720, result.Height());
|
| }
|
| }
|
|
|
| // The "Advanced" tests check selection criteria involving advanced constraint
|
| // sets.
|
| -TEST_F(MediaStreamConstraintsUtilVideoSourceTest, AdvancedExactResolution) {
|
| +TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, AdvancedExactResolution) {
|
| {
|
| constraint_factory_.Reset();
|
| blink::WebMediaTrackConstraintSet& advanced1 =
|
| @@ -1206,62 +1205,62 @@ TEST_F(MediaStreamConstraintsUtilVideoSourceTest, AdvancedExactResolution) {
|
| auto result = SelectSettings();
|
| // No device supports the advanced constraint sets.
|
| // Tie-breaker rule that applies is closeness to default settings.
|
| - EXPECT_EQ(default_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(*default_closest_format_, result.settings.format());
|
| + EXPECT_EQ(default_device_->device_id, result.device_id);
|
| + EXPECT_EQ(*default_closest_format_, result.Format());
|
|
|
| blink::WebMediaTrackConstraintSet& advanced3 =
|
| constraint_factory_.AddAdvanced();
|
| advanced3.width.setExact(1920);
|
| advanced3.height.setExact(1080);
|
| result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| + EXPECT_TRUE(result.HasValue());
|
| // The high-res device natively supports the third advanced constraint set
|
| // and should be selected.
|
| // First tie-breaker rule that applies is support for advanced constraints
|
| // that appear first. Second tie-breaker rule is custom distance to advanced
|
| // constraint sets that appear first.
|
| - EXPECT_EQ(high_res_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(1920, result.settings.GetWidth());
|
| - EXPECT_EQ(1080, result.settings.GetHeight());
|
| + EXPECT_EQ(high_res_device_->device_id, result.device_id);
|
| + EXPECT_EQ(1920, result.Width());
|
| + EXPECT_EQ(1080, result.Height());
|
|
|
| blink::WebMediaTrackConstraintSet& advanced4 =
|
| constraint_factory_.AddAdvanced();
|
| advanced4.width.setExact(640);
|
| advanced4.height.setExact(480);
|
| result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| + EXPECT_TRUE(result.HasValue());
|
| // First tie-breaker rule that applies is support for advanced constraints
|
| // that appear first, which leaves out configurations that only support the
|
| // fourth advanced constraint set in favor of configurations that support
|
| // the third set.
|
| // Second tie-breaker rule is custom distance to advanced constraint sets
|
| // that appear first.
|
| - EXPECT_EQ(high_res_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(1920, result.settings.GetWidth());
|
| - EXPECT_EQ(1080, result.settings.GetHeight());
|
| + EXPECT_EQ(high_res_device_->device_id, result.device_id);
|
| + EXPECT_EQ(1920, result.Width());
|
| + EXPECT_EQ(1080, result.Height());
|
|
|
| constraint_factory_.basic().width.setIdeal(800);
|
| constraint_factory_.basic().height.setIdeal(600);
|
| result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| + EXPECT_TRUE(result.HasValue());
|
| // The ideal value is supported by the same configuration, so nothing
|
| // changes.
|
| - EXPECT_EQ(high_res_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(1920, result.settings.GetWidth());
|
| - EXPECT_EQ(1080, result.settings.GetHeight());
|
| + EXPECT_EQ(high_res_device_->device_id, result.device_id);
|
| + EXPECT_EQ(1920, result.Width());
|
| + EXPECT_EQ(1080, result.Height());
|
|
|
| constraint_factory_.basic().width.setIdeal(2000);
|
| constraint_factory_.basic().height.setIdeal(1500);
|
| result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| + EXPECT_TRUE(result.HasValue());
|
| // The closest configuration to the ideal resolution is the high-res device
|
| // at the highest resolution.
|
| - EXPECT_EQ(high_res_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(*high_res_highest_format_, result.settings.format());
|
| + EXPECT_EQ(high_res_device_->device_id, result.device_id);
|
| + EXPECT_EQ(*high_res_highest_format_, result.Format());
|
| }
|
| }
|
|
|
| -TEST_F(MediaStreamConstraintsUtilVideoSourceTest,
|
| +TEST_F(MediaStreamConstraintsUtilVideoDeviceTest,
|
| AdvancedResolutionAndFrameRate) {
|
| {
|
| constraint_factory_.Reset();
|
| @@ -1277,36 +1276,36 @@ TEST_F(MediaStreamConstraintsUtilVideoSourceTest,
|
| advanced3.width.setExact(2304);
|
| advanced3.height.setExact(1536);
|
| auto result = SelectSettings();
|
| - EXPECT_TRUE(result.has_value());
|
| + EXPECT_TRUE(result.HasValue());
|
| // The high-res device is the only one that satisfies the first advanced
|
| // set. 2304x1536x10.0 satisfies sets 1 and 3, while 1920x1080x60.0
|
| // satisfies sets 1, and 2. The latter must be selected, regardless of
|
| // any other criteria.
|
| - EXPECT_EQ(high_res_device_->device_id, result.settings.device_id());
|
| - EXPECT_EQ(1920, result.settings.GetWidth());
|
| - EXPECT_EQ(1080, result.settings.GetHeight());
|
| - EXPECT_EQ(60.0, result.settings.GetFrameRate());
|
| + EXPECT_EQ(high_res_device_->device_id, result.device_id);
|
| + EXPECT_EQ(1920, result.Width());
|
| + EXPECT_EQ(1080, result.Height());
|
| + EXPECT_EQ(60.0, result.FrameRate());
|
| }
|
| }
|
|
|
| // The "NoDevices" tests verify that the algorithm returns the expected result
|
| // when there are no candidates to choose from.
|
| -TEST_F(MediaStreamConstraintsUtilVideoSourceTest, NoDevicesNoConstraints) {
|
| +TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, NoDevicesNoConstraints) {
|
| constraint_factory_.Reset();
|
| - VideoCaptureCapabilities capabilities;
|
| - auto result = SelectVideoCaptureSourceSettings(
|
| + VideoDeviceCaptureCapabilities capabilities;
|
| + auto result = SelectVideoDeviceCaptureSourceSettings(
|
| capabilities, constraint_factory_.CreateWebMediaConstraints());
|
| - EXPECT_FALSE(result.has_value());
|
| + EXPECT_FALSE(result.HasValue());
|
| EXPECT_TRUE(std::string(result.failed_constraint_name).empty());
|
| }
|
|
|
| -TEST_F(MediaStreamConstraintsUtilVideoSourceTest, NoDevicesWithConstraints) {
|
| +TEST_F(MediaStreamConstraintsUtilVideoDeviceTest, NoDevicesWithConstraints) {
|
| constraint_factory_.Reset();
|
| constraint_factory_.basic().height.setExact(100);
|
| - VideoCaptureCapabilities capabilities;
|
| - auto result = SelectVideoCaptureSourceSettings(
|
| + VideoDeviceCaptureCapabilities capabilities;
|
| + auto result = SelectVideoDeviceCaptureSourceSettings(
|
| capabilities, constraint_factory_.CreateWebMediaConstraints());
|
| - EXPECT_FALSE(result.has_value());
|
| + EXPECT_FALSE(result.HasValue());
|
| EXPECT_TRUE(std::string(result.failed_constraint_name).empty());
|
| }
|
|
|
|
|