@@ -913,9 +913,14 @@ impl RTCPeerConnection {
913913 _options : Option < RTCAnswerOptions > ,
914914 ) -> Result < RTCSessionDescription > {
915915 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 {
917921 return Err ( Error :: ErrNoRemoteDescription ) ;
918- } else if use_identity {
922+ }
923+ if use_identity {
919924 return Err ( Error :: ErrIdentityProviderNotImplemented ) ;
920925 } else if self . internal . is_closed . load ( Ordering :: SeqCst ) {
921926 return Err ( Error :: ErrConnectionClosed ) ;
@@ -932,6 +937,11 @@ impl RTCPeerConnection {
932937 . to_connection_role ( ) ;
933938 if connection_role == ConnectionRole :: Unspecified {
934939 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+ }
935945 }
936946
937947 let local_transceivers = self . get_transceivers ( ) . await ;
@@ -1302,6 +1312,15 @@ impl RTCPeerConnection {
13021312 self . current_local_description ( ) . await
13031313 }
13041314
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+
13051324 /// set_remote_description sets the SessionDescription of the remote peer
13061325 pub async fn set_remote_description ( & self , mut desc : RTCSessionDescription ) -> Result < ( ) > {
13071326 if self . internal . is_closed . load ( Ordering :: SeqCst ) {
@@ -1521,13 +1540,7 @@ impl RTCPeerConnection {
15211540 return Ok ( ( ) ) ;
15221541 }
15231542
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) ;
15311544
15321545 let ( fingerprint, fingerprint_hash) = extract_fingerprint ( parsed) ?;
15331546
0 commit comments