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

Unified Diff: webrtc/examples/objc/AppRTCDemo/ios/ARDMainView.m

Issue 1334003002: Loopback mode for AppRTCDemo on iOS. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Review Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/examples/objc/AppRTCDemo/ios/ARDMainView.m
diff --git a/webrtc/examples/objc/AppRTCDemo/ios/ARDMainView.m b/webrtc/examples/objc/AppRTCDemo/ios/ARDMainView.m
index 295b59c5541e38852f61e320a48add4aade16e14..98046aa6efe837d01d33759877a70385d1ae75e9 100644
--- a/webrtc/examples/objc/AppRTCDemo/ios/ARDMainView.m
+++ b/webrtc/examples/objc/AppRTCDemo/ios/ARDMainView.m
@@ -18,6 +18,7 @@ static CGFloat const kStatusBarHeight = 20;
static CGFloat const kRoomTextButtonSize = 40;
static CGFloat const kRoomTextFieldHeight = 40;
static CGFloat const kRoomTextFieldMargin = 8;
+static CGFloat const kCallControlMargin = 8;
static CGFloat const kAppLabelHeight = 20;
@class ARDRoomTextField;
@@ -125,6 +126,9 @@ static CGFloat const kAppLabelHeight = 20;
@implementation ARDMainView {
UILabel *_appLabel;
ARDRoomTextField *_roomText;
+ UISwitch *_audioOnlySwitch;
+ UILabel *_audioOnlyLabel;
+ UIButton *_loopbackButton;
}
@synthesize delegate = _delegate;
@@ -142,6 +146,28 @@ static CGFloat const kAppLabelHeight = 20;
_roomText.delegate = self;
[self addSubview:_roomText];
+ _audioOnlySwitch = [[UISwitch alloc] initWithFrame:CGRectZero];
+ [_audioOnlySwitch sizeToFit];
+ [self addSubview:_audioOnlySwitch];
+
+ _audioOnlyLabel = [[UILabel alloc] initWithFrame:CGRectZero];
tkchin_webrtc 2015/09/11 17:53:53 I know it's a demo app, but can we make this prett
Chuck 2015/09/28 16:26:40 Made a couple changes to help the new controls fit
+ _audioOnlyLabel.text = @"audio only";
+ _audioOnlyLabel.font = [UIFont fontWithName:@"Roboto" size:26];
+ _audioOnlyLabel.textColor = [UIColor colorWithWhite:0 alpha:.6];
+ [_audioOnlyLabel sizeToFit];
+ [self addSubview:_audioOnlyLabel];
+
+ _loopbackButton = [[UIButton alloc] initWithFrame:CGRectZero];
+ [_loopbackButton setTitle:@"loopback call" forState:UIControlStateNormal];
+ _loopbackButton.titleLabel.font = [UIFont fontWithName:@"Roboto" size:26];
+ [_loopbackButton setTitleColor:[UIColor colorWithWhite:0 alpha:.6]
+ forState:UIControlStateNormal];
+ [_loopbackButton sizeToFit];
+ [_loopbackButton addTarget:self
+ action:@selector(onLoopback:)
+ forControlEvents:UIControlEventTouchUpInside];
+ [self addSubview:_loopbackButton];
+
self.backgroundColor = [UIColor whiteColor];
}
return self;
@@ -156,13 +182,49 @@ static CGFloat const kAppLabelHeight = 20;
roomTextWidth,
roomTextHeight);
_appLabel.center = CGPointMake(CGRectGetMidX(bounds), CGRectGetMidY(bounds));
+
tkchin_webrtc 2015/09/11 17:53:53 nit: fix indentation + remove unneeded line breaks
Chuck 2015/09/28 16:26:40 Done.
+
+ CGFloat audioOnlyTop =
+ CGRectGetMaxY(_roomText.frame) + kCallControlMargin * 2;
+ CGRect audioOnlyRect = CGRectMake(kCallControlMargin,
+ audioOnlyTop,
+ _audioOnlySwitch.frame.size.width,
+ _audioOnlySwitch.frame.size.height);
+
+ _audioOnlySwitch.frame = audioOnlyRect;
+
+ CGFloat audioOnlyLabelCenterX = CGRectGetMaxX(audioOnlyRect) +
+ kCallControlMargin + _audioOnlyLabel.frame.size.width / 2;
+
+ _audioOnlyLabel.center = CGPointMake(audioOnlyLabelCenterX,
+ CGRectGetMidY(audioOnlyRect));
+
+ CGFloat loopbackTop = CGRectGetMaxY(audioOnlyRect) + kCallControlMargin * 2;
+ _loopbackButton.frame = CGRectMake(kCallControlMargin * 2,
+ loopbackTop,
+ _loopbackButton.frame.size.width,
+ _loopbackButton.frame.size.height);
}
#pragma mark - ARDRoomTextFieldDelegate
- (void)roomTextField:(ARDRoomTextField *)roomTextField
didInputRoom:(NSString *)room {
- [_delegate mainView:self didInputRoom:room];
+ [_delegate mainView:self
+ didInputRoom:room
+ isLoopback:NO
+ isAudioOnly:_audioOnlySwitch.isOn];
+}
+
+#pragma mark - Private
+
+- (void)onLoopback:(id)sender {
+ NSString *room = [[NSUUID UUID] UUIDString];
+ room = [room stringByReplacingOccurrencesOfString:@"-" withString:@""];
+ [_delegate mainView:self
+ didInputRoom:room
+ isLoopback:YES
+ isAudioOnly:_audioOnlySwitch.isOn];
}
@end

Powered by Google App Engine
This is Rietveld 408576698