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 |
(...skipping 14 matching lines...) Expand all Loading... |
25 self.view = mainView; | 25 self.view = mainView; |
26 } | 26 } |
27 | 27 |
28 - (void)applicationWillResignActive:(UIApplication *)application { | 28 - (void)applicationWillResignActive:(UIApplication *)application { |
29 // Terminate any calls when we aren't active. | 29 // Terminate any calls when we aren't active. |
30 [self dismissViewControllerAnimated:NO completion:nil]; | 30 [self dismissViewControllerAnimated:NO completion:nil]; |
31 } | 31 } |
32 | 32 |
33 #pragma mark - ARDMainViewDelegate | 33 #pragma mark - ARDMainViewDelegate |
34 | 34 |
35 - (void)mainView:(ARDMainView *)mainView didInputRoom:(NSString *)room { | 35 - (void)mainView:(ARDMainView *)mainView |
| 36 didInputRoom:(NSString *)room |
| 37 isLoopback:(BOOL)isLoopback |
| 38 isAudioOnly:(BOOL)isAudioOnly { |
36 if (!room.length) { | 39 if (!room.length) { |
| 40 [self showAlertWithMessage:@"Missing room name."]; |
37 return; | 41 return; |
38 } | 42 } |
39 // Trim whitespaces. | 43 // Trim whitespaces. |
40 NSCharacterSet *whitespaceSet = [NSCharacterSet whitespaceCharacterSet]; | 44 NSCharacterSet *whitespaceSet = [NSCharacterSet whitespaceCharacterSet]; |
41 NSString *trimmedRoom = [room stringByTrimmingCharactersInSet:whitespaceSet]; | 45 NSString *trimmedRoom = [room stringByTrimmingCharactersInSet:whitespaceSet]; |
42 | 46 |
43 // Check that room name is valid. | 47 // Check that room name is valid. |
44 NSError *error = nil; | 48 NSError *error = nil; |
45 NSRegularExpressionOptions options = NSRegularExpressionCaseInsensitive; | 49 NSRegularExpressionOptions options = NSRegularExpressionCaseInsensitive; |
46 NSRegularExpression *regex = | 50 NSRegularExpression *regex = |
47 [NSRegularExpression regularExpressionWithPattern:@"\\w+" | 51 [NSRegularExpression regularExpressionWithPattern:@"\\w+" |
48 options:options | 52 options:options |
49 error:&error]; | 53 error:&error]; |
50 if (error) { | 54 if (error) { |
51 [self showAlertWithMessage:error.localizedDescription]; | 55 [self showAlertWithMessage:error.localizedDescription]; |
52 return; | 56 return; |
53 } | 57 } |
54 NSRange matchRange = | 58 NSRange matchRange = |
55 [regex rangeOfFirstMatchInString:trimmedRoom | 59 [regex rangeOfFirstMatchInString:trimmedRoom |
56 options:0 | 60 options:0 |
57 range:NSMakeRange(0, trimmedRoom.length)]; | 61 range:NSMakeRange(0, trimmedRoom.length)]; |
58 if (matchRange.location == NSNotFound || | 62 if (matchRange.location == NSNotFound || |
59 matchRange.length != trimmedRoom.length) { | 63 matchRange.length != trimmedRoom.length) { |
60 [self showAlertWithMessage:@"Invalid room name."]; | 64 [self showAlertWithMessage:@"Invalid room name."]; |
61 return; | 65 return; |
62 } | 66 } |
63 | 67 |
64 // Kick off the video call. | 68 // Kick off the video call. |
65 ARDVideoCallViewController *videoCallViewController = | 69 ARDVideoCallViewController *videoCallViewController = |
66 [[ARDVideoCallViewController alloc] initForRoom:trimmedRoom]; | 70 [[ARDVideoCallViewController alloc] initForRoom:trimmedRoom |
| 71 isLoopback:isLoopback |
| 72 isAudioOnly:isAudioOnly]; |
67 videoCallViewController.modalTransitionStyle = | 73 videoCallViewController.modalTransitionStyle = |
68 UIModalTransitionStyleCrossDissolve; | 74 UIModalTransitionStyleCrossDissolve; |
69 [self presentViewController:videoCallViewController | 75 [self presentViewController:videoCallViewController |
70 animated:YES | 76 animated:YES |
71 completion:nil]; | 77 completion:nil]; |
72 } | 78 } |
73 | 79 |
74 #pragma mark - Private | 80 #pragma mark - Private |
75 | 81 |
76 - (void)showAlertWithMessage:(NSString*)message { | 82 - (void)showAlertWithMessage:(NSString*)message { |
77 UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:nil | 83 UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:nil |
78 message:message | 84 message:message |
79 delegate:nil | 85 delegate:nil |
80 cancelButtonTitle:@"OK" | 86 cancelButtonTitle:@"OK" |
81 otherButtonTitles:nil]; | 87 otherButtonTitles:nil]; |
82 [alertView show]; | 88 [alertView show]; |
83 } | 89 } |
84 | 90 |
85 @end | 91 @end |
OLD | NEW |