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 "base/logging.h" | 6 #include "base/logging.h" |
7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
8 #include "content/common/media/media_stream_options.h" | 8 #include "content/common/media/media_stream_options.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/WebCString.h" | 10 #include "third_party/WebKit/public/platform/WebCString.h" |
(...skipping 24 matching lines...) Expand all Loading... | |
35 continue; | 35 continue; |
36 | 36 |
37 DVLOG(3) << "MediaStreamConstraints:" << new_constraint.key | 37 DVLOG(3) << "MediaStreamConstraints:" << new_constraint.key |
38 << " : " << new_constraint.value; | 38 << " : " << new_constraint.value; |
39 native_constraints->push_back(new_constraint); | 39 native_constraints->push_back(new_constraint); |
40 } | 40 } |
41 } | 41 } |
42 | 42 |
43 } // namespace | 43 } // namespace |
44 | 44 |
45 RTCMediaConstraints::RTCMediaConstraints() {} | |
46 | |
45 RTCMediaConstraints::RTCMediaConstraints( | 47 RTCMediaConstraints::RTCMediaConstraints( |
46 const WebKit::WebMediaConstraints& constraints) { | 48 const WebKit::WebMediaConstraints& constraints) { |
47 if (constraints.isNull()) | 49 if (constraints.isNull()) |
48 return; // Will happen in unit tests. | 50 return; // Will happen in unit tests. |
49 WebKit::WebVector<WebKit::WebMediaConstraint> mandatory; | 51 WebKit::WebVector<WebKit::WebMediaConstraint> mandatory; |
50 constraints.getMandatoryConstraints(mandatory); | 52 constraints.getMandatoryConstraints(mandatory); |
51 GetNativeMediaConstraints(mandatory, &mandatory_); | 53 GetNativeMediaConstraints(mandatory, &mandatory_); |
52 WebKit::WebVector<WebKit::WebMediaConstraint> optional; | 54 WebKit::WebVector<WebKit::WebMediaConstraint> optional; |
53 constraints.getOptionalConstraints(optional); | 55 constraints.getOptionalConstraints(optional); |
54 GetNativeMediaConstraints(optional, &optional_); | 56 GetNativeMediaConstraints(optional, &optional_); |
55 } | 57 } |
56 | 58 |
57 RTCMediaConstraints::~RTCMediaConstraints() {} | 59 RTCMediaConstraints::~RTCMediaConstraints() {} |
58 | 60 |
59 const webrtc::MediaConstraintsInterface::Constraints& | 61 const webrtc::MediaConstraintsInterface::Constraints& |
60 RTCMediaConstraints::GetMandatory() const { | 62 RTCMediaConstraints::GetMandatory() const { |
61 return mandatory_; | 63 return mandatory_; |
62 } | 64 } |
63 | 65 |
64 const webrtc::MediaConstraintsInterface::Constraints& | 66 const webrtc::MediaConstraintsInterface::Constraints& |
65 RTCMediaConstraints::GetOptional() const { | 67 RTCMediaConstraints::GetOptional() const { |
66 return optional_; | 68 return optional_; |
67 } | 69 } |
68 | 70 |
69 void RTCMediaConstraints::AddOptional(const std::string& key, | 71 void RTCMediaConstraints::AddOptional(const std::string& key, |
70 const std::string& value) { | 72 const std::string& value) { |
71 optional_.push_back(Constraint(key, value)); | 73 optional_.push_back(Constraint(key, value)); |
72 } | 74 } |
73 | 75 |
76 bool RTCMediaConstraints::AddMandatory(const std::string& key, | |
no longer working on chromium
2013/08/27 11:10:51
nit, remove the extra space.
tommi (sloooow) - chröme
2013/08/30 16:20:46
Done.
| |
77 const std::string& value, | |
78 bool override_if_exists) { | |
79 for (Constraints::iterator iter = mandatory_.begin(); | |
80 iter != mandatory_.end(); | |
81 ++iter) { | |
82 if (iter->key == key) { | |
83 if (override_if_exists) | |
84 iter->value = value; | |
85 return override_if_exists; | |
86 } | |
87 } | |
88 // The key wasn't found, add it. | |
89 mandatory_.push_back(Constraint(key, value)); | |
90 return true; | |
91 } | |
92 | |
74 } // namespace content | 93 } // namespace content |
OLD | NEW |