@@ -913,9 +913,14 @@ impl RTCPeerConnection {
913
913
_options : Option < RTCAnswerOptions > ,
914
914
) -> Result < RTCSessionDescription > {
915
915
let use_identity = self . idp_login_url . is_some ( ) ;
916
- if self . remote_description ( ) . await . is_none ( ) {
916
+ let remote_desc = self . remote_description ( ) . await ;
917
+ let remote_description: RTCSessionDescription ;
918
+ if let Some ( desc) = remote_desc {
919
+ remote_description = desc;
920
+ } else {
917
921
return Err ( Error :: ErrNoRemoteDescription ) ;
918
- } else if use_identity {
922
+ }
923
+ if use_identity {
919
924
return Err ( Error :: ErrIdentityProviderNotImplemented ) ;
920
925
} else if self . internal . is_closed . load ( Ordering :: SeqCst ) {
921
926
return Err ( Error :: ErrConnectionClosed ) ;
@@ -932,6 +937,11 @@ impl RTCPeerConnection {
932
937
. to_connection_role ( ) ;
933
938
if connection_role == ConnectionRole :: Unspecified {
934
939
connection_role = DEFAULT_DTLS_ROLE_ANSWER . to_connection_role ( ) ;
940
+ if let Some ( parsed) = remote_description. parsed {
941
+ if Self :: is_lite_set ( & parsed) && !self . internal . setting_engine . candidates . ice_lite {
942
+ connection_role = DTLSRole :: Server . to_connection_role ( ) ;
943
+ }
944
+ }
935
945
}
936
946
937
947
let local_transceivers = self . get_transceivers ( ) . await ;
@@ -1302,6 +1312,15 @@ impl RTCPeerConnection {
1302
1312
self . current_local_description ( ) . await
1303
1313
}
1304
1314
1315
+ pub fn is_lite_set ( desc : & SessionDescription ) -> bool {
1316
+ for a in & desc. attributes {
1317
+ if a. key . trim ( ) == ATTR_KEY_ICELITE {
1318
+ return true ;
1319
+ }
1320
+ }
1321
+ false
1322
+ }
1323
+
1305
1324
/// set_remote_description sets the SessionDescription of the remote peer
1306
1325
pub async fn set_remote_description ( & self , mut desc : RTCSessionDescription ) -> Result < ( ) > {
1307
1326
if self . internal . is_closed . load ( Ordering :: SeqCst ) {
@@ -1521,13 +1540,7 @@ impl RTCPeerConnection {
1521
1540
return Ok ( ( ) ) ;
1522
1541
}
1523
1542
1524
- let mut remote_is_lite = false ;
1525
- for a in & parsed. attributes {
1526
- if a. key . trim ( ) == ATTR_KEY_ICELITE {
1527
- remote_is_lite = true ;
1528
- break ;
1529
- }
1530
- }
1543
+ let remote_is_lite = Self :: is_lite_set ( parsed) ;
1531
1544
1532
1545
let ( fingerprint, fingerprint_hash) = extract_fingerprint ( parsed) ?;
1533
1546
0 commit comments