OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #import "RTCMediaConstraints.h" | 11 #import "RTCMediaConstraints.h" |
12 | 12 |
13 #import "webrtc/api/objc/RTCMediaConstraints+Private.h" | 13 #import "webrtc/api/objc/RTCMediaConstraints+Private.h" |
14 #import "webrtc/base/objc/NSString+StdString.h" | 14 #import "webrtc/base/objc/NSString+StdString.h" |
15 | 15 |
| 16 // TODO(hjon): Update nullability types. See http://crbug/webrtc/5592 |
| 17 |
16 namespace webrtc { | 18 namespace webrtc { |
17 | 19 |
18 MediaConstraints::~MediaConstraints() {} | 20 MediaConstraints::~MediaConstraints() {} |
19 | 21 |
20 MediaConstraints::MediaConstraints() {} | 22 MediaConstraints::MediaConstraints() {} |
21 | 23 |
22 MediaConstraints::MediaConstraints( | 24 MediaConstraints::MediaConstraints( |
23 const MediaConstraintsInterface::Constraints& mandatory, | 25 const MediaConstraintsInterface::Constraints& mandatory, |
24 const MediaConstraintsInterface::Constraints& optional) | 26 const MediaConstraintsInterface::Constraints& optional) |
25 : mandatory_(mandatory), optional_(optional) {} | 27 : mandatory_(mandatory), optional_(optional) {} |
26 | 28 |
27 const MediaConstraintsInterface::Constraints& | 29 const MediaConstraintsInterface::Constraints& |
28 MediaConstraints::GetMandatory() const { | 30 MediaConstraints::GetMandatory() const { |
29 return mandatory_; | 31 return mandatory_; |
30 } | 32 } |
31 | 33 |
32 const MediaConstraintsInterface::Constraints& | 34 const MediaConstraintsInterface::Constraints& |
33 MediaConstraints::GetOptional() const { | 35 MediaConstraints::GetOptional() const { |
34 return optional_; | 36 return optional_; |
35 } | 37 } |
36 | 38 |
37 } // namespace webrtc | 39 } // namespace webrtc |
38 | 40 |
39 | 41 |
40 @implementation RTCMediaConstraints { | 42 @implementation RTCMediaConstraints { |
41 NSDictionary<NSString *, NSString *> *_mandatory; | 43 NSDictionary *_mandatory; |
42 NSDictionary<NSString *, NSString *> *_optional; | 44 // NSDictionary<NSString *, NSString *> *_mandatory; |
| 45 NSDictionary *_optional; |
| 46 // NSDictionary<NSString *, NSString *> *_optional; |
43 } | 47 } |
44 | 48 |
45 - (instancetype)initWithMandatoryConstraints: | 49 - (instancetype)initWithMandatoryConstraints: |
46 (NSDictionary<NSString *, NSString *> *)mandatory | 50 (NSDictionary *)mandatory |
| 51 // (NSDictionary<NSString *, NSString *> *)mandatory |
47 optionalConstraints: | 52 optionalConstraints: |
48 (NSDictionary<NSString *, NSString *> *)optional { | 53 (NSDictionary *)optional { |
| 54 // (NSDictionary<NSString *, NSString *> *)optional { |
49 if (self = [super init]) { | 55 if (self = [super init]) { |
50 _mandatory = [[NSDictionary alloc] initWithDictionary:mandatory | 56 _mandatory = [[NSDictionary alloc] initWithDictionary:mandatory |
51 copyItems:YES]; | 57 copyItems:YES]; |
52 _optional = [[NSDictionary alloc] initWithDictionary:optional | 58 _optional = [[NSDictionary alloc] initWithDictionary:optional |
53 copyItems:YES]; | 59 copyItems:YES]; |
54 } | 60 } |
55 return self; | 61 return self; |
56 } | 62 } |
57 | 63 |
58 - (NSString *)description { | 64 - (NSString *)description { |
(...skipping 10 matching lines...) Expand all Loading... |
69 webrtc::MediaConstraintsInterface::Constraints optional = | 75 webrtc::MediaConstraintsInterface::Constraints optional = |
70 [[self class] nativeConstraintsForConstraints:_optional]; | 76 [[self class] nativeConstraintsForConstraints:_optional]; |
71 | 77 |
72 webrtc::MediaConstraints *nativeConstraints = | 78 webrtc::MediaConstraints *nativeConstraints = |
73 new webrtc::MediaConstraints(mandatory, optional); | 79 new webrtc::MediaConstraints(mandatory, optional); |
74 return rtc::scoped_ptr<webrtc::MediaConstraints>(nativeConstraints); | 80 return rtc::scoped_ptr<webrtc::MediaConstraints>(nativeConstraints); |
75 } | 81 } |
76 | 82 |
77 + (webrtc::MediaConstraintsInterface::Constraints) | 83 + (webrtc::MediaConstraintsInterface::Constraints) |
78 nativeConstraintsForConstraints: | 84 nativeConstraintsForConstraints: |
79 (NSDictionary<NSString *, NSString *> *)constraints { | 85 (NSDictionary *)constraints { |
| 86 // (NSDictionary<NSString *, NSString *> *)constraints { |
80 webrtc::MediaConstraintsInterface::Constraints nativeConstraints; | 87 webrtc::MediaConstraintsInterface::Constraints nativeConstraints; |
81 for (NSString *key in constraints) { | 88 for (NSString *key in constraints) { |
82 NSAssert([key isKindOfClass:[NSString class]], | 89 NSAssert([key isKindOfClass:[NSString class]], |
83 @"%@ is not an NSString.", key); | 90 @"%@ is not an NSString.", key); |
84 NSAssert([constraints[key] isKindOfClass:[NSString class]], | 91 NSString *value = [constraints objectForKey:key]; |
85 @"%@ is not an NSString.", constraints[key]); | 92 NSAssert([value isKindOfClass:[NSString class]], |
| 93 @"%@ is not an NSString.", value); |
86 nativeConstraints.push_back(webrtc::MediaConstraintsInterface::Constraint( | 94 nativeConstraints.push_back(webrtc::MediaConstraintsInterface::Constraint( |
87 key.stdString, constraints[key].stdString)); | 95 key.stdString, value.stdString)); |
88 } | 96 } |
89 return nativeConstraints; | 97 return nativeConstraints; |
90 } | 98 } |
91 | 99 |
92 @end | 100 @end |
OLD | NEW |