| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/media/media_stream_constraints_util_video_device.h" | 5 #include "content/renderer/media/media_stream_constraints_util_video_device.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 // With device capture, incoming frames are expected to have the size | 178 // With device capture, incoming frames are expected to have the size |
| 179 // specified in the requested capture format. | 179 // specified in the requested capture format. |
| 180 bool expect_source_native_size = true; | 180 bool expect_source_native_size = true; |
| 181 auto track_adapter_settings = SelectVideoTrackAdapterSettings( | 181 auto track_adapter_settings = SelectVideoTrackAdapterSettings( |
| 182 basic_constraint_set, constrained_format.constrained_resolution(), | 182 basic_constraint_set, constrained_format.constrained_resolution(), |
| 183 constrained_format.constrained_frame_rate(), | 183 constrained_format.constrained_frame_rate(), |
| 184 capture_params.requested_format, expect_source_native_size); | 184 capture_params.requested_format, expect_source_native_size); |
| 185 | 185 |
| 186 return VideoCaptureSettings( | 186 return VideoCaptureSettings( |
| 187 candidate.device_id(), capture_params, candidate.noise_reduction(), | 187 candidate.device_id(), capture_params, candidate.noise_reduction(), |
| 188 track_adapter_settings, | 188 track_adapter_settings, constrained_format.constrained_frame_rate().Min(), |
| 189 constrained_format.constrained_frame_rate().Min()); | 189 constrained_format.constrained_frame_rate().Max()); |
| 190 } | 190 } |
| 191 | 191 |
| 192 // Generic distance function between two numeric values. Based on the fitness | 192 // Generic distance function between two numeric values. Based on the fitness |
| 193 // distance function described in | 193 // distance function described in |
| 194 // https://w3c.github.io/mediacapture-main/#dfn-fitness-distance | 194 // https://w3c.github.io/mediacapture-main/#dfn-fitness-distance |
| 195 double Distance(double value1, double value2) { | 195 double Distance(double value1, double value2) { |
| 196 if (std::fabs(value1 - value2) <= blink::DoubleConstraint::kConstraintEpsilon) | 196 if (std::fabs(value1 - value2) <= blink::DoubleConstraint::kConstraintEpsilon) |
| 197 return 0.0; | 197 return 0.0; |
| 198 | 198 |
| 199 return std::fabs(value1 - value2) / | 199 return std::fabs(value1 - value2) / |
| (...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 878 } | 878 } |
| 879 } | 879 } |
| 880 | 880 |
| 881 if (!result.HasValue()) | 881 if (!result.HasValue()) |
| 882 return VideoCaptureSettings(failed_constraint_name); | 882 return VideoCaptureSettings(failed_constraint_name); |
| 883 | 883 |
| 884 return result; | 884 return result; |
| 885 } | 885 } |
| 886 | 886 |
| 887 } // namespace content | 887 } // namespace content |
| OLD | NEW |