Add ios bindings for PeerConnectionState.
This change makes it possible for ios apps to use the new standards-compliant PeerConnectionState. Bug: webrtc:9977 Change-Id: Icf69bb1faa0383ae239cb7508f2a740a2d489697 Reviewed-on: https://webrtc-review.googlesource.com/c/110502 Commit-Queue: Jonas Olsson <jonasolsson@webrtc.org> Reviewed-by: Kári Helgason <kthelgason@webrtc.org> Cr-Commit-Position: refs/heads/master@{#25651}
This commit is contained in:
@ -404,6 +404,11 @@ static int const kKbpsMultiplier = 1000;
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)peerConnection:(RTCPeerConnection *)peerConnection
|
||||||
|
didChangeConnectionState:(RTCPeerConnectionState)newState {
|
||||||
|
RTCLog(@"ICE+DTLS state changed: %ld", (long)newState);
|
||||||
|
}
|
||||||
|
|
||||||
- (void)peerConnection:(RTCPeerConnection *)peerConnection
|
- (void)peerConnection:(RTCPeerConnection *)peerConnection
|
||||||
didChangeIceGatheringState:(RTCIceGatheringState)newState {
|
didChangeIceGatheringState:(RTCIceGatheringState)newState {
|
||||||
RTCLog(@"ICE gathering state changed: %ld", (long)newState);
|
RTCLog(@"ICE gathering state changed: %ld", (long)newState);
|
||||||
|
|||||||
@ -39,6 +39,8 @@ class PeerConnectionDelegateAdapter : public PeerConnectionObserver {
|
|||||||
|
|
||||||
void OnIceConnectionChange(PeerConnectionInterface::IceConnectionState new_state) override;
|
void OnIceConnectionChange(PeerConnectionInterface::IceConnectionState new_state) override;
|
||||||
|
|
||||||
|
void OnConnectionChange(PeerConnectionInterface::PeerConnectionState new_state) override;
|
||||||
|
|
||||||
void OnIceGatheringChange(PeerConnectionInterface::IceGatheringState new_state) override;
|
void OnIceGatheringChange(PeerConnectionInterface::IceGatheringState new_state) override;
|
||||||
|
|
||||||
void OnIceCandidate(const IceCandidateInterface *candidate) override;
|
void OnIceCandidate(const IceCandidateInterface *candidate) override;
|
||||||
@ -85,11 +87,19 @@ class PeerConnectionDelegateAdapter : public PeerConnectionObserver {
|
|||||||
+ (webrtc::PeerConnectionInterface::IceConnectionState)nativeIceConnectionStateForState:
|
+ (webrtc::PeerConnectionInterface::IceConnectionState)nativeIceConnectionStateForState:
|
||||||
(RTCIceConnectionState)state;
|
(RTCIceConnectionState)state;
|
||||||
|
|
||||||
|
+ (webrtc::PeerConnectionInterface::PeerConnectionState)nativeConnectionStateForState:
|
||||||
|
(RTCPeerConnectionState)state;
|
||||||
|
|
||||||
+ (RTCIceConnectionState)iceConnectionStateForNativeState:
|
+ (RTCIceConnectionState)iceConnectionStateForNativeState:
|
||||||
(webrtc::PeerConnectionInterface::IceConnectionState)nativeState;
|
(webrtc::PeerConnectionInterface::IceConnectionState)nativeState;
|
||||||
|
|
||||||
|
+ (RTCPeerConnectionState)connectionStateForNativeState:
|
||||||
|
(webrtc::PeerConnectionInterface::PeerConnectionState)nativeState;
|
||||||
|
|
||||||
+ (NSString *)stringForIceConnectionState:(RTCIceConnectionState)state;
|
+ (NSString *)stringForIceConnectionState:(RTCIceConnectionState)state;
|
||||||
|
|
||||||
|
+ (NSString *)stringForConnectionState:(RTCPeerConnectionState)state;
|
||||||
|
|
||||||
+ (webrtc::PeerConnectionInterface::IceGatheringState)nativeIceGatheringStateForState:
|
+ (webrtc::PeerConnectionInterface::IceGatheringState)nativeIceGatheringStateForState:
|
||||||
(RTCIceGatheringState)state;
|
(RTCIceGatheringState)state;
|
||||||
|
|
||||||
|
|||||||
@ -57,6 +57,16 @@ typedef NS_ENUM(NSInteger, RTCIceConnectionState) {
|
|||||||
RTCIceConnectionStateCount,
|
RTCIceConnectionStateCount,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Represents the combined ice+dtls connection state of the peer connection. */
|
||||||
|
typedef NS_ENUM(NSInteger, RTCPeerConnectionState) {
|
||||||
|
RTCPeerConnectionStateNew,
|
||||||
|
RTCPeerConnectionStateConnecting,
|
||||||
|
RTCPeerConnectionStateConnected,
|
||||||
|
RTCPeerConnectionStateDisconnected,
|
||||||
|
RTCPeerConnectionStateFailed,
|
||||||
|
RTCPeerConnectionStateClosed,
|
||||||
|
};
|
||||||
|
|
||||||
/** Represents the ice gathering state of the peer connection. */
|
/** Represents the ice gathering state of the peer connection. */
|
||||||
typedef NS_ENUM(NSInteger, RTCIceGatheringState) {
|
typedef NS_ENUM(NSInteger, RTCIceGatheringState) {
|
||||||
RTCIceGatheringStateNew,
|
RTCIceGatheringStateNew,
|
||||||
@ -115,11 +125,14 @@ RTC_OBJC_EXPORT
|
|||||||
* This is only called with RTCSdpSemanticsUnifiedPlan specified.
|
* This is only called with RTCSdpSemanticsUnifiedPlan specified.
|
||||||
*/
|
*/
|
||||||
@optional
|
@optional
|
||||||
|
/** Called any time the PeerConnectionState changes. */
|
||||||
|
- (void)peerConnection:(RTCPeerConnection *)peerConnection
|
||||||
|
didChangeConnectionState:(RTCPeerConnectionState)newState;
|
||||||
|
|
||||||
- (void)peerConnection:(RTCPeerConnection *)peerConnection
|
- (void)peerConnection:(RTCPeerConnection *)peerConnection
|
||||||
didStartReceivingOnTransceiver:(RTCRtpTransceiver *)transceiver;
|
didStartReceivingOnTransceiver:(RTCRtpTransceiver *)transceiver;
|
||||||
|
|
||||||
/** Called when a receiver and its track are created. */
|
/** Called when a receiver and its track are created. */
|
||||||
@optional
|
|
||||||
- (void)peerConnection:(RTCPeerConnection *)peerConnection
|
- (void)peerConnection:(RTCPeerConnection *)peerConnection
|
||||||
didAddReceiver:(RTCRtpReceiver *)rtpReceiver
|
didAddReceiver:(RTCRtpReceiver *)rtpReceiver
|
||||||
streams:(NSArray<RTCMediaStream *> *)mediaStreams;
|
streams:(NSArray<RTCMediaStream *> *)mediaStreams;
|
||||||
@ -145,6 +158,7 @@ RTC_OBJC_EXPORT
|
|||||||
@property(nonatomic, readonly, nullable) RTCSessionDescription *remoteDescription;
|
@property(nonatomic, readonly, nullable) RTCSessionDescription *remoteDescription;
|
||||||
@property(nonatomic, readonly) RTCSignalingState signalingState;
|
@property(nonatomic, readonly) RTCSignalingState signalingState;
|
||||||
@property(nonatomic, readonly) RTCIceConnectionState iceConnectionState;
|
@property(nonatomic, readonly) RTCIceConnectionState iceConnectionState;
|
||||||
|
@property(nonatomic, readonly) RTCPeerConnectionState connectionState;
|
||||||
@property(nonatomic, readonly) RTCIceGatheringState iceGatheringState;
|
@property(nonatomic, readonly) RTCIceGatheringState iceGatheringState;
|
||||||
@property(nonatomic, readonly, copy) RTCConfiguration *configuration;
|
@property(nonatomic, readonly, copy) RTCConfiguration *configuration;
|
||||||
|
|
||||||
|
|||||||
@ -175,11 +175,14 @@ void PeerConnectionDelegateAdapter::OnRenegotiationNeeded() {
|
|||||||
|
|
||||||
void PeerConnectionDelegateAdapter::OnIceConnectionChange(
|
void PeerConnectionDelegateAdapter::OnIceConnectionChange(
|
||||||
PeerConnectionInterface::IceConnectionState new_state) {
|
PeerConnectionInterface::IceConnectionState new_state) {
|
||||||
RTCIceConnectionState state =
|
RTCIceConnectionState state = [RTCPeerConnection iceConnectionStateForNativeState:new_state];
|
||||||
[[RTCPeerConnection class] iceConnectionStateForNativeState:new_state];
|
[peer_connection_.delegate peerConnection:peer_connection_ didChangeIceConnectionState:state];
|
||||||
RTCPeerConnection *peer_connection = peer_connection_;
|
}
|
||||||
[peer_connection.delegate peerConnection:peer_connection
|
|
||||||
didChangeIceConnectionState:state];
|
void PeerConnectionDelegateAdapter::OnConnectionChange(
|
||||||
|
PeerConnectionInterface::PeerConnectionState new_state) {
|
||||||
|
RTCPeerConnectionState state = [RTCPeerConnection connectionStateForNativeState:new_state];
|
||||||
|
[peer_connection_.delegate peerConnection:peer_connection_ didChangeConnectionState:state];
|
||||||
}
|
}
|
||||||
|
|
||||||
void PeerConnectionDelegateAdapter::OnIceGatheringChange(
|
void PeerConnectionDelegateAdapter::OnIceGatheringChange(
|
||||||
@ -322,6 +325,10 @@ void PeerConnectionDelegateAdapter::OnRemoveTrack(
|
|||||||
_peerConnection->ice_connection_state()];
|
_peerConnection->ice_connection_state()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (RTCPeerConnectionState)connectionState {
|
||||||
|
return [[self class] connectionStateForNativeState:_peerConnection->peer_connection_state()];
|
||||||
|
}
|
||||||
|
|
||||||
- (RTCIceGatheringState)iceGatheringState {
|
- (RTCIceGatheringState)iceGatheringState {
|
||||||
return [[self class] iceGatheringStateForNativeState:
|
return [[self class] iceGatheringStateForNativeState:
|
||||||
_peerConnection->ice_gathering_state()];
|
_peerConnection->ice_gathering_state()];
|
||||||
@ -632,6 +639,59 @@ void PeerConnectionDelegateAdapter::OnRemoveTrack(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ (webrtc::PeerConnectionInterface::PeerConnectionState)nativeConnectionStateForState:
|
||||||
|
(RTCPeerConnectionState)state {
|
||||||
|
switch (state) {
|
||||||
|
case RTCPeerConnectionStateNew:
|
||||||
|
return webrtc::PeerConnectionInterface::PeerConnectionState::kNew;
|
||||||
|
case RTCPeerConnectionStateConnecting:
|
||||||
|
return webrtc::PeerConnectionInterface::PeerConnectionState::kConnecting;
|
||||||
|
case RTCPeerConnectionStateConnected:
|
||||||
|
return webrtc::PeerConnectionInterface::PeerConnectionState::kConnected;
|
||||||
|
case RTCPeerConnectionStateFailed:
|
||||||
|
return webrtc::PeerConnectionInterface::PeerConnectionState::kFailed;
|
||||||
|
case RTCPeerConnectionStateDisconnected:
|
||||||
|
return webrtc::PeerConnectionInterface::PeerConnectionState::kDisconnected;
|
||||||
|
case RTCPeerConnectionStateClosed:
|
||||||
|
return webrtc::PeerConnectionInterface::PeerConnectionState::kClosed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (RTCPeerConnectionState)connectionStateForNativeState:
|
||||||
|
(webrtc::PeerConnectionInterface::PeerConnectionState)nativeState {
|
||||||
|
switch (nativeState) {
|
||||||
|
case webrtc::PeerConnectionInterface::PeerConnectionState::kNew:
|
||||||
|
return RTCPeerConnectionStateNew;
|
||||||
|
case webrtc::PeerConnectionInterface::PeerConnectionState::kConnecting:
|
||||||
|
return RTCPeerConnectionStateConnecting;
|
||||||
|
case webrtc::PeerConnectionInterface::PeerConnectionState::kConnected:
|
||||||
|
return RTCPeerConnectionStateConnected;
|
||||||
|
case webrtc::PeerConnectionInterface::PeerConnectionState::kFailed:
|
||||||
|
return RTCPeerConnectionStateFailed;
|
||||||
|
case webrtc::PeerConnectionInterface::PeerConnectionState::kDisconnected:
|
||||||
|
return RTCPeerConnectionStateDisconnected;
|
||||||
|
case webrtc::PeerConnectionInterface::PeerConnectionState::kClosed:
|
||||||
|
return RTCPeerConnectionStateClosed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (NSString *)stringForConnectionState:(RTCPeerConnectionState)state {
|
||||||
|
switch (state) {
|
||||||
|
case RTCPeerConnectionStateNew:
|
||||||
|
return @"NEW";
|
||||||
|
case RTCPeerConnectionStateConnecting:
|
||||||
|
return @"CONNECTING";
|
||||||
|
case RTCPeerConnectionStateConnected:
|
||||||
|
return @"CONNECTED";
|
||||||
|
case RTCPeerConnectionStateFailed:
|
||||||
|
return @"FAILED";
|
||||||
|
case RTCPeerConnectionStateDisconnected:
|
||||||
|
return @"DISCONNECTED";
|
||||||
|
case RTCPeerConnectionStateClosed:
|
||||||
|
return @"CLOSED";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
+ (webrtc::PeerConnectionInterface::IceConnectionState)
|
+ (webrtc::PeerConnectionInterface::IceConnectionState)
|
||||||
nativeIceConnectionStateForState:(RTCIceConnectionState)state {
|
nativeIceConnectionStateForState:(RTCIceConnectionState)state {
|
||||||
switch (state) {
|
switch (state) {
|
||||||
|
|||||||
Reference in New Issue
Block a user