Skip to content

Commit df899df

Browse files
PerondasPerondas
andauthored
Hold fix (#351)
* Fixed bug where hold() would not work under specific circumstances --------- Closes: #339 Co-authored-by: Perondas <Pperondas@gmail.com>
1 parent 676f526 commit df899df

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

lib/src/rtc_session.dart

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,8 +1550,11 @@ class RTCSession extends EventManager implements Owner {
15501550
}
15511551

15521552
void _iceRestart() async {
1553-
Map<String, dynamic> offerConstraints =
1554-
_rtcOfferConstraints ?? <String, dynamic>{};
1553+
Map<String, dynamic> offerConstraints = _rtcOfferConstraints ??
1554+
<String, dynamic>{
1555+
'mandatory': <String, dynamic>{},
1556+
'optional': <dynamic>[],
1557+
};
15551558
offerConstraints['mandatory']['IceRestart'] = true;
15561559
renegotiate(offerConstraints);
15571560
}
@@ -1608,11 +1611,17 @@ class RTCSession extends EventManager implements Owner {
16081611
Completer<RTCSessionDescription> completer =
16091612
Completer<RTCSessionDescription>();
16101613

1614+
constraints = constraints ??
1615+
<String, dynamic>{
1616+
'mandatory': <String, dynamic>{},
1617+
'optional': <dynamic>[],
1618+
};
1619+
16111620
List<Future<RTCSessionDescription> Function(RTCSessionDescription)>
1612-
_modifiers = constraints?['offerModifiers'] ??
1621+
_modifiers = constraints['offerModifiers'] ??
16131622
<Future<RTCSessionDescription> Function(RTCSessionDescription)>[];
16141623

1615-
constraints?['offerModifiers'] = null;
1624+
constraints['offerModifiers'] = null;
16161625

16171626
if (type != 'offer' && type != 'answer') {
16181627
completer.completeError(Exceptions.TypeError(
@@ -1623,7 +1632,7 @@ class RTCSession extends EventManager implements Owner {
16231632
late RTCSessionDescription desc;
16241633
if (type == 'offer') {
16251634
try {
1626-
desc = await _connection!.createOffer(constraints!);
1635+
desc = await _connection!.createOffer(constraints);
16271636
} catch (error) {
16281637
logger.e(
16291638
'emit "peerconnection:createofferfailed" [error:${error.toString()}]');
@@ -1632,7 +1641,7 @@ class RTCSession extends EventManager implements Owner {
16321641
}
16331642
} else {
16341643
try {
1635-
desc = await _connection!.createAnswer(constraints!);
1644+
desc = await _connection!.createAnswer(constraints);
16361645
} catch (error) {
16371646
logger.e(
16381647
'emit "peerconnection:createanswerfailed" [error:${error.toString()}]');

0 commit comments

Comments
 (0)