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