| 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_content.h" | 5 #include "content/renderer/media/media_stream_constraints_util_video_content.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 const double kMaxScreenCastFrameRate = 120.0; | 38 const double kMaxScreenCastFrameRate = 120.0; |
| 39 const double kDefaultScreenCastFrameRate = | 39 const double kDefaultScreenCastFrameRate = |
| 40 MediaStreamVideoSource::kDefaultFrameRate; | 40 MediaStreamVideoSource::kDefaultFrameRate; |
| 41 | 41 |
| 42 namespace { | 42 namespace { |
| 43 | 43 |
| 44 using Point = ResolutionSet::Point; | 44 using Point = ResolutionSet::Point; |
| 45 using StringSet = DiscreteSet<std::string>; | 45 using StringSet = DiscreteSet<std::string>; |
| 46 using BoolSet = DiscreteSet<bool>; | 46 using BoolSet = DiscreteSet<bool>; |
| 47 | 47 |
| 48 | |
| 49 constexpr double kMinScreenCastAspectRatio = | 48 constexpr double kMinScreenCastAspectRatio = |
| 50 static_cast<double>(kMinScreenCastDimension) / | 49 static_cast<double>(kMinScreenCastDimension) / |
| 51 static_cast<double>(kMaxScreenCastDimension); | 50 static_cast<double>(kMaxScreenCastDimension); |
| 52 constexpr double kMaxScreenCastAspectRatio = | 51 constexpr double kMaxScreenCastAspectRatio = |
| 53 static_cast<double>(kMaxScreenCastDimension) / | 52 static_cast<double>(kMaxScreenCastDimension) / |
| 54 static_cast<double>(kMinScreenCastDimension); | 53 static_cast<double>(kMinScreenCastDimension); |
| 55 | 54 |
| 56 StringSet StringSetFromConstraint(const blink::StringConstraint& constraint) { | |
| 57 if (!constraint.HasExact()) | |
| 58 return StringSet::UniversalSet(); | |
| 59 | |
| 60 std::vector<std::string> elements; | |
| 61 for (const auto& entry : constraint.Exact()) | |
| 62 elements.push_back(entry.Ascii()); | |
| 63 | |
| 64 return StringSet(std::move(elements)); | |
| 65 } | |
| 66 | |
| 67 BoolSet BoolSetFromConstraint(const blink::BooleanConstraint& constraint) { | |
| 68 if (!constraint.HasExact()) | |
| 69 return BoolSet::UniversalSet(); | |
| 70 | |
| 71 return BoolSet({constraint.Exact()}); | |
| 72 } | |
| 73 | |
| 74 using DoubleRangeSet = NumericRangeSet<double>; | 55 using DoubleRangeSet = NumericRangeSet<double>; |
| 75 | 56 |
| 76 class VideoContentCaptureCandidates { | 57 class VideoContentCaptureCandidates { |
| 77 public: | 58 public: |
| 78 VideoContentCaptureCandidates() | 59 VideoContentCaptureCandidates() |
| 79 : has_explicit_max_height_(false), | 60 : has_explicit_max_height_(false), |
| 80 has_explicit_max_width_(false), | 61 has_explicit_max_width_(false), |
| 81 has_explicit_min_frame_rate_(false), | 62 has_explicit_min_frame_rate_(false), |
| 82 has_explicit_max_frame_rate_(false), | 63 has_explicit_max_frame_rate_(false) {} |
| 83 device_id_set_(StringSet::UniversalSet()), | |
| 84 noise_reduction_set_(BoolSet::UniversalSet()) {} | |
| 85 explicit VideoContentCaptureCandidates( | 64 explicit VideoContentCaptureCandidates( |
| 86 const blink::WebMediaTrackConstraintSet& constraint_set) | 65 const blink::WebMediaTrackConstraintSet& constraint_set) |
| 87 : resolution_set_(ResolutionSet::FromConstraintSet(constraint_set)), | 66 : resolution_set_(ResolutionSet::FromConstraintSet(constraint_set)), |
| 88 has_explicit_max_height_(ConstraintHasMax(constraint_set.height) && | 67 has_explicit_max_height_(ConstraintHasMax(constraint_set.height) && |
| 89 ConstraintMax(constraint_set.height) <= | 68 ConstraintMax(constraint_set.height) <= |
| 90 kMaxScreenCastDimension), | 69 kMaxScreenCastDimension), |
| 91 has_explicit_max_width_(ConstraintHasMax(constraint_set.width) && | 70 has_explicit_max_width_(ConstraintHasMax(constraint_set.width) && |
| 92 ConstraintMax(constraint_set.width) <= | 71 ConstraintMax(constraint_set.width) <= |
| 93 kMaxScreenCastDimension), | 72 kMaxScreenCastDimension), |
| 94 frame_rate_set_( | 73 frame_rate_set_( |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 if (!intersection.IsEmpty()) | 396 if (!intersection.IsEmpty()) |
| 418 candidates = std::move(intersection); | 397 candidates = std::move(intersection); |
| 419 } | 398 } |
| 420 | 399 |
| 421 DCHECK(!candidates.IsEmpty()); | 400 DCHECK(!candidates.IsEmpty()); |
| 422 return SelectResultFromCandidates(candidates, constraints.Basic(), | 401 return SelectResultFromCandidates(candidates, constraints.Basic(), |
| 423 stream_source); | 402 stream_source); |
| 424 } | 403 } |
| 425 | 404 |
| 426 } // namespace content | 405 } // namespace content |
| OLD | NEW |