RTCPeerConnection+Private.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. * Copyright 2015 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 "RTCPeerConnection.h"
  11. #include "api/peer_connection_interface.h"
  12. NS_ASSUME_NONNULL_BEGIN
  13. namespace webrtc {
  14. /**
  15. * These objects are created by RTCPeerConnectionFactory to wrap an
  16. * id<RTCPeerConnectionDelegate> and call methods on that interface.
  17. */
  18. class PeerConnectionDelegateAdapter : public PeerConnectionObserver {
  19. public:
  20. PeerConnectionDelegateAdapter(RTC_OBJC_TYPE(RTCPeerConnection) * peerConnection);
  21. ~PeerConnectionDelegateAdapter() override;
  22. void OnSignalingChange(PeerConnectionInterface::SignalingState new_state) override;
  23. void OnAddStream(rtc::scoped_refptr<MediaStreamInterface> stream) override;
  24. void OnRemoveStream(rtc::scoped_refptr<MediaStreamInterface> stream) override;
  25. void OnTrack(rtc::scoped_refptr<RtpTransceiverInterface> transceiver) override;
  26. void OnDataChannel(rtc::scoped_refptr<DataChannelInterface> data_channel) override;
  27. void OnRenegotiationNeeded() override;
  28. void OnIceConnectionChange(PeerConnectionInterface::IceConnectionState new_state) override;
  29. void OnStandardizedIceConnectionChange(
  30. PeerConnectionInterface::IceConnectionState new_state) override;
  31. void OnConnectionChange(PeerConnectionInterface::PeerConnectionState new_state) override;
  32. void OnIceGatheringChange(PeerConnectionInterface::IceGatheringState new_state) override;
  33. void OnIceCandidate(const IceCandidateInterface *candidate) override;
  34. void OnIceCandidatesRemoved(const std::vector<cricket::Candidate> &candidates) override;
  35. void OnIceSelectedCandidatePairChanged(const cricket::CandidatePairChangeEvent &event) override;
  36. void OnAddTrack(rtc::scoped_refptr<RtpReceiverInterface> receiver,
  37. const std::vector<rtc::scoped_refptr<MediaStreamInterface>> &streams) override;
  38. void OnRemoveTrack(rtc::scoped_refptr<RtpReceiverInterface> receiver) override;
  39. private:
  40. __weak RTC_OBJC_TYPE(RTCPeerConnection) * peer_connection_;
  41. };
  42. } // namespace webrtc
  43. @interface RTC_OBJC_TYPE (RTCPeerConnection)
  44. ()
  45. /** The factory used to create this RTCPeerConnection */
  46. @property(nonatomic, readonly) RTC_OBJC_TYPE(RTCPeerConnectionFactory) *
  47. factory;
  48. /** The native PeerConnectionInterface created during construction. */
  49. @property(nonatomic, readonly) rtc::scoped_refptr<webrtc::PeerConnectionInterface>
  50. nativePeerConnection;
  51. /** Initialize an RTCPeerConnection with a configuration, constraints, and
  52. * delegate.
  53. */
  54. - (instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory
  55. configuration:(RTC_OBJC_TYPE(RTCConfiguration) *)configuration
  56. constraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints
  57. delegate:(nullable id<RTC_OBJC_TYPE(RTCPeerConnectionDelegate)>)delegate;
  58. /** Initialize an RTCPeerConnection with a configuration, constraints,
  59. * delegate and PeerConnectionDependencies.
  60. */
  61. - (instancetype)initWithDependencies:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory
  62. configuration:(RTC_OBJC_TYPE(RTCConfiguration) *)configuration
  63. constraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints
  64. dependencies:
  65. (std::unique_ptr<webrtc::PeerConnectionDependencies>)dependencies
  66. delegate:(nullable id<RTC_OBJC_TYPE(RTCPeerConnectionDelegate)>)delegate
  67. NS_DESIGNATED_INITIALIZER;
  68. + (webrtc::PeerConnectionInterface::SignalingState)nativeSignalingStateForState:
  69. (RTCSignalingState)state;
  70. + (RTCSignalingState)signalingStateForNativeState:
  71. (webrtc::PeerConnectionInterface::SignalingState)nativeState;
  72. + (NSString *)stringForSignalingState:(RTCSignalingState)state;
  73. + (webrtc::PeerConnectionInterface::IceConnectionState)nativeIceConnectionStateForState:
  74. (RTCIceConnectionState)state;
  75. + (webrtc::PeerConnectionInterface::PeerConnectionState)nativeConnectionStateForState:
  76. (RTCPeerConnectionState)state;
  77. + (RTCIceConnectionState)iceConnectionStateForNativeState:
  78. (webrtc::PeerConnectionInterface::IceConnectionState)nativeState;
  79. + (RTCPeerConnectionState)connectionStateForNativeState:
  80. (webrtc::PeerConnectionInterface::PeerConnectionState)nativeState;
  81. + (NSString *)stringForIceConnectionState:(RTCIceConnectionState)state;
  82. + (NSString *)stringForConnectionState:(RTCPeerConnectionState)state;
  83. + (webrtc::PeerConnectionInterface::IceGatheringState)nativeIceGatheringStateForState:
  84. (RTCIceGatheringState)state;
  85. + (RTCIceGatheringState)iceGatheringStateForNativeState:
  86. (webrtc::PeerConnectionInterface::IceGatheringState)nativeState;
  87. + (NSString *)stringForIceGatheringState:(RTCIceGatheringState)state;
  88. + (webrtc::PeerConnectionInterface::StatsOutputLevel)nativeStatsOutputLevelForLevel:
  89. (RTCStatsOutputLevel)level;
  90. @end
  91. NS_ASSUME_NONNULL_END