mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-09-25 17:02:22 -04:00
frontend: Add obs_frontend_is_safe_mode_enabled() API call
Adds a new API call to the frontend API to check if OBS was launched in Safe Mode. This will primarily be used by core modules that need to know if they should disable certain functionality when OBS is launched in Safe Mode, e.g., frontend-tools disabling third party scripts, or obs-websocket turning off its server by default in Safe Mode.
This commit is contained in:
committed by
Ryan Foster
parent
bdf6dbe17c
commit
b2e51f63a2
@@ -989,3 +989,11 @@ Functions
|
||||
:param duplicate: *true* for paste duplicate, *false* for paste reference
|
||||
|
||||
.. versionadded:: 32.2
|
||||
|
||||
---------------------------------------
|
||||
|
||||
.. function:: bool obs_frontend_is_safe_mode_enabled(void)
|
||||
|
||||
:return: *true* if OBS was launched in Safe Mode, *false* otherwise
|
||||
|
||||
.. versionadded:: 33.0
|
||||
|
||||
@@ -11,6 +11,7 @@ extern volatile bool recording_active;
|
||||
extern volatile bool recording_paused;
|
||||
extern volatile bool replaybuf_active;
|
||||
extern volatile bool virtualcam_active;
|
||||
extern bool safe_mode;
|
||||
|
||||
template<typename T>
|
||||
inline size_t GetCallbackIdx(std::vector<OBSStudioCallback<T>> &callbacks, T callback, void *private_data)
|
||||
@@ -720,6 +721,11 @@ void OBSStudioAPI::obs_frontend_paste_sceneitem(obs_scene_t *scene, bool duplica
|
||||
main->pasteSceneItem(scene, duplicate);
|
||||
}
|
||||
|
||||
bool OBSStudioAPI::obs_frontend_is_safe_mode_enabled()
|
||||
{
|
||||
return safe_mode;
|
||||
}
|
||||
|
||||
void OBSStudioAPI::on_load(obs_data_t *settings)
|
||||
{
|
||||
for (size_t i = saveCallbacks.size(); i > 0; i--) {
|
||||
|
||||
@@ -230,6 +230,8 @@ struct OBSStudioAPI : obs_frontend_callbacks {
|
||||
|
||||
void obs_frontend_paste_sceneitem(obs_scene_t *scene, bool duplicate) override;
|
||||
|
||||
bool obs_frontend_is_safe_mode_enabled(void) override;
|
||||
|
||||
void on_load(obs_data_t *settings) override;
|
||||
|
||||
void on_preload(obs_data_t *settings) override;
|
||||
|
||||
@@ -686,3 +686,8 @@ void obs_frontend_paste_sceneitem(obs_scene_t *scene, bool duplicate)
|
||||
return c->obs_frontend_paste_sceneitem(scene, duplicate);
|
||||
}
|
||||
}
|
||||
|
||||
bool obs_frontend_is_safe_mode_enabled(void)
|
||||
{
|
||||
return !!callbacks_valid() ? c->obs_frontend_is_safe_mode_enabled() : false;
|
||||
}
|
||||
|
||||
@@ -262,6 +262,8 @@ EXPORT void obs_frontend_copy_sceneitem(obs_sceneitem_t *item);
|
||||
EXPORT bool obs_frontend_can_paste_sceneitem(bool duplicate);
|
||||
EXPORT void obs_frontend_paste_sceneitem(obs_scene_t *scene, bool duplicate);
|
||||
|
||||
EXPORT bool obs_frontend_is_safe_mode_enabled(void);
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -142,6 +142,7 @@ struct obs_frontend_callbacks {
|
||||
virtual void obs_frontend_copy_sceneitem(obs_sceneitem_t *item) = 0;
|
||||
virtual bool obs_frontend_can_paste_sceneitem(bool duplicate) = 0;
|
||||
virtual void obs_frontend_paste_sceneitem(obs_scene_t *scene, bool duplicate) = 0;
|
||||
virtual bool obs_frontend_is_safe_mode_enabled(void) = 0;
|
||||
};
|
||||
|
||||
EXPORT void obs_frontend_set_callbacks_internal(obs_frontend_callbacks *callbacks);
|
||||
|
||||
Reference in New Issue
Block a user