NCPeerConnection.h 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /**
  2. * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
  3. * SPDX-License-Identifier: GPL-3.0-or-later
  4. */
  5. #import <Foundation/Foundation.h>
  6. #import <WebRTC/RTCPeerConnection.h>
  7. #import <WebRTC/RTCDataChannel.h>
  8. @class NCPeerConnection;
  9. @protocol NCPeerConnectionDelegate <NSObject>
  10. /** Called when media is received on a new stream from remote peer. */
  11. - (void)peerConnection:(NCPeerConnection *)peerConnection didAddStream:(RTCMediaStream *)stream;
  12. /** Called when a remote peer closes a stream. */
  13. - (void)peerConnection:(NCPeerConnection *)peerConnection didRemoveStream:(RTCMediaStream *)stream;
  14. /** Called any time the IceConnectionState changes. */
  15. - (void)peerConnection:(NCPeerConnection *)peerConnection didChangeIceConnectionState:(RTCIceConnectionState)newState;
  16. /** Status data channel has been opened. */
  17. //- (void)peerConnectionDidOpenStatusDataChannel:(NCPeerConnection *)peerConnection;
  18. /** Message received from status data channel has been opened. */
  19. - (void)peerConnection:(NCPeerConnection *)peerConnection didReceiveStatusDataChannelMessage:(NSString *)type;
  20. /** Peer's nick received from status data channel has been opened. */
  21. - (void)peerConnection:(NCPeerConnection *)peerConnection didReceivePeerNick:(NSString *)nick;
  22. /** New ice candidate has been found. */
  23. - (void)peerConnection:(NCPeerConnection *)peerConnection didGenerateIceCandidate:(RTCIceCandidate *)candidate;
  24. /** Called when a peer connection creates session description */
  25. - (void)peerConnection:(NCPeerConnection *)peerConnection needsToSendSessionDescription:(RTCSessionDescription *)sessionDescription;
  26. @end
  27. @interface NCPeerConnection : NSObject
  28. @property (nonatomic, weak) id<NCPeerConnectionDelegate> delegate;
  29. @property (nonatomic, copy, readonly) NSString *peerIdentifier; // "peerId-sid"
  30. @property (nonatomic, copy) NSString *peerId;
  31. @property (nonatomic, copy) NSString *sid;
  32. @property (nonatomic, copy) NSString *peerName;
  33. @property (nonatomic, copy) NSString *roomType;
  34. @property (nonatomic, assign) BOOL isAudioOnly;
  35. @property (nonatomic, assign) BOOL isMCUPublisherPeer;
  36. @property (nonatomic, assign) BOOL isDummyPeer;
  37. @property (nonatomic, assign) BOOL isOwnScreensharePeer;
  38. @property (nonatomic, assign) BOOL isRemoteAudioDisabled;
  39. @property (nonatomic, assign) BOOL isRemoteVideoDisabled;
  40. @property (nonatomic, assign) BOOL isPeerSpeaking;
  41. @property (nonatomic, assign) BOOL isHandRaised;
  42. @property (nonatomic, assign) BOOL showRemoteVideoInOriginalSize;
  43. @property (nonatomic, strong, readonly) NSMutableArray *queuedRemoteCandidates;
  44. - (instancetype)initWithSessionId:(NSString *)sessionId sid:(NSString *)sid andICEServers:(NSArray *)iceServers forAudioOnlyCall:(BOOL)audioOnly;
  45. - (instancetype)initForPublisherWithSessionId:(NSString *)sessionId andICEServers:(NSArray *)iceServers forAudioOnlyCall:(BOOL)audioOnly;
  46. - (void)addICECandidate:(RTCIceCandidate *)candidate;
  47. - (void)setRemoteDescription:(RTCSessionDescription *)sessionDescription;
  48. - (void)sendPublisherOffer;
  49. - (void)sendOffer;
  50. - (void)sendDataChannelMessageOfType:(NSString *)type withPayload:(id)payload;
  51. - (void)setStatusForDataChannelMessageType:(NSString *)type withPayload:(id)payload;
  52. - (void)drainRemoteCandidates;
  53. - (void)close;
  54. - (RTCPeerConnection *)getPeerConnection;
  55. - (RTCMediaStream *)getRemoteStream;
  56. - (BOOL)hasRemoteStream;
  57. @end