Some webclient fixes

This commit is contained in:
WolverinDEV 2020-11-15 23:30:51 +01:00
parent 9b1de50f1b
commit b438684f20
5 changed files with 54 additions and 2 deletions

View File

@ -716,6 +716,7 @@ void SpeakingClient::processJoin() {
} else if(this->getType() == ClientType::CLIENT_WEB) {
this->rtc_client_id = this->server->rtc_server().create_rtp_client(dynamic_pointer_cast<SpeakingClient>(this->ref()));
}
this->rtc_session_pending_describe = true;
TIMING_STEP(timings, "server reg ");
ref_server->getGroupManager()->cleanupAssignments(this->getClientDatabaseId());
@ -929,7 +930,11 @@ command_result SpeakingClient::handleCommand(Command &command) {
command_result SpeakingClient::handleCommandRtcSessionDescribe(Command &command) {
CMD_REQ_SERVER;
CMD_CHK_AND_INC_FLOOD_POINTS(15);
if(this->rtc_session_pending_describe) {
this->rtc_session_pending_describe = false;
} else {
CMD_CHK_AND_INC_FLOOD_POINTS(15);
}
uint32_t mode;
if(command["mode"].string() == "offer") {

View File

@ -97,6 +97,7 @@ namespace ts::server {
std::shared_ptr<Json::Value> identityData;
} handshake;
bool rtc_session_pending_describe{false};
rtc::RTCClientId rtc_client_id{0};
};
}

View File

@ -414,7 +414,8 @@ void WebClient::disconnectFinal() {
this->processLeave();
this->ssl_handler.finalize();
/* We do not finalize here since we might still try to send some data */
/* this->ssl_handler.finalize(); */
this->handle->unregisterConnection(static_pointer_cast<WebClient>(self_lock));
}

View File

@ -9,6 +9,7 @@ extern "C" {
struct NativeCallbacks {
uint32_t version;
void(*log)(uint8_t /* level */, const void* /* callback data */, const char* /* message */, uint32_t /* length */);
void(*free_client_data)(const void*);
void(*client_stream_assignment)(const void* /* callback data */, uint32_t /* stream id */, const void* /* source callback data */);

View File

@ -17,6 +17,47 @@ struct LibCallbackData {
std::weak_ptr<SpeakingClient> weak_ref;
};
#define log(...) \
switch(level) { \
case 0: \
logTrace(__VA_ARGS__); \
break; \
case 1: \
debugMessage(__VA_ARGS__); \
break; \
case 2: \
logMessage(__VA_ARGS__); \
break; \
case 3: \
logWarning(__VA_ARGS__); \
break; \
case 4: \
logError(__VA_ARGS__); \
break; \
case 5: \
logCritical(__VA_ARGS__); \
break; \
default: \
debugMessage(__VA_ARGS__); \
break; \
}
void librtc_callback_log(uint8_t level, const void* callback_data_ptr, const char* message_ptr, uint32_t length) {
auto callback_data = (LibCallbackData*) callback_data_ptr;
std::string_view message{message_ptr, length};
if(callback_data) {
auto source_client = callback_data->weak_ref.lock();
if(!source_client) { return; }
log(source_client->getServerId(), "{} [WebRTC] {}", CLIENT_STR_LOG_PREFIX_(source_client), message);
} else {
log(LOG_GENERAL, "{}", message);
}
}
#undef log
void librtc_callback_free_client_data(const void* data) {
delete (LibCallbackData*) data;
}
@ -56,6 +97,8 @@ void librtc_callback_client_offer_generated(const void* callback_data_ptr, const
notify.put_unchecked(0, "mode", "offer");
notify.put_unchecked(0, "sdp", std::string_view{offer, offer_length});
target_client->sendCommand(notify);
/* don't blame the client if we require him to do anything */
target_client->rtc_session_pending_describe = true;
}
void librtc_callback_client_audio_start(const void* callback_data_ptr, uint32_t stream_id, const void* source_data_ptr) {
@ -137,6 +180,7 @@ void librtc_callback_client_audio_sender_data(const void* callback_data_ptr, con
static NativeCallbacks native_callbacks{
.version = 1,
.log = librtc_callback_log,
.free_client_data = librtc_callback_free_client_data,
.client_stream_assignment = librtc_callback_client_stream_assignment,