Donald E Curtis | a873644 | 2015-08-05 15:48:13 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 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 <Foundation/Foundation.h> |
tkchin | 9eeb624 | 2016-04-27 01:54:20 -0700 | [diff] [blame] | 12 | |
| 13 | #import "WebRTC/RTCPeerConnection.h" |
| 14 | #import "WebRTC/RTCVideoTrack.h" |
Donald E Curtis | a873644 | 2015-08-05 15:48:13 -0700 | [diff] [blame] | 15 | |
| 16 | typedef NS_ENUM(NSInteger, ARDAppClientState) { |
| 17 | // Disconnected from servers. |
| 18 | kARDAppClientStateDisconnected, |
| 19 | // Connecting to servers. |
| 20 | kARDAppClientStateConnecting, |
| 21 | // Connected to servers. |
| 22 | kARDAppClientStateConnected, |
| 23 | }; |
| 24 | |
| 25 | @class ARDAppClient; |
| 26 | // The delegate is informed of pertinent events and will be called on the |
| 27 | // main queue. |
| 28 | @protocol ARDAppClientDelegate <NSObject> |
| 29 | |
| 30 | - (void)appClient:(ARDAppClient *)client |
| 31 | didChangeState:(ARDAppClientState)state; |
| 32 | |
| 33 | - (void)appClient:(ARDAppClient *)client |
hjon | 79858f8 | 2016-03-13 22:08:26 -0700 | [diff] [blame] | 34 | didChangeConnectionState:(RTCIceConnectionState)state; |
Donald E Curtis | a873644 | 2015-08-05 15:48:13 -0700 | [diff] [blame] | 35 | |
| 36 | - (void)appClient:(ARDAppClient *)client |
| 37 | didReceiveLocalVideoTrack:(RTCVideoTrack *)localVideoTrack; |
| 38 | |
| 39 | - (void)appClient:(ARDAppClient *)client |
| 40 | didReceiveRemoteVideoTrack:(RTCVideoTrack *)remoteVideoTrack; |
| 41 | |
| 42 | - (void)appClient:(ARDAppClient *)client |
| 43 | didError:(NSError *)error; |
| 44 | |
Zeke Chin | d332580 | 2015-08-14 11:00:02 -0700 | [diff] [blame] | 45 | - (void)appClient:(ARDAppClient *)client |
| 46 | didGetStats:(NSArray *)stats; |
| 47 | |
Donald E Curtis | a873644 | 2015-08-05 15:48:13 -0700 | [diff] [blame] | 48 | @end |
| 49 | |
| 50 | // Handles connections to the AppRTC server for a given room. Methods on this |
| 51 | // class should only be called from the main queue. |
| 52 | @interface ARDAppClient : NSObject |
| 53 | |
Zeke Chin | d332580 | 2015-08-14 11:00:02 -0700 | [diff] [blame] | 54 | // If |shouldGetStats| is true, stats will be reported in 1s intervals through |
| 55 | // the delegate. |
| 56 | @property(nonatomic, assign) BOOL shouldGetStats; |
Donald E Curtis | a873644 | 2015-08-05 15:48:13 -0700 | [diff] [blame] | 57 | @property(nonatomic, readonly) ARDAppClientState state; |
| 58 | @property(nonatomic, weak) id<ARDAppClientDelegate> delegate; |
| 59 | |
| 60 | // Convenience constructor since all expected use cases will need a delegate |
| 61 | // in order to receive remote tracks. |
| 62 | - (instancetype)initWithDelegate:(id<ARDAppClientDelegate>)delegate; |
| 63 | |
| 64 | // Establishes a connection with the AppRTC servers for the given room id. |
haysc | 913e645 | 2015-10-02 11:44:03 -0700 | [diff] [blame] | 65 | // If |isLoopback| is true, the call will connect to itself. |
| 66 | // If |isAudioOnly| is true, video will be disabled for the call. |
peah | 5085b0c | 2016-08-25 22:15:14 -0700 | [diff] [blame] | 67 | // If |shouldMakeAecDump| is true, an aecdump will be created for the call. |
Donald E Curtis | a873644 | 2015-08-05 15:48:13 -0700 | [diff] [blame] | 68 | - (void)connectToRoomWithId:(NSString *)roomId |
haysc | 913e645 | 2015-10-02 11:44:03 -0700 | [diff] [blame] | 69 | isLoopback:(BOOL)isLoopback |
peah | 5085b0c | 2016-08-25 22:15:14 -0700 | [diff] [blame] | 70 | isAudioOnly:(BOOL)isAudioOnly |
| 71 | shouldMakeAecDump:(BOOL)shouldMakeAecDump; |
Donald E Curtis | a873644 | 2015-08-05 15:48:13 -0700 | [diff] [blame] | 72 | |
| 73 | // Disconnects from the AppRTC servers and any connected clients. |
| 74 | - (void)disconnect; |
| 75 | |
| 76 | @end |