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

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

Issue 2941553003: Reland "SelectSettings algorithm for audio constraints." (Closed)
Patch Set: fix test Created 3 years, 6 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_sets.h
diff --git a/content/renderer/media/media_stream_constraints_util_sets.h b/content/renderer/media/media_stream_constraints_util_sets.h
index 0cc6ab97e664176825d30117d569230a326ff635..053db68e74200d4b7900225ef0b4e3fe8f82fb34 100644
--- a/content/renderer/media/media_stream_constraints_util_sets.h
+++ b/content/renderer/media/media_stream_constraints_util_sets.h
@@ -7,6 +7,7 @@
#include <algorithm>
#include <limits>
+#include <string>
#include <utility>
#include <vector>
@@ -71,9 +72,12 @@ class NumericRangeSet {
// is application defined (e.g., it could be all possible boolean values, all
// possible strings of length N, or anything that suits a particular
// application).
+// TODO(guidou): Rename this class. http://crbug.com/731166
template <typename T>
class DiscreteSet {
public:
+ // Creates a universal set.
+ DiscreteSet() : is_universal_(true) {}
// Creates a set containing the elements in |elements|.
// It is the responsibility of the caller to ensure that |elements| is not
// equivalent to the universal set and that |elements| has no repeated
@@ -127,16 +131,25 @@ class DiscreteSet {
return elements_[0];
}
+ // Returns a reference to the list of elements in the set.
+ // Behavior is undefined if the set is universal.
+ const std::vector<T>& elements() const {
+ DCHECK(!is_universal_);
+ return elements_;
+ }
+
bool is_universal() const { return is_universal_; }
private:
- // Creates a universal set.
- DiscreteSet() : is_universal_(true) {}
-
bool is_universal_;
std::vector<T> elements_;
};
+DiscreteSet<std::string> StringSetFromConstraint(
+ const blink::StringConstraint& constraint);
+DiscreteSet<bool> BoolSetFromConstraint(
+ const blink::BooleanConstraint& constraint);
+
// This class represents a set of (height, width) screen resolution candidates
// determined by width, height and aspect-ratio constraints.
// This class supports widths and heights from 0 to kMaxDimension, both

Powered by Google App Engine
This is Rietveld 408576698