 Chromium Code Reviews
 Chromium Code Reviews Issue 2462623002:
  Add setting to AppRTCMobile for iOS, that can change capture resolution.  (Closed)
    
  
    Issue 2462623002:
  Add setting to AppRTCMobile for iOS, that can change capture resolution.  (Closed) 
  | OLD | NEW | 
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. | |
| 3 * | |
| 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 | |
| 6 * tree. An additional intellectual property rights grant can be found | |
| 7 * in the file PATENTS. All contributing project authors may | |
| 8 * be found in the AUTHORS file in the root of the source tree. | |
| 9 */ | |
| 10 | |
| 11 #import "ARDSettingsViewController.h" | |
| 12 #import "ARDMediaConstraintsModel.h" | |
| 13 | |
| 14 NS_ASSUME_NONNULL_BEGIN | |
| 15 @interface ARDSettingsViewController () { | |
| 16 ARDMediaConstraintsModel *_mediaConstraintsModel; | |
| 17 } | |
| 18 | |
| 19 @end | |
| 20 | |
| 21 @implementation ARDSettingsViewController | |
| 22 | |
| 23 - (instancetype)initWithStyle:(UITableViewStyle)style | |
| 24 mediaConstraintsModel:(ARDMediaConstraintsModel *)mediaConstraintsModel { | |
| 25 self = [super initWithStyle:style]; | |
| 26 if (self) { | |
| 27 _mediaConstraintsModel = mediaConstraintsModel; | |
| 28 } | |
| 29 return self; | |
| 30 } | |
| 31 | |
| 32 #pragma mark - View lifecycle | |
| 33 | |
| 34 - (void)viewDidLoad { | |
| 35 [super viewDidLoad]; | |
| 36 self.title = @"Settings"; | |
| 37 [self addDoneBarButton]; | |
| 38 } | |
| 39 | |
| 40 - (void)viewDidAppear:(BOOL)animated { | |
| 41 [super viewDidAppear:animated]; | |
| 42 [self selectCurrentlyStoredOrDefaultMediaConstraints]; | |
| 43 } | |
| 44 | |
| 45 - (NSArray<NSString *> *)mediaConstraintsArray { | |
| 
magjed_webrtc
2016/10/31 19:26:39
should this function be under 'View lifecycle'?
 
daniela-webrtc
2016/11/01 09:51:12
Done.
 | |
| 46 return _mediaConstraintsModel.availableVideoResoultionsMediaConstraints; | |
| 47 } | |
| 48 | |
| 49 #pragma mark - | |
| 
magjed_webrtc
2016/10/31 19:26:39
nit: Shouldn't this section have a name?
 
daniela-webrtc
2016/11/01 09:51:13
Not necessarily. The pragma marks are useful for l
 | |
| 50 | |
| 51 - (void)addDoneBarButton { | |
| 52 UIBarButtonItem *barItem = | |
| 53 [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItem Done | |
| 54 target:self | |
| 55 action:@selector(dismissModa lly:)]; | |
| 56 self.navigationItem.leftBarButtonItem = barItem; | |
| 57 } | |
| 58 | |
| 59 - (void)selectCurrentlyStoredOrDefaultMediaConstraints { | |
| 60 NSString *currentSelection = [_mediaConstraintsModel currentVideoResoultionCon straintFromStore]; | |
| 61 | |
| 62 NSUInteger indexOfSelection = [[self mediaConstraintsArray] indexOfObject:curr entSelection]; | |
| 63 NSIndexPath *pathToBeSelected = [NSIndexPath indexPathForRow:indexOfSelection inSection:0]; | |
| 64 [self.tableView selectRowAtIndexPath:pathToBeSelected | |
| 65 animated:NO | |
| 66 scrollPosition:UITableViewScrollPositionNone]; | |
| 67 // Manully invoke the delegate method because the previous invocation will not | |
| 
magjed_webrtc
2016/10/31 19:26:39
nit: dot at end of sentence.
 
daniela-webrtc
2016/11/01 09:51:12
Done.
 | |
| 68 [self tableView:self.tableView didSelectRowAtIndexPath:pathToBeSelected]; | |
| 69 } | |
| 70 | |
| 71 #pragma mark - Dismissall of view controller | |
| 
magjed_webrtc
2016/10/31 19:26:39
nit: dismissal
 
daniela-webrtc
2016/11/01 09:51:13
Done.
 | |
