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> |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 12 | #import <WebRTC/RTCPeerConnection.h> |
| 13 | #import <WebRTC/RTCVideoTrack.h> |
Donald E Curtis | a873644 | 2015-08-05 15:48:13 -0700 | [diff] [blame] | 14 | |
| 15 | typedef 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; |
sakal | c4adacf | 2017-03-28 01:22:48 -0700 | [diff] [blame] | 25 | @class ARDSettingsModel; |
Anders Carlsson | 358f2e0 | 2018-06-04 10:24:37 +0200 | [diff] [blame] | 26 | @class ARDExternalSampleCapturer; |
denicija | d17d536 | 2016-11-02 02:56:09 -0700 | [diff] [blame] | 27 | @class RTCMediaConstraints; |
Daniela | 012b56b | 2017-11-15 13:15:24 +0100 | [diff] [blame] | 28 | @class RTCCameraVideoCapturer; |
| 29 | @class RTCFileVideoCapturer; |
denicija | d17d536 | 2016-11-02 02:56:09 -0700 | [diff] [blame] | 30 | |
Donald E Curtis | a873644 | 2015-08-05 15:48:13 -0700 | [diff] [blame] | 31 | // The delegate is informed of pertinent events and will be called on the |
| 32 | // main queue. |
| 33 | @protocol ARDAppClientDelegate <NSObject> |
| 34 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 35 | - (void)appClient:(ARDAppClient *)client didChangeState:(ARDAppClientState)state; |
Donald E Curtis | a873644 | 2015-08-05 15:48:13 -0700 | [diff] [blame] | 36 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 37 | - (void)appClient:(ARDAppClient *)client didChangeConnectionState:(RTCIceConnectionState)state; |
Donald E Curtis | a873644 | 2015-08-05 15:48:13 -0700 | [diff] [blame] | 38 | |
| 39 | - (void)appClient:(ARDAppClient *)client |
sakal | c522e75 | 2017-04-05 12:17:48 -0700 | [diff] [blame] | 40 | didCreateLocalCapturer:(RTCCameraVideoCapturer *)localCapturer; |
| 41 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 42 | - (void)appClient:(ARDAppClient *)client didReceiveLocalVideoTrack:(RTCVideoTrack *)localVideoTrack; |
Donald E Curtis | a873644 | 2015-08-05 15:48:13 -0700 | [diff] [blame] | 43 | |
| 44 | - (void)appClient:(ARDAppClient *)client |
| 45 | didReceiveRemoteVideoTrack:(RTCVideoTrack *)remoteVideoTrack; |
| 46 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 47 | - (void)appClient:(ARDAppClient *)client didError:(NSError *)error; |
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 didGetStats:(NSArray *)stats; |
Zeke Chin | d332580 | 2015-08-14 11:00:02 -0700 | [diff] [blame] | 50 | |
Daniela | 012b56b | 2017-11-15 13:15:24 +0100 | [diff] [blame] | 51 | @optional |
| 52 | - (void)appClient:(ARDAppClient *)client |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 53 | didCreateLocalFileCapturer:(RTCFileVideoCapturer *)fileCapturer; |
Daniela | 012b56b | 2017-11-15 13:15:24 +0100 | [diff] [blame] | 54 | |
Anders Carlsson | 358f2e0 | 2018-06-04 10:24:37 +0200 | [diff] [blame] | 55 | - (void)appClient:(ARDAppClient *)client |
| 56 | didCreateLocalExternalSampleCapturer:(ARDExternalSampleCapturer *)externalSampleCapturer; |
| 57 | |
Donald E Curtis | a873644 | 2015-08-05 15:48:13 -0700 | [diff] [blame] | 58 | @end |
| 59 | |
| 60 | // Handles connections to the AppRTC server for a given room. Methods on this |
| 61 | // class should only be called from the main queue. |
| 62 | @interface ARDAppClient : NSObject |
| 63 | |
Zeke Chin | d332580 | 2015-08-14 11:00:02 -0700 | [diff] [blame] | 64 | // If |shouldGetStats| is true, stats will be reported in 1s intervals through |
| 65 | // the delegate. |
| 66 | @property(nonatomic, assign) BOOL shouldGetStats; |
Donald E Curtis | a873644 | 2015-08-05 15:48:13 -0700 | [diff] [blame] | 67 | @property(nonatomic, readonly) ARDAppClientState state; |
| 68 | @property(nonatomic, weak) id<ARDAppClientDelegate> delegate; |
Anders Carlsson | 358f2e0 | 2018-06-04 10:24:37 +0200 | [diff] [blame] | 69 | @property(nonatomic, assign, getter=isBroadcast) BOOL broadcast; |
| 70 | |
Donald E Curtis | a873644 | 2015-08-05 15:48:13 -0700 | [diff] [blame] | 71 | // Convenience constructor since all expected use cases will need a delegate |
| 72 | // in order to receive remote tracks. |
sakal | c4adacf | 2017-03-28 01:22:48 -0700 | [diff] [blame] | 73 | - (instancetype)initWithDelegate:(id<ARDAppClientDelegate>)delegate; |
denicija | 8c375de | 2016-11-08 06:28:17 -0800 | [diff] [blame] | 74 | |
Donald E Curtis | a873644 | 2015-08-05 15:48:13 -0700 | [diff] [blame] | 75 | // Establishes a connection with the AppRTC servers for the given room id. |
sakal | c4adacf | 2017-03-28 01:22:48 -0700 | [diff] [blame] | 76 | // |settings| is an object containing settings such as video codec for the call. |
haysc | 913e645 | 2015-10-02 11:44:03 -0700 | [diff] [blame] | 77 | // If |isLoopback| is true, the call will connect to itself. |
Donald E Curtis | a873644 | 2015-08-05 15:48:13 -0700 | [diff] [blame] | 78 | - (void)connectToRoomWithId:(NSString *)roomId |
sakal | c4adacf | 2017-03-28 01:22:48 -0700 | [diff] [blame] | 79 | settings:(ARDSettingsModel *)settings |
Anders Carlsson | e150058 | 2017-06-15 16:05:13 +0200 | [diff] [blame] | 80 | isLoopback:(BOOL)isLoopback; |
Donald E Curtis | a873644 | 2015-08-05 15:48:13 -0700 | [diff] [blame] | 81 | |
| 82 | // Disconnects from the AppRTC servers and any connected clients. |
| 83 | - (void)disconnect; |
| 84 | |
| 85 | @end |