Index: third_party/WebKit/Source/platform/exported/WebMediaConstraints.cpp |
diff --git a/third_party/WebKit/Source/platform/exported/WebMediaConstraints.cpp b/third_party/WebKit/Source/platform/exported/WebMediaConstraints.cpp |
index 313aeba6c35b01103a0feb636aec8d27de48dd9a..b9826cdc068959ee0fa3c9817e4d16b2740f89c0 100644 |
--- a/third_party/WebKit/Source/platform/exported/WebMediaConstraints.cpp |
+++ b/third_party/WebKit/Source/platform/exported/WebMediaConstraints.cpp |
@@ -186,6 +186,11 @@ bool LongConstraint::isEmpty() const |
return !m_hasMin && !m_hasMax && !m_hasExact && !m_hasIdeal; |
} |
+bool LongConstraint::hasMandatory() const |
+{ |
+ return m_hasMin || m_hasMax || m_hasExact; |
+} |
+ |
double DoubleConstraint::kConstraintEpsilon = 0.00001; |
DoubleConstraint::DoubleConstraint(const char* name) |
@@ -220,6 +225,11 @@ bool DoubleConstraint::isEmpty() const |
return !m_hasMin && !m_hasMax && !m_hasExact && !m_hasIdeal; |
} |
+bool DoubleConstraint::hasMandatory() const |
+{ |
+ return m_hasMin || m_hasMax || m_hasExact; |
+} |
+ |
StringConstraint::StringConstraint(const char* name) |
: BaseConstraint(name) |
, m_exact() |
@@ -245,6 +255,11 @@ bool StringConstraint::isEmpty() const |
return m_exact.isEmpty() && m_ideal.isEmpty(); |
} |
+bool StringConstraint::hasMandatory() const |
+{ |
+ return !m_exact.isEmpty(); |
+} |
+ |
const WebVector<WebString>& StringConstraint::exact() const |
{ |
return m_exact; |
@@ -277,6 +292,11 @@ bool BooleanConstraint::isEmpty() const |
return !m_hasIdeal && !m_hasExact; |
} |
+bool BooleanConstraint::hasMandatory() const |
+{ |
+ return m_hasExact; |
+} |
+ |
WebMediaTrackConstraintSet::WebMediaTrackConstraintSet() |
: width("width") |
, height("height") |
@@ -332,24 +352,59 @@ WebMediaTrackConstraintSet::WebMediaTrackConstraintSet() |
{ |
} |
+std::vector<const BaseConstraint*> WebMediaTrackConstraintSet::allConstraints() const |
+{ |
+ const BaseConstraint* temp[] = { |
+ &width, &height, &aspectRatio, &frameRate, &facingMode, &volume, |
+ &sampleRate, &sampleSize, &echoCancellation, &latency, &channelCount, |
+ &deviceId, &groupId, &mediaStreamSource, &renderToAssociatedSink, |
+ &hotwordEnabled, &googEchoCancellation, |
+ &googExperimentalEchoCancellation, &googAutoGainControl, |
+ &googExperimentalAutoGainControl, &googNoiseSuppression, |
+ &googHighpassFilter, &googTypingNoiseDetection, |
+ &googExperimentalNoiseSuppression, &googBeamforming, |
+ &googArrayGeometry, &googAudioMirroring, &googDAEchoCancellation, |
+ &googAecDump, &googNoiseReduction, &offerToReceiveAudio, |
+ &offerToReceiveVideo, &voiceActivityDetection, &iceRestart, |
+ &googUseRtpMux, &enableDtlsSrtp, &enableRtpDataChannels, |
+ &enableDscp, &enableIPv6, &googEnableVideoSuspendBelowMinBitrate, |
+ &googNumUnsignalledRecvStreams, &googCombinedAudioVideoBwe, |
+ &googScreencastMinBitrate, &googCpuOveruseDetection, |
+ &googCpuUnderuseThreshold, &googCpuOveruseThreshold, |
+ &googCpuUnderuseEncodeRsdThreshold, &googCpuOveruseEncodeRsdThreshold, |
+ &googCpuOveruseEncodeUsage, &googHighStartBitrate, &googPayloadPadding |
+ }; |
+ const int elementCount = sizeof(temp) / sizeof(temp[0]); |
+ return std::vector<const BaseConstraint*>(&temp[0], &temp[elementCount]); |
+} |
+ |
bool WebMediaTrackConstraintSet::isEmpty() const |
{ |
- return width.isEmpty() && height.isEmpty() && aspectRatio.isEmpty() |
- && frameRate.isEmpty() && facingMode.isEmpty() && volume.isEmpty() |
- && sampleRate.isEmpty() && sampleSize.isEmpty() |
- && echoCancellation.isEmpty() && latency.isEmpty() |
- && channelCount.isEmpty() && deviceId.isEmpty() && groupId.isEmpty() |
- && mediaStreamSource.isEmpty() && renderToAssociatedSink.isEmpty() |
- && hotwordEnabled.isEmpty() && googEchoCancellation.isEmpty() |
- && googExperimentalEchoCancellation.isEmpty() |
- && googAutoGainControl.isEmpty() |
- && googExperimentalAutoGainControl.isEmpty() |
- && googNoiseSuppression.isEmpty() |
- && googHighpassFilter.isEmpty() |
- && googTypingNoiseDetection.isEmpty() |
- && googExperimentalNoiseSuppression.isEmpty() |
- && googBeamforming.isEmpty() && googArrayGeometry.isEmpty() |
- && googAudioMirroring.isEmpty(); |
+ for (const auto& constraint : allConstraints()) { |
+ if (!constraint->isEmpty()) |
+ return false; |
+ } |
+ return true; |
+} |
+ |
+bool WebMediaTrackConstraintSet::hasMandatoryOutsideSet(const std::vector<std::string>& goodNames, std::string& foundName) const |
+{ |
+ for (const auto& constraint : allConstraints()) { |
+ if (constraint->hasMandatory()) { |
+ const auto& result = std::find(goodNames.begin(), goodNames.end(), constraint->name()); |
+ if (result == goodNames.end()) { |
mcasas
2016/01/26 16:08:02
No need for |result|?
hta - Chromium
2016/01/26 19:35:25
I thought so, but it turned out not to be the case
|
+ foundName = constraint->name(); |
+ return true; |
+ } |
+ } |
+ } |
+ return false; |
+} |
+ |
+bool WebMediaTrackConstraintSet::hasMandatory() const |
+{ |
+ std::string dummyString; |
+ return hasMandatoryOutsideSet(std::vector<std::string>(), dummyString); |
} |
// WebMediaConstraints |