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> 12 13 #import "sdk/objc/api/peerconnection/RTCPeerConnection.h" 14 #import "sdk/objc/api/peerconnection/RTCVideoTrack.h" 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; 26 @class ARDSettingsModel; 27 @class ARDExternalSampleCapturer; 28 @class RTC_OBJC_TYPE(RTCMediaConstraints); 29 @class RTC_OBJC_TYPE(RTCCameraVideoCapturer); 30 @class RTC_OBJC_TYPE(RTCFileVideoCapturer); 31 32 // The delegate is informed of pertinent events and will be called on the 33 // main queue. 34 @protocol ARDAppClientDelegate <NSObject> 35 36 - (void)appClient:(ARDAppClient *)client didChangeState:(ARDAppClientState)state; 37 38 - (void)appClient:(ARDAppClient *)client didChangeConnectionState:(RTCIceConnectionState)state; 39 40 - (void)appClient:(ARDAppClient *)client 41 didCreateLocalCapturer:(RTC_OBJC_TYPE(RTCCameraVideoCapturer) *)localCapturer; 42 43 - (void)appClient:(ARDAppClient *)client 44 didReceiveLocalVideoTrack:(RTC_OBJC_TYPE(RTCVideoTrack) *)localVideoTrack; 45 46 - (void)appClient:(ARDAppClient *)client 47 didReceiveRemoteVideoTrack:(RTC_OBJC_TYPE(RTCVideoTrack) *)remoteVideoTrack; 48 49 - (void)appClient:(ARDAppClient *)client didError:(NSError *)error; 50 51 - (void)appClient:(ARDAppClient *)client didGetStats:(RTC_OBJC_TYPE(RTCStatisticsReport) *)stats; 52 53 @optional 54 - (void)appClient:(ARDAppClient *)client 55 didCreateLocalFileCapturer:(RTC_OBJC_TYPE(RTCFileVideoCapturer) *)fileCapturer; 56 57 - (void)appClient:(ARDAppClient *)client 58 didCreateLocalExternalSampleCapturer:(ARDExternalSampleCapturer *)externalSampleCapturer; 59 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 66 // If `shouldGetStats` is true, stats will be reported in 1s intervals through 67 // the delegate. 68 @property(nonatomic, assign) BOOL shouldGetStats; 69 @property(nonatomic, readonly) ARDAppClientState state; 70 @property(nonatomic, weak) id<ARDAppClientDelegate> delegate; 71 @property(nonatomic, assign, getter=isBroadcast) BOOL broadcast; 72 73 // Convenience constructor since all expected use cases will need a delegate 74 // in order to receive remote tracks. 75 - (instancetype)initWithDelegate:(id<ARDAppClientDelegate>)delegate; 76 77 // Establishes a connection with the AppRTC servers for the given room id. 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. 80 - (void)connectToRoomWithId:(NSString *)roomId 81 settings:(ARDSettingsModel *)settings 82 isLoopback:(BOOL)isLoopback; 83 84 // Disconnects from the AppRTC servers and any connected clients. 85 - (void)disconnect; 86 87 @end 88