| 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 return false; | 72 return false; |
| 73 | 73 |
| 74 HashMap<String, String>::const_iterator iter = mandatoryConstraintsHashM
ap.begin(); | 74 HashMap<String, String>::const_iterator iter = mandatoryConstraintsHashM
ap.begin(); |
| 75 for (; iter != mandatoryConstraintsHashMap.end(); ++iter) | 75 for (; iter != mandatoryConstraintsHashMap.end(); ++iter) |
| 76 mandatoryConstraintsVector.append(blink::WebMediaConstraint(iter->ke
y, iter->value)); | 76 mandatoryConstraintsVector.append(blink::WebMediaConstraint(iter->ke
y, iter->value)); |
| 77 } | 77 } |
| 78 | 78 |
| 79 Vector<blink::WebMediaConstraint> optionalConstraintsVector; | 79 Vector<blink::WebMediaConstraint> optionalConstraintsVector; |
| 80 if (names.contains(optionalName)) { | 80 if (names.contains(optionalName)) { |
| 81 ArrayValue optionalConstraints; | 81 ArrayValue optionalConstraints; |
| 82 bool ok = constraintsDictionary.get(optionalName, optionalConstraints); | 82 bool ok = DictionaryHelper::get(constraintsDictionary, optionalName, opt
ionalConstraints); |
| 83 if (!ok || optionalConstraints.isUndefinedOrNull()) | 83 if (!ok || optionalConstraints.isUndefinedOrNull()) |
| 84 return false; | 84 return false; |
| 85 | 85 |
| 86 size_t numberOfConstraints; | 86 size_t numberOfConstraints; |
| 87 ok = optionalConstraints.length(numberOfConstraints); | 87 ok = optionalConstraints.length(numberOfConstraints); |
| 88 if (!ok) | 88 if (!ok) |
| 89 return false; | 89 return false; |
| 90 | 90 |
| 91 for (size_t i = 0; i < numberOfConstraints; ++i) { | 91 for (size_t i = 0; i < numberOfConstraints; ++i) { |
| 92 Dictionary constraint; | 92 Dictionary constraint; |
| 93 ok = optionalConstraints.get(i, constraint); | 93 ok = optionalConstraints.get(i, constraint); |
| 94 if (!ok || constraint.isUndefinedOrNull()) | 94 if (!ok || constraint.isUndefinedOrNull()) |
| 95 return false; | 95 return false; |
| 96 Vector<String> localNames; | 96 Vector<String> localNames; |
| 97 constraint.getOwnPropertyNames(localNames); | 97 constraint.getOwnPropertyNames(localNames); |
| 98 if (localNames.size() != 1) | 98 if (localNames.size() != 1) |
| 99 return false; | 99 return false; |
| 100 String key = localNames[0]; | 100 String key = localNames[0]; |
| 101 String value; | 101 String value; |
| 102 ok = constraint.get(key, value); | 102 ok = DictionaryHelper::get(constraint, key, value); |
| 103 if (!ok) | 103 if (!ok) |
| 104 return false; | 104 return false; |
| 105 optionalConstraintsVector.append(blink::WebMediaConstraint(key, valu
e)); | 105 optionalConstraintsVector.append(blink::WebMediaConstraint(key, valu
e)); |
| 106 } | 106 } |
| 107 } | 107 } |
| 108 | 108 |
| 109 optional.assign(optionalConstraintsVector); | 109 optional.assign(optionalConstraintsVector); |
| 110 mandatory.assign(mandatoryConstraintsVector); | 110 mandatory.assign(mandatoryConstraintsVector); |
| 111 return true; | 111 return true; |
| 112 } | 112 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 128 | 128 |
| 129 blink::WebMediaConstraints create() | 129 blink::WebMediaConstraints create() |
| 130 { | 130 { |
| 131 blink::WebMediaConstraints constraints; | 131 blink::WebMediaConstraints constraints; |
| 132 constraints.initialize(); | 132 constraints.initialize(); |
| 133 return constraints; | 133 return constraints; |
| 134 } | 134 } |
| 135 | 135 |
| 136 } // namespace MediaConstraintsImpl | 136 } // namespace MediaConstraintsImpl |
| 137 } // namespace WebCore | 137 } // namespace WebCore |
| OLD | NEW |