Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: webrtc/examples/objc/AppRTCMobile/ARDSettingsModel.m

Issue 2778163005: Use new RTCCameraVideoCapturer in AppRTCMobile. (Closed)
Patch Set: Remove localCapturer property from ARDVideoCallViewController. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2016 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
(...skipping 10 matching lines...) Expand all
21 return @[ @"H264", @"VP8", @"VP9" ]; 21 return @[ @"H264", @"VP8", @"VP9" ];
22 } 22 }
23 23
24 @interface ARDSettingsModel () { 24 @interface ARDSettingsModel () {
25 ARDSettingsStore *_settingsStore; 25 ARDSettingsStore *_settingsStore;
26 } 26 }
27 @end 27 @end
28 28
29 @implementation ARDSettingsModel 29 @implementation ARDSettingsModel
30 30
31 - (NSArray<NSString *> *)availableVideoResoultionsMediaConstraints { 31 - (NSArray<NSString *> *)availableVideoResolutions {
32 return videoResolutionsStaticValues(); 32 return videoResolutionsStaticValues();
33 } 33 }
34 34
35 - (NSString *)currentVideoResoultionConstraintFromStore { 35 - (NSString *)currentVideoResolutionSettingFromStore {
36 NSString *constraint = [[self settingsStore] videoResolutionConstraints]; 36 NSString *resolution = [[self settingsStore] videoResolution];
37 if (!constraint) { 37 if (!resolution) {
38 constraint = [self defaultVideoResolutionMediaConstraint]; 38 resolution = [self defaultVideoResolutionSetting];
39 // To ensure consistency add the default to the store. 39 // To ensure consistency add the default to the store.
40 [[self settingsStore] setVideoResolutionConstraints:constraint]; 40 [[self settingsStore] setVideoResolution:resolution];
41 } 41 }
42 return constraint; 42 return resolution;
43 } 43 }
44 44
45 - (BOOL)storeVideoResoultionConstraint:(NSString *)constraint { 45 - (BOOL)storeVideoResolutionSetting:(NSString *)resolution {
46 if (![[self availableVideoResoultionsMediaConstraints] containsObject:constrai nt]) { 46 if (![[self availableVideoResolutions] containsObject:resolution]) {
47 return NO; 47 return NO;
48 } 48 }
49 [[self settingsStore] setVideoResolutionConstraints:constraint]; 49 [[self settingsStore] setVideoResolution:resolution];
50 return YES; 50 return YES;
51 } 51 }
52 52
53 - (NSArray<NSString *> *)availableVideoCodecs { 53 - (NSArray<NSString *> *)availableVideoCodecs {
54 return videoCodecsStaticValues(); 54 return videoCodecsStaticValues();
55 } 55 }
56 56
57 - (NSString *)currentVideoCodecSettingFromStore { 57 - (NSString *)currentVideoCodecSettingFromStore {
58 NSString *videoCodec = [[self settingsStore] videoCodec]; 58 NSString *videoCodec = [[self settingsStore] videoCodec];
59 if (!videoCodec) { 59 if (!videoCodec) {
(...skipping 21 matching lines...) Expand all
81 81
82 #pragma mark - Testable 82 #pragma mark - Testable
83 83
84 - (ARDSettingsStore *)settingsStore { 84 - (ARDSettingsStore *)settingsStore {
85 if (!_settingsStore) { 85 if (!_settingsStore) {
86 _settingsStore = [[ARDSettingsStore alloc] init]; 86 _settingsStore = [[ARDSettingsStore alloc] init];
87 } 87 }
88 return _settingsStore; 88 return _settingsStore;
89 } 89 }
90 90
91 - (nullable NSString *)currentVideoResolutionWidthFromStore { 91 - (int)currentVideoResolutionWidthFromStore {
92 NSString *mediaConstraintFromStore = [self currentVideoResoultionConstraintFro mStore]; 92 NSString *resolution = [self currentVideoResolutionSettingFromStore];
93 93
94 return [self videoResolutionComponentAtIndex:0 inConstraintsString:mediaConstr aintFromStore]; 94 return [self videoResolutionComponentAtIndex:0 inString:resolution];
95 } 95 }
96 96
97 - (nullable NSString *)currentVideoResolutionHeightFromStore { 97 - (int)currentVideoResolutionHeightFromStore {
98 NSString *mediaConstraintFromStore = [self currentVideoResoultionConstraintFro mStore]; 98 NSString *resolution = [self currentVideoResolutionSettingFromStore];
99 return [self videoResolutionComponentAtIndex:1 inConstraintsString:mediaConstr aintFromStore]; 99 return [self videoResolutionComponentAtIndex:1 inString:resolution];
100 } 100 }
101 101
102 #pragma mark - 102 #pragma mark -
103 103
104 - (NSString *)defaultVideoResolutionMediaConstraint { 104 - (NSString *)defaultVideoResolutionSetting {
105 return videoResolutionsStaticValues()[0]; 105 return videoResolutionsStaticValues()[0];
106 } 106 }
107 107
108 - (nullable NSString *)videoResolutionComponentAtIndex:(int)index 108 - (int)videoResolutionComponentAtIndex:(int)index inString:(NSString *)resolutio n {
109 inConstraintsString:(NSString *)constraint {
110 if (index != 0 && index != 1) { 109 if (index != 0 && index != 1) {
111 return nil; 110 return 0;
112 } 111 }
113 NSArray *components = [constraint componentsSeparatedByString:@"x"]; 112 NSArray<NSString *> *components = [resolution componentsSeparatedByString:@"x" ];
114 if (components.count != 2) { 113 if (components.count != 2) {
115 return nil; 114 return 0;
116 } 115 }
117 return components[index]; 116 return components[index].intValue;
118 } 117 }
119 118
120 - (NSString *)defaultVideoCodecSetting { 119 - (NSString *)defaultVideoCodecSetting {
121 return videoCodecsStaticValues()[0]; 120 return videoCodecsStaticValues()[0];
122 } 121 }
123 122
124 #pragma mark - Conversion to RTCMediaConstraints
125
126 - (nullable NSDictionary *)currentMediaConstraintFromStoreAsRTCDictionary {
127 NSDictionary *mediaConstraintsDictionary = nil;
128
129 NSString *widthConstraint = [self currentVideoResolutionWidthFromStore];
130 NSString *heightConstraint = [self currentVideoResolutionHeightFromStore];
131 if (widthConstraint && heightConstraint) {
132 mediaConstraintsDictionary = @{
133 kRTCMediaConstraintsMinWidth : widthConstraint,
134 kRTCMediaConstraintsMinHeight : heightConstraint
135 };
136 }
137 return mediaConstraintsDictionary;
138 }
139
140 @end 123 @end
141 NS_ASSUME_NONNULL_END 124 NS_ASSUME_NONNULL_END
OLDNEW
« no previous file with comments | « webrtc/examples/objc/AppRTCMobile/ARDSettingsModel.h ('k') | webrtc/examples/objc/AppRTCMobile/ARDSettingsModel+Private.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698