Remote desk client supports MacOS

This commit is contained in:
dijunkun
2023-09-19 17:06:00 +08:00
parent ebd7d87e91
commit b16b29780b
19 changed files with 312 additions and 55 deletions

View File

@@ -6,7 +6,15 @@
#include "log.h"
IceAgent::IceAgent(std::string &ip, uint16_t port) : ip_(ip), port_(port) {}
IceAgent::IceAgent(std::string &stun_ip, uint16_t stun_port,
std::string &turn_ip, uint16_t turn_port,
std::string &turn_username, std::string &turn_password)
: stun_ip_(stun_ip),
stun_port_(stun_port),
turn_ip_(turn_ip),
turn_port_(turn_port),
turn_username_(turn_username),
turn_password_(turn_password) {}
IceAgent::~IceAgent() {}
@@ -20,8 +28,20 @@ int IceAgent::CreateIceAgent(juice_cb_state_changed_t on_state_changed,
memset(&config, 0, sizeof(config));
// STUN server example
config.stun_server_host = ip_.c_str();
config.stun_server_port = port_;
config.stun_server_host = stun_ip_.c_str();
config.stun_server_port = stun_port_;
if (!turn_ip_.empty() && -1 != turn_port_ && !turn_username_.empty() &&
!turn_password_.empty()) {
juice_turn_server_t turn_server;
memset(&turn_server, 0, sizeof(turn_server));
turn_server.host = turn_ip_.c_str();
turn_server.port = turn_port_;
turn_server.username = turn_username_.c_str();
turn_server.password = turn_password_.c_str();
config.turn_servers = &turn_server;
config.turn_servers_count = 1;
}
config.cb_state_changed = on_state_changed;
config.cb_candidate = on_candidate;

View File

@@ -7,7 +7,9 @@
class IceAgent {
public:
IceAgent(std::string& ip, uint16_t port);
IceAgent(std::string& stun_ip, uint16_t stun_port, std::string& turn_ip,
uint16_t turn_port, std::string& turn_username,
std::string& turn_password);
~IceAgent();
int CreateIceAgent(juice_cb_state_changed_t on_state_changed,
@@ -36,8 +38,12 @@ class IceAgent {
int Send(const char* data, size_t size);
private:
std::string ip_ = "";
uint16_t port_ = 0;
std::string stun_ip_ = "";
uint16_t stun_port_ = 0;
std::string turn_ip_ = "";
uint16_t turn_port_ = 0;
std::string turn_username_ = "";
std::string turn_password_ = "";
juice_agent_t* agent_ = nullptr;
char local_sdp_[JUICE_MAX_SDP_STRING_LEN];
juice_state_t state_;