OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_CONSTRAINTS_UTIL_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_CONSTRAINTS_UTIL_H_ |
6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_CONSTRAINTS_UTIL_H_ | 6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_CONSTRAINTS_UTIL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 // constraints. | 62 // constraints. |
63 bool CONTENT_EXPORT GetConstraintValueAsString( | 63 bool CONTENT_EXPORT GetConstraintValueAsString( |
64 const blink::WebMediaConstraints& constraints, | 64 const blink::WebMediaConstraints& constraints, |
65 const blink::StringConstraint blink::WebMediaTrackConstraintSet::*picker, | 65 const blink::StringConstraint blink::WebMediaTrackConstraintSet::*picker, |
66 std::string* value); | 66 std::string* value); |
67 | 67 |
68 rtc::Optional<bool> ConstraintToOptional( | 68 rtc::Optional<bool> ConstraintToOptional( |
69 const blink::WebMediaConstraints& constraints, | 69 const blink::WebMediaConstraints& constraints, |
70 const blink::BooleanConstraint blink::WebMediaTrackConstraintSet::*picker); | 70 const blink::BooleanConstraint blink::WebMediaTrackConstraintSet::*picker); |
71 | 71 |
| 72 template <typename ConstraintType> |
| 73 bool ConstraintHasMax(const ConstraintType& constraint) { |
| 74 return constraint.hasMax() || constraint.hasExact(); |
| 75 } |
| 76 |
| 77 template <typename ConstraintType> |
| 78 bool ConstraintHasMin(const ConstraintType& constraint) { |
| 79 return constraint.hasMin() || constraint.hasExact(); |
| 80 } |
| 81 |
| 82 template <typename ConstraintType> |
| 83 auto ConstraintMax(const ConstraintType& constraint) |
| 84 -> decltype(constraint.max()) { |
| 85 DCHECK(ConstraintHasMax(constraint)); |
| 86 return constraint.hasExact() ? constraint.exact() : constraint.max(); |
| 87 } |
| 88 |
| 89 template <typename ConstraintType> |
| 90 auto ConstraintMin(const ConstraintType& constraint) |
| 91 -> decltype(constraint.min()) { |
| 92 DCHECK(ConstraintHasMin(constraint)); |
| 93 return constraint.hasExact() ? constraint.exact() : constraint.min(); |
| 94 } |
| 95 |
72 } // namespace content | 96 } // namespace content |
73 | 97 |
74 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_CONSTRAINTS_UTIL_H_ | 98 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_CONSTRAINTS_UTIL_H_ |
OLD | NEW |