[feat] support libdatachannel trickle ICE

This commit is contained in:
dijunkun
2025-11-05 00:03:10 +08:00
parent 477c62bb12
commit 0d582bacc4
3 changed files with 28 additions and 4 deletions
+23 -1
View File
@@ -103,7 +103,7 @@ bool SignalNegotiation::leave_transmission(websocketpp::connection_hdl hdl,
}
}
transmission_manager_->ReleaseUserFromWsHandle(hdl);
// transmission_manager_->ReleaseUserFromWsHandle(hdl);
bool is_host =
transmission_manager_->IsHostOfTransmission(user_id, transmission_id);
@@ -295,3 +295,25 @@ bool SignalNegotiation::new_candidate(websocketpp::connection_hdl hdl,
return true;
}
bool SignalNegotiation::new_candidate_mid(websocketpp::connection_hdl hdl,
const json& j) {
std::string transmission_id = j["transmission_id"].get<std::string>();
std::string user_id = j["user_id"].get<std::string>();
std::string remote_user_id = j["remote_user_id"].get<std::string>();
std::string candidate = j["candidate"].get<std::string>();
std::string mid = j["mid"].get<std::string>();
websocketpp::connection_hdl destination_hdl =
transmission_manager_->GetWsHandle(remote_user_id);
// LOG_INFO("send candidate [{}]", candidate.c_str());
json message = {{"type", "new_candidate_mid"},
{"remote_user_id", user_id},
{"transmission_id", transmission_id},
{"candidate", candidate},
{"mid", mid}};
send_msg_(destination_hdl, message);
return true;
}
+2 -2
View File
@@ -28,11 +28,11 @@ class SignalNegotiation {
bool login_user(websocketpp::connection_hdl hdl, const json& j);
bool leave_transmission(websocketpp::connection_hdl hdl, const json& j);
bool query_user_id_list(websocketpp::connection_hdl hdl, const json& j);
bool join_transmission(websocketpp::connection_hdl hdl,
const json& j);
bool join_transmission(websocketpp::connection_hdl hdl, const json& j);
bool offer(websocketpp::connection_hdl hdl, const json& j);
bool answer(websocketpp::connection_hdl hdl, const json& j);
bool new_candidate(websocketpp::connection_hdl hdl, const json& j);
bool new_candidate_mid(websocketpp::connection_hdl hdl, const json& j);
private:
std::shared_ptr<TransmissionManager> transmission_manager_;
+3 -1
View File
@@ -154,7 +154,7 @@ void SignalServer::SendMsg(websocketpp::connection_hdl hdl, json message) {
if (!hdl.expired()) {
server_.send(hdl, message.dump(), websocketpp::frame::opcode::text);
} else {
LOG_ERROR("Destination hdl invalid");
LOG_ERROR("Destination hdl invalid, msg: {}", message.dump());
}
}
@@ -194,6 +194,8 @@ void SignalServer::OnMessage(websocketpp::connection_hdl hdl,
case "new_candidate"_H:
signal_negotiation_->new_candidate(hdl, j);
break;
case "new_candidate_mid"_H:
signal_negotiation_->new_candidate_mid(hdl, j);
default:
break;
}