mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-26 12:15:34 +08:00
Fix crash when connecting to local desk
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
|
||||
Continuous Desk is a lightweight cross-platform remote desktop. It allows multiple users to remotely control the same computer at the same time. In addition to desktop image transmission, it also supports end-to-end voice transmission, providing collaboration capabilities on the basis of remote desktop.
|
||||
|
||||
Continuous Desk is an experimental application of [Projectx](https://github.com/dijunkun/projectx) real-time communications library. Projectx is a lightweight cross-platform real-time communications library. It has basic capabilities such as network traversal ([RFC5245](https://datatracker.ietf.org/doc/html/rfc5245)), video softwar/hardware encoding/decoding (H264), audio encoding/decoding ([Opus](https://github.com/xiph/opus)), signaling interaction, and network congestion control ([TCP over UDP](https://libnice.freedesktop.org/)).
|
||||
Continuous Desk is an experimental application of [Projectx](https://github.com/dijunkun/projectx) real-time communications library. Projectx is a lightweight cross-platform real-time communications library. It has basic capabilities such as network traversal ([RFC5245](https://datatracker.ietf.org/doc/html/rfc5245)), video software/hardware encoding/decoding (H264), audio encoding/decoding ([Opus](https://github.com/xiph/opus)), signaling interaction, and network congestion control ([TCP over UDP](https://libnice.freedesktop.org/)).
|
||||
|
||||
## Usage
|
||||
|
||||
|
||||
@@ -185,8 +185,8 @@ int MainWindow::CreateConnectionPeer() {
|
||||
peer_ = CreatePeer(¶ms_);
|
||||
if (peer_) {
|
||||
LOG_INFO("Create peer instance successful");
|
||||
std::string user_id = mac_addr_str_;
|
||||
Init(peer_, user_id.c_str());
|
||||
local_id_ = mac_addr_str_;
|
||||
Init(peer_, local_id_.c_str());
|
||||
LOG_INFO("Peer init finish");
|
||||
} else {
|
||||
LOG_INFO("Create peer instance failed");
|
||||
@@ -464,32 +464,51 @@ int MainWindow::Run() {
|
||||
ImGui::Separator();
|
||||
ImGui::Spacing();
|
||||
|
||||
if (ImGui::Button(connect_button_label_.c_str())) {
|
||||
if (ImGui::Button(connect_button_label_.c_str()) || rejoin_) {
|
||||
int ret = -1;
|
||||
if ("SignalConnected" == signal_status_str_) {
|
||||
if (connect_button_label_ ==
|
||||
localization::connect[localization_language_index_] &&
|
||||
!connection_established_) {
|
||||
ret = JoinConnection(peer_, remote_id_, client_password_);
|
||||
if (remote_id_ == local_id_ && !peer_reserved_) {
|
||||
peer_reserved_ = CreatePeer(¶ms_);
|
||||
if (peer_reserved_) {
|
||||
LOG_INFO("Create peer[reserved] instance successful");
|
||||
std::string local_id = "C-" + mac_addr_str_;
|
||||
Init(peer_reserved_, local_id.c_str());
|
||||
LOG_INFO("Peer[reserved] init finish");
|
||||
} else {
|
||||
LOG_INFO("Create peer[reserved] instance failed");
|
||||
}
|
||||
}
|
||||
ret = JoinConnection(peer_reserved_ ? peer_reserved_ : peer_,
|
||||
remote_id_, client_password_);
|
||||
if (0 == ret) {
|
||||
if (!peer_reserved_) {
|
||||
is_client_mode_ = true;
|
||||
}
|
||||
rejoin_ = false;
|
||||
} else {
|
||||
rejoin_ = true;
|
||||
}
|
||||
|
||||
} else if (connect_button_label_ ==
|
||||
localization::disconnect
|
||||
[localization_language_index_] &&
|
||||
connection_established_) {
|
||||
ret = LeaveConnection(peer_);
|
||||
memset(audio_buffer_, 0, 960);
|
||||
ret = LeaveConnection(peer_reserved_ ? peer_reserved_ : peer_);
|
||||
|
||||
if (0 == ret) {
|
||||
rejoin_ = false;
|
||||
memset(audio_buffer_, 0, 960);
|
||||
connection_established_ = false;
|
||||
received_frame_ = false;
|
||||
is_client_mode_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (0 == ret) {
|
||||
connect_button_pressed_ = !connect_button_pressed_;
|
||||
|
||||
connect_button_label_ =
|
||||
connect_button_pressed_
|
||||
? localization::disconnect[localization_language_index_]
|
||||
@@ -823,6 +842,10 @@ int MainWindow::Run() {
|
||||
DestroyPeer(peer_);
|
||||
}
|
||||
|
||||
if (peer_reserved_) {
|
||||
DestroyPeer(peer_reserved_);
|
||||
}
|
||||
|
||||
SDL_CloseAudioDevice(output_dev_);
|
||||
SDL_CloseAudioDevice(input_dev_);
|
||||
|
||||
|
||||
@@ -96,6 +96,7 @@ class MainWindow {
|
||||
std::string settings_button_label_ = "Setting";
|
||||
char input_password_tmp_[7] = "";
|
||||
char input_password_[7] = "";
|
||||
std::string local_id_ = "";
|
||||
char remote_id_[20] = "";
|
||||
char client_password_[20] = "";
|
||||
bool is_client_mode_ = false;
|
||||
@@ -126,6 +127,7 @@ class MainWindow {
|
||||
bool received_frame_ = false;
|
||||
bool is_create_connection_ = false;
|
||||
bool audio_buffer_fresh_ = false;
|
||||
bool rejoin_ = false;
|
||||
|
||||
int fps_ = 0;
|
||||
uint32_t start_time_;
|
||||
@@ -141,6 +143,7 @@ class MainWindow {
|
||||
|
||||
private:
|
||||
PeerPtr *peer_ = nullptr;
|
||||
PeerPtr *peer_reserved_ = nullptr;
|
||||
Params params_;
|
||||
|
||||
private:
|
||||
|
||||
2
thirdparty/projectx
vendored
2
thirdparty/projectx
vendored
Submodule thirdparty/projectx updated: eee3b2a95e...c575a9170c
Reference in New Issue
Block a user