| 72 | |
| 73 - (void)dismissModally:(id)sender { | |
| 74 [self dismissViewControllerAnimated:YES completion:nil]; | |
| 75 } | |
| 76 | |
| 77 #pragma mark - Table view data source | |
| 78 | |
| 79 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { | |
| 80 return 1; | |
| 81 } | |
| 82 | |
| 83 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger )section { | |
| 84 return self.mediaConstraintsArray.count; | |
| 85 } | |
| 86 | |
| 87 #pragma mark - Tablev view delegate | |
| 
magjed_webrtc
2016/10/31 19:26:39
nit: Table
 
daniela-webrtc
2016/11/01 09:51:12
Done.
 | |
| 88 | |
| 89 - (BOOL)sectionIsMediaConstraints:(int)section { | |
| 90 return section == 0; | |
| 91 } | |
| 92 | |
| 93 - (BOOL)indexPathIsMediaConstraints:(NSIndexPath *)indexPath { | |
| 94 return [self sectionIsMediaConstraints:indexPath.section]; | |
| 95 } | |
| 96 | |
| 97 - (nullable NSString *)tableView:(UITableView *)tableView | |
| 98 titleForHeaderInSection:(NSInteger)section { | |
| 99 if ([self sectionIsMediaConstraints:section]) { | |
| 100 return @"Media constraints"; | |
| 101 } | |
| 102 return @""; | |
| 103 } | |
| 104 | |
| 105 - (UITableViewCell *)tableView:(UITableView *)tableView | |
| 
magjed_webrtc
2016/10/31 19:26:39
The following functions - are they standard boiler
 
daniela-webrtc
2016/11/01 09:51:12
Standard boiler plate :( And this is the bare mini
 | |
| 106 cellForRowAtIndexPath:(NSIndexPath *)indexPath { | |
| 107 if ([self indexPathIsMediaConstraints:indexPath]) { | |
| 108 return [self mediaConstraintsTableViewCellForTableView:tableView atIndexPath :indexPath]; | |
| 109 } | |
| 110 return [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault | |
| 111 reuseIdentifier:@"identifier"]; | |
| 112 } | |
| 113 | |
| 114 - (nullable NSIndexPath *)tableView:(UITableView *)tableView | |
| 115 willSelectRowAtIndexPath:(nonnull NSIndexPath *)indexPath { | |
| 116 if ([self indexPathIsMediaConstraints:indexPath]) { | |
| 117 return [self tableView:tableView willDeselectMediaConstraintsRowAtIndexPath: indexPath]; | |
| 118 } | |
| 119 return indexPath; | |
| 120 } | |
| 121 | |
| 122 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { | |
| 123 if ([self indexPathIsMediaConstraints:indexPath]) { | |
| 124 [self tableView:tableView didSelectMediaConstraintsCellAtIndexPath:indexPath ]; | |
| 125 } | |
| 126 } | |
| 127 | |
| 128 #pragma mark - Table view delegate(Media Constraints) | |
| 129 | |
| 130 - (UITableViewCell *)mediaConstraintsTableViewCellForTableView:(UITableView *)ta bleView | |
| 131 atIndexPath:(NSIndexPath *)in dexPath { | |
| 132 NSString *dequeueIdentifier = @"ARDSettingsMediaConstraintsViewCellIdentifier" ; | |
| 133 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:dequeueId entifier]; | |
| 134 if (!cell) { | |
| 135 cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault | |
| 136 reuseIdentifier:dequeueIdentifier]; | |
| 137 } | |
| 138 cell.textLabel.text = self.mediaConstraintsArray[indexPath.row]; | |
| 139 return cell; | |
| 140 } | |
| 141 | |
| 142 - (void)tableView:(UITableView *)tableView | |
| 143 didSelectMediaConstraintsCellAtIndexPath:(NSIndexPath *)indexPath { | |
| 144 UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; | |
| 145 cell.accessoryType = UITableViewCellAccessoryCheckmark; | |
| 146 | |
| 147 NSString *mediaConstraintsString = self.mediaConstraintsArray[indexPath.row]; | |
| 148 [_mediaConstraintsModel storeVideoResoultionConstraint:mediaConstraintsString] ; | |
| 149 } | |
| 150 | |
| 151 - (NSIndexPath *)tableView:(UITableView *)tableView | |
| 152 willDeselectMediaConstraintsRowAtIndexPath:(NSIndexPath *)indexPath { | |
| 153 NSIndexPath *oldSelection = [tableView indexPathForSelectedRow]; | |
| 154 UITableViewCell *cell = [tableView cellForRowAtIndexPath:oldSelection]; | |
| 155 cell.accessoryType = UITableViewCellAccessoryNone; | |
| 156 return indexPath; | |
| 157 } | |
| 158 | |
| 159 @end | |
| 160 NS_ASSUME_NONNULL_END | |
| OLD | NEW |