mirror of
https://github.com/kunkundi/crossdesk.git
synced 2026-11-11 19:07:33 +08:00
[refactor] migrate clients to unified MiniRTC APIs
This commit is contained in:
1 parent
1a12a1d7d5
commit
84466ccea4
39 files changed
+498
-498
No files matched your search
@@ -83,13 +83,13 @@ void Session::Error(MiniRtcDirectError error, void* context) {
|
||||
s->failed = true;
|
||||
}
|
||||
}
|
||||
void Session::Status(ConnectionStatus status) {
|
||||
void Session::Status(MiniRtcConnectionStatus status) {
|
||||
if (closing) return;
|
||||
if (status == ConnectionStatus::Connected)
|
||||
if (status == MiniRtcConnectionStatus::MiniRtcConnectionConnected)
|
||||
ready = true;
|
||||
else if (status == ConnectionStatus::Closed ||
|
||||
status == ConnectionStatus::Failed ||
|
||||
status == ConnectionStatus::Disconnected)
|
||||
else if (status == MiniRtcConnectionStatus::MiniRtcConnectionClosed ||
|
||||
status == MiniRtcConnectionStatus::MiniRtcConnectionFailed ||
|
||||
status == MiniRtcConnectionStatus::MiniRtcConnectionDisconnected)
|
||||
failed = true;
|
||||
}
|
||||
SessionManager::SessionManager(std::filesystem::path path, Hooks hooks)
|
||||
@@ -417,9 +417,9 @@ void SessionManager::Prepare(const SessionPtr& s) {
|
||||
options.send_signal = Session::SendSignal;
|
||||
options.on_error = Session::Error;
|
||||
options.context = s.get();
|
||||
if (InitDirectPeer(prepared.peer, &options) != 0 ||
|
||||
if (MiniRtcInitDirectPeer(prepared.peer, &options) != 0 ||
|
||||
(!s->closing &&
|
||||
StartDirectSession(prepared.peer, !s->incoming) != 0))
|
||||
MiniRtcStartDirectSession(prepared.peer, !s->incoming) != 0))
|
||||
s->failed = true;
|
||||
return prepared;
|
||||
})});
|
||||
@@ -560,7 +560,7 @@ void SessionManager::Message(const SessionPtr& s, const std::string& text) {
|
||||
Check(type == "candidate" &&
|
||||
(s->phase == Session::AwaitAnswer ||
|
||||
s->phase == Session::Negotiating || s->phase == Session::Connected));
|
||||
if (ReceiveDirectSignal(s->peer, text.data(), text.size()) != 0)
|
||||
if (MiniRtcReceiveDirectSignal(s->peer, text.data(), text.size()) != 0)
|
||||
Fail(s, "InvalidSignal");
|
||||
}
|
||||
void SessionManager::Dispose(const SessionPtr& s) {
|
||||
@@ -571,8 +571,8 @@ void SessionManager::Dispose(const SessionPtr& s) {
|
||||
cleanup_jobs_.push_back(
|
||||
std::async(std::launch::async, [s, peer, owner, drain]() mutable {
|
||||
if (drain) drain();
|
||||
CloseDirectSession(peer);
|
||||
DestroyPeer(&peer);
|
||||
MiniRtcCloseDirectSession(peer);
|
||||
MiniRtcDestroyPeer(&peer);
|
||||
}));
|
||||
}
|
||||
void SessionManager::Close(const SessionPtr& s, const std::string& error) {
|
||||
|
||||
@@ -43,7 +43,7 @@ struct Session {
|
||||
bool incoming = false;
|
||||
uint64_t epoch = 0, receive_seq = 0, send_seq = 0;
|
||||
std::chrono::steady_clock::time_point deadline;
|
||||
PeerPtr* peer = nullptr; // Only published/cleared by the manager.
|
||||
MiniRtcPeerPtr* peer = nullptr; // Only published/cleared by the manager.
|
||||
std::atomic<bool> closing{false}, authorized{false}, ready{false},
|
||||
failed{false};
|
||||
std::atomic<int> failure_code{-1};
|
||||
@@ -54,7 +54,7 @@ struct Session {
|
||||
std::function<void()> drain_callbacks;
|
||||
static int SendSignal(const char* data, size_t size, void* context);
|
||||
static void Error(MiniRtcDirectError error, void* context);
|
||||
void Status(ConnectionStatus status);
|
||||
void Status(MiniRtcConnectionStatus status);
|
||||
};
|
||||
|
||||
// All public methods run on the GUI manager thread. Only Session's bounded
|
||||
@@ -63,7 +63,7 @@ class SessionManager {
|
||||
public:
|
||||
using SessionPtr = std::shared_ptr<Session>;
|
||||
struct Prepared {
|
||||
PeerPtr* peer = nullptr;
|
||||
MiniRtcPeerPtr* peer = nullptr;
|
||||
std::shared_ptr<void> callback_owner;
|
||||
std::function<void()> drain_callbacks;
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user