OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "content/renderer/media/media_stream_constraints_util.h" | |
6 | |
7 #include "base/strings/string_number_conversions.h" | |
8 #include "base/strings/utf_string_conversions.h" | |
9 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" | |
10 #include "third_party/WebKit/public/platform/WebString.h" | |
11 | |
12 namespace content { | |
13 | |
14 bool GetConstraintValue(const blink::WebMediaConstraints& constraints, | |
15 const std::string& name, | |
16 bool* value) { | |
17 int constraint_value = 0; | |
18 if (!GetConstraintValue(constraints, name, &constraint_value)) | |
19 return false; | |
20 | |
21 *value = static_cast<bool>(constraint_value); | |
tommi (sloooow) - chröme
2014/04/08 10:49:30
Are you sure this works?
The values of these cons
no longer working on chromium
2014/04/11 08:56:30
Yes, the value is stored as blink::WebString in bl
| |
22 return true; | |
23 } | |
24 | |
25 bool GetConstraintValue(const blink::WebMediaConstraints& constraints, | |
26 const std::string& name, | |
27 int* value) { | |
28 return GetManatoryConstraintValue(constraints, name, value) || | |
29 GetOptionalConstraintValue(constraints, name, value); | |
30 } | |
31 | |
32 bool GetManatoryConstraintValue(const blink::WebMediaConstraints& constraints, | |
tommi (sloooow) - chröme
2014/04/08 10:49:30
GetMandatoryConstraintValue
(missing 'd')
no longer working on chromium
2014/04/11 08:56:30
Done.
| |
33 const std::string& name, | |
34 int* value) { | |
35 blink::WebString value_str; | |
36 if (!constraints.getMandatoryConstraintValue(base::UTF8ToUTF16(name), | |
37 value_str)) | |
38 return false; | |
39 | |
40 base::StringToInt(value_str.utf8(), value); | |
tommi (sloooow) - chröme
2014/04/08 10:49:30
return base::StringToInt(value_str.utf8(), value);
no longer working on chromium
2014/04/11 08:56:30
Done.
| |
41 return true; | |
42 } | |
43 | |
44 bool GetOptionalConstraintValue(const blink::WebMediaConstraints& constraints, | |
45 const std::string& name, | |
46 int* value) { | |
47 blink::WebString value_str; | |
48 if (!constraints.getOptionalConstraintValue(base::UTF8ToUTF16(name), | |
49 value_str)) | |
tommi (sloooow) - chröme
2014/04/08 10:49:30
{}
no longer working on chromium
2014/04/11 08:56:30
Done.
| |
50 return false; | |
51 | |
52 base::StringToInt(value_str.utf8(), value); | |
tommi (sloooow) - chröme
2014/04/08 10:49:30
return base::StringToInt(value_str.utf8(), value);
no longer working on chromium
2014/04/11 08:56:30
Done.
| |
53 return true; | |
54 } | |
55 | |
56 } // namespace content | |
OLD | NEW |