blob: 91d2cef1ce90fe8c339ea34c5f3d93bc272c113c [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>
Mirko Bonadei19640aa2020-10-19 16:12:43 +020012
13#import "sdk/objc/api/peerconnection/RTCPeerConnection.h"
14#import "sdk/objc/api/peerconnection/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;
sakalc4adacf2017-03-28 01:22:48 -070026@class ARDSettingsModel;
Anders Carlsson358f2e02018-06-04 10:24:37 +020027@class ARDExternalSampleCapturer;
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020028@class RTC_OBJC_TYPE(RTCMediaConstraints);
29@class RTC_OBJC_TYPE(RTCCameraVideoCapturer);
30@class RTC_OBJC_TYPE(RTCFileVideoCapturer);
denicijad17d5362016-11-02 02:56:09 -070031
Donald E Curtisa8736442015-08-05 15:48:13 -070032// The delegate is informed of pertinent events and will be called on the
33// main queue.
34@protocol ARDAppClientDelegate <NSObject>
35
Yves Gerey665174f2018-06-19 15:03:05 +020036- (void)appClient:(ARDAppClient *)client didChangeState:(ARDAppClientState)state;
Donald E Curtisa8736442015-08-05 15:48:13 -070037
Yves Gerey665174f2018-06-19 15:03:05 +020038- (void)appClient:(ARDAppClient *)client didChangeConnectionState:(RTCIceConnectionState)state;
Donald E Curtisa8736442015-08-05 15:48:13 -070039
40- (void)appClient:(ARDAppClient *)client
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020041 didCreateLocalCapturer:(RTC_OBJC_TYPE(RTCCameraVideoCapturer) *)localCapturer;
Donald E Curtisa8736442015-08-05 15:48:13 -070042
43- (void)appClient:(ARDAppClient *)client
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020044 didReceiveLocalVideoTrack:(RTC_OBJC_TYPE(RTCVideoTrack) *)localVideoTrack;
45
46- (void)appClient:(ARDAppClient *)client
47 didReceiveRemoteVideoTrack:(RTC_OBJC_TYPE(RTCVideoTrack) *)remoteVideoTrack;
Donald E Curtisa8736442015-08-05 15:48:13 -070048
Yves Gerey665174f2018-06-19 15:03:05 +020049- (void)appClient:(ARDAppClient *)client didError:(NSError *)error;
Donald E Curtisa8736442015-08-05 15:48:13 -070050
Jaehyun Ko193f4bf2021-05-20 15:04:02 +090051- (void)appClient:(ARDAppClient *)client didGetStats:(RTC_OBJC_TYPE(RTCStatisticsReport) *)stats;
Zeke Chind3325802015-08-14 11:00:02 -070052
Daniela012b56b2017-11-15 13:15:24 +010053@optional
54- (void)appClient:(ARDAppClient *)client
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020055 didCreateLocalFileCapturer:(RTC_OBJC_TYPE(RTCFileVideoCapturer) *)fileCapturer;
Daniela012b56b2017-11-15 13:15:24 +010056
Anders Carlsson358f2e02018-06-04 10:24:37 +020057- (void)appClient:(ARDAppClient *)client
58 didCreateLocalExternalSampleCapturer:(ARDExternalSampleCapturer *)externalSampleCapturer;
59
Donald E Curtisa8736442015-08-05 15:48:13 -070060@end
61
62// Handles connections to the AppRTC server for a given room. Methods on this
63// class should only be called from the main queue.
64@interface ARDAppClient : NSObject
65
Artem Titov36de9df2021-07-26 13:21:35 +020066// If `shouldGetStats` is true, stats will be reported in 1s intervals through
Zeke Chind3325802015-08-14 11:00:02 -070067// the delegate.
68@property(nonatomic, assign) BOOL shouldGetStats;
Donald E Curtisa8736442015-08-05 15:48:13 -070069@property(nonatomic, readonly) ARDAppClientState state;
70@property(nonatomic, weak) id<ARDAppClientDelegate> delegate;
Anders Carlsson358f2e02018-06-04 10:24:37 +020071@property(nonatomic, assign, getter=isBroadcast) BOOL broadcast;
72
Donald E Curtisa8736442015-08-05 15:48:13 -070073// Convenience constructor since all expected use cases will need a delegate
74// in order to receive remote tracks.
sakalc4adacf2017-03-28 01:22:48 -070075- (instancetype)initWithDelegate:(id<ARDAppClientDelegate>)delegate;
denicija8c375de2016-11-08 06:28:17 -080076
Donald E Curtisa8736442015-08-05 15:48:13 -070077// Establishes a connection with the AppRTC servers for the given room id.
Artem Titov36de9df2021-07-26 13:21:35 +020078// `settings` is an object containing settings such as video codec for the call.
79// If `isLoopback` is true, the call will connect to itself.
Donald E Curtisa8736442015-08-05 15:48:13 -070080- (void)connectToRoomWithId:(NSString *)roomId
sakalc4adacf2017-03-28 01:22:48 -070081 settings:(ARDSettingsModel *)settings
Anders Carlssone1500582017-06-15 16:05:13 +020082 isLoopback:(BOOL)isLoopback;
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