You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
3.0 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  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. #import <Foundation/Foundation.h>
  11. #import <WebRTC/RTCPeerConnection.h>
  12. #import <WebRTC/RTCVideoTrack.h>
  13. typedef NS_ENUM(NSInteger, ARDAppClientState) {
  14. // Disconnected from servers.
  15. kARDAppClientStateDisconnected,
  16. // Connecting to servers.
  17. kARDAppClientStateConnecting,
  18. // Connected to servers.
  19. kARDAppClientStateConnected,
  20. };
  21. @class ARDAppClient;
  22. @class ARDSettingsModel;
  23. @class ARDExternalSampleCapturer;
  24. @class RTCMediaConstraints;
  25. @class RTCCameraVideoCapturer;
  26. @class RTCFileVideoCapturer;
  27. // The delegate is informed of pertinent events and will be called on the
  28. // main queue.
  29. @protocol ARDAppClientDelegate <NSObject>
  30. - (void)appClient:(ARDAppClient *)client didChangeState:(ARDAppClientState)state;
  31. - (void)appClient:(ARDAppClient *)client didChangeConnectionState:(RTCIceConnectionState)state;
  32. - (void)appClient:(ARDAppClient *)client
  33. didCreateLocalCapturer:(RTCCameraVideoCapturer *)localCapturer;
  34. - (void)appClient:(ARDAppClient *)client didReceiveLocalVideoTrack:(RTCVideoTrack *)localVideoTrack;
  35. - (void)appClient:(ARDAppClient *)client
  36. didReceiveRemoteVideoTrack:(RTCVideoTrack *)remoteVideoTrack;
  37. - (void)appClient:(ARDAppClient *)client didError:(NSError *)error;
  38. - (void)appClient:(ARDAppClient *)client didGetStats:(NSArray *)stats;
  39. @optional
  40. - (void)appClient:(ARDAppClient *)client
  41. didCreateLocalFileCapturer:(RTCFileVideoCapturer *)fileCapturer;
  42. - (void)appClient:(ARDAppClient *)client
  43. didCreateLocalExternalSampleCapturer:(ARDExternalSampleCapturer *)externalSampleCapturer;
  44. @end
  45. // Handles connections to the AppRTC server for a given room. Methods on this
  46. // class should only be called from the main queue.
  47. @interface ARDAppClient : NSObject
  48. // If |shouldGetStats| is true, stats will be reported in 1s intervals through
  49. // the delegate.
  50. @property(nonatomic, assign) BOOL shouldGetStats;
  51. @property(nonatomic, readonly) ARDAppClientState state;
  52. @property(nonatomic, weak) id<ARDAppClientDelegate> delegate;
  53. @property(nonatomic, assign, getter=isBroadcast) BOOL broadcast;
  54. // Convenience constructor since all expected use cases will need a delegate
  55. // in order to receive remote tracks.
  56. - (instancetype)initWithDelegate:(id<ARDAppClientDelegate>)delegate;
  57. // Establishes a connection with the AppRTC servers for the given room id.
  58. // |settings| is an object containing settings such as video codec for the call.
  59. // If |isLoopback| is true, the call will connect to itself.
  60. - (void)connectToRoomWithId:(NSString *)roomId
  61. settings:(ARDSettingsModel *)settings
  62. isLoopback:(BOOL)isLoopback;
  63. // Disconnects from the AppRTC servers and any connected clients.
  64. - (void)disconnect;
  65. @end