From bc2c951ddea6720d6590aa4ee84ab16447b2beca Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Mon, 26 Apr 2021 15:14:09 +0200 Subject: [PATCH] Adding support for the video broadcaster to trace his followers --- git-teaspeak | 2 +- rtclib | 2 +- server/CMakeLists.txt | 2 +- server/src/rtc/imports.h | 3 +++ server/src/rtc/lib.cpp | 48 +++++++++++++++++++++++++++++++++++----- 5 files changed, 49 insertions(+), 8 deletions(-) diff --git a/git-teaspeak b/git-teaspeak index 50c0265..64a573c 160000 --- a/git-teaspeak +++ b/git-teaspeak @@ -1 +1 @@ -Subproject commit 50c0265be2f44dff2225d8e8a9c29514c95263c2 +Subproject commit 64a573cbd0f890907d4416c87021092e8cce7367 diff --git a/rtclib b/rtclib index ea2dd19..1079698 160000 --- a/rtclib +++ b/rtclib @@ -1 +1 @@ -Subproject commit ea2dd197d26330850dfef795cf7db140d26194d7 +Subproject commit 1079698605b08b508c8d44c9cf9108f60ba292f2 diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt index 3869c17..b6a64df 100644 --- a/server/CMakeLists.txt +++ b/server/CMakeLists.txt @@ -222,7 +222,7 @@ target_link_libraries(PermMapHelper SET(CPACK_PACKAGE_VERSION_MAJOR "1") SET(CPACK_PACKAGE_VERSION_MINOR "5") -SET(CPACK_PACKAGE_VERSION_PATCH "4") +SET(CPACK_PACKAGE_VERSION_PATCH "5") if (BUILD_TYPE_NAME EQUAL OFF) SET(CPACK_PACKAGE_VERSION_DATA "beta") elseif (BUILD_TYPE_NAME STREQUAL "") diff --git a/server/src/rtc/imports.h b/server/src/rtc/imports.h index 231c89d..7f88996 100644 --- a/server/src/rtc/imports.h +++ b/server/src/rtc/imports.h @@ -27,6 +27,9 @@ struct NativeCallbacks { 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 */); + void(*client_video_join)(const void* /* callback data */, uint32_t /* stream id */, const void* /* source callback data */); + void(*client_video_leave)(const void* /* callback data */, uint32_t /* stream id */, const void* /* source callback data */); + void(*client_video_broadcast_info)(const void* const* /* callback data array */, uint32_t /* callback data length */, const BroadcastInfo* /* broadcasts */, uint32_t /* broadcast count */); void(*client_audio_sender_data)(const void* /* callback data */, const void* /* source callback data */, uint8_t /* mode */, uint16_t /* seq. no. */, uint8_t /* codec */, const void* /* data */, uint32_t /* length */); diff --git a/server/src/rtc/lib.cpp b/server/src/rtc/lib.cpp index 8d8d793..260a6f7 100644 --- a/server/src/rtc/lib.cpp +++ b/server/src/rtc/lib.cpp @@ -167,7 +167,7 @@ void librtc_callback_client_ice_candidate(const void* callback_data_ptr, uint32_ target_client->sendCommand(notify); } -void librtc_callback_client_audio_start(const void* callback_data_ptr, uint32_t stream_id, const void* source_data_ptr) { +void librtc_callback_client_stream_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; @@ -222,7 +222,7 @@ void librtc_callback_client_video_broadcast_info(const void* const* callback_dat } } -void librtc_callback_client_audio_stop(const void* callback_data_ptr, uint32_t stream_id, const void* source_data_ptr) { +void librtc_callback_client_stream_stop(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; @@ -279,8 +279,43 @@ void librtc_client_whisper_session_reset(const void* callback_data_ptr) { client->sendCommand(notify); } +void librtc_callback_client_video_join(const void* callback_data_ptr, uint32_t stream_id, const void* target_data_ptr) { + auto callback_data = (LibCallbackData*) callback_data_ptr; + auto target_data = (LibCallbackData*) target_data_ptr; + + auto stream_client = callback_data->weak_ref.lock(); + if(!stream_client) { return; } + + auto target_client = target_data->weak_ref.lock(); + if(!target_client) { return; } + + ts::command_builder notify{"notifystreamjoined"}; + notify.put_unchecked(0, "streamid", stream_id); + notify.put_unchecked(0, "clid", target_client->getClientId()); + notify.put_unchecked(0, "cluid", target_client->getUid()); + notify.put_unchecked(0, "cldbid", target_client->getClientDatabaseId()); + notify.put_unchecked(0, "clname", target_client->getDisplayName()); + stream_client->sendCommand(notify); +} + +void librtc_callback_client_video_leave(const void* callback_data_ptr, uint32_t stream_id, const void* target_data_ptr) { + auto callback_data = (LibCallbackData*) callback_data_ptr; + auto target_data = (LibCallbackData*) target_data_ptr; + + auto stream_client = callback_data->weak_ref.lock(); + if(!stream_client) { return; } + + auto target_client = target_data->weak_ref.lock(); + if(!target_client) { return; } + + ts::command_builder notify{"notifystreamleft"}; + notify.put_unchecked(0, "streamid", stream_id); + notify.put_unchecked(0, "clid", target_client->getClientId()); + stream_client->sendCommand(notify); +} + static NativeCallbacks native_callbacks{ - .version = 6, + .version = 7, .log = librtc_callback_log, .free_client_data = librtc_callback_free_client_data, @@ -291,8 +326,11 @@ static NativeCallbacks native_callbacks{ .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, + .client_stream_start = librtc_callback_client_stream_start, + .client_stream_stop = librtc_callback_client_stream_stop, + + .client_video_join = librtc_callback_client_video_join, + .client_video_leave = librtc_callback_client_video_leave, .client_video_broadcast_info = librtc_callback_client_video_broadcast_info,