Donald E Curtis | a873644 | 2015-08-05 15:48:13 -0700 | [diff] [blame] | 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> |
Mirko Bonadei | 19640aa | 2020-10-19 16:12:43 +0200 | [diff] [blame] | 12 | |
| 13 | #import "sdk/objc/api/peerconnection/RTCPeerConnection.h" |
| 14 | #import "sdk/objc/api/peerconnection/RTCVideoTrack.h" |
Donald E Curtis | a873644 | 2015-08-05 15:48:13 -0700 | [diff] [blame] | 15 | |
| 16 | typedef 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; |
sakal | c4adacf | 2017-03-28 01:22:48 -0700 | [diff] [blame] | 26 | @class ARDSettingsModel; |
Anders Carlsson | 358f2e0 | 2018-06-04 10:24:37 +0200 | [diff] [blame] | 27 | @class ARDExternalSampleCapturer; |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 28 | @class RTC_OBJC_TYPE(RTCMediaConstraints); |
| 29 | @class RTC_OBJC_TYPE(RTCCameraVideoCapturer); |
| 30 | @class RTC_OBJC_TYPE(RTCFileVideoCapturer); |
denicija | d17d536 | 2016-11-02 02:56:09 -0700 | [diff] [blame] | 31 | |
Donald E Curtis | a873644 | 2015-08-05 15:48:13 -0700 | [diff] [blame] | 32 | // The delegate is informed of pertinent events and will be called on the |
| 33 | // main queue. |
| 34 | @protocol ARDAppClientDelegate <NSObject> |
| 35 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 36 | - (void)appClient:(ARDAppClient *)client didChangeState:(ARDAppClientState)state; |
Donald E Curtis | a873644 | 2015-08-05 15:48:13 -0700 | [diff] [blame] | 37 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 38 | - (void)appClient:(ARDAppClient *)client didChangeConnectionState:(RTCIceConnectionState)state; |
Donald E Curtis | a873644 | 2015-08-05 15:48:13 -0700 | [diff] [blame] | 39 | |
| 40 | - (void)appClient:(ARDAppClient *)client |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 41 | didCreateLocalCapturer:(RTC_OBJC_TYPE(RTCCameraVideoCapturer) *)localCapturer; |
Donald E Curtis | a873644 | 2015-08-05 15:48:13 -0700 | [diff] [blame] | 42 | |
| 43 | - (void)appClient:(ARDAppClient *)client |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 44 | didReceiveLocalVideoTrack:(RTC_OBJC_TYPE(RTCVideoTrack) *)localVideoTrack; |
| 45 | |
| 46 | - (void)appClient:(ARDAppClient *)client |
| 47 | didReceiveRemoteVideoTrack:(RTC_OBJC_TYPE(RTCVideoTrack) *)remoteVideoTrack; |
Donald E Curtis | a873644 | 2015-08-05 15:48:13 -0700 | [diff] [blame] | 48 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 49 | - (void)appClient:(ARDAppClient *)client didError:(NSError *)error; |
Donald E Curtis | a873644 | 2015-08-05 15:48:13 -0700 | [diff] [blame] | 50 | |
Jaehyun Ko | 193f4bf | 2021-05-20 15:04:02 +0900 | [diff] [blame] | 51 | - (void)appClient:(ARDAppClient *)client didGetStats:(RTC_OBJC_TYPE(RTCStatisticsReport) *)stats; |
Zeke Chin | d332580 | 2015-08-14 11:00:02 -0700 | [diff] [blame] | 52 | |
Daniela | 012b56b | 2017-11-15 13:15:24 +0100 | [diff] [blame] | 53 | @optional |
| 54 | - (void)appClient:(ARDAppClient *)client |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 55 | didCreateLocalFileCapturer:(RTC_OBJC_TYPE(RTCFileVideoCapturer) *)fileCapturer; |
Daniela | 012b56b | 2017-11-15 13:15:24 +0100 | [diff] [blame] | 56 | |
Anders Carlsson | 358f2e0 | 2018-06-04 10:24:37 +0200 | [diff] [blame] | 57 | - (void)appClient:(ARDAppClient *)client |
| 58 | didCreateLocalExternalSampleCapturer:(ARDExternalSampleCapturer *)externalSampleCapturer; |
| 59 | |
Donald E Curtis | a873644 | 2015-08-05 15:48:13 -0700 | [diff] [blame] | 60 | @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 Titov | 36de9df | 2021-07-26 13:21:35 +0200 | [diff] [blame^] | 66 | // If `shouldGetStats` is true, stats will be reported in 1s intervals through |
Zeke Chin | d332580 | 2015-08-14 11:00:02 -0700 | [diff] [blame] | 67 | // the delegate. |
| 68 | @property(nonatomic, assign) BOOL shouldGetStats; |
Donald E Curtis | a873644 | 2015-08-05 15:48:13 -0700 | [diff] [blame] | 69 | @property(nonatomic, readonly) ARDAppClientState state; |
| 70 | @property(nonatomic, weak) id<ARDAppClientDelegate> delegate; |
Anders Carlsson | 358f2e0 | 2018-06-04 10:24:37 +0200 | [diff] [blame] | 71 | @property(nonatomic, assign, getter=isBroadcast) BOOL broadcast; |
| 72 | |
Donald E Curtis | a873644 | 2015-08-05 15:48:13 -0700 | [diff] [blame] | 73 | // Convenience constructor since all expected use cases will need a delegate |
| 74 | // in order to receive remote tracks. |
sakal | c4adacf | 2017-03-28 01:22:48 -0700 | [diff] [blame] | 75 | - (instancetype)initWithDelegate:(id<ARDAppClientDelegate>)delegate; |
denicija | 8c375de | 2016-11-08 06:28:17 -0800 | [diff] [blame] | 76 | |
Donald E Curtis | a873644 | 2015-08-05 15:48:13 -0700 | [diff] [blame] | 77 | // Establishes a connection with the AppRTC servers for the given room id. |
Artem Titov | 36de9df | 2021-07-26 13:21:35 +0200 | [diff] [blame^] | 78 | // `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 Curtis | a873644 | 2015-08-05 15:48:13 -0700 | [diff] [blame] | 80 | - (void)connectToRoomWithId:(NSString *)roomId |
sakal | c4adacf | 2017-03-28 01:22:48 -0700 | [diff] [blame] | 81 | settings:(ARDSettingsModel *)settings |
Anders Carlsson | e150058 | 2017-06-15 16:05:13 +0200 | [diff] [blame] | 82 | isLoopback:(BOOL)isLoopback; |
Donald E Curtis | a873644 | 2015-08-05 15:48:13 -0700 | [diff] [blame] | 83 | |
| 84 | // Disconnects from the AppRTC servers and any connected clients. |
| 85 | - (void)disconnect; |
| 86 | |
| 87 | @end |