| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/media/media_stream_constraints_util.h" | 5 #include "content/renderer/media/media_stream_constraints_util.h" |
| 6 | 6 |
| 7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" | 9 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" |
| 10 #include "third_party/WebKit/public/platform/WebString.h" | 10 #include "third_party/WebKit/public/platform/WebString.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 template <typename P, typename T> | 35 template <typename P, typename T> |
| 36 bool ScanConstraintsForMaxValue(const blink::WebMediaConstraints& constraints, | 36 bool ScanConstraintsForMaxValue(const blink::WebMediaConstraints& constraints, |
| 37 P picker, | 37 P picker, |
| 38 T* value) { | 38 T* value) { |
| 39 const auto& the_field = constraints.basic().*picker; | 39 const auto& the_field = constraints.basic().*picker; |
| 40 if (the_field.hasMax()) { | 40 if (the_field.hasMax()) { |
| 41 *value = the_field.max(); | 41 *value = the_field.max(); |
| 42 return true; | 42 return true; |
| 43 } | 43 } |
| 44 if (the_field.hasExact()) { |
| 45 *value = the_field.exact(); |
| 46 return true; |
| 47 } |
| 44 for (const auto& advanced_constraint : constraints.advanced()) { | 48 for (const auto& advanced_constraint : constraints.advanced()) { |
| 45 const auto& the_field = advanced_constraint.*picker; | 49 const auto& the_field = advanced_constraint.*picker; |
| 46 if (the_field.hasMax()) { | 50 if (the_field.hasMax()) { |
| 47 *value = the_field.max(); | 51 *value = the_field.max(); |
| 48 return true; | 52 return true; |
| 49 } | 53 } |
| 54 if (the_field.hasExact()) { |
| 55 *value = the_field.exact(); |
| 56 return true; |
| 57 } |
| 50 } | 58 } |
| 51 return false; | 59 return false; |
| 52 } | 60 } |
| 53 | 61 |
| 54 template <typename P, typename T> | 62 template <typename P, typename T> |
| 55 bool ScanConstraintsForMinValue(const blink::WebMediaConstraints& constraints, | 63 bool ScanConstraintsForMinValue(const blink::WebMediaConstraints& constraints, |
| 56 P picker, | 64 P picker, |
| 57 T* value) { | 65 T* value) { |
| 58 const auto& the_field = constraints.basic().*picker; | 66 const auto& the_field = constraints.basic().*picker; |
| 59 if (the_field.hasMin()) { | 67 if (the_field.hasMin()) { |
| 60 *value = the_field.min(); | 68 *value = the_field.min(); |
| 61 return true; | 69 return true; |
| 62 } | 70 } |
| 71 if (the_field.hasExact()) { |
| 72 *value = the_field.exact(); |
| 73 return true; |
| 74 } |
| 63 for (const auto& advanced_constraint : constraints.advanced()) { | 75 for (const auto& advanced_constraint : constraints.advanced()) { |
| 64 const auto& the_field = advanced_constraint.*picker; | 76 const auto& the_field = advanced_constraint.*picker; |
| 65 if (the_field.hasMin()) { | 77 if (the_field.hasMin()) { |
| 66 *value = the_field.min(); | 78 *value = the_field.min(); |
| 67 return true; | 79 return true; |
| 68 } | 80 } |
| 81 if (the_field.hasExact()) { |
| 82 *value = the_field.exact(); |
| 83 return true; |
| 84 } |
| 69 } | 85 } |
| 70 return false; | 86 return false; |
| 71 } | 87 } |
| 72 | 88 |
| 73 } // namespace | 89 } // namespace |
| 74 | 90 |
| 75 bool GetConstraintValueAsBoolean( | 91 bool GetConstraintValueAsBoolean( |
| 76 const blink::WebMediaConstraints& constraints, | 92 const blink::WebMediaConstraints& constraints, |
| 77 const blink::BooleanConstraint blink::WebMediaTrackConstraintSet::*picker, | 93 const blink::BooleanConstraint blink::WebMediaTrackConstraintSet::*picker, |
| 78 bool* value) { | 94 bool* value) { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 const blink::WebMediaConstraints& constraints, | 153 const blink::WebMediaConstraints& constraints, |
| 138 const blink::BooleanConstraint blink::WebMediaTrackConstraintSet::*picker) { | 154 const blink::BooleanConstraint blink::WebMediaTrackConstraintSet::*picker) { |
| 139 bool value; | 155 bool value; |
| 140 if (GetConstraintValueAsBoolean(constraints, picker, &value)) { | 156 if (GetConstraintValueAsBoolean(constraints, picker, &value)) { |
| 141 return rtc::Optional<bool>(value); | 157 return rtc::Optional<bool>(value); |
| 142 } | 158 } |
| 143 return rtc::Optional<bool>(); | 159 return rtc::Optional<bool>(); |
| 144 } | 160 } |
| 145 | 161 |
| 146 } // namespace content | 162 } // namespace content |
| OLD | NEW |