ARDAppClient.h (3317B)
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 37 didChangeState:(ARDAppClientState)state; 38 39 - (void)appClient:(ARDAppClient *)client 40 didChangeConnectionState:(RTCIceConnectionState)state; 41 42 - (void)appClient:(ARDAppClient *)client 43 didCreateLocalCapturer: 44 (RTC_OBJC_TYPE(RTCCameraVideoCapturer) *)localCapturer; 45 46 - (void)appClient:(ARDAppClient *)client 47 didReceiveLocalVideoTrack:(RTC_OBJC_TYPE(RTCVideoTrack) *)localVideoTrack; 48 49 - (void)appClient:(ARDAppClient *)client 50 didReceiveRemoteVideoTrack:(RTC_OBJC_TYPE(RTCVideoTrack) *)remoteVideoTrack; 51 52 - (void)appClient:(ARDAppClient *)client didError:(NSError *)error; 53 54 - (void)appClient:(ARDAppClient *)client 55 didGetStats:(RTC_OBJC_TYPE(RTCStatisticsReport) *)stats; 56 57 @optional 58 - (void)appClient:(ARDAppClient *)client 59 didCreateLocalFileCapturer: 60 (RTC_OBJC_TYPE(RTCFileVideoCapturer) *)fileCapturer; 61 62 - (void)appClient:(ARDAppClient *)client 63 didCreateLocalExternalSampleCapturer: 64 (ARDExternalSampleCapturer *)externalSampleCapturer; 65 66 @end 67 68 // Handles connections to the AppRTC server for a given room. Methods on this 69 // class should only be called from the main queue. 70 @interface ARDAppClient : NSObject 71 72 // If `shouldGetStats` is true, stats will be reported in 1s intervals through 73 // the delegate. 74 @property(nonatomic, assign) BOOL shouldGetStats; 75 @property(nonatomic, readonly) ARDAppClientState state; 76 @property(nonatomic, weak) id<ARDAppClientDelegate> delegate; 77 @property(nonatomic, assign, getter=isBroadcast) BOOL broadcast; 78 79 // Convenience constructor since all expected use cases will need a delegate 80 // in order to receive remote tracks. 81 - (instancetype)initWithDelegate:(id<ARDAppClientDelegate>)delegate; 82 83 // Establishes a connection with the AppRTC servers for the given room id. 84 // `settings` is an object containing settings such as video codec for the call. 85 // If `isLoopback` is true, the call will connect to itself. 86 - (void)connectToRoomWithId:(NSString *)roomId 87 settings:(ARDSettingsModel *)settings 88 isLoopback:(BOOL)isLoopback; 89 90 // Disconnects from the AppRTC servers and any connected clients. 91 - (void)disconnect; 92 93 @end