From b3bd58385eaf927a862c46afafe41db65e03dd15 Mon Sep 17 00:00:00 2001 From: Valmo Trindade Date: Sat, 17 May 2025 22:10:28 -0300 Subject: [PATCH] Created video addon --- addons/video/$PBOPREFIX$ | 1 + addons/video/CfgEventHandlers.hpp | 11 +++ addons/video/XEH_PREP.hpp | 1 + addons/video/XEH_preInit.sqf | 9 +++ addons/video/XEH_preStart.sqf | 3 + addons/video/config.cpp | 41 +++++++++++ addons/video/functions/fnc_videoParser.sqf | 83 ++++++++++++++++++++++ addons/video/script_component.hpp | 17 +++++ 8 files changed, 166 insertions(+) create mode 100644 addons/video/$PBOPREFIX$ create mode 100644 addons/video/CfgEventHandlers.hpp create mode 100644 addons/video/XEH_PREP.hpp create mode 100644 addons/video/XEH_preInit.sqf create mode 100644 addons/video/XEH_preStart.sqf create mode 100644 addons/video/config.cpp create mode 100644 addons/video/functions/fnc_videoParser.sqf create mode 100644 addons/video/script_component.hpp diff --git a/addons/video/$PBOPREFIX$ b/addons/video/$PBOPREFIX$ new file mode 100644 index 0000000..d8aab57 --- /dev/null +++ b/addons/video/$PBOPREFIX$ @@ -0,0 +1 @@ +armatak\armatak\addons\video \ No newline at end of file diff --git a/addons/video/CfgEventHandlers.hpp b/addons/video/CfgEventHandlers.hpp new file mode 100644 index 0000000..865276c --- /dev/null +++ b/addons/video/CfgEventHandlers.hpp @@ -0,0 +1,11 @@ +class Extended_PreStart_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_SCRIPT(XEH_preStart)); + }; +}; + +class Extended_PreInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_SCRIPT(XEH_preInit)); + }; +}; diff --git a/addons/video/XEH_PREP.hpp b/addons/video/XEH_PREP.hpp new file mode 100644 index 0000000..eca2ead --- /dev/null +++ b/addons/video/XEH_PREP.hpp @@ -0,0 +1 @@ +PREP(videoParser); \ No newline at end of file diff --git a/addons/video/XEH_preInit.sqf b/addons/video/XEH_preInit.sqf new file mode 100644 index 0000000..1bf862a --- /dev/null +++ b/addons/video/XEH_preInit.sqf @@ -0,0 +1,9 @@ +#include "script_component.hpp" + +ADDON = false; + +PREP_RECOMPILE_START; +#include "XEH_PREP.hpp" +PREP_RECOMPILE_END; + +ADDON = true; \ No newline at end of file diff --git a/addons/video/XEH_preStart.sqf b/addons/video/XEH_preStart.sqf new file mode 100644 index 0000000..3880138 --- /dev/null +++ b/addons/video/XEH_preStart.sqf @@ -0,0 +1,3 @@ +#include "script_component.hpp" + +#include "XEH_PREP.hpp" \ No newline at end of file diff --git a/addons/video/config.cpp b/addons/video/config.cpp new file mode 100644 index 0000000..0841f1f --- /dev/null +++ b/addons/video/config.cpp @@ -0,0 +1,41 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + name = COMPONENT_NAME; + units[] = { + "armatak_module_core", + "armatak_module_callsign" + }; + weapons[] = {}; + requiredAddons[] = { + "cba_main", + "ace_main", + "armatak_main" + }; + requiredVersion = REQUIRED_VERSION; + author = PROJECT_AUTHOR; + url = "https://github.com/valmojr/armatak"; + }; +}; + +class CfgMods { + class PREFIX { + name = "Arma Team Awareness Kit"; + author = PROJECT_AUTHOR; + logo = "logo_ca.paa"; + logoOver = "logo_hover_ca.paa"; + tooltip = "ARMATAK"; + tooltipOwned = "ARMATAK"; + picture = "picture.paa"; + actionName = "GitHub"; + action = "https://github.com/valmojr/armatak"; + overview = "ARMATAK Addons allows Arma 3 sessions to be parsed to TAK Clients"; + hideName = 0; + hidePicture = 0; + dlcColor[] = { 0.23, 0.39, 0.30, 1 }; + logoSmall = "logo_small_ca.paa"; + }; +}; + +#include "CfgEventHandlers.hpp" \ No newline at end of file diff --git a/addons/video/functions/fnc_videoParser.sqf b/addons/video/functions/fnc_videoParser.sqf new file mode 100644 index 0000000..77b1592 --- /dev/null +++ b/addons/video/functions/fnc_videoParser.sqf @@ -0,0 +1,83 @@ +#include "..\script_component.hpp" + +params [ + ["_logic", objNull, [objNull]], + ["_units", [], [[]]], + ["_activated", true, [true]] +]; + +if (isServer) exitWith { + private _instance_address = GETVAR(_logic,instance_address,false); + private _instance_port = GETVAR(_logic,instance_port,false); + private _instance_auth_user = GETVAR(_logic,instance_auth_user,false); + private _instance_auth_pass = GETVAR(_logic,instance_auth_pass,false); + + SETMVAR(GVAR(instance_address),_instance_address); + SETMVAR(GVAR(instance_port),_instance_port); + SETMVAR(GVAR(instance_auth_user),_instance_auth_user); + SETMVAR(GVAR(instance_auth_pass),_instance_auth_pass); + + _startAction = [ + QGVAR(startStream), + "Start Video Feed", + "", + { + _uuid = (_this select 0) call armatak_fnc_extract_uuid; + _uuid_short = _uuid select [0, 8]; + _role = roleDescription (_this select 0); + _name = name (_this select 0); + + _role = [_role] call BIS_fnc_filterString; + _name = [_name] call BIS_fnc_filterString; + + _stream_path = _name + "_" + _role + "_" + _uuid_short; + + armatak_mediamtx_video_stream_instance_address = GETMVAR(instance_address,false); + armatak_mediamtx_video_stream_instance_port = missionNamespace getVariable "instance_port"; + armatak_mediamtx_video_stream_instance_auth_user = missionNamespace getVariable "instance_auth_user"; + armatak_mediamtx_video_stream_instance_auth_pass = missionNamespace getVariable "instance_auth_pass"; + + "armatak" callExtension ["video_stream:start", [armatak_mediamtx_video_stream_instance_address, armatak_mediamtx_video_stream_instance_port, _stream_path, armatak_mediamtx_video_stream_instance_auth_user, armatak_mediamtx_video_stream_instance_auth_pass]]; + (_this select 0) setVariable ["armatak_video_feed_is_streaming", true]; + }, + { + (_this select 0) getVariable "armatak_video_feed_is_streaming" == false + } + ] call ace_interact_menu_fnc_createAction; + [ + "Man", + 1, + ["ACE_SelfActions"], + _startAction, + true + ] call ace_interact_menu_fnc_addActionToClass; + + _stopAction = [ + "ArmatakStopStream", + "Stop Video Feed", + "", + { + "armatak" callExtension ["video_stream:stop", []]; + SETVAR(_this select 0,GVAR(isStreaming),false); + }, + { + GETVAR((this select 0),GVAR(isStreaming),false) + } + ] call ace_interact_menu_fnc_createAction; + [ + "Man", + 1, + ["ACE_SelfActions"], + _stopAction, + true + ] call ace_interact_menu_fnc_addActionToClass; + if (isMultiplayer) then { + { + SETVAR(_x,GVAR(isStreaming),false); + } forEach playableUnits; + } else { + SETVAR(player,GVAR(isStreaming),false); + }; +}; + +true; \ No newline at end of file diff --git a/addons/video/script_component.hpp b/addons/video/script_component.hpp new file mode 100644 index 0000000..1b8e67f --- /dev/null +++ b/addons/video/script_component.hpp @@ -0,0 +1,17 @@ +#define COMPONENT video +#define COMPONENT_BEAUTIFIED Video Streaming +#include "\armatak\armatak\addons\main\script_mod.hpp" + +// #define DEBUG_MODE_FULL +// #define DISABLE_COMPILE_CACHE +// #define ENABLE_PERFORMANCE_COUNTERS + +#ifdef DEBUG_ENABLED_MAIN + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_SETTINGS_MAIN + #define DEBUG_SETTINGS DEBUG_SETTINGS_MAIN +#endif + +#include "\z\ace\addons\main\script_macros.hpp"