@@ -907,9 +907,14 @@ impl RTCPeerConnection {
907907 _options : Option < RTCAnswerOptions > ,
908908 ) -> Result < RTCSessionDescription > {
909909 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 {
911915 return Err ( Error :: ErrNoRemoteDescription ) ;
912- } else if use_identity {
916+ }
917+ if use_identity {
913918 return Err ( Error :: ErrIdentityProviderNotImplemented ) ;
914919 } else if self . internal . is_closed . load ( Ordering :: SeqCst ) {
915920 return Err ( Error :: ErrConnectionClosed ) ;
@@ -926,8 +931,10 @@ impl RTCPeerConnection {
926931 . to_connection_role ( ) ;
927932 if connection_role == ConnectionRole :: Unspecified {
928933 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+ }
931938 }
932939 }
933940
@@ -1299,6 +1306,15 @@ impl RTCPeerConnection {
12991306 self . current_local_description ( ) . await
13001307 }
13011308
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+
13021318 /// set_remote_description sets the SessionDescription of the remote peer
13031319 pub async fn set_remote_description ( & self , mut desc : RTCSessionDescription ) -> Result < ( ) > {
13041320 if self . internal . is_closed . load ( Ordering :: SeqCst ) {
@@ -1518,13 +1534,7 @@ impl RTCPeerConnection {
15181534 return Ok ( ( ) ) ;
15191535 }
15201536
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) ;
15281538
15291539 let ( fingerprint, fingerprint_hash) = extract_fingerprint ( parsed) ?;
15301540
0 commit comments