| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 builder.appendLiteral("true"); | 64 builder.appendLiteral("true"); |
| 65 else | 65 else |
| 66 builder.appendLiteral("false"); | 66 builder.appendLiteral("false"); |
| 67 } | 67 } |
| 68 | 68 |
| 69 } // namespace | 69 } // namespace |
| 70 | 70 |
| 71 class WebMediaConstraintsPrivate final : public RefCounted<WebMediaConstraintsPr
ivate> { | 71 class WebMediaConstraintsPrivate final : public RefCounted<WebMediaConstraintsPr
ivate> { |
| 72 public: | 72 public: |
| 73 static PassRefPtr<WebMediaConstraintsPrivate> create(); | 73 static PassRefPtr<WebMediaConstraintsPrivate> create(); |
| 74 static PassRefPtr<WebMediaConstraintsPrivate> create(const WebVector<WebMedi
aConstraint>& optional, const WebVector<WebMediaConstraint>& mandatory, const We
bMediaTrackConstraintSet& basic, const WebVector<WebMediaTrackConstraintSet>& ad
vanced); | |
| 75 static PassRefPtr<WebMediaConstraintsPrivate> create(const WebMediaTrackCons
traintSet& basic, const WebVector<WebMediaTrackConstraintSet>& advanced); | 74 static PassRefPtr<WebMediaConstraintsPrivate> create(const WebMediaTrackCons
traintSet& basic, const WebVector<WebMediaTrackConstraintSet>& advanced); |
| 76 | 75 |
| 77 bool isEmpty() const; | 76 bool isEmpty() const; |
| 78 void getOptionalConstraints(WebVector<WebMediaConstraint>&); | |
| 79 void getMandatoryConstraints(WebVector<WebMediaConstraint>&); | |
| 80 bool getMandatoryConstraintValue(const WebString& name, WebString& value); | |
| 81 bool getOptionalConstraintValue(const WebString& name, WebString& value); | |
| 82 const WebMediaTrackConstraintSet& basic() const; | 77 const WebMediaTrackConstraintSet& basic() const; |
| 83 const WebVector<WebMediaTrackConstraintSet>& advanced() const; | 78 const WebVector<WebMediaTrackConstraintSet>& advanced() const; |
| 84 const String toString() const; | 79 const String toString() const; |
| 85 | 80 |
| 86 private: | 81 private: |
| 87 WebMediaConstraintsPrivate(const WebVector<WebMediaConstraint>& optional, co
nst WebVector<WebMediaConstraint>& mandatory, const WebMediaTrackConstraintSet&
basic, const WebVector<WebMediaTrackConstraintSet>& advanced); | |
| 88 WebMediaConstraintsPrivate(const WebMediaTrackConstraintSet& basic, const We
bVector<WebMediaTrackConstraintSet>& advanced); | 82 WebMediaConstraintsPrivate(const WebMediaTrackConstraintSet& basic, const We
bVector<WebMediaTrackConstraintSet>& advanced); |
| 89 | 83 |
| 90 WebVector<WebMediaConstraint> m_optional; | |
| 91 WebVector<WebMediaConstraint> m_mandatory; | |
| 92 WebMediaTrackConstraintSet m_basic; | 84 WebMediaTrackConstraintSet m_basic; |
| 93 WebVector<WebMediaTrackConstraintSet> m_advanced; | 85 WebVector<WebMediaTrackConstraintSet> m_advanced; |
| 94 }; | 86 }; |
| 95 | 87 |
| 96 PassRefPtr<WebMediaConstraintsPrivate> WebMediaConstraintsPrivate::create() | 88 PassRefPtr<WebMediaConstraintsPrivate> WebMediaConstraintsPrivate::create() |
| 97 { | 89 { |
| 98 WebMediaTrackConstraintSet basic; | 90 WebMediaTrackConstraintSet basic; |
| 99 WebVector<WebMediaTrackConstraintSet> advanced; | 91 WebVector<WebMediaTrackConstraintSet> advanced; |
| 100 return adoptRef(new WebMediaConstraintsPrivate(basic, advanced)); | 92 return adoptRef(new WebMediaConstraintsPrivate(basic, advanced)); |
| 101 } | 93 } |
| 102 | 94 |
| 103 PassRefPtr<WebMediaConstraintsPrivate> WebMediaConstraintsPrivate::create(const
WebVector<WebMediaConstraint>& optional, const WebVector<WebMediaConstraint>& ma
ndatory, const WebMediaTrackConstraintSet& basic, const WebVector<WebMediaTrackC
onstraintSet>& advanced) | 95 PassRefPtr<WebMediaConstraintsPrivate> WebMediaConstraintsPrivate::create(const
WebMediaTrackConstraintSet& basic, const WebVector<WebMediaTrackConstraintSet>&
advanced) |
| 104 { | 96 { |
| 105 return adoptRef(new WebMediaConstraintsPrivate(optional, mandatory, basic, a
dvanced)); | 97 return adoptRef(new WebMediaConstraintsPrivate(basic, advanced)); |
| 106 } | 98 } |
| 107 | 99 |
| 108 WebMediaConstraintsPrivate::WebMediaConstraintsPrivate(const WebVector<WebMediaC
onstraint>& optional, const WebVector<WebMediaConstraint>& mandatory, const WebM
ediaTrackConstraintSet& basic, const WebVector<WebMediaTrackConstraintSet>& adva
nced) | 100 WebMediaConstraintsPrivate::WebMediaConstraintsPrivate(const WebMediaTrackConstr
aintSet& basic, const WebVector<WebMediaTrackConstraintSet>& advanced) |
| 109 : m_optional(optional) | 101 : m_basic(basic) |
| 110 , m_mandatory(mandatory) | |
| 111 , m_basic(basic) | |
| 112 , m_advanced(advanced) | 102 , m_advanced(advanced) |
| 113 { | 103 { |
| 114 } | 104 } |
| 115 | 105 |
| 116 bool WebMediaConstraintsPrivate::isEmpty() const | 106 bool WebMediaConstraintsPrivate::isEmpty() const |
| 117 { | 107 { |
| 118 // TODO(hta): When generating advanced constraints, make sure no empty | 108 // TODO(hta): When generating advanced constraints, make sure no empty |
| 119 // elements can be added to the m_advanced vector. | 109 // elements can be added to the m_advanced vector. |
| 120 return m_basic.isEmpty() && m_advanced.isEmpty() | 110 return m_basic.isEmpty() && m_advanced.isEmpty(); |
| 121 && m_optional.isEmpty() && m_mandatory.isEmpty(); | |
| 122 } | |
| 123 | |
| 124 PassRefPtr<WebMediaConstraintsPrivate> WebMediaConstraintsPrivate::create(const
WebMediaTrackConstraintSet& basic, const WebVector<WebMediaTrackConstraintSet>&
advanced) | |
| 125 { | |
| 126 return adoptRef(new WebMediaConstraintsPrivate(basic, advanced)); | |
| 127 } | |
| 128 | |
| 129 WebMediaConstraintsPrivate::WebMediaConstraintsPrivate(const WebMediaTrackConstr
aintSet& basic, const WebVector<WebMediaTrackConstraintSet>& advanced) | |
| 130 : m_optional() | |
| 131 , m_mandatory() | |
| 132 , m_basic(basic) | |
| 133 , m_advanced(advanced) | |
| 134 { | |
| 135 } | |
| 136 | |
| 137 void WebMediaConstraintsPrivate::getOptionalConstraints(WebVector<WebMediaConstr
aint>& constraints) | |
| 138 { | |
| 139 constraints = m_optional; | |
| 140 } | |
| 141 | |
| 142 void WebMediaConstraintsPrivate::getMandatoryConstraints(WebVector<WebMediaConst
raint>& constraints) | |
| 143 { | |
| 144 constraints = m_mandatory; | |
| 145 } | |
| 146 | |
| 147 bool WebMediaConstraintsPrivate::getMandatoryConstraintValue(const WebString& na
me, WebString& value) | |
| 148 { | |
| 149 for (size_t i = 0; i < m_mandatory.size(); ++i) { | |
| 150 if (m_mandatory[i].m_name == name) { | |
| 151 value = m_mandatory[i].m_value; | |
| 152 return true; | |
| 153 } | |
| 154 } | |
| 155 return false; | |
| 156 } | |
| 157 | |
| 158 bool WebMediaConstraintsPrivate::getOptionalConstraintValue(const WebString& nam
e, WebString& value) | |
| 159 { | |
| 160 for (size_t i = 0; i < m_optional.size(); ++i) { | |
| 161 if (m_optional[i].m_name == name) { | |
| 162 value = m_optional[i].m_value; | |
| 163 return true; | |
| 164 } | |
| 165 } | |
| 166 return false; | |
| 167 } | 111 } |
| 168 | 112 |
| 169 const WebMediaTrackConstraintSet& WebMediaConstraintsPrivate::basic() const | 113 const WebMediaTrackConstraintSet& WebMediaConstraintsPrivate::basic() const |
| 170 { | 114 { |
| 171 return m_basic; | 115 return m_basic; |
| 172 } | 116 } |
| 173 | 117 |
| 174 const WebVector<WebMediaTrackConstraintSet>& WebMediaConstraintsPrivate::advance
d() const | 118 const WebVector<WebMediaTrackConstraintSet>& WebMediaConstraintsPrivate::advance
d() const |
| 175 { | 119 { |
| 176 return m_advanced; | 120 return m_advanced; |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 , googCombinedAudioVideoBwe("googCombinedAudioVideoBwe") | 413 , googCombinedAudioVideoBwe("googCombinedAudioVideoBwe") |
| 470 , googScreencastMinBitrate("googScreencastMinBitrate") | 414 , googScreencastMinBitrate("googScreencastMinBitrate") |
| 471 , googCpuOveruseDetection("googCpuOveruseDetection") | 415 , googCpuOveruseDetection("googCpuOveruseDetection") |
| 472 , googCpuUnderuseThreshold("googCpuUnderuseThreshold") | 416 , googCpuUnderuseThreshold("googCpuUnderuseThreshold") |
| 473 , googCpuOveruseThreshold("googCpuOveruseThreshold") | 417 , googCpuOveruseThreshold("googCpuOveruseThreshold") |
| 474 , googCpuUnderuseEncodeRsdThreshold("googCpuUnderuseEncodeRsdThreshold") | 418 , googCpuUnderuseEncodeRsdThreshold("googCpuUnderuseEncodeRsdThreshold") |
| 475 , googCpuOveruseEncodeRsdThreshold("googCpuOveruseEncodeRsdThreshold") | 419 , googCpuOveruseEncodeRsdThreshold("googCpuOveruseEncodeRsdThreshold") |
| 476 , googCpuOveruseEncodeUsage("googCpuOveruseEncodeUsage") | 420 , googCpuOveruseEncodeUsage("googCpuOveruseEncodeUsage") |
| 477 , googHighStartBitrate("googHighStartBitrate") | 421 , googHighStartBitrate("googHighStartBitrate") |
| 478 , googPayloadPadding("googPayloadPadding") | 422 , googPayloadPadding("googPayloadPadding") |
| 423 , googLatencyMs("latencyMs") |
| 424 , googPowerLineFrequency("googPowerLineFrequency") |
| 479 { | 425 { |
| 480 } | 426 } |
| 481 | 427 |
| 482 std::vector<const BaseConstraint*> WebMediaTrackConstraintSet::allConstraints()
const | 428 std::vector<const BaseConstraint*> WebMediaTrackConstraintSet::allConstraints()
const |
| 483 { | 429 { |
| 484 const BaseConstraint* temp[] = { | 430 const BaseConstraint* temp[] = { |
| 485 &width, &height, &aspectRatio, &frameRate, &facingMode, &volume, | 431 &width, &height, &aspectRatio, &frameRate, &facingMode, &volume, |
| 486 &sampleRate, &sampleSize, &echoCancellation, &latency, &channelCount, | 432 &sampleRate, &sampleSize, &echoCancellation, &latency, &channelCount, |
| 487 &deviceId, &groupId, &mediaStreamSource, &renderToAssociatedSink, | 433 &deviceId, &groupId, &mediaStreamSource, &renderToAssociatedSink, |
| 488 &hotwordEnabled, &googEchoCancellation, | 434 &hotwordEnabled, &googEchoCancellation, |
| 489 &googExperimentalEchoCancellation, &googAutoGainControl, | 435 &googExperimentalEchoCancellation, &googAutoGainControl, |
| 490 &googExperimentalAutoGainControl, &googNoiseSuppression, | 436 &googExperimentalAutoGainControl, &googNoiseSuppression, |
| 491 &googHighpassFilter, &googTypingNoiseDetection, | 437 &googHighpassFilter, &googTypingNoiseDetection, |
| 492 &googExperimentalNoiseSuppression, &googBeamforming, | 438 &googExperimentalNoiseSuppression, &googBeamforming, |
| 493 &googArrayGeometry, &googAudioMirroring, &googDAEchoCancellation, | 439 &googArrayGeometry, &googAudioMirroring, &googDAEchoCancellation, |
| 494 &googNoiseReduction, &offerToReceiveAudio, | 440 &googNoiseReduction, &offerToReceiveAudio, |
| 495 &offerToReceiveVideo, &voiceActivityDetection, &iceRestart, | 441 &offerToReceiveVideo, &voiceActivityDetection, &iceRestart, |
| 496 &googUseRtpMux, &enableDtlsSrtp, &enableRtpDataChannels, | 442 &googUseRtpMux, &enableDtlsSrtp, &enableRtpDataChannels, |
| 497 &enableDscp, &enableIPv6, &googEnableVideoSuspendBelowMinBitrate, | 443 &enableDscp, &enableIPv6, &googEnableVideoSuspendBelowMinBitrate, |
| 498 &googNumUnsignalledRecvStreams, &googCombinedAudioVideoBwe, | 444 &googNumUnsignalledRecvStreams, &googCombinedAudioVideoBwe, |
| 499 &googScreencastMinBitrate, &googCpuOveruseDetection, | 445 &googScreencastMinBitrate, &googCpuOveruseDetection, |
| 500 &googCpuUnderuseThreshold, &googCpuOveruseThreshold, | 446 &googCpuUnderuseThreshold, &googCpuOveruseThreshold, |
| 501 &googCpuUnderuseEncodeRsdThreshold, &googCpuOveruseEncodeRsdThreshold, | 447 &googCpuUnderuseEncodeRsdThreshold, &googCpuOveruseEncodeRsdThreshold, |
| 502 &googCpuOveruseEncodeUsage, &googHighStartBitrate, &googPayloadPadding | 448 &googCpuOveruseEncodeUsage, &googHighStartBitrate, &googPayloadPadding, |
| 449 &googLatencyMs, &googPowerLineFrequency |
| 503 }; | 450 }; |
| 504 const int elementCount = sizeof(temp) / sizeof(temp[0]); | 451 const int elementCount = sizeof(temp) / sizeof(temp[0]); |
| 505 return std::vector<const BaseConstraint*>(&temp[0], &temp[elementCount]); | 452 return std::vector<const BaseConstraint*>(&temp[0], &temp[elementCount]); |
| 506 } | 453 } |
| 507 | 454 |
| 508 bool WebMediaTrackConstraintSet::isEmpty() const | 455 bool WebMediaTrackConstraintSet::isEmpty() const |
| 509 { | 456 { |
| 510 for (const auto& constraint : allConstraints()) { | 457 for (const auto& constraint : allConstraints()) { |
| 511 if (!constraint->isEmpty()) | 458 if (!constraint->isEmpty()) |
| 512 return false; | 459 return false; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 void WebMediaConstraints::reset() | 508 void WebMediaConstraints::reset() |
| 562 { | 509 { |
| 563 m_private.reset(); | 510 m_private.reset(); |
| 564 } | 511 } |
| 565 | 512 |
| 566 bool WebMediaConstraints::isEmpty() const | 513 bool WebMediaConstraints::isEmpty() const |
| 567 { | 514 { |
| 568 return m_private.isNull() || m_private->isEmpty(); | 515 return m_private.isNull() || m_private->isEmpty(); |
| 569 } | 516 } |
| 570 | 517 |
| 571 void WebMediaConstraints::getMandatoryConstraints(WebVector<WebMediaConstraint>&
constraints) const | |
| 572 { | |
| 573 ASSERT(!isNull()); | |
| 574 m_private->getMandatoryConstraints(constraints); | |
| 575 } | |
| 576 | |
| 577 void WebMediaConstraints::getOptionalConstraints(WebVector<WebMediaConstraint>&
constraints) const | |
| 578 { | |
| 579 ASSERT(!isNull()); | |
| 580 m_private->getOptionalConstraints(constraints); | |
| 581 } | |
| 582 | |
| 583 bool WebMediaConstraints::getMandatoryConstraintValue(const WebString& name, Web
String& value) const | |
| 584 { | |
| 585 ASSERT(!isNull()); | |
| 586 return m_private->getMandatoryConstraintValue(name, value); | |
| 587 } | |
| 588 | |
| 589 bool WebMediaConstraints::getOptionalConstraintValue(const WebString& name, WebS
tring& value) const | |
| 590 { | |
| 591 ASSERT(!isNull()); | |
| 592 return m_private->getOptionalConstraintValue(name, value); | |
| 593 } | |
| 594 | |
| 595 void WebMediaConstraints::initialize() | 518 void WebMediaConstraints::initialize() |
| 596 { | 519 { |
| 597 ASSERT(isNull()); | 520 ASSERT(isNull()); |
| 598 m_private = WebMediaConstraintsPrivate::create(); | 521 m_private = WebMediaConstraintsPrivate::create(); |
| 599 } | 522 } |
| 600 | 523 |
| 601 void WebMediaConstraints::initialize(const WebVector<WebMediaConstraint>& option
al, const WebVector<WebMediaConstraint>& mandatory, const WebMediaTrackConstrain
tSet& basic, const WebVector<WebMediaTrackConstraintSet>& advanced) | |
| 602 { | |
| 603 ASSERT(isNull()); | |
| 604 m_private = WebMediaConstraintsPrivate::create(optional, mandatory, basic, a
dvanced); | |
| 605 } | |
| 606 | |
| 607 void WebMediaConstraints::initialize(const WebMediaTrackConstraintSet& basic, co
nst WebVector<WebMediaTrackConstraintSet>& advanced) | 524 void WebMediaConstraints::initialize(const WebMediaTrackConstraintSet& basic, co
nst WebVector<WebMediaTrackConstraintSet>& advanced) |
| 608 { | 525 { |
| 609 ASSERT(isNull()); | 526 ASSERT(isNull()); |
| 610 m_private = WebMediaConstraintsPrivate::create(basic, advanced); | 527 m_private = WebMediaConstraintsPrivate::create(basic, advanced); |
| 611 } | 528 } |
| 612 | 529 |
| 613 const WebMediaTrackConstraintSet& WebMediaConstraints::basic() const | 530 const WebMediaTrackConstraintSet& WebMediaConstraints::basic() const |
| 614 { | 531 { |
| 615 ASSERT(!isNull()); | 532 ASSERT(!isNull()); |
| 616 return m_private->basic(); | 533 return m_private->basic(); |
| 617 } | 534 } |
| 618 | 535 |
| 619 const WebVector<WebMediaTrackConstraintSet>& WebMediaConstraints::advanced() con
st | 536 const WebVector<WebMediaTrackConstraintSet>& WebMediaConstraints::advanced() con
st |
| 620 { | 537 { |
| 621 ASSERT(!isNull()); | 538 ASSERT(!isNull()); |
| 622 return m_private->advanced(); | 539 return m_private->advanced(); |
| 623 } | 540 } |
| 624 | 541 |
| 625 const WebString WebMediaConstraints::toString() const | 542 const WebString WebMediaConstraints::toString() const |
| 626 { | 543 { |
| 627 if (isNull()) | 544 if (isNull()) |
| 628 return WebString(""); | 545 return WebString(""); |
| 629 return m_private->toString(); | 546 return m_private->toString(); |
| 630 } | 547 } |
| 631 | 548 |
| 632 } // namespace blink | 549 } // namespace blink |
| OLD | NEW |