@@ -907,9 +907,14 @@ impl RTCPeerConnection {
907
907
_options : Option < RTCAnswerOptions > ,
908
908
) -> Result < RTCSessionDescription > {
909
909
let use_identity = self . idp_login_url . is_some ( ) ;
910
- if self . remote_description ( ) . await . is_none ( ) {
910
+ let remote_desc = self . remote_description ( ) . await ;
911
+ let remote_description: RTCSessionDescription ;
912
+ if let Some ( desc) = remote_desc {
913
+ remote_description = desc;
914
+ } else {
911
915
return Err ( Error :: ErrNoRemoteDescription ) ;
912
- } else if use_identity {
916
+ }
917
+ if use_identity {
913
918
return Err ( Error :: ErrIdentityProviderNotImplemented ) ;
914
919
} else if self . internal . is_closed . load ( Ordering :: SeqCst ) {
915
920
return Err ( Error :: ErrConnectionClosed ) ;
@@ -926,8 +931,10 @@ impl RTCPeerConnection {
926
931
. to_connection_role ( ) ;
927
932
if connection_role == ConnectionRole :: Unspecified {
928
933
connection_role = DEFAULT_DTLS_ROLE_ANSWER . to_connection_role ( ) ;
929
- if remote_is_lite && !self . internal . setting_engine . candidates . ice_lite {
930
- connection_role = DTLSRole :: Server . to_connection_role ( ) ;
934
+ if let Some ( parsed) = remote_description. parsed {
935
+ if Self :: is_lite_set ( & parsed) && !self . internal . setting_engine . candidates . ice_lite {
936
+ connection_role = DTLSRole :: Server . to_connection_role ( ) ;
937
+ }
931
938
}
932
939
}
933
940
@@ -1299,6 +1306,15 @@ impl RTCPeerConnection {
1299
1306
self . current_local_description ( ) . await
1300
1307
}
1301
1308
1309
+ pub fn is_lite_set ( desc : & SessionDescription ) -> bool {
1310
+ for a in & desc. attributes {
1311
+ if a. key . trim ( ) == ATTR_KEY_ICELITE {
1312
+ return true ;
1313
+ }
1314
+ }
1315
+ return false ;
1316
+ }
1317
+
1302
1318
/// set_remote_description sets the SessionDescription of the remote peer
1303
1319
pub async fn set_remote_description ( & self , mut desc : RTCSessionDescription ) -> Result < ( ) > {
1304
1320
if self . internal . is_closed . load ( Ordering :: SeqCst ) {
@@ -1518,13 +1534,7 @@ impl RTCPeerConnection {
1518
1534
return Ok ( ( ) ) ;
1519
1535
}
1520
1536
1521
- let mut remote_is_lite = false ;
1522
- for a in & parsed. attributes {
1523
- if a. key . trim ( ) == ATTR_KEY_ICELITE {
1524
- remote_is_lite = true ;
1525
- break ;
1526
- }
1527
- }
1537
+ let remote_is_lite = Self :: is_lite_set ( parsed) ;
1528
1538
1529
1539
let ( fingerprint, fingerprint_hash) = extract_fingerprint ( parsed) ?;
1530
1540
0 commit comments