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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 return false; | 179 return false; |
180 } | 180 } |
181 return true; | 181 return true; |
182 } | 182 } |
183 | 183 |
184 bool LongConstraint::isEmpty() const | 184 bool LongConstraint::isEmpty() const |
185 { | 185 { |
186 return !m_hasMin && !m_hasMax && !m_hasExact && !m_hasIdeal; | 186 return !m_hasMin && !m_hasMax && !m_hasExact && !m_hasIdeal; |
187 } | 187 } |
188 | 188 |
| 189 bool LongConstraint::hasMandatory() const |
| 190 { |
| 191 return m_hasMin || m_hasMax || m_hasExact; |
| 192 } |
| 193 |
189 double DoubleConstraint::kConstraintEpsilon = 0.00001; | 194 double DoubleConstraint::kConstraintEpsilon = 0.00001; |
190 | 195 |
191 DoubleConstraint::DoubleConstraint(const char* name) | 196 DoubleConstraint::DoubleConstraint(const char* name) |
192 : BaseConstraint(name) | 197 : BaseConstraint(name) |
193 , m_min() | 198 , m_min() |
194 , m_max() | 199 , m_max() |
195 , m_exact() | 200 , m_exact() |
196 , m_ideal() | 201 , m_ideal() |
197 , m_hasMin(false) | 202 , m_hasMin(false) |
198 , m_hasMax(false) | 203 , m_hasMax(false) |
(...skipping 14 matching lines...) Expand all Loading... |
213 return false; | 218 return false; |
214 } | 219 } |
215 return true; | 220 return true; |
216 } | 221 } |
217 | 222 |
218 bool DoubleConstraint::isEmpty() const | 223 bool DoubleConstraint::isEmpty() const |
219 { | 224 { |
220 return !m_hasMin && !m_hasMax && !m_hasExact && !m_hasIdeal; | 225 return !m_hasMin && !m_hasMax && !m_hasExact && !m_hasIdeal; |
221 } | 226 } |
222 | 227 |
| 228 bool DoubleConstraint::hasMandatory() const |
| 229 { |
| 230 return m_hasMin || m_hasMax || m_hasExact; |
| 231 } |
| 232 |
223 StringConstraint::StringConstraint(const char* name) | 233 StringConstraint::StringConstraint(const char* name) |
224 : BaseConstraint(name) | 234 : BaseConstraint(name) |
225 , m_exact() | 235 , m_exact() |
226 , m_ideal() | 236 , m_ideal() |
227 { | 237 { |
228 } | 238 } |
229 | 239 |
230 bool StringConstraint::matches(WebString value) const | 240 bool StringConstraint::matches(WebString value) const |
231 { | 241 { |
232 if (m_exact.isEmpty()) { | 242 if (m_exact.isEmpty()) { |
233 return true; | 243 return true; |
234 } | 244 } |
235 for (const auto& choice : m_exact) { | 245 for (const auto& choice : m_exact) { |
236 if (value == choice) { | 246 if (value == choice) { |
237 return true; | 247 return true; |
238 } | 248 } |
239 } | 249 } |
240 return false; | 250 return false; |
241 } | 251 } |
242 | 252 |
243 bool StringConstraint::isEmpty() const | 253 bool StringConstraint::isEmpty() const |
244 { | 254 { |
245 return m_exact.isEmpty() && m_ideal.isEmpty(); | 255 return m_exact.isEmpty() && m_ideal.isEmpty(); |
246 } | 256 } |
247 | 257 |
| 258 bool StringConstraint::hasMandatory() const |
| 259 { |
| 260 return !m_exact.isEmpty(); |
| 261 } |
| 262 |
248 const WebVector<WebString>& StringConstraint::exact() const | 263 const WebVector<WebString>& StringConstraint::exact() const |
249 { | 264 { |
250 return m_exact; | 265 return m_exact; |
251 } | 266 } |
252 | 267 |
253 const WebVector<WebString>& StringConstraint::ideal() const | 268 const WebVector<WebString>& StringConstraint::ideal() const |
254 { | 269 { |
255 return m_ideal; | 270 return m_ideal; |
256 } | 271 } |
257 | 272 |
(...skipping 12 matching lines...) Expand all Loading... |
270 return false; | 285 return false; |
271 } | 286 } |
272 return true; | 287 return true; |
273 } | 288 } |
274 | 289 |
275 bool BooleanConstraint::isEmpty() const | 290 bool BooleanConstraint::isEmpty() const |
276 { | 291 { |
277 return !m_hasIdeal && !m_hasExact; | 292 return !m_hasIdeal && !m_hasExact; |
278 } | 293 } |
279 | 294 |
| 295 bool BooleanConstraint::hasMandatory() const |
| 296 { |
| 297 return m_hasExact; |
| 298 } |
| 299 |
280 WebMediaTrackConstraintSet::WebMediaTrackConstraintSet() | 300 WebMediaTrackConstraintSet::WebMediaTrackConstraintSet() |
281 : width("width") | 301 : width("width") |
282 , height("height") | 302 , height("height") |
283 , aspectRatio("aspectRatio") | 303 , aspectRatio("aspectRatio") |
284 , frameRate("frameRate") | 304 , frameRate("frameRate") |
285 , facingMode("facingMode") | 305 , facingMode("facingMode") |
286 , volume("volume") | 306 , volume("volume") |
287 , sampleRate("sampleRate") | 307 , sampleRate("sampleRate") |
288 , sampleSize("sampleSize") | 308 , sampleSize("sampleSize") |
289 , echoCancellation("echoCancellation") | 309 , echoCancellation("echoCancellation") |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 , googCpuUnderuseThreshold("googCpuUnderuseThreshold") | 345 , googCpuUnderuseThreshold("googCpuUnderuseThreshold") |
326 , googCpuOveruseThreshold("googCpuOveruseThreshold") | 346 , googCpuOveruseThreshold("googCpuOveruseThreshold") |
327 , googCpuUnderuseEncodeRsdThreshold("googCpuUnderuseEncodeRsdThreshold") | 347 , googCpuUnderuseEncodeRsdThreshold("googCpuUnderuseEncodeRsdThreshold") |
328 , googCpuOveruseEncodeRsdThreshold("googCpuOveruseEncodeRsdThreshold") | 348 , googCpuOveruseEncodeRsdThreshold("googCpuOveruseEncodeRsdThreshold") |
329 , googCpuOveruseEncodeUsage("googCpuOveruseEncodeUsage") | 349 , googCpuOveruseEncodeUsage("googCpuOveruseEncodeUsage") |
330 , googHighStartBitrate("googHighStartBitrate") | 350 , googHighStartBitrate("googHighStartBitrate") |
331 , googPayloadPadding("googPayloadPadding") | 351 , googPayloadPadding("googPayloadPadding") |
332 { | 352 { |
333 } | 353 } |
334 | 354 |
| 355 std::vector<const BaseConstraint*> WebMediaTrackConstraintSet::allConstraints()
const |
| 356 { |
| 357 const BaseConstraint* temp[] = { |
| 358 &width, &height, &aspectRatio, &frameRate, &facingMode, &volume, |
| 359 &sampleRate, &sampleSize, &echoCancellation, &latency, &channelCount, |
| 360 &deviceId, &groupId, &mediaStreamSource, &renderToAssociatedSink, |
| 361 &hotwordEnabled, &googEchoCancellation, |
| 362 &googExperimentalEchoCancellation, &googAutoGainControl, |
| 363 &googExperimentalAutoGainControl, &googNoiseSuppression, |
| 364 &googHighpassFilter, &googTypingNoiseDetection, |
| 365 &googExperimentalNoiseSuppression, &googBeamforming, |
| 366 &googArrayGeometry, &googAudioMirroring, &googDAEchoCancellation, |
| 367 &googAecDump, &googNoiseReduction, &offerToReceiveAudio, |
| 368 &offerToReceiveVideo, &voiceActivityDetection, &iceRestart, |
| 369 &googUseRtpMux, &enableDtlsSrtp, &enableRtpDataChannels, |
| 370 &enableDscp, &enableIPv6, &googEnableVideoSuspendBelowMinBitrate, |
| 371 &googNumUnsignalledRecvStreams, &googCombinedAudioVideoBwe, |
| 372 &googScreencastMinBitrate, &googCpuOveruseDetection, |
| 373 &googCpuUnderuseThreshold, &googCpuOveruseThreshold, |
| 374 &googCpuUnderuseEncodeRsdThreshold, &googCpuOveruseEncodeRsdThreshold, |
| 375 &googCpuOveruseEncodeUsage, &googHighStartBitrate, &googPayloadPadding |
| 376 }; |
| 377 const int elementCount = sizeof(temp) / sizeof(temp[0]); |
| 378 return std::vector<const BaseConstraint*>(&temp[0], &temp[elementCount]); |
| 379 } |
| 380 |
335 bool WebMediaTrackConstraintSet::isEmpty() const | 381 bool WebMediaTrackConstraintSet::isEmpty() const |
336 { | 382 { |
337 return width.isEmpty() && height.isEmpty() && aspectRatio.isEmpty() | 383 for (const auto& constraint : allConstraints()) { |
338 && frameRate.isEmpty() && facingMode.isEmpty() && volume.isEmpty() | 384 if (!constraint->isEmpty()) |
339 && sampleRate.isEmpty() && sampleSize.isEmpty() | 385 return false; |
340 && echoCancellation.isEmpty() && latency.isEmpty() | 386 } |
341 && channelCount.isEmpty() && deviceId.isEmpty() && groupId.isEmpty() | 387 return true; |
342 && mediaStreamSource.isEmpty() && renderToAssociatedSink.isEmpty() | 388 } |
343 && hotwordEnabled.isEmpty() && googEchoCancellation.isEmpty() | 389 |
344 && googExperimentalEchoCancellation.isEmpty() | 390 bool WebMediaTrackConstraintSet::hasMandatoryOutsideSet(const std::vector<std::s
tring>& goodNames, std::string& foundName) const |
345 && googAutoGainControl.isEmpty() | 391 { |
346 && googExperimentalAutoGainControl.isEmpty() | 392 for (const auto& constraint : allConstraints()) { |
347 && googNoiseSuppression.isEmpty() | 393 if (constraint->hasMandatory()) { |
348 && googHighpassFilter.isEmpty() | 394 if (std::find(goodNames.begin(), goodNames.end(), constraint->name()
) |
349 && googTypingNoiseDetection.isEmpty() | 395 == goodNames.end()) { |
350 && googExperimentalNoiseSuppression.isEmpty() | 396 foundName = constraint->name(); |
351 && googBeamforming.isEmpty() && googArrayGeometry.isEmpty() | 397 return true; |
352 && googAudioMirroring.isEmpty(); | 398 } |
| 399 } |
| 400 } |
| 401 return false; |
| 402 } |
| 403 |
| 404 bool WebMediaTrackConstraintSet::hasMandatory() const |
| 405 { |
| 406 std::string dummyString; |
| 407 return hasMandatoryOutsideSet(std::vector<std::string>(), dummyString); |
353 } | 408 } |
354 | 409 |
355 // WebMediaConstraints | 410 // WebMediaConstraints |
356 | 411 |
357 void WebMediaConstraints::assign(const WebMediaConstraints& other) | 412 void WebMediaConstraints::assign(const WebMediaConstraints& other) |
358 { | 413 { |
359 m_private = other.m_private; | 414 m_private = other.m_private; |
360 } | 415 } |
361 | 416 |
362 void WebMediaConstraints::reset() | 417 void WebMediaConstraints::reset() |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 return m_private->basic(); | 472 return m_private->basic(); |
418 } | 473 } |
419 | 474 |
420 const WebVector<WebMediaTrackConstraintSet>& WebMediaConstraints::advanced() con
st | 475 const WebVector<WebMediaTrackConstraintSet>& WebMediaConstraints::advanced() con
st |
421 { | 476 { |
422 ASSERT(!isNull()); | 477 ASSERT(!isNull()); |
423 return m_private->advanced(); | 478 return m_private->advanced(); |
424 } | 479 } |
425 | 480 |
426 } // namespace blink | 481 } // namespace blink |
OLD | NEW |