From 88c4485278871f74b2715ddffa668df290cc97c7 Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Sat, 5 Dec 2020 21:50:02 +0100 Subject: [PATCH] Fixed some minor speaking bugs --- server/src/client/SpeakingClient.cpp | 4 ++++ server/src/client/voice/CryptSetupHandler.cpp | 7 ++++--- server/src/rtc/imports.h | 1 + server/src/rtc/lib.cpp | 14 +++++++++++++- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/server/src/client/SpeakingClient.cpp b/server/src/client/SpeakingClient.cpp index 8e744e2..c6b6c4c 100644 --- a/server/src/client/SpeakingClient.cpp +++ b/server/src/client/SpeakingClient.cpp @@ -686,6 +686,10 @@ command_result SpeakingClient::handleCommandRtcSessionReset(Command &command) { CMD_CHK_AND_INC_FLOOD_POINTS(15); this->server->rtc_server().reset_rtp_session(this->rtc_client_id); + if(this->getType() == ClientType::CLIENT_TEASPEAK) { + /* registering the broadcast again since rtp session reset resets the broadcasts as well */ + this->server->rtc_server().start_broadcast(this->rtc_client_id, 1, 1); + } return command_result{error::ok}; } diff --git a/server/src/client/voice/CryptSetupHandler.cpp b/server/src/client/voice/CryptSetupHandler.cpp index 549a619..5a76d31 100644 --- a/server/src/client/voice/CryptSetupHandler.cpp +++ b/server/src/client/voice/CryptSetupHandler.cpp @@ -24,12 +24,13 @@ CryptSetupHandler::CryptSetupHandler(VoiceClientConnection *connection) : connec CryptSetupHandler::CommandHandleResult CryptSetupHandler::handle_command(const std::string_view &payload) { std::variant(CryptSetupHandler::*command_handler)(const ts::command_parser&) = nullptr; - if(payload.starts_with("clientinitiv")) + if(payload.starts_with("clientinitiv")) { command_handler = &CryptSetupHandler::handleCommandClientInitIv; - else if(payload.starts_with("clientek")) + } else if(payload.starts_with("clientek")) { command_handler = &CryptSetupHandler::handleCommandClientEk; - else if(payload.starts_with("clientinit")) + } else if(payload.starts_with("clientinit")) { command_handler = &CryptSetupHandler::handleCommandClientInit; + } if(!command_handler) return CommandHandleResult::PASS_THROUGH; diff --git a/server/src/rtc/imports.h b/server/src/rtc/imports.h index e50c7d5..fc1f26e 100644 --- a/server/src/rtc/imports.h +++ b/server/src/rtc/imports.h @@ -16,6 +16,7 @@ struct NativeCallbacks { void(*client_stream_assignment)(const void* /* callback data */, uint32_t /* stream id */, uint8_t /* media type */, const void* /* source callback data */); void(*client_offer_generated)(const void* /* callback data */, const char* /* offer */, size_t /* offer length */); + void(*client_ice_candidate)(const void* /* callback data */, uint32_t /* media line */, const char* /* candidate */, size_t /* candidate length */); void(*client_stream_start)(const void* /* callback data */, uint32_t /* stream id */, const void* /* source callback data */); void(*client_stream_stop)(const void* /* callback data */, uint32_t /* stream id */, const void* /* source callback data */); diff --git a/server/src/rtc/lib.cpp b/server/src/rtc/lib.cpp index e1a2c2f..469f64a 100644 --- a/server/src/rtc/lib.cpp +++ b/server/src/rtc/lib.cpp @@ -134,6 +134,17 @@ void librtc_callback_client_offer_generated(const void* callback_data_ptr, const target_client->rtc_session_pending_describe = true; } +void librtc_callback_client_ice_candidate(const void* callback_data_ptr, uint32_t media_line, const char* candidate, size_t candidate_length) { + auto callback_data = (LibCallbackData*) callback_data_ptr; + auto target_client = callback_data->weak_ref.lock(); + if(!target_client) { return; } + + ts::command_builder notify{"notifyrtcicecandidate"}; + notify.put_unchecked(0, "medialine", media_line); + notify.put_unchecked(0, "candidate", std::string_view{candidate, candidate_length}); + target_client->sendCommand(notify); +} + void librtc_callback_client_audio_start(const void* callback_data_ptr, uint32_t stream_id, const void* source_data_ptr) { auto callback_data = (LibCallbackData*) callback_data_ptr; auto source_data = (LibCallbackData*) source_data_ptr; @@ -212,7 +223,7 @@ void librtc_client_whisper_session_reset(const void* callback_data_ptr) { } static NativeCallbacks native_callbacks{ - .version = 4, + .version = 5, .log = librtc_callback_log, .free_client_data = librtc_callback_free_client_data, @@ -221,6 +232,7 @@ static NativeCallbacks native_callbacks{ .client_stream_assignment = librtc_callback_client_stream_assignment, .client_offer_generated = librtc_callback_client_offer_generated, + .client_ice_candidate = librtc_callback_client_ice_candidate, .client_stream_start = librtc_callback_client_audio_start, .client_stream_stop = librtc_callback_client_audio_stop,