| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "content/renderer/media/rtc_media_constraints.h" | 4 #include "content/renderer/media/rtc_media_constraints.h" |
| 5 | 5 |
| 6 #include <string> |
| 7 |
| 6 #include "base/logging.h" | 8 #include "base/logging.h" |
| 7 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 8 #include "content/common/media/media_stream_options.h" | 10 #include "content/common/media/media_stream_options.h" |
| 9 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" | 11 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" |
| 10 #include "third_party/WebKit/public/platform/WebCString.h" | 12 #include "third_party/WebKit/public/platform/WebCString.h" |
| 11 #include "third_party/WebKit/public/platform/WebString.h" | 13 #include "third_party/WebKit/public/platform/WebString.h" |
| 12 | 14 |
| 13 namespace content { | 15 namespace content { |
| 14 namespace { | 16 namespace { |
| 15 | 17 |
| 16 void GetNativeMediaConstraints( | 18 void GetNativeMediaConstraints( |
| 17 const WebKit::WebVector<WebKit::WebMediaConstraint>& constraints, | 19 const WebKit::WebVector<WebKit::WebMediaConstraint>& constraints, |
| 18 webrtc::MediaConstraintsInterface::Constraints* native_constraints) { | 20 webrtc::MediaConstraintsInterface::Constraints* native_constraints) { |
| 19 DCHECK(native_constraints); | 21 DCHECK(native_constraints); |
| 20 for (size_t i = 0; i < constraints.size(); ++i) { | 22 for (size_t i = 0; i < constraints.size(); ++i) { |
| 21 webrtc::MediaConstraintsInterface::Constraint new_constraint; | 23 webrtc::MediaConstraintsInterface::Constraint new_constraint; |
| 22 new_constraint.key = constraints[i].m_name.utf8(); | 24 new_constraint.key = constraints[i].m_name.utf8(); |
| 23 new_constraint.value = constraints[i].m_value.utf8(); | 25 new_constraint.value = constraints[i].m_value.utf8(); |
| 24 | 26 |
| 25 // Ignore Chrome specific Tab capture constraints. | 27 // Ignore Chrome specific Tab capture constraints. |
| 26 if (new_constraint.key == kMediaStreamSource || | 28 if (new_constraint.key == kMediaStreamSource || |
| 27 new_constraint.key == kMediaStreamSourceId) | 29 new_constraint.key == kMediaStreamSourceId) |
| 28 continue; | 30 continue; |
| 29 | 31 |
| 30 // Ignore internal constraints set by JS. | 32 // Ignore internal constraints set by JS. |
| 31 // TODO(jiayl): replace the hard coded string with | 33 if (StartsWithASCII( |
| 32 // webrtc::MediaConstraintsInterface::kInternalConstraintPrefix when | 34 new_constraint.key, |
| 33 // the Libjingle change is rolled. | 35 webrtc::MediaConstraintsInterface::kInternalConstraintPrefix, |
| 34 if (StartsWithASCII(new_constraint.key, "internal", true)) | 36 true)) { |
| 35 continue; | 37 continue; |
| 38 } |
| 36 | 39 |
| 37 DVLOG(3) << "MediaStreamConstraints:" << new_constraint.key | 40 DVLOG(3) << "MediaStreamConstraints:" << new_constraint.key |
| 38 << " : " << new_constraint.value; | 41 << " : " << new_constraint.value; |
| 39 native_constraints->push_back(new_constraint); | 42 native_constraints->push_back(new_constraint); |
| 40 } | 43 } |
| 41 } | 44 } |
| 42 | 45 |
| 43 } // namespace | 46 } // namespace |
| 44 | 47 |
| 45 RTCMediaConstraints::RTCMediaConstraints() {} | 48 RTCMediaConstraints::RTCMediaConstraints() {} |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 iter->value = value; | 87 iter->value = value; |
| 85 return override_if_exists; | 88 return override_if_exists; |
| 86 } | 89 } |
| 87 } | 90 } |
| 88 // The key wasn't found, add it. | 91 // The key wasn't found, add it. |
| 89 mandatory_.push_back(Constraint(key, value)); | 92 mandatory_.push_back(Constraint(key, value)); |
| 90 return true; | 93 return true; |
| 91 } | 94 } |
| 92 | 95 |
| 93 } // namespace content | 96 } // namespace content |
| OLD | NEW |