Rename media constraints model and store.
ARDMediaConstraintsModel -> ARDSettingsModel ARDMediaConstraintsSettingsStore -> ARDSettingsStore ARDMediaConstraintsModelTests -> ARDSettingsModelTests Both classes will be used to storing other settings as well, so we need a more appropriate naming. BUG=webrtc:6654 Review-Url: https://codereview.webrtc.org/2479153002 Cr-Commit-Position: refs/heads/master@{#15002}
This commit is contained in:
@ -241,10 +241,11 @@ if (is_ios || (is_mac && target_cpu != "x86")) {
|
||||
"objc/AppRTCMobile/ios/ARDMainView.m",
|
||||
"objc/AppRTCMobile/ios/ARDMainViewController.h",
|
||||
"objc/AppRTCMobile/ios/ARDMainViewController.m",
|
||||
"objc/AppRTCMobile/ios/ARDMediaConstraintsModel.h",
|
||||
"objc/AppRTCMobile/ios/ARDMediaConstraintsModel.m",
|
||||
"objc/AppRTCMobile/ios/ARDMediaConstraintsSettingsStore.h",
|
||||
"objc/AppRTCMobile/ios/ARDMediaConstraintsSettingsStore.m",
|
||||
"objc/AppRTCMobile/ios/ARDSettingsModel+Private.h",
|
||||
"objc/AppRTCMobile/ios/ARDSettingsModel.h",
|
||||
"objc/AppRTCMobile/ios/ARDSettingsModel.m",
|
||||
"objc/AppRTCMobile/ios/ARDSettingsStore.h",
|
||||
"objc/AppRTCMobile/ios/ARDSettingsStore.m",
|
||||
"objc/AppRTCMobile/ios/ARDSettingsViewController.h",
|
||||
"objc/AppRTCMobile/ios/ARDSettingsViewController.m",
|
||||
"objc/AppRTCMobile/ios/ARDStatsView.h",
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
|
||||
#import "ARDAppClient.h"
|
||||
#import "ARDMainView.h"
|
||||
#import "ARDMediaConstraintsModel.h"
|
||||
#import "ARDSettingsModel.h"
|
||||
#import "ARDSettingsViewController.h"
|
||||
#import "ARDVideoCallViewController.h"
|
||||
|
||||
@ -173,7 +173,8 @@ static NSString *const barButtonImageString = @"ic_settings_black_24dp.png";
|
||||
- (void)showSettings:(id)sender {
|
||||
ARDSettingsViewController *settingsController =
|
||||
[[ARDSettingsViewController alloc] initWithStyle:UITableViewStyleGrouped
|
||||
mediaConstraintsModel:[[ARDMediaConstraintsModel alloc] init]];
|
||||
settingsModel:[[ARDSettingsModel alloc] init]];
|
||||
|
||||
UINavigationController *navigationController =
|
||||
[[UINavigationController alloc] initWithRootViewController:settingsController];
|
||||
[self presentViewControllerAsModal:navigationController];
|
||||
|
||||
@ -9,13 +9,13 @@
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "ARDMediaConstraintsModel.h"
|
||||
#import "ARDSettingsModel.h"
|
||||
|
||||
@class ARDMediaConstraintsSettingsStore;
|
||||
@class ARDSettingsStore;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@interface ARDMediaConstraintsModel ()
|
||||
- (ARDMediaConstraintsSettingsStore *)settingsStore;
|
||||
@interface ARDSettingsModel ()
|
||||
- (ARDSettingsStore *)settingsStore;
|
||||
- (nullable NSString *)currentVideoResolutionWidthFromStore;
|
||||
- (nullable NSString *)currentVideoResolutionHeightFromStore;
|
||||
@end
|
||||
@ -12,16 +12,16 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
/**
|
||||
* Model class for user defined media constraints.
|
||||
* Model class for user defined settings.
|
||||
*
|
||||
* Currently used for streaming media constraints only.
|
||||
* Currently used for streaming media constraints and bitrate only.
|
||||
* In future audio media constraints support can be added as well.
|
||||
* Offers list of avaliable video resolutions that can construct streaming media constraint.
|
||||
* Exposes methods for reading and storing media constraints from persistent store.
|
||||
* Also translates current user defined media constraint into RTCMediaConstraints
|
||||
* dictionary.
|
||||
*/
|
||||
@interface ARDMediaConstraintsModel : NSObject
|
||||
@interface ARDSettingsModel : NSObject
|
||||
|
||||
/**
|
||||
* Returns array of available capture resoultions.
|
||||
@ -55,6 +55,5 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
* @return NSDictionary with RTC width and height parameters
|
||||
*/
|
||||
- (nullable NSDictionary *)currentMediaConstraintFromStoreAsRTCDictionary;
|
||||
|
||||
@end
|
||||
NS_ASSUME_NONNULL_END
|
||||
@ -8,8 +8,8 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#import "ARDMediaConstraintsModel+Private.h"
|
||||
#import "ARDMediaConstraintsSettingsStore.h"
|
||||
#import "ARDSettingsModel+Private.h"
|
||||
#import "ARDSettingsStore.h"
|
||||
#import "WebRTC/RTCMediaConstraints.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@ -17,12 +17,12 @@ static NSArray<NSString *> *videoResolutionsStaticValues() {
|
||||
return @[ @"640x480", @"960x540", @"1280x720" ];
|
||||
}
|
||||
|
||||
@interface ARDMediaConstraintsModel () {
|
||||
ARDMediaConstraintsSettingsStore *_settingsStore;
|
||||
@interface ARDSettingsModel () {
|
||||
ARDSettingsStore *_settingsStore;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation ARDMediaConstraintsModel
|
||||
@implementation ARDSettingsModel
|
||||
|
||||
- (NSArray<NSString *> *)availableVideoResoultionsMediaConstraints {
|
||||
return videoResolutionsStaticValues();
|
||||
@ -48,9 +48,9 @@ static NSArray<NSString *> *videoResolutionsStaticValues() {
|
||||
|
||||
#pragma mark - Testable
|
||||
|
||||
- (ARDMediaConstraintsSettingsStore *)settingsStore {
|
||||
- (ARDSettingsStore *)settingsStore {
|
||||
if (!_settingsStore) {
|
||||
_settingsStore = [[ARDMediaConstraintsSettingsStore alloc] init];
|
||||
_settingsStore = [[ARDSettingsStore alloc] init];
|
||||
}
|
||||
return _settingsStore;
|
||||
}
|
||||
@ -13,11 +13,11 @@
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
* Light-weight persistent store for media constraints user settings.
|
||||
* Light-weight persistent store for user settings.
|
||||
*
|
||||
* It will persist between application launches and application updates.
|
||||
*/
|
||||
@interface ARDMediaConstraintsSettingsStore : NSObject
|
||||
@interface ARDSettingsStore : NSObject
|
||||
|
||||
/**
|
||||
* Returns current video resolution media constraint string stored in the store.
|
||||
@ -8,13 +8,13 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#import "ARDMediaConstraintsSettingsStore.h"
|
||||
#import "ARDSettingsStore.h"
|
||||
|
||||
static NSString *const kUserDefaultsMediaConstraintsKey =
|
||||
@"rtc_video_resolution_media_constraints_key";
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@implementation ARDMediaConstraintsSettingsStore
|
||||
@implementation ARDSettingsStore
|
||||
|
||||
- (nullable NSString *)videoResolutionConstraintsSetting {
|
||||
return [[NSUserDefaults standardUserDefaults] objectForKey:kUserDefaultsMediaConstraintsKey];
|
||||
@ -10,7 +10,7 @@
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@class ARDMediaConstraintsModel;
|
||||
@class ARDSettingsModel;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
/**
|
||||
@ -22,10 +22,10 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
* Creates new instance.
|
||||
*
|
||||
* @param style the table view style that should be used
|
||||
* @param mediaConstraintsModel model class for the media constraints settings.
|
||||
* @param settingsModel model class for the user settings.
|
||||
*/
|
||||
- (instancetype)initWithStyle:(UITableViewStyle)style
|
||||
mediaConstraintsModel:(ARDMediaConstraintsModel *)mediaConstraintsModel;
|
||||
settingsModel:(ARDSettingsModel *)settingsModel;
|
||||
|
||||
#pragma mark - Unavailable
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
*/
|
||||
|
||||
#import "ARDSettingsViewController.h"
|
||||
#import "ARDMediaConstraintsModel.h"
|
||||
#import "ARDSettingsModel.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@ -19,7 +19,7 @@ typedef NS_ENUM(int, ARDSettingsSections) {
|
||||
};
|
||||
|
||||
@interface ARDSettingsViewController () {
|
||||
ARDMediaConstraintsModel *_mediaConstraintsModel;
|
||||
ARDSettingsModel *_settingsModel;
|
||||
}
|
||||
|
||||
@end
|
||||
@ -27,10 +27,10 @@ typedef NS_ENUM(int, ARDSettingsSections) {
|
||||
@implementation ARDSettingsViewController
|
||||
|
||||
- (instancetype)initWithStyle:(UITableViewStyle)style
|
||||
mediaConstraintsModel:(ARDMediaConstraintsModel *)mediaConstraintsModel {
|
||||
settingsModel:(ARDSettingsModel *)settingsModel {
|
||||
self = [super initWithStyle:style];
|
||||
if (self) {
|
||||
_mediaConstraintsModel = mediaConstraintsModel;
|
||||
_settingsModel = settingsModel;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@ -51,7 +51,7 @@ typedef NS_ENUM(int, ARDSettingsSections) {
|
||||
#pragma mark - Data source
|
||||
|
||||
- (NSArray<NSString *> *)mediaConstraintsArray {
|
||||
return _mediaConstraintsModel.availableVideoResoultionsMediaConstraints;
|
||||
return _settingsModel.availableVideoResoultionsMediaConstraints;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
@ -65,7 +65,7 @@ typedef NS_ENUM(int, ARDSettingsSections) {
|
||||
}
|
||||
|
||||
- (void)selectCurrentlyStoredOrDefaultMediaConstraints {
|
||||
NSString *currentSelection = [_mediaConstraintsModel currentVideoResoultionConstraintFromStore];
|
||||
NSString *currentSelection = [_settingsModel currentVideoResoultionConstraintFromStore];
|
||||
|
||||
NSUInteger indexOfSelection = [[self mediaConstraintsArray] indexOfObject:currentSelection];
|
||||
NSIndexPath *pathToBeSelected = [NSIndexPath indexPathForRow:indexOfSelection inSection:0];
|
||||
@ -177,7 +177,7 @@ typedef NS_ENUM(int, ARDSettingsSections) {
|
||||
cell.accessoryType = UITableViewCellAccessoryCheckmark;
|
||||
|
||||
NSString *mediaConstraintsString = self.mediaConstraintsArray[indexPath.row];
|
||||
[_mediaConstraintsModel storeVideoResoultionConstraint:mediaConstraintsString];
|
||||
[_settingsModel storeVideoResoultionConstraint:mediaConstraintsString];
|
||||
}
|
||||
|
||||
- (NSIndexPath *)tableView:(UITableView *)tableView
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
#import "webrtc/modules/audio_device/ios/objc/RTCAudioSession.h"
|
||||
|
||||
#import "ARDAppClient.h"
|
||||
#import "ARDMediaConstraintsModel.h"
|
||||
#import "ARDSettingsModel.h"
|
||||
#import "ARDVideoCallView.h"
|
||||
#import "WebRTC/RTCAVFoundationVideoSource.h"
|
||||
#import "WebRTC/RTCDispatcher.h"
|
||||
@ -46,10 +46,10 @@
|
||||
if (self = [super init]) {
|
||||
_delegate = delegate;
|
||||
_client = [[ARDAppClient alloc] initWithDelegate:self];
|
||||
ARDMediaConstraintsModel *mediaConstraintsModel = [[ARDMediaConstraintsModel alloc] init];
|
||||
ARDSettingsModel *settingsModel = [[ARDSettingsModel alloc] init];
|
||||
RTCMediaConstraints *cameraConstraints = [[RTCMediaConstraints alloc]
|
||||
initWithMandatoryConstraints:nil
|
||||
optionalConstraints:[mediaConstraintsModel
|
||||
optionalConstraints:[settingsModel
|
||||
currentMediaConstraintFromStoreAsRTCDictionary]];
|
||||
[_client setCameraConstraints:cameraConstraints];
|
||||
[_client connectToRoomWithId:room
|
||||
|
||||
@ -10,14 +10,14 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <OCMock/OCMock.h>
|
||||
#import "ARDMediaConstraintsModel+Private.h"
|
||||
#import "ARDMediaConstraintsSettingsStore.h"
|
||||
#import "ARDSettingsModel+Private.h"
|
||||
#import "ARDSettingsStore.h"
|
||||
#import "WebRTC/RTCMediaConstraints.h"
|
||||
#include "webrtc/base/gunit.h"
|
||||
|
||||
|
||||
@interface ARDMediaConstraintsModelTests : NSObject {
|
||||
ARDMediaConstraintsModel *_model;
|
||||
@interface ARDSettingsModelTests : NSObject {
|
||||
ARDSettingsModel *_model;
|
||||
}
|
||||
|
||||
- (void)testStoringInavlidConstraintReturnsNo;
|
||||
@ -27,18 +27,18 @@
|
||||
|
||||
@end
|
||||
|
||||
@implementation ARDMediaConstraintsModelTests
|
||||
@implementation ARDSettingsModelTests
|
||||
|
||||
- (instancetype)init {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_model = [[ARDMediaConstraintsModel alloc] init];
|
||||
_model = [[ARDSettingsModel alloc] init];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)setupMockStoreWithMediaConstraintString:(NSString *)constraintString {
|
||||
id storeMock = [OCMockObject mockForClass:[ARDMediaConstraintsSettingsStore class]];
|
||||
id storeMock = [OCMockObject mockForClass:[ARDSettingsStore class]];
|
||||
[([[storeMock stub] andReturn:constraintString]) videoResolutionConstraintsSetting];
|
||||
|
||||
id partialMock = [OCMockObject partialMockForObject:_model];
|
||||
@ -116,43 +116,43 @@
|
||||
}
|
||||
@end
|
||||
|
||||
class ARDMediaConstraintsModelTest : public ::testing::Test {
|
||||
class ARDSettingsModelTest : public ::testing::Test {
|
||||
protected:
|
||||
ARDMediaConstraintsModelTests *test;
|
||||
ARDMediaConstraintsModelTest() { test = [[ARDMediaConstraintsModelTests alloc] init]; }
|
||||
ARDSettingsModelTests *test;
|
||||
ARDSettingsModelTest() { test = [[ARDSettingsModelTests alloc] init]; }
|
||||
};
|
||||
|
||||
TEST_F(ARDMediaConstraintsModelTest, DefaultMediaFromStore) {
|
||||
TEST_F(ARDSettingsModelTest, DefaultMediaFromStore) {
|
||||
@autoreleasepool {
|
||||
[test testDefaultMediaFromStore];
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(ARDMediaConstraintsModelTest, StoringInvalidConstraintsReturnsNo) {
|
||||
TEST_F(ARDSettingsModelTest, StoringInvalidConstraintsReturnsNo) {
|
||||
@autoreleasepool {
|
||||
[test testStoringInavlidConstraintReturnsNo];
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(ARDMediaConstraintsModelTest, WidthConstraintFromStore) {
|
||||
TEST_F(ARDSettingsModelTest, WidthConstraintFromStore) {
|
||||
@autoreleasepool {
|
||||
[test testWidthConstraintFromStore];
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(ARDMediaConstraintsModelTest, HeightConstraintFromStore) {
|
||||
TEST_F(ARDSettingsModelTest, HeightConstraintFromStore) {
|
||||
@autoreleasepool {
|
||||
[test testHeightConstraintFromStore];
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(ARDMediaConstraintsModelTest, ConstratintIsNil) {
|
||||
TEST_F(ARDSettingsModelTest, ConstratintIsNil) {
|
||||
@autoreleasepool {
|
||||
[test testConstraintComponentIsNilWhenInvalidConstraintString];
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(ARDMediaConstraintsModelTest, DictionaryIsNil) {
|
||||
TEST_F(ARDSettingsModelTest, DictionaryIsNil) {
|
||||
@autoreleasepool {
|
||||
[test testConstraintsDictionaryIsNilWhenInvalidConstraintString];
|
||||
}
|
||||
Reference in New Issue
Block a user