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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 namespace blink { | 43 namespace blink { |
44 | 44 |
45 namespace MediaConstraintsImpl { | 45 namespace MediaConstraintsImpl { |
46 | 46 |
47 static bool parse(const Dictionary& constraintsDictionary, WebVector<WebMediaCon
straint>& optional, WebVector<WebMediaConstraint>& mandatory) | 47 static bool parse(const Dictionary& constraintsDictionary, WebVector<WebMediaCon
straint>& optional, WebVector<WebMediaConstraint>& mandatory) |
48 { | 48 { |
49 if (constraintsDictionary.isUndefinedOrNull()) | 49 if (constraintsDictionary.isUndefinedOrNull()) |
50 return true; | 50 return true; |
51 | 51 |
52 Vector<String> names; | 52 Vector<String> names; |
53 constraintsDictionary.getOwnPropertyNames(names); | 53 constraintsDictionary.getPropertyNames(names); |
54 | 54 |
55 String mandatoryName("mandatory"); | 55 String mandatoryName("mandatory"); |
56 String optionalName("optional"); | 56 String optionalName("optional"); |
57 | 57 |
58 for (Vector<String>::iterator it = names.begin(); it != names.end(); ++it) { | 58 for (Vector<String>::iterator it = names.begin(); it != names.end(); ++it) { |
59 if (*it != mandatoryName && *it != optionalName) | 59 if (*it != mandatoryName && *it != optionalName) |
60 return false; | 60 return false; |
61 } | 61 } |
62 | 62 |
63 Vector<WebMediaConstraint> mandatoryConstraintsVector; | 63 Vector<WebMediaConstraint> mandatoryConstraintsVector; |
(...skipping 24 matching lines...) Expand all Loading... |
88 ok = optionalConstraints.length(numberOfConstraints); | 88 ok = optionalConstraints.length(numberOfConstraints); |
89 if (!ok) | 89 if (!ok) |
90 return false; | 90 return false; |
91 | 91 |
92 for (size_t i = 0; i < numberOfConstraints; ++i) { | 92 for (size_t i = 0; i < numberOfConstraints; ++i) { |
93 Dictionary constraint; | 93 Dictionary constraint; |
94 ok = optionalConstraints.get(i, constraint); | 94 ok = optionalConstraints.get(i, constraint); |
95 if (!ok || constraint.isUndefinedOrNull()) | 95 if (!ok || constraint.isUndefinedOrNull()) |
96 return false; | 96 return false; |
97 Vector<String> localNames; | 97 Vector<String> localNames; |
98 constraint.getOwnPropertyNames(localNames); | 98 constraint.getPropertyNames(localNames); |
99 if (localNames.size() != 1) | 99 if (localNames.size() != 1) |
100 return false; | 100 return false; |
101 String key = localNames[0]; | 101 String key = localNames[0]; |
102 String value; | 102 String value; |
103 ok = DictionaryHelper::get(constraint, key, value); | 103 ok = DictionaryHelper::get(constraint, key, value); |
104 if (!ok) | 104 if (!ok) |
105 return false; | 105 return false; |
106 optionalConstraintsVector.append(WebMediaConstraint(key, value)); | 106 optionalConstraintsVector.append(WebMediaConstraint(key, value)); |
107 } | 107 } |
108 } | 108 } |
(...skipping 20 matching lines...) Expand all Loading... |
129 | 129 |
130 WebMediaConstraints create() | 130 WebMediaConstraints create() |
131 { | 131 { |
132 WebMediaConstraints constraints; | 132 WebMediaConstraints constraints; |
133 constraints.initialize(); | 133 constraints.initialize(); |
134 return constraints; | 134 return constraints; |
135 } | 135 } |
136 | 136 |
137 } // namespace MediaConstraintsImpl | 137 } // namespace MediaConstraintsImpl |
138 } // namespace blink | 138 } // namespace blink |
OLD | NEW |