From 706cecb66c528adb5c374d74d9e1873d0e2aae34 Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Mon, 30 Nov 2020 19:06:18 +0100 Subject: [PATCH] Fixed crash --- server/src/rtc/lib.cpp | 12 +++++++----- server/src/rtc/lib.h | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/server/src/rtc/lib.cpp b/server/src/rtc/lib.cpp index 930195c..e1a2c2f 100644 --- a/server/src/rtc/lib.cpp +++ b/server/src/rtc/lib.cpp @@ -285,8 +285,8 @@ void Server::reset_rtp_session(RTCClientId client_id) { librtc_reset_rtp_session(this->server_ptr, client_id); } -bool Server::apply_remote_description(std::string &error, RTCClientId client_id, uint32_t mode, const std::string_view &description) { - auto error_ptr = librtc_apply_remote_description(this->server_ptr, client_id, mode, description.data()); +bool Server::apply_remote_description(std::string &error, RTCClientId client_id, uint32_t mode, const std::string &description) { + auto error_ptr = librtc_apply_remote_description(this->server_ptr, client_id, mode, description.c_str()); if(!error_ptr) { return true; } error = std::string{error_ptr}; @@ -308,8 +308,8 @@ bool Server::generate_local_description(RTCClientId client, std::string &result) } } -bool Server::add_ice_candidate(std::string &error, RTCClientId client_id, uint32_t media_line, const std::string_view &description) { - auto error_ptr = librtc_add_ice_candidate(this->server_ptr, client_id, media_line, description.length() == 0 ? nullptr : description.data()); +bool Server::add_ice_candidate(std::string &error, RTCClientId client_id, uint32_t media_line, const std::string &description) { + auto error_ptr = librtc_add_ice_candidate(this->server_ptr, client_id, media_line, description.length() == 0 ? nullptr : description.c_str()); if(!error_ptr) { return true; } error = std::string{error_ptr}; @@ -382,5 +382,7 @@ NativeAudioSourceSupplier::~NativeAudioSourceSupplier() noexcept { } void NativeAudioSourceSupplier::send_audio(uint16_t seq_no, bool marked, uint32_t timestamp, uint8_t codec, const std::string_view &data) { - librtc_audio_source_supply(this->sender_ptr, seq_no, marked, timestamp, codec, data.empty() ? nullptr : data.data(), data.length()); + if(this->sender_ptr) { + librtc_audio_source_supply(this->sender_ptr, seq_no, marked, timestamp, codec, data.empty() ? nullptr : data.data(), data.length()); + } } \ No newline at end of file diff --git a/server/src/rtc/lib.h b/server/src/rtc/lib.h index ddd1cc0..92b5cee 100644 --- a/server/src/rtc/lib.h +++ b/server/src/rtc/lib.h @@ -45,9 +45,9 @@ namespace ts::rtc { /* RTC client actions */ void reset_rtp_session(RTCClientId /* client */); - bool apply_remote_description(std::string& /* error */, RTCClientId /* client id */, uint32_t /* mode */, const std::string_view& /* description */); + bool apply_remote_description(std::string& /* error */, RTCClientId /* client id */, uint32_t /* mode */, const std::string& /* description */); bool generate_local_description(RTCClientId /* client id */, std::string& /* result */); - bool add_ice_candidate(std::string& /* error */, RTCClientId /* client id */, uint32_t /* media line */, const std::string_view& /* description */); + bool add_ice_candidate(std::string& /* error */, RTCClientId /* client id */, uint32_t /* media line */, const std::string& /* description */); void ice_candidates_finished(RTCClientId /* client id */); /* Native client actions */