iAppRTCDemo: WebSocket based signaling.

Updates the iOS code to use the new signaling model. Removes old Channel API
code. Note that this no longer logs messages to UI. UI update forthcoming.

BUG=
R=glaznev@webrtc.org, jiayl@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/35369004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@7852 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
tkchin@webrtc.org
2014-12-09 19:32:35 +00:00
parent 0babb4a4e6
commit 87776a8935
26 changed files with 3481 additions and 1201 deletions

View File

@ -28,7 +28,7 @@
#import "APPRTCViewController.h"
#import <AVFoundation/AVFoundation.h>
#import "APPRTCConnectionManager.h"
#import "ARDAppClient.h"
#import "RTCNSGLVideoView.h"
#import "RTCVideoTrack.h"
@ -222,26 +222,16 @@ static NSUInteger const kLogViewHeight = 280;
@end
@interface APPRTCViewController ()
<APPRTCConnectionManagerDelegate, APPRTCMainViewDelegate, APPRTCLogger>
<ARDAppClientDelegate, APPRTCMainViewDelegate>
@property(nonatomic, readonly) APPRTCMainView* mainView;
@end
@implementation APPRTCViewController {
APPRTCConnectionManager* _connectionManager;
ARDAppClient* _client;
RTCVideoTrack* _localVideoTrack;
RTCVideoTrack* _remoteVideoTrack;
}
- (instancetype)initWithNibName:(NSString*)nibName
bundle:(NSBundle*)bundle {
if (self = [super initWithNibName:nibName bundle:bundle]) {
_connectionManager =
[[APPRTCConnectionManager alloc] initWithDelegate:self
logger:self];
}
return self;
}
- (void)dealloc {
[self disconnect];
}
@ -257,43 +247,50 @@ static NSUInteger const kLogViewHeight = 280;
[self disconnect];
}
#pragma mark - APPRTCConnectionManagerDelegate
#pragma mark - ARDAppClientDelegate
- (void)connectionManager:(APPRTCConnectionManager*)manager
didReceiveLocalVideoTrack:(RTCVideoTrack*)localVideoTrack {
- (void)appClient:(ARDAppClient *)client
didChangeState:(ARDAppClientState)state {
switch (state) {
case kARDAppClientStateConnected:
NSLog(@"Client connected.");
break;
case kARDAppClientStateConnecting:
NSLog(@"Client connecting.");
break;
case kARDAppClientStateDisconnected:
NSLog(@"Client disconnected.");
[self resetUI];
_client = nil;
break;
}
}
- (void)appClient:(ARDAppClient *)client
didReceiveLocalVideoTrack:(RTCVideoTrack *)localVideoTrack {
_localVideoTrack = localVideoTrack;
}
- (void)connectionManager:(APPRTCConnectionManager*)manager
didReceiveRemoteVideoTrack:(RTCVideoTrack*)remoteVideoTrack {
- (void)appClient:(ARDAppClient *)client
didReceiveRemoteVideoTrack:(RTCVideoTrack *)remoteVideoTrack {
_remoteVideoTrack = remoteVideoTrack;
[_remoteVideoTrack addRenderer:self.mainView.remoteVideoView];
}
- (void)connectionManagerDidReceiveHangup:(APPRTCConnectionManager*)manager {
[self showAlertWithMessage:@"Remote closed connection"];
- (void)appClient:(ARDAppClient *)client
didError:(NSError *)error {
[self showAlertWithMessage:[NSString stringWithFormat:@"%@", error]];
[self disconnect];
}
- (void)connectionManager:(APPRTCConnectionManager*)manager
didErrorWithMessage:(NSString*)message {
[self showAlertWithMessage:message];
[self disconnect];
}
#pragma mark - APPRTCLogger
- (void)logMessage:(NSString*)message {
[self.mainView displayLogMessage:message];
}
#pragma mark - APPRTCMainViewDelegate
- (void)appRTCMainView:(APPRTCMainView*)mainView
didEnterRoomId:(NSString*)roomId {
NSString* urlString =
[NSString stringWithFormat:@"https://apprtc.appspot.com/?r=%@", roomId];
[_connectionManager connectToRoomWithURL:[NSURL URLWithString:urlString]];
[_client disconnect];
ARDAppClient *client = [[ARDAppClient alloc] initWithDelegate:self];
[client connectToRoomWithId:roomId options:nil];
_client = client;
}
#pragma mark - Private
@ -308,11 +305,15 @@ static NSUInteger const kLogViewHeight = 280;
[alert runModal];
}
- (void)disconnect {
- (void)resetUI {
[_remoteVideoTrack removeRenderer:self.mainView.remoteVideoView];
_remoteVideoTrack = nil;
[self.mainView.remoteVideoView renderFrame:nil];
[_connectionManager disconnect];
}
- (void)disconnect {
[self resetUI];
[_client disconnect];
}
@end