Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1396)

Unified Diff: content/renderer/media/media_stream_constraints_util.h

Issue 2707203006: Minor refactoring of support classes for video-device constraints. (Closed)
Patch Set: move Settings type to .cc file Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/renderer/media/media_stream_constraints_util.h
diff --git a/content/renderer/media/media_stream_constraints_util.h b/content/renderer/media/media_stream_constraints_util.h
index 7b24be2f25f22ebe2ebc5fbaa5bb670dd134d252..a3f75a6e65bf3a19fd1fdeb5b6d9b99d141f7ae0 100644
--- a/content/renderer/media/media_stream_constraints_util.h
+++ b/content/renderer/media/media_stream_constraints_util.h
@@ -69,6 +69,30 @@ rtc::Optional<bool> ConstraintToOptional(
const blink::WebMediaConstraints& constraints,
const blink::BooleanConstraint blink::WebMediaTrackConstraintSet::*picker);
+template <typename ConstraintType>
+bool ConstraintHasMax(const ConstraintType& constraint) {
+ return constraint.hasMax() || constraint.hasExact();
+}
+
+template <typename ConstraintType>
+bool ConstraintHasMin(const ConstraintType& constraint) {
+ return constraint.hasMin() || constraint.hasExact();
+}
+
+template <typename ConstraintType>
+auto ConstraintMax(const ConstraintType& constraint)
+ -> decltype(constraint.max()) {
+ DCHECK(ConstraintHasMax(constraint));
+ return constraint.hasExact() ? constraint.exact() : constraint.max();
+}
+
+template <typename ConstraintType>
+auto ConstraintMin(const ConstraintType& constraint)
+ -> decltype(constraint.min()) {
+ DCHECK(ConstraintHasMin(constraint));
+ return constraint.hasExact() ? constraint.exact() : constraint.min();
+}
+
} // namespace content
#endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_CONSTRAINTS_UTIL_H_

Powered by Google App Engine
This is Rietveld 408576698