ARDAppClient.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 RTC_OBJC_TYPE(RTCMediaConstraints);
  25. @class RTC_OBJC_TYPE(RTCCameraVideoCapturer);
  26. @class RTC_OBJC_TYPE(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:(RTC_OBJC_TYPE(RTCCameraVideoCapturer) *)localCapturer;
  34. - (void)appClient:(ARDAppClient *)client
  35. didReceiveLocalVideoTrack:(RTC_OBJC_TYPE(RTCVideoTrack) *)localVideoTrack;
  36. - (void)appClient:(ARDAppClient *)client
  37. didReceiveRemoteVideoTrack:(RTC_OBJC_TYPE(RTCVideoTrack) *)remoteVideoTrack;
  38. - (void)appClient:(ARDAppClient *)client didError:(NSError *)error;
  39. - (void)appClient:(ARDAppClient *)client didGetStats:(NSArray *)stats;
  40. @optional
  41. - (void)appClient:(ARDAppClient *)client
  42. didCreateLocalFileCapturer:(RTC_OBJC_TYPE(RTCFileVideoCapturer) *)fileCapturer;
  43. - (void)appClient:(ARDAppClient *)client
  44. didCreateLocalExternalSampleCapturer:(ARDExternalSampleCapturer *)externalSampleCapturer;
  45. @end
  46. // Handles connections to the AppRTC server for a given room. Methods on this
  47. // class should only be called from the main queue.
  48. @interface ARDAppClient : NSObject
  49. // If |shouldGetStats| is true, stats will be reported in 1s intervals through
  50. // the delegate.
  51. @property(nonatomic, assign) BOOL shouldGetStats;
  52. @property(nonatomic, readonly) ARDAppClientState state;
  53. @property(nonatomic, weak) id<ARDAppClientDelegate> delegate;
  54. @property(nonatomic, assign, getter=isBroadcast) BOOL broadcast;
  55. // Convenience constructor since all expected use cases will need a delegate
  56. // in order to receive remote tracks.
  57. - (instancetype)initWithDelegate:(id<ARDAppClientDelegate>)delegate;
  58. // Establishes a connection with the AppRTC servers for the given room id.
  59. // |settings| is an object containing settings such as video codec for the call.
  60. // If |isLoopback| is true, the call will connect to itself.
  61. - (void)connectToRoomWithId:(NSString *)roomId
  62. settings:(ARDSettingsModel *)settings
  63. isLoopback:(BOOL)isLoopback;
  64. // Disconnects from the AppRTC servers and any connected clients.
  65. - (void)disconnect;
  66. @end