blob: e513db19c211fd39acfce54a95dd22e54110d62c [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#import "WebRTC/RTCPeerConnection.h"
13#import "WebRTC/RTCVideoTrack.h"
Donald E Curtisa8736442015-08-05 15:48:13 -070014
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;
sakalc4adacf2017-03-28 01:22:48 -070025@class ARDSettingsModel;
Anders Carlsson358f2e02018-06-04 10:24:37 +020026@class ARDExternalSampleCapturer;
denicijad17d5362016-11-02 02:56:09 -070027@class RTCMediaConstraints;
Daniela012b56b2017-11-15 13:15:24 +010028@class RTCCameraVideoCapturer;
29@class RTCFileVideoCapturer;
denicijad17d5362016-11-02 02:56:09 -070030
Donald E Curtisa8736442015-08-05 15:48:13 -070031// The delegate is informed of pertinent events and will be called on the
32// main queue.
33@protocol ARDAppClientDelegate <NSObject>
34
35- (void)appClient:(ARDAppClient *)client
36 didChangeState:(ARDAppClientState)state;
37
38- (void)appClient:(ARDAppClient *)client
hjon79858f82016-03-13 22:08:26 -070039 didChangeConnectionState:(RTCIceConnectionState)state;
Donald E Curtisa8736442015-08-05 15:48:13 -070040
41- (void)appClient:(ARDAppClient *)client
sakalc522e752017-04-05 12:17:48 -070042 didCreateLocalCapturer:(RTCCameraVideoCapturer *)localCapturer;
43
44- (void)appClient:(ARDAppClient *)client
Donald E Curtisa8736442015-08-05 15:48:13 -070045 didReceiveLocalVideoTrack:(RTCVideoTrack *)localVideoTrack;
46
47- (void)appClient:(ARDAppClient *)client
48 didReceiveRemoteVideoTrack:(RTCVideoTrack *)remoteVideoTrack;
49
50- (void)appClient:(ARDAppClient *)client
51 didError:(NSError *)error;
52
Zeke Chind3325802015-08-14 11:00:02 -070053- (void)appClient:(ARDAppClient *)client
54 didGetStats:(NSArray *)stats;
55
Daniela012b56b2017-11-15 13:15:24 +010056@optional
57- (void)appClient:(ARDAppClient *)client
58didCreateLocalFileCapturer:(RTCFileVideoCapturer *)fileCapturer;
59
Anders Carlsson358f2e02018-06-04 10:24:37 +020060- (void)appClient:(ARDAppClient *)client
61 didCreateLocalExternalSampleCapturer:(ARDExternalSampleCapturer *)externalSampleCapturer;
62
Donald E Curtisa8736442015-08-05 15:48:13 -070063@end
64
65// Handles connections to the AppRTC server for a given room. Methods on this
66// class should only be called from the main queue.
67@interface ARDAppClient : NSObject
68
Zeke Chind3325802015-08-14 11:00:02 -070069// If |shouldGetStats| is true, stats will be reported in 1s intervals through
70// the delegate.
71@property(nonatomic, assign) BOOL shouldGetStats;
Donald E Curtisa8736442015-08-05 15:48:13 -070072@property(nonatomic, readonly) ARDAppClientState state;
73@property(nonatomic, weak) id<ARDAppClientDelegate> delegate;
Anders Carlsson358f2e02018-06-04 10:24:37 +020074@property(nonatomic, assign, getter=isBroadcast) BOOL broadcast;
75
Donald E Curtisa8736442015-08-05 15:48:13 -070076// Convenience constructor since all expected use cases will need a delegate
77// in order to receive remote tracks.
sakalc4adacf2017-03-28 01:22:48 -070078- (instancetype)initWithDelegate:(id<ARDAppClientDelegate>)delegate;
denicija8c375de2016-11-08 06:28:17 -080079
Donald E Curtisa8736442015-08-05 15:48:13 -070080// Establishes a connection with the AppRTC servers for the given room id.
sakalc4adacf2017-03-28 01:22:48 -070081// |settings| is an object containing settings such as video codec for the call.
haysc913e6452015-10-02 11:44:03 -070082// If |isLoopback| is true, the call will connect to itself.
Donald E Curtisa8736442015-08-05 15:48:13 -070083- (void)connectToRoomWithId:(NSString *)roomId
sakalc4adacf2017-03-28 01:22:48 -070084 settings:(ARDSettingsModel *)settings
Anders Carlssone1500582017-06-15 16:05:13 +020085 isLoopback:(BOOL)isLoopback;
Donald E Curtisa8736442015-08-05 15:48:13 -070086
87// Disconnects from the AppRTC servers and any connected clients.
88- (void)disconnect;
89
90@end