Skip to content

Commit

Permalink
Support IceRestart when Ice State Disconnected。 (#218)
Browse files Browse the repository at this point in the history
* 网络切换后重新协商 SDP,使用IceRestart实现

* 在通话过程中持续坚挺Ice事件

* update.

* update.

Co-authored-by: cloudwebrtc <[email protected]>
  • Loading branch information
zjzhang-cn and cloudwebrtc authored Aug 24, 2021
1 parent 5947a4d commit 5c1819e
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions lib/src/rtc_session.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,8 @@ class RTCSession extends EventManager {

options = options ?? <String, dynamic>{};

Map<String, dynamic> rtcOfferConstraints = options['rtcOfferConstraints'];
Map<String, dynamic> rtcOfferConstraints =
options['rtcOfferConstraints'] ?? _rtcOfferConstraints;

if (_status != C.STATUS_WAITING_FOR_ACK && _status != C.STATUS_CONFIRMED) {
return false;
Expand Down Expand Up @@ -1574,6 +1575,13 @@ class RTCSession extends EventManager {
}, Timers.TIMER_H);
}

void _iceRestart() async {
Map<String, dynamic> offerConstraints =
_rtcOfferConstraints ?? <String, dynamic>{};
offerConstraints['mandatory']['IceRestart'] = true;
renegotiate(offerConstraints);
}

Future<void> _createRTCConnection(Map<String, dynamic> pcConfig,
Map<String, dynamic> rtcConstraints) async {
_connection = await createPeerConnection(pcConfig, rtcConstraints);
Expand All @@ -1585,6 +1593,9 @@ class RTCSession extends EventManager {
'status_code': 408,
'reason_phrase': DartSIP_C.causes.RTP_TIMEOUT
});
} else if (state ==
RTCIceConnectionState.RTCIceConnectionStateDisconnected) {
_iceRestart();
}
};

Expand Down Expand Up @@ -1619,7 +1630,7 @@ class RTCSession extends EventManager {
FutureOr<RTCSessionDescription> _createLocalDescription(
String type, Map<String, dynamic> constraints) async {
logger.debug('createLocalDescription()');

_iceGatheringState = RTCIceGatheringState.RTCIceGatheringStateNew;
Completer<RTCSessionDescription> completer =
Completer<RTCSessionDescription>();

Expand Down Expand Up @@ -1655,7 +1666,6 @@ class RTCSession extends EventManager {
Future<Null> Function() ready = () async {
_connection.onIceCandidate = null;
_connection.onIceGatheringState = null;
_connection.onIceConnectionState = null;
_iceGatheringState = RTCIceGatheringState.RTCIceGatheringStateComplete;
finished = true;
_rtcReady = true;
Expand Down

0 comments on commit 5c1819e

Please sign in to comment.