blob: 98b1fe91e556751c81397e45ec1c4ed5b3f5dbaa [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>
Anders Carlsson7bca8ca2018-08-30 09:30:29 +020012#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;
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020027@class RTC_OBJC_TYPE(RTCMediaConstraints);
28@class RTC_OBJC_TYPE(RTCCameraVideoCapturer);
29@class RTC_OBJC_TYPE(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
Yves Gerey665174f2018-06-19 15:03:05 +020035- (void)appClient:(ARDAppClient *)client didChangeState:(ARDAppClientState)state;
Donald E Curtisa8736442015-08-05 15:48:13 -070036
Yves Gerey665174f2018-06-19 15:03:05 +020037- (void)appClient:(ARDAppClient *)client didChangeConnectionState:(RTCIceConnectionState)state;
Donald E Curtisa8736442015-08-05 15:48:13 -070038
39- (void)appClient:(ARDAppClient *)client
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020040 didCreateLocalCapturer:(RTC_OBJC_TYPE(RTCCameraVideoCapturer) *)localCapturer;
Donald E Curtisa8736442015-08-05 15:48:13 -070041
42- (void)appClient:(ARDAppClient *)client
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020043 didReceiveLocalVideoTrack:(RTC_OBJC_TYPE(RTCVideoTrack) *)localVideoTrack;
44
45- (void)appClient:(ARDAppClient *)client
46 didReceiveRemoteVideoTrack:(RTC_OBJC_TYPE(RTCVideoTrack) *)remoteVideoTrack;
Donald E Curtisa8736442015-08-05 15:48:13 -070047
Yves Gerey665174f2018-06-19 15:03:05 +020048- (void)appClient:(ARDAppClient *)client didError:(NSError *)error;
Donald E Curtisa8736442015-08-05 15:48:13 -070049
Yves Gerey665174f2018-06-19 15:03:05 +020050- (void)appClient:(ARDAppClient *)client didGetStats:(NSArray *)stats;
Zeke Chind3325802015-08-14 11:00:02 -070051
Daniela012b56b2017-11-15 13:15:24 +010052@optional
53- (void)appClient:(ARDAppClient *)client
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020054 didCreateLocalFileCapturer:(RTC_OBJC_TYPE(RTCFileVideoCapturer) *)fileCapturer;
Daniela012b56b2017-11-15 13:15:24 +010055
Anders Carlsson358f2e02018-06-04 10:24:37 +020056- (void)appClient:(ARDAppClient *)client
57 didCreateLocalExternalSampleCapturer:(ARDExternalSampleCapturer *)externalSampleCapturer;
58
Donald E Curtisa8736442015-08-05 15:48:13 -070059@end
60
61// Handles connections to the AppRTC server for a given room. Methods on this
62// class should only be called from the main queue.
63@interface ARDAppClient : NSObject
64
Zeke Chind3325802015-08-14 11:00:02 -070065// If |shouldGetStats| is true, stats will be reported in 1s intervals through
66// the delegate.
67@property(nonatomic, assign) BOOL shouldGetStats;
Donald E Curtisa8736442015-08-05 15:48:13 -070068@property(nonatomic, readonly) ARDAppClientState state;
69@property(nonatomic, weak) id<ARDAppClientDelegate> delegate;
Anders Carlsson358f2e02018-06-04 10:24:37 +020070@property(nonatomic, assign, getter=isBroadcast) BOOL broadcast;
71
Donald E Curtisa8736442015-08-05 15:48:13 -070072// Convenience constructor since all expected use cases will need a delegate
73// in order to receive remote tracks.
sakalc4adacf2017-03-28 01:22:48 -070074- (instancetype)initWithDelegate:(id<ARDAppClientDelegate>)delegate;
denicija8c375de2016-11-08 06:28:17 -080075
Donald E Curtisa8736442015-08-05 15:48:13 -070076// Establishes a connection with the AppRTC servers for the given room id.
sakalc4adacf2017-03-28 01:22:48 -070077// |settings| is an object containing settings such as video codec for the call.
haysc913e6452015-10-02 11:44:03 -070078// If |isLoopback| is true, the call will connect to itself.
Donald E Curtisa8736442015-08-05 15:48:13 -070079- (void)connectToRoomWithId:(NSString *)roomId
sakalc4adacf2017-03-28 01:22:48 -070080 settings:(ARDSettingsModel *)settings
Anders Carlssone1500582017-06-15 16:05:13 +020081 isLoopback:(BOOL)isLoopback;
Donald E Curtisa8736442015-08-05 15:48:13 -070082
83// Disconnects from the AppRTC servers and any connected clients.
84- (void)disconnect;
85
86@end