diff --git a/UI/api-interface.cpp b/UI/api-interface.cpp index dc3fa6337..ebc200c73 100644 --- a/UI/api-interface.cpp +++ b/UI/api-interface.cpp @@ -320,6 +320,23 @@ struct OBSStudioAPI : obs_frontend_callbacks { return os_atomic_load_bool(&recording_paused); } + bool obs_frontend_recording_split_file(void) override + { + if (os_atomic_load_bool(&recording_active) && + !os_atomic_load_bool(&recording_paused)) { + proc_handler_t *ph = obs_output_get_proc_handler( + main->outputHandler->fileOutput); + uint8_t stack[128]; + calldata cd; + calldata_init_fixed(&cd, stack, sizeof(stack)); + proc_handler_call(ph, "split_file", &cd); + bool result = calldata_bool(&cd, "split_file_enabled"); + return result; + } else { + return false; + } + } + void obs_frontend_replay_buffer_start(void) override { QMetaObject::invokeMethod(main, "StartReplayBuffer"); diff --git a/UI/obs-frontend-api/obs-frontend-api.cpp b/UI/obs-frontend-api/obs-frontend-api.cpp index b5131ea8c..18ace62c4 100644 --- a/UI/obs-frontend-api/obs-frontend-api.cpp +++ b/UI/obs-frontend-api/obs-frontend-api.cpp @@ -279,6 +279,12 @@ bool obs_frontend_recording_paused(void) return !!callbacks_valid() ? c->obs_frontend_recording_paused() : false; } +bool obs_frontend_recording_split_file(void) +{ + return !!callbacks_valid() ? c->obs_frontend_recording_split_file() + : false; +} + void obs_frontend_replay_buffer_start(void) { if (callbacks_valid()) diff --git a/UI/obs-frontend-api/obs-frontend-api.h b/UI/obs-frontend-api/obs-frontend-api.h index c1c141b76..14c811279 100644 --- a/UI/obs-frontend-api/obs-frontend-api.h +++ b/UI/obs-frontend-api/obs-frontend-api.h @@ -177,6 +177,7 @@ EXPORT void obs_frontend_recording_stop(void); EXPORT bool obs_frontend_recording_active(void); EXPORT void obs_frontend_recording_pause(bool pause); EXPORT bool obs_frontend_recording_paused(void); +EXPORT bool obs_frontend_recording_split_file(void); EXPORT void obs_frontend_replay_buffer_start(void); EXPORT void obs_frontend_replay_buffer_save(void); diff --git a/UI/obs-frontend-api/obs-frontend-internal.hpp b/UI/obs-frontend-api/obs-frontend-internal.hpp index 775870334..3197b4348 100644 --- a/UI/obs-frontend-api/obs-frontend-internal.hpp +++ b/UI/obs-frontend-api/obs-frontend-internal.hpp @@ -52,6 +52,7 @@ struct obs_frontend_callbacks { virtual bool obs_frontend_recording_active(void) = 0; virtual void obs_frontend_recording_pause(bool pause) = 0; virtual bool obs_frontend_recording_paused(void) = 0; + virtual bool obs_frontend_recording_split_file(void) = 0; virtual void obs_frontend_replay_buffer_start(void) = 0; virtual void obs_frontend_replay_buffer_save(void) = 0; diff --git a/docs/sphinx/reference-frontend-api.rst b/docs/sphinx/reference-frontend-api.rst index ad831f87e..302d1be00 100644 --- a/docs/sphinx/reference-frontend-api.rst +++ b/docs/sphinx/reference-frontend-api.rst @@ -553,6 +553,17 @@ Functions --------------------------------------- +.. function:: bool obs_frontend_recording_split_file(void) + + Asks OBS to split the current recording file. + + :return: *true* if splitting was successfully requested (this + does not mean that splitting has finished or guarantee that it + split successfully), *false* if recording is inactive or paused + or if file splitting is disabled. + +--------------------------------------- + .. function:: void obs_frontend_replay_buffer_start(void) Starts the replay buffer.