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