diff --git a/src/pc/peer_connection.cpp b/src/pc/peer_connection.cpp index f3057a6..dfc991f 100644 --- a/src/pc/peer_connection.cpp +++ b/src/pc/peer_connection.cpp @@ -191,17 +191,19 @@ int PeerConnection::Init(PeerConnectionParams params, try_rejoin_with_turn_ = true; if (try_rejoin_with_turn_) { enable_turn_ = true; - LOG_INFO("Ice failed, destroy ice agent"); + LOG_INFO( + "Ice failed, destroy ice agent and rereate it with TURN enabled"); IceWorkMsg msg; msg.type = IceWorkMsg::Type::Destroy; PushIceWorkMsg(msg); - LOG_INFO("Create ice agent with TURN"); - msg.type = IceWorkMsg::Type::UserIdList; - msg.transmission_id = remote_transmission_id_; - msg.user_id_list = user_id_list_; - PushIceWorkMsg(msg); + if (offer_peer_) { + msg.type = IceWorkMsg::Type::UserIdList; + msg.transmission_id = remote_transmission_id_; + msg.user_id_list = user_id_list_; + PushIceWorkMsg(msg); + } } else { LOG_INFO("Unknown ice state"); } @@ -389,6 +391,7 @@ int PeerConnection::Join(const std::string &transmission_id, int ret = 0; + offer_peer_ = true; password_ = password; leave_ = false; diff --git a/src/pc/peer_connection.h b/src/pc/peer_connection.h index f20d673..44d1417 100644 --- a/src/pc/peer_connection.h +++ b/src/pc/peer_connection.h @@ -136,6 +136,7 @@ class PeerConnection { std::function on_receive_ws_msg_ = nullptr; std::function on_ws_status_ = nullptr; unsigned int ws_connection_id_ = 0; + bool offer_peer_ = false; std::string user_id_ = ""; std::string local_transmission_id_ = ""; std::string remote_transmission_id_ = "";