| 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 } | 107 } |
| 108 | 108 |
| 109 WebMediaConstraintsPrivate::WebMediaConstraintsPrivate( | 109 WebMediaConstraintsPrivate::WebMediaConstraintsPrivate( |
| 110 const WebMediaTrackConstraintSet& basic, | 110 const WebMediaTrackConstraintSet& basic, |
| 111 const WebVector<WebMediaTrackConstraintSet>& advanced) | 111 const WebVector<WebMediaTrackConstraintSet>& advanced) |
| 112 : m_basic(basic), m_advanced(advanced) {} | 112 : m_basic(basic), m_advanced(advanced) {} |
| 113 | 113 |
| 114 bool WebMediaConstraintsPrivate::isEmpty() const { | 114 bool WebMediaConstraintsPrivate::isEmpty() const { |
| 115 // TODO(hta): When generating advanced constraints, make sure no empty | 115 // TODO(hta): When generating advanced constraints, make sure no empty |
| 116 // elements can be added to the m_advanced vector. | 116 // elements can be added to the m_advanced vector. |
| 117 return m_basic.isEmpty() && m_advanced.isEmpty(); | 117 return m_basic.isEmpty() && m_advanced.empty(); |
| 118 } | 118 } |
| 119 | 119 |
| 120 const WebMediaTrackConstraintSet& WebMediaConstraintsPrivate::basic() const { | 120 const WebMediaTrackConstraintSet& WebMediaConstraintsPrivate::basic() const { |
| 121 return m_basic; | 121 return m_basic; |
| 122 } | 122 } |
| 123 | 123 |
| 124 const WebVector<WebMediaTrackConstraintSet>& | 124 const WebVector<WebMediaTrackConstraintSet>& |
| 125 WebMediaConstraintsPrivate::advanced() const { | 125 WebMediaConstraintsPrivate::advanced() const { |
| 126 return m_advanced; | 126 return m_advanced; |
| 127 } | 127 } |
| 128 | 128 |
| 129 const String WebMediaConstraintsPrivate::toString() const { | 129 const String WebMediaConstraintsPrivate::toString() const { |
| 130 StringBuilder builder; | 130 StringBuilder builder; |
| 131 if (!isEmpty()) { | 131 if (!isEmpty()) { |
| 132 builder.append('{'); | 132 builder.append('{'); |
| 133 builder.append(basic().toString()); | 133 builder.append(basic().toString()); |
| 134 if (!advanced().isEmpty()) { | 134 if (!advanced().empty()) { |
| 135 if (builder.length() > 1) | 135 if (builder.length() > 1) |
| 136 builder.append(", "); | 136 builder.append(", "); |
| 137 builder.append("advanced: ["); | 137 builder.append("advanced: ["); |
| 138 bool first = true; | 138 bool first = true; |
| 139 for (const auto& constraintSet : advanced()) { | 139 for (const auto& constraintSet : advanced()) { |
| 140 if (!first) | 140 if (!first) |
| 141 builder.append(", "); | 141 builder.append(", "); |
| 142 builder.append('{'); | 142 builder.append('{'); |
| 143 builder.append(constraintSet.toString()); | 143 builder.append(constraintSet.toString()); |
| 144 builder.append('}'); | 144 builder.append('}'); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 maybeEmitNamedValue(builder, m_hasExact, "exact", m_exact); | 243 maybeEmitNamedValue(builder, m_hasExact, "exact", m_exact); |
| 244 maybeEmitNamedValue(builder, m_hasIdeal, "ideal", m_ideal); | 244 maybeEmitNamedValue(builder, m_hasIdeal, "ideal", m_ideal); |
| 245 builder.append('}'); | 245 builder.append('}'); |
| 246 return builder.toString(); | 246 return builder.toString(); |
| 247 } | 247 } |
| 248 | 248 |
| 249 StringConstraint::StringConstraint(const char* name) | 249 StringConstraint::StringConstraint(const char* name) |
| 250 : BaseConstraint(name), m_exact(), m_ideal() {} | 250 : BaseConstraint(name), m_exact(), m_ideal() {} |
| 251 | 251 |
| 252 bool StringConstraint::matches(WebString value) const { | 252 bool StringConstraint::matches(WebString value) const { |
| 253 if (m_exact.isEmpty()) { | 253 if (m_exact.empty()) { |
| 254 return true; | 254 return true; |
| 255 } | 255 } |
| 256 for (const auto& choice : m_exact) { | 256 for (const auto& choice : m_exact) { |
| 257 if (value == choice) { | 257 if (value == choice) { |
| 258 return true; | 258 return true; |
| 259 } | 259 } |
| 260 } | 260 } |
| 261 return false; | 261 return false; |
| 262 } | 262 } |
| 263 | 263 |
| 264 bool StringConstraint::isEmpty() const { | 264 bool StringConstraint::isEmpty() const { |
| 265 return m_exact.isEmpty() && m_ideal.isEmpty(); | 265 return m_exact.empty() && m_ideal.empty(); |
| 266 } | 266 } |
| 267 | 267 |
| 268 bool StringConstraint::hasMandatory() const { | 268 bool StringConstraint::hasMandatory() const { |
| 269 return !m_exact.isEmpty(); | 269 return !m_exact.empty(); |
| 270 } | 270 } |
| 271 | 271 |
| 272 const WebVector<WebString>& StringConstraint::exact() const { | 272 const WebVector<WebString>& StringConstraint::exact() const { |
| 273 return m_exact; | 273 return m_exact; |
| 274 } | 274 } |
| 275 | 275 |
| 276 const WebVector<WebString>& StringConstraint::ideal() const { | 276 const WebVector<WebString>& StringConstraint::ideal() const { |
| 277 return m_ideal; | 277 return m_ideal; |
| 278 } | 278 } |
| 279 | 279 |
| 280 WebString StringConstraint::toString() const { | 280 WebString StringConstraint::toString() const { |
| 281 StringBuilder builder; | 281 StringBuilder builder; |
| 282 builder.append('{'); | 282 builder.append('{'); |
| 283 if (!m_ideal.isEmpty()) { | 283 if (!m_ideal.empty()) { |
| 284 builder.append("ideal: ["); | 284 builder.append("ideal: ["); |
| 285 bool first = true; | 285 bool first = true; |
| 286 for (const auto& iter : m_ideal) { | 286 for (const auto& iter : m_ideal) { |
| 287 if (!first) | 287 if (!first) |
| 288 builder.append(", "); | 288 builder.append(", "); |
| 289 builder.append('"'); | 289 builder.append('"'); |
| 290 builder.append(iter); | 290 builder.append(iter); |
| 291 builder.append('"'); | 291 builder.append('"'); |
| 292 first = false; | 292 first = false; |
| 293 } | 293 } |
| 294 builder.append(']'); | 294 builder.append(']'); |
| 295 } | 295 } |
| 296 if (!m_exact.isEmpty()) { | 296 if (!m_exact.empty()) { |
| 297 if (builder.length() > 1) | 297 if (builder.length() > 1) |
| 298 builder.append(", "); | 298 builder.append(", "); |
| 299 builder.append("exact: ["); | 299 builder.append("exact: ["); |
| 300 bool first = true; | 300 bool first = true; |
| 301 for (const auto& iter : m_exact) { | 301 for (const auto& iter : m_exact) { |
| 302 if (!first) | 302 if (!first) |
| 303 builder.append(", "); | 303 builder.append(", "); |
| 304 builder.append('"'); | 304 builder.append('"'); |
| 305 builder.append(iter); | 305 builder.append(iter); |
| 306 builder.append('"'); | 306 builder.append('"'); |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 return m_private->advanced(); | 548 return m_private->advanced(); |
| 549 } | 549 } |
| 550 | 550 |
| 551 const WebString WebMediaConstraints::toString() const { | 551 const WebString WebMediaConstraints::toString() const { |
| 552 if (isNull()) | 552 if (isNull()) |
| 553 return WebString(""); | 553 return WebString(""); |
| 554 return m_private->toString(); | 554 return m_private->toString(); |
| 555 } | 555 } |
| 556 | 556 |
| 557 } // namespace blink | 557 } // namespace blink |
| OLD | NEW |