Do not use 'S-' or 'C-' as the prefix for the user id of a peer

This commit is contained in:
dijunkun
2024-06-07 16:27:05 +08:00
parent 4b3839aa34
commit 5a690ebbb6
4 changed files with 8 additions and 35 deletions

View File

@@ -185,7 +185,7 @@ int MainWindow::CreateConnectionPeer() {
peer_ = CreatePeer(&params_); peer_ = CreatePeer(&params_);
if (peer_) { if (peer_) {
LOG_INFO("Create peer instance successful"); LOG_INFO("Create peer instance successful");
std::string user_id = "S-" + mac_addr_str_; std::string user_id = mac_addr_str_;
Init(peer_, user_id.c_str()); Init(peer_, user_id.c_str());
LOG_INFO("Peer init finish"); LOG_INFO("Peer init finish");
} else { } else {
@@ -291,34 +291,7 @@ int MainWindow::Run() {
// Our state // Our state
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
mac_addr_str_ = GetMac(); CreateConnectionPeer();
params_.use_cfg_file = false;
params_.signal_server_ip = "150.158.81.30";
params_.signal_server_port = 9099;
params_.stun_server_ip = "150.158.81.30";
params_.stun_server_port = 3478;
params_.turn_server_ip = "150.158.81.30";
params_.turn_server_port = 3478;
params_.turn_server_username = "dijunkun";
params_.turn_server_password = "dijunkunpw";
params_.hardware_acceleration = config_center_.IsHardwareVideoCodec();
params_.av1_encoding = config_center_.GetVideoEncodeFormat() ==
ConfigCenter::VIDEO_ENCODE_FORMAT::AV1
? true
: false;
params_.on_receive_video_buffer = OnReceiveVideoBufferCb;
params_.on_receive_audio_buffer = OnReceiveAudioBufferCb;
params_.on_receive_data_buffer = OnReceiveDataBufferCb;
params_.on_signal_status = OnSignalStatusCb;
params_.on_connection_status = OnConnectionStatusCb;
params_.user_data = this;
peer_ = CreatePeer(&params_);
LOG_INFO("Create peer");
std::string user_id = "S-" + mac_addr_str_;
Init(peer_, user_id.c_str());
LOG_INFO("Peer init finish");
{ {
nv12_buffer_ = new char[NV12_BUFFER_SIZE]; nv12_buffer_ = new char[NV12_BUFFER_SIZE];
@@ -499,7 +472,7 @@ int MainWindow::Run() {
!connection_established_) { !connection_established_) {
ret = JoinConnection(peer_, remote_id_, client_password_); ret = JoinConnection(peer_, remote_id_, client_password_);
if (0 == ret) { if (0 == ret) {
is_client_ = true; is_client_mode_ = true;
} }
} else if (connect_button_label_ == } else if (connect_button_label_ ==
@@ -512,7 +485,7 @@ int MainWindow::Run() {
is_create_connection_ = false; is_create_connection_ = false;
connection_established_ = false; connection_established_ = false;
received_frame_ = false; received_frame_ = false;
is_client_ = false; is_client_mode_ = false;
} }
if (0 == ret) { if (0 == ret) {
@@ -844,7 +817,7 @@ int MainWindow::Run() {
// Cleanup // Cleanup
if (is_create_connection_) { if (is_create_connection_) {
LeaveConnection(peer_); LeaveConnection(peer_);
is_client_ = false; is_client_mode_ = false;
} }
if (peer_) { if (peer_) {

View File

@@ -98,7 +98,7 @@ class MainWindow {
char input_password_[7] = ""; char input_password_[7] = "";
char remote_id_[20] = ""; char remote_id_[20] = "";
char client_password_[20] = ""; char client_password_[20] = "";
bool is_client_ = false; bool is_client_mode_ = false;
private: private:
int screen_width_ = 1280; int screen_width_ = 1280;

View File

@@ -154,7 +154,7 @@ void MainWindow::OnConnectionStatusCb(ConnectionStatus status,
} else if (ConnectionStatus::Connected == status) { } else if (ConnectionStatus::Connected == status) {
main_window->connection_status_str_ = "Connected"; main_window->connection_status_str_ = "Connected";
main_window->connection_established_ = true; main_window->connection_established_ = true;
if (!main_window->is_client_) { if (main_window->is_client_mode_) {
main_window->start_screen_capture_ = true; main_window->start_screen_capture_ = true;
main_window->start_mouse_control_ = true; main_window->start_mouse_control_ = true;
} }