OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 #ifndef WebMediaConstraints_h | 31 #ifndef WebMediaConstraints_h |
32 #define WebMediaConstraints_h | 32 #define WebMediaConstraints_h |
33 | 33 |
34 #include "WebCommon.h" | 34 #include "WebCommon.h" |
35 #include "WebNonCopyable.h" | 35 #include "WebNonCopyable.h" |
36 #include "WebPrivatePtr.h" | 36 #include "WebPrivatePtr.h" |
37 #include "WebString.h" | 37 #include "WebString.h" |
38 #include "WebVector.h" | 38 #include "WebVector.h" |
39 | 39 |
| 40 #include <vector> |
| 41 |
40 namespace blink { | 42 namespace blink { |
41 | 43 |
42 class WebMediaConstraintsPrivate; | 44 class WebMediaConstraintsPrivate; |
43 | 45 |
44 class BLINK_PLATFORM_EXPORT BaseConstraint { | 46 class BLINK_PLATFORM_EXPORT BaseConstraint { |
45 public: | 47 public: |
46 explicit BaseConstraint(const char* name); | 48 explicit BaseConstraint(const char* name); |
47 virtual ~BaseConstraint(); | 49 virtual ~BaseConstraint(); |
48 virtual bool isEmpty() const = 0; | 50 virtual bool isEmpty() const = 0; |
49 const char* name() | 51 virtual bool hasMandatory() const = 0; |
| 52 const char* name() const |
50 { | 53 { |
51 return m_name; | 54 return m_name; |
52 } | 55 } |
53 private: | 56 private: |
54 const char* m_name; | 57 const char* m_name; |
55 }; | 58 }; |
56 | 59 |
57 class BLINK_PLATFORM_EXPORT LongConstraint : public BaseConstraint { | 60 class BLINK_PLATFORM_EXPORT LongConstraint : public BaseConstraint { |
58 public: | 61 public: |
59 explicit LongConstraint(const char* name); | 62 explicit LongConstraint(const char* name); |
(...skipping 17 matching lines...) Expand all Loading... |
77 } | 80 } |
78 | 81 |
79 void setIdeal(long value) | 82 void setIdeal(long value) |
80 { | 83 { |
81 m_ideal = value; | 84 m_ideal = value; |
82 m_hasIdeal = true; | 85 m_hasIdeal = true; |
83 } | 86 } |
84 | 87 |
85 bool matches(long value) const; | 88 bool matches(long value) const; |
86 bool isEmpty() const override; | 89 bool isEmpty() const override; |
| 90 bool hasMandatory() const override; |
| 91 bool hasMin() const { return m_hasMin; } |
| 92 long min() const { return m_min; } |
| 93 bool hasMax() const { return m_hasMax; } |
| 94 long max() const { return m_max; } |
87 | 95 |
88 private: | 96 private: |
89 long m_min; | 97 long m_min; |
90 long m_max; | 98 long m_max; |
91 long m_exact; | 99 long m_exact; |
92 long m_ideal; | 100 long m_ideal; |
93 unsigned m_hasMin : 1; | 101 unsigned m_hasMin : 1; |
94 unsigned m_hasMax : 1; | 102 unsigned m_hasMax : 1; |
95 unsigned m_hasExact : 1; | 103 unsigned m_hasExact : 1; |
96 unsigned m_hasIdeal : 1; | 104 unsigned m_hasIdeal : 1; |
(...skipping 27 matching lines...) Expand all Loading... |
124 } | 132 } |
125 | 133 |
126 void setIdeal(double value) | 134 void setIdeal(double value) |
127 { | 135 { |
128 m_ideal = value; | 136 m_ideal = value; |
129 m_hasIdeal = true; | 137 m_hasIdeal = true; |
130 } | 138 } |
131 | 139 |
132 bool matches(double value) const; | 140 bool matches(double value) const; |
133 bool isEmpty() const override; | 141 bool isEmpty() const override; |
| 142 bool hasMandatory() const override; |
| 143 bool hasMin() const { return m_hasMin; } |
| 144 double min() const { return m_min; } |
| 145 bool hasMax() const { return m_hasMax; } |
| 146 double max() const { return m_max; } |
134 | 147 |
135 private: | 148 private: |
136 double m_min; | 149 double m_min; |
137 double m_max; | 150 double m_max; |
138 double m_exact; | 151 double m_exact; |
139 double m_ideal; | 152 double m_ideal; |
140 unsigned m_hasMin : 1; | 153 unsigned m_hasMin : 1; |
141 unsigned m_hasMax : 1; | 154 unsigned m_hasMax : 1; |
142 unsigned m_hasExact : 1; | 155 unsigned m_hasExact : 1; |
143 unsigned m_hasIdeal : 1; | 156 unsigned m_hasIdeal : 1; |
(...skipping 16 matching lines...) Expand all Loading... |
160 } | 173 } |
161 | 174 |
162 void setIdeal(const WebVector<WebString>& ideal) | 175 void setIdeal(const WebVector<WebString>& ideal) |
163 { | 176 { |
164 m_ideal.assign(ideal); | 177 m_ideal.assign(ideal); |
165 } | 178 } |
166 | 179 |
167 | 180 |
168 bool matches(WebString value) const; | 181 bool matches(WebString value) const; |
169 bool isEmpty() const override; | 182 bool isEmpty() const override; |
| 183 bool hasMandatory() const override; |
170 const WebVector<WebString>& exact() const; | 184 const WebVector<WebString>& exact() const; |
171 const WebVector<WebString>& ideal() const; | 185 const WebVector<WebString>& ideal() const; |
172 | 186 |
173 private: | 187 private: |
174 WebVector<WebString> m_exact; | 188 WebVector<WebString> m_exact; |
175 WebVector<WebString> m_ideal; | 189 WebVector<WebString> m_ideal; |
176 }; | 190 }; |
177 | 191 |
178 class BLINK_PLATFORM_EXPORT BooleanConstraint : public BaseConstraint { | 192 class BLINK_PLATFORM_EXPORT BooleanConstraint : public BaseConstraint { |
179 public: | 193 public: |
180 explicit BooleanConstraint(const char* name); | 194 explicit BooleanConstraint(const char* name); |
181 | 195 |
182 void setIdeal(bool value) | 196 void setIdeal(bool value) |
183 { | 197 { |
184 m_ideal = value; | 198 m_ideal = value; |
185 m_hasIdeal = true; | 199 m_hasIdeal = true; |
186 } | 200 } |
187 | 201 |
188 void setExact(bool value) | 202 void setExact(bool value) |
189 { | 203 { |
190 m_exact = value; | 204 m_exact = value; |
191 m_hasExact = true; | 205 m_hasExact = true; |
192 } | 206 } |
193 | 207 |
194 bool matches(bool value) const; | 208 bool matches(bool value) const; |
195 bool isEmpty() const override; | 209 bool isEmpty() const override; |
| 210 bool hasMandatory() const override; |
196 | 211 |
197 private: | 212 private: |
198 unsigned m_ideal : 1; | 213 unsigned m_ideal : 1; |
199 unsigned m_exact : 1; | 214 unsigned m_exact : 1; |
200 unsigned m_hasIdeal : 1; | 215 unsigned m_hasIdeal : 1; |
201 unsigned m_hasExact : 1; | 216 unsigned m_hasExact : 1; |
202 }; | 217 }; |
203 | 218 |
204 struct WebMediaTrackConstraintSet { | 219 struct WebMediaTrackConstraintSet { |
205 public: | 220 public: |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 BooleanConstraint googCpuOveruseDetection; | 268 BooleanConstraint googCpuOveruseDetection; |
254 LongConstraint googCpuUnderuseThreshold; | 269 LongConstraint googCpuUnderuseThreshold; |
255 LongConstraint googCpuOveruseThreshold; | 270 LongConstraint googCpuOveruseThreshold; |
256 LongConstraint googCpuUnderuseEncodeRsdThreshold; | 271 LongConstraint googCpuUnderuseEncodeRsdThreshold; |
257 LongConstraint googCpuOveruseEncodeRsdThreshold; | 272 LongConstraint googCpuOveruseEncodeRsdThreshold; |
258 BooleanConstraint googCpuOveruseEncodeUsage; | 273 BooleanConstraint googCpuOveruseEncodeUsage; |
259 LongConstraint googHighStartBitrate; | 274 LongConstraint googHighStartBitrate; |
260 BooleanConstraint googPayloadPadding; | 275 BooleanConstraint googPayloadPadding; |
261 | 276 |
262 BLINK_PLATFORM_EXPORT bool isEmpty() const; | 277 BLINK_PLATFORM_EXPORT bool isEmpty() const; |
| 278 BLINK_PLATFORM_EXPORT bool hasMandatory() const; |
| 279 BLINK_PLATFORM_EXPORT bool hasMandatoryOutsideSet(const std::vector<std::str
ing>&, std::string&) const; |
| 280 |
| 281 private: |
| 282 std::vector<const BaseConstraint*> allConstraints() const; |
263 }; | 283 }; |
264 | 284 |
265 // Old type/value form of constraint. Will be deprecated. | 285 // Old type/value form of constraint. Will be deprecated. |
266 struct WebMediaConstraint { | 286 struct WebMediaConstraint { |
267 WebMediaConstraint() | 287 WebMediaConstraint() |
268 { | 288 { |
269 } | 289 } |
270 | 290 |
271 WebMediaConstraint(WebString name, WebString value) | 291 WebMediaConstraint(WebString name, WebString value) |
272 : m_name(name) | 292 : m_name(name) |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 BLINK_PLATFORM_EXPORT const WebMediaTrackConstraintSet& basic() const; | 335 BLINK_PLATFORM_EXPORT const WebMediaTrackConstraintSet& basic() const; |
316 BLINK_PLATFORM_EXPORT const WebVector<WebMediaTrackConstraintSet>& advanced(
) const; | 336 BLINK_PLATFORM_EXPORT const WebVector<WebMediaTrackConstraintSet>& advanced(
) const; |
317 | 337 |
318 private: | 338 private: |
319 WebPrivatePtr<WebMediaConstraintsPrivate> m_private; | 339 WebPrivatePtr<WebMediaConstraintsPrivate> m_private; |
320 }; | 340 }; |
321 | 341 |
322 } // namespace blink | 342 } // namespace blink |
323 | 343 |
324 #endif // WebMediaConstraints_h | 344 #endif // WebMediaConstraints_h |
OLD | NEW |