[feat] add config param to control use TURN or not

This commit is contained in:
dijunkun
2024-08-27 17:05:41 +08:00
parent 35f26283de
commit 0b0e61cdc4
8 changed files with 45 additions and 24 deletions

View File

@@ -12,11 +12,13 @@
using nlohmann::json;
IceTransmission::IceTransmission(
bool trickle_ice, bool offer_peer, std::string &transmission_id,
std::string &user_id, std::string &remote_user_id,
bool enable_turn, bool trickle_ice, bool offer_peer,
std::string &transmission_id, std::string &user_id,
std::string &remote_user_id,
std::shared_ptr<WsTransmission> ice_ws_transmission,
std::function<void(std::string)> on_ice_status_change)
: trickle_ice_(trickle_ice),
: enable_turn_(enable_turn),
trickle_ice_(trickle_ice),
offer_peer_(offer_peer),
transmission_id_(transmission_id),
user_id_(user_id),
@@ -163,9 +165,9 @@ int IceTransmission::InitIceTransmission(
remote_user_id_.size());
});
ice_agent_ = std::make_unique<IceAgent>(trickle_ice_, offer_peer_, stun_ip,
stun_port, turn_ip, turn_port,
turn_username, turn_password);
ice_agent_ = std::make_unique<IceAgent>(
enable_turn_, trickle_ice_, offer_peer_, stun_ip, stun_port, turn_ip,
turn_port, turn_username, turn_password);
ice_agent_->CreateIceAgent(
[](NiceAgent *agent, guint stream_id, guint component_id,

View File

@@ -34,7 +34,7 @@ class IceTransmission {
enum TraversalType { TP2P = 0, TRelay = 1, TUnknown = 2 };
public:
IceTransmission(bool trickle_ice, bool offer_peer,
IceTransmission(bool enable_turn, bool trickle_ice, bool offer_peer,
std::string &transmission_id, std::string &user_id,
std::string &remote_user_id,
std::shared_ptr<WsTransmission> ice_ws_transmission,
@@ -105,6 +105,7 @@ class IceTransmission {
uint8_t CheckIsDataPacket(const char *buffer, size_t size);
private:
bool enable_turn_ = false;
bool trickle_ice_ = true;
std::string local_sdp_;
std::string remote_sdp_;