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