mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-27 04:35:34 +08:00
Dev version: Support multiple ice connections
This commit is contained in:
@@ -49,7 +49,8 @@ char *IceAgent::GenerateLocalSdp() {
|
||||
}
|
||||
|
||||
juice_get_local_description(agent_, local_sdp_, JUICE_MAX_SDP_STRING_LEN);
|
||||
LOG_INFO("Generate local sdp:[\n{}]", local_sdp_);
|
||||
// LOG_INFO("Generate local sdp:[\n{}]", local_sdp_);
|
||||
LOG_INFO("Generate local sdp");
|
||||
|
||||
return local_sdp_;
|
||||
}
|
||||
@@ -57,13 +58,13 @@ char *IceAgent::GenerateLocalSdp() {
|
||||
int IceAgent::SetRemoteSdp(const char *remote_sdp) {
|
||||
LOG_INFO("Set remote sdp");
|
||||
juice_set_remote_description(agent_, remote_sdp);
|
||||
LOG_INFO("Remote description:[\n{}]", remote_sdp);
|
||||
// LOG_INFO("Remote description:[\n{}]", remote_sdp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int IceAgent::GatherCandidates() {
|
||||
LOG_INFO("Gather candidates");
|
||||
LOG_INFO("[{}] Gather candidates", (void *)this);
|
||||
juice_gather_candidates(agent_);
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -31,7 +31,7 @@ int IceTransmission::InitIceTransmission(std::string &ip, int port) {
|
||||
LOG_INFO("state_change: {}", ice_status[state]);
|
||||
},
|
||||
[](juice_agent_t *agent, const char *sdp, void *user_ptr) {
|
||||
LOG_INFO("candadite: {}", sdp);
|
||||
// LOG_INFO("candadite: {}", sdp);
|
||||
// trickle
|
||||
// static_cast<IceTransmission
|
||||
// *>(user_ptr)->SendOfferLocalCandidate(sdp);
|
||||
@@ -136,7 +136,8 @@ int IceTransmission::SendOffer() {
|
||||
json message = {{"type", "offer"},
|
||||
{"transmission_id", transmission_id_},
|
||||
{"sdp", local_sdp_}};
|
||||
LOG_INFO("Send offer:\n{}", message.dump().c_str());
|
||||
// LOG_INFO("Send offer:\n{}", message.dump().c_str());
|
||||
LOG_INFO("Send offer");
|
||||
|
||||
if (ice_ws_transport_) {
|
||||
ice_ws_transport_->Send(message.dump());
|
||||
@@ -165,7 +166,9 @@ int IceTransmission::SendAnswer() {
|
||||
{"transmission_id", transmission_id_},
|
||||
{"sdp", local_sdp_},
|
||||
{"guest", remote_ice_username_}};
|
||||
LOG_INFO("Send answer:\n{}", message.dump().c_str());
|
||||
// LOG_INFO("Send answer:\n{}", message.dump().c_str());
|
||||
LOG_INFO("[{}] Send answer to [{}]", GetIceUsername(local_sdp_),
|
||||
remote_ice_username_);
|
||||
|
||||
if (ice_ws_transport_) {
|
||||
ice_ws_transport_->Send(message.dump());
|
||||
@@ -178,7 +181,8 @@ int IceTransmission::SendOfferLocalCandidate(
|
||||
json message = {{"type", "offer_candidate"},
|
||||
{"transmission_id", transmission_id_},
|
||||
{"sdp", remote_candidate}};
|
||||
LOG_INFO("Send candidate:\n{}", message.dump().c_str());
|
||||
// LOG_INFO("Send candidate:\n{}", message.dump().c_str());
|
||||
LOG_INFO("Send candidate");
|
||||
|
||||
if (ice_ws_transport_) {
|
||||
ice_ws_transport_->Send(message.dump());
|
||||
@@ -191,7 +195,8 @@ int IceTransmission::SendAnswerLocalCandidate(
|
||||
json message = {{"type", "answer_candidate"},
|
||||
{"transmission_id", transmission_id_},
|
||||
{"sdp", remote_candidate}};
|
||||
LOG_INFO("Send candidate:\n{}", message.dump().c_str());
|
||||
// LOG_INFO("Send candidate:\n{}", message.dump().c_str());
|
||||
LOG_INFO("Send candidate");
|
||||
|
||||
if (ice_ws_transport_) {
|
||||
ice_ws_transport_->Send(message.dump());
|
||||
@@ -206,7 +211,7 @@ int IceTransmission::SendData(const char *data, size_t size) {
|
||||
|
||||
void IceTransmission::OnReceiveMessage(const std::string &msg) {
|
||||
auto j = json::parse(msg);
|
||||
LOG_INFO("msg: {}", msg.c_str());
|
||||
// LOG_INFO("msg: {}", msg.c_str());
|
||||
|
||||
std::string type = j["type"];
|
||||
|
||||
@@ -217,7 +222,8 @@ void IceTransmission::OnReceiveMessage(const std::string &msg) {
|
||||
if (remote_sdp_.empty()) {
|
||||
LOG_INFO("Invalid remote sdp");
|
||||
} else {
|
||||
LOG_INFO("Receive remote sdp [{}]", remote_sdp_);
|
||||
// LOG_INFO("Receive remote sdp [{}]", remote_sdp_);
|
||||
LOG_INFO("Receive remote sdp");
|
||||
SetRemoteSdp(remote_sdp_);
|
||||
|
||||
GatherCandidates();
|
||||
@@ -243,7 +249,8 @@ void IceTransmission::OnReceiveMessage(const std::string &msg) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
|
||||
QueryRemoteSdp(transmission_id_);
|
||||
} else {
|
||||
LOG_INFO("Receive remote sdp [{}]", remote_sdp_);
|
||||
// LOG_INFO("Receive remote sdp [{}]", remote_sdp_);
|
||||
LOG_INFO("Receive remote sdp");
|
||||
SetRemoteSdp(remote_sdp_);
|
||||
|
||||
if (!offer_peer_) {
|
||||
@@ -254,7 +261,8 @@ void IceTransmission::OnReceiveMessage(const std::string &msg) {
|
||||
}
|
||||
case "candidate"_H: {
|
||||
std::string candidate = j["sdp"].get<std::string>();
|
||||
LOG_INFO("Receive candidate [{}]", candidate);
|
||||
// LOG_INFO("Receive candidate [{}]", candidate);
|
||||
LOG_INFO("Receive candidate");
|
||||
AddRemoteCandidate(candidate);
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user