| 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 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 const int kDefaultScreenCastWidth = 2880; | 29 const int kDefaultScreenCastWidth = 2880; |
| 30 const int kDefaultScreenCastHeight = 1800; | 30 const int kDefaultScreenCastHeight = 1800; |
| 31 const double kDefaultScreenCastAspectRatio = | 31 const double kDefaultScreenCastAspectRatio = |
| 32 static_cast<double>(kDefaultScreenCastWidth) / kDefaultScreenCastHeight; | 32 static_cast<double>(kDefaultScreenCastWidth) / kDefaultScreenCastHeight; |
| 33 static_assert(kDefaultScreenCastWidth <= kMaxScreenCastDimension, | 33 static_assert(kDefaultScreenCastWidth <= kMaxScreenCastDimension, |
| 34 "Invalid kDefaultScreenCastWidth"); | 34 "Invalid kDefaultScreenCastWidth"); |
| 35 static_assert(kDefaultScreenCastHeight <= kMaxScreenCastDimension, | 35 static_assert(kDefaultScreenCastHeight <= kMaxScreenCastDimension, |
| 36 "Invalid kDefaultScreenCastHeight"); | 36 "Invalid kDefaultScreenCastHeight"); |
| 37 | 37 |
| 38 const double kMinScreenCastFrameRate = 1.0 / 60.0; |
| 38 const double kMaxScreenCastFrameRate = 120.0; | 39 const double kMaxScreenCastFrameRate = 120.0; |
| 39 const double kDefaultScreenCastFrameRate = | 40 const double kDefaultScreenCastFrameRate = |
| 40 MediaStreamVideoSource::kDefaultFrameRate; | 41 MediaStreamVideoSource::kDefaultFrameRate; |
| 41 | 42 |
| 42 namespace { | 43 namespace { |
| 43 | 44 |
| 44 using Point = ResolutionSet::Point; | 45 using Point = ResolutionSet::Point; |
| 45 using StringSet = DiscreteSet<std::string>; | 46 using StringSet = DiscreteSet<std::string>; |
| 46 using BoolSet = DiscreteSet<bool>; | 47 using BoolSet = DiscreteSet<bool>; |
| 47 | 48 |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 } | 377 } |
| 377 | 378 |
| 378 } // namespace | 379 } // namespace |
| 379 | 380 |
| 380 VideoCaptureSettings SelectSettingsVideoContentCapture( | 381 VideoCaptureSettings SelectSettingsVideoContentCapture( |
| 381 const blink::WebMediaConstraints& constraints, | 382 const blink::WebMediaConstraints& constraints, |
| 382 const std::string& stream_source) { | 383 const std::string& stream_source) { |
| 383 VideoContentCaptureCandidates candidates; | 384 VideoContentCaptureCandidates candidates; |
| 384 candidates.set_resolution_set(ScreenCastResolutionCapabilities()); | 385 candidates.set_resolution_set(ScreenCastResolutionCapabilities()); |
| 385 candidates.set_frame_rate_set( | 386 candidates.set_frame_rate_set( |
| 386 DoubleRangeSet(0.0, kMaxScreenCastFrameRate)); | 387 DoubleRangeSet(kMinScreenCastFrameRate, kMaxScreenCastFrameRate)); |
| 387 // candidates.device_id_set and candidates.noise_reduction_set are | 388 // candidates.device_id_set and candidates.noise_reduction_set are |
| 388 // automatically initialized with the universal set. | 389 // automatically initialized with the universal set. |
| 389 | 390 |
| 390 candidates = candidates.Intersection( | 391 candidates = candidates.Intersection( |
| 391 VideoContentCaptureCandidates(constraints.Basic())); | 392 VideoContentCaptureCandidates(constraints.Basic())); |
| 392 if (candidates.IsEmpty()) | 393 if (candidates.IsEmpty()) |
| 393 return UnsatisfiedConstraintsResult(candidates, constraints.Basic()); | 394 return UnsatisfiedConstraintsResult(candidates, constraints.Basic()); |
| 394 | 395 |
| 395 for (const auto& advanced_set : constraints.Advanced()) { | 396 for (const auto& advanced_set : constraints.Advanced()) { |
| 396 VideoContentCaptureCandidates advanced_candidates(advanced_set); | 397 VideoContentCaptureCandidates advanced_candidates(advanced_set); |
| 397 VideoContentCaptureCandidates intersection = | 398 VideoContentCaptureCandidates intersection = |
| 398 candidates.Intersection(advanced_candidates); | 399 candidates.Intersection(advanced_candidates); |
| 399 if (!intersection.IsEmpty()) | 400 if (!intersection.IsEmpty()) |
| 400 candidates = std::move(intersection); | 401 candidates = std::move(intersection); |
| 401 } | 402 } |
| 402 | 403 |
| 403 DCHECK(!candidates.IsEmpty()); | 404 DCHECK(!candidates.IsEmpty()); |
| 404 return SelectResultFromCandidates(candidates, constraints.Basic(), | 405 return SelectResultFromCandidates(candidates, constraints.Basic(), |
| 405 stream_source); | 406 stream_source); |
| 406 } | 407 } |
| 407 | 408 |
| 408 } // namespace content | 409 } // namespace content |
| OLD | NEW |