blob: 0feb01586aab2a0760267f591c3012d6a477886b [file] [log] [blame]
Donald E Curtisa8736442015-08-05 15:48:13 -07001/*
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>
tkchin9eeb6242016-04-27 01:54:20 -070012
13#import "WebRTC/RTCPeerConnection.h"
14#import "WebRTC/RTCVideoTrack.h"
Donald E Curtisa8736442015-08-05 15:48:13 -070015
16typedef 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;
denicijad17d5362016-11-02 02:56:09 -070026@class RTCMediaConstraints;
27
Donald E Curtisa8736442015-08-05 15:48:13 -070028// The delegate is informed of pertinent events and will be called on the
29// main queue.
30@protocol ARDAppClientDelegate <NSObject>
31
32- (void)appClient:(ARDAppClient *)client
33 didChangeState:(ARDAppClientState)state;
34
35- (void)appClient:(ARDAppClient *)client
hjon79858f82016-03-13 22:08:26 -070036 didChangeConnectionState:(RTCIceConnectionState)state;
Donald E Curtisa8736442015-08-05 15:48:13 -070037
38- (void)appClient:(ARDAppClient *)client
39 didReceiveLocalVideoTrack:(RTCVideoTrack *)localVideoTrack;
40
41- (void)appClient:(ARDAppClient *)client
42 didReceiveRemoteVideoTrack:(RTCVideoTrack *)remoteVideoTrack;
43
44- (void)appClient:(ARDAppClient *)client
45 didError:(NSError *)error;
46
Zeke Chind3325802015-08-14 11:00:02 -070047- (void)appClient:(ARDAppClient *)client
48 didGetStats:(NSArray *)stats;
49
Donald E Curtisa8736442015-08-05 15:48:13 -070050@end
51
52// Handles connections to the AppRTC server for a given room. Methods on this
53// class should only be called from the main queue.
54@interface ARDAppClient : NSObject
55
Zeke Chind3325802015-08-14 11:00:02 -070056// If |shouldGetStats| is true, stats will be reported in 1s intervals through
57// the delegate.
58@property(nonatomic, assign) BOOL shouldGetStats;
Donald E Curtisa8736442015-08-05 15:48:13 -070059@property(nonatomic, readonly) ARDAppClientState state;
60@property(nonatomic, weak) id<ARDAppClientDelegate> delegate;
Donald E Curtisa8736442015-08-05 15:48:13 -070061// Convenience constructor since all expected use cases will need a delegate
62// in order to receive remote tracks.
sakal68b5df92017-03-17 09:01:59 -070063- (instancetype)initWithDelegate:(id<ARDAppClientDelegate>)delegate
64 preferVideoCodec:(NSString*)codec;
Donald E Curtisa8736442015-08-05 15:48:13 -070065
denicijad17d5362016-11-02 02:56:09 -070066// Sets camera constraints.
67- (void)setCameraConstraints:(RTCMediaConstraints *)mediaConstraints;
68
denicija8c375de2016-11-08 06:28:17 -080069// Sets maximum bitrate the rtp sender should use.
70- (void)setMaxBitrate:(NSNumber *)maxBitrate;
71
Donald E Curtisa8736442015-08-05 15:48:13 -070072// Establishes a connection with the AppRTC servers for the given room id.
haysc913e6452015-10-02 11:44:03 -070073// If |isLoopback| is true, the call will connect to itself.
74// If |isAudioOnly| is true, video will be disabled for the call.
peah5085b0c2016-08-25 22:15:14 -070075// If |shouldMakeAecDump| is true, an aecdump will be created for the call.
tkchinab1293a2016-08-30 12:35:05 -070076// If |shouldUseLevelControl| is true, the level controller will be used
77// in the call.
Donald E Curtisa8736442015-08-05 15:48:13 -070078- (void)connectToRoomWithId:(NSString *)roomId
haysc913e6452015-10-02 11:44:03 -070079 isLoopback:(BOOL)isLoopback
peah5085b0c2016-08-25 22:15:14 -070080 isAudioOnly:(BOOL)isAudioOnly
tkchinab1293a2016-08-30 12:35:05 -070081 shouldMakeAecDump:(BOOL)shouldMakeAecDump
82 shouldUseLevelControl:(BOOL)shouldUseLevelControl;
Donald E Curtisa8736442015-08-05 15:48:13 -070083
84// Disconnects from the AppRTC servers and any connected clients.
85- (void)disconnect;
86
87@end