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 | |
18 namespace webrtc { | 16 namespace webrtc { |
19 | 17 |
20 MediaConstraints::~MediaConstraints() {} | 18 MediaConstraints::~MediaConstraints() {} |
21 | 19 |
22 MediaConstraints::MediaConstraints() {} | 20 MediaConstraints::MediaConstraints() {} |
23 | 21 |
24 MediaConstraints::MediaConstraints( | 22 MediaConstraints::MediaConstraints( |
25 const MediaConstraintsInterface::Constraints& mandatory, | 23 const MediaConstraintsInterface::Constraints& mandatory, |
26 const MediaConstraintsInterface::Constraints& optional) | 24 const MediaConstraintsInterface::Constraints& optional) |
27 : mandatory_(mandatory), optional_(optional) {} | 25 : mandatory_(mandatory), optional_(optional) {} |
28 | 26 |
29 const MediaConstraintsInterface::Constraints& | 27 const MediaConstraintsInterface::Constraints& |
30 MediaConstraints::GetMandatory() const { | 28 MediaConstraints::GetMandatory() const { |
31 return mandatory_; | 29 return mandatory_; |
32 } | 30 } |
33 | 31 |
34 const MediaConstraintsInterface::Constraints& | 32 const MediaConstraintsInterface::Constraints& |
35 MediaConstraints::GetOptional() const { | 33 MediaConstraints::GetOptional() const { |
36 return optional_; | 34 return optional_; |
37 } | 35 } |
38 | 36 |
39 } // namespace webrtc | 37 } // namespace webrtc |
40 | 38 |
41 | 39 |
42 @implementation RTCMediaConstraints { | 40 @implementation RTCMediaConstraints { |
43 NSDictionary *_mandatory; | 41 NSDictionary<NSString *, NSString *> *_mandatory; |
44 // NSDictionary<NSString *, NSString *> *_mandatory; | 42 NSDictionary<NSString *, NSString *> *_optional; |
45 NSDictionary *_optional; | |
46 // NSDictionary<NSString *, NSString *> *_optional; | |
47 } | 43 } |
48 | 44 |
49 - (instancetype)initWithMandatoryConstraints: | 45 - (instancetype)initWithMandatoryConstraints: |
50 (NSDictionary *)mandatory | 46 (NSDictionary<NSString *, NSString *> *)mandatory |
51 // (NSDictionary<NSString *, NSString *> *)mandatory | |
52 optionalConstraints: | 47 optionalConstraints: |
53 (NSDictionary *)optional { | 48 (NSDictionary<NSString *, NSString *> *)optional { |
54 // (NSDictionary<NSString *, NSString *> *)optional { | |
55 if (self = [super init]) { | 49 if (self = [super init]) { |
56 _mandatory = [[NSDictionary alloc] initWithDictionary:mandatory | 50 _mandatory = [[NSDictionary alloc] initWithDictionary:mandatory |
57 copyItems:YES]; | 51 copyItems:YES]; |
58 _optional = [[NSDictionary alloc] initWithDictionary:optional | 52 _optional = [[NSDictionary alloc] initWithDictionary:optional |
59 copyItems:YES]; | 53 copyItems:YES]; |
60 } | 54 } |
61 return self; | 55 return self; |
62 } | 56 } |
63 | 57 |
64 - (NSString *)description { | 58 - (NSString *)description { |
(...skipping 10 matching lines...) Expand all Loading... |
75 webrtc::MediaConstraintsInterface::Constraints optional = | 69 webrtc::MediaConstraintsInterface::Constraints optional = |
76 [[self class] nativeConstraintsForConstraints:_optional]; | 70 [[self class] nativeConstraintsForConstraints:_optional]; |
77 | 71 |
78 webrtc::MediaConstraints *nativeConstraints = | 72 webrtc::MediaConstraints *nativeConstraints = |
79 new webrtc::MediaConstraints(mandatory, optional); | 73 new webrtc::MediaConstraints(mandatory, optional); |
80 return rtc::scoped_ptr<webrtc::MediaConstraints>(nativeConstraints); | 74 return rtc::scoped_ptr<webrtc::MediaConstraints>(nativeConstraints); |
81 } | 75 } |
82 | 76 |
83 + (webrtc::MediaConstraintsInterface::Constraints) | 77 + (webrtc::MediaConstraintsInterface::Constraints) |
84 nativeConstraintsForConstraints: | 78 nativeConstraintsForConstraints: |
85 (NSDictionary *)constraints { | 79 (NSDictionary<NSString *, NSString *> *)constraints { |
86 // (NSDictionary<NSString *, NSString *> *)constraints { | |
87 webrtc::MediaConstraintsInterface::Constraints nativeConstraints; | 80 webrtc::MediaConstraintsInterface::Constraints nativeConstraints; |
88 for (NSString *key in constraints) { | 81 for (NSString *key in constraints) { |
89 NSAssert([key isKindOfClass:[NSString class]], | 82 NSAssert([key isKindOfClass:[NSString class]], |
90 @"%@ is not an NSString.", key); | 83 @"%@ is not an NSString.", key); |
91 NSString *value = [constraints objectForKey:key]; | 84 NSString *value = [constraints objectForKey:key]; |
92 NSAssert([value isKindOfClass:[NSString class]], | 85 NSAssert([value isKindOfClass:[NSString class]], |
93 @"%@ is not an NSString.", value); | 86 @"%@ is not an NSString.", value); |
94 nativeConstraints.push_back(webrtc::MediaConstraintsInterface::Constraint( | 87 nativeConstraints.push_back(webrtc::MediaConstraintsInterface::Constraint( |
95 key.stdString, value.stdString)); | 88 key.stdString, value.stdString)); |
96 } | 89 } |
97 return nativeConstraints; | 90 return nativeConstraints; |
98 } | 91 } |
99 | 92 |
100 @end | 93 @end |
OLD | NEW |