2016-08-28 14:24:14 -07:00
|
|
|
#include <obs-frontend-internal.hpp>
|
|
|
|
#include "obs-app.hpp"
|
|
|
|
#include "qt-wrappers.hpp"
|
|
|
|
#include "window-basic-main.hpp"
|
|
|
|
#include "window-basic-main-outputs.hpp"
|
|
|
|
|
|
|
|
#include <functional>
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
Q_DECLARE_METATYPE(OBSScene);
|
|
|
|
Q_DECLARE_METATYPE(OBSSource);
|
|
|
|
|
2019-06-22 22:13:45 -07:00
|
|
|
template<typename T> static T GetOBSRef(QListWidgetItem *item)
|
2016-08-28 14:24:14 -07:00
|
|
|
{
|
|
|
|
return item->data(static_cast<int>(QtDataRole::OBSRef)).value<T>();
|
|
|
|
}
|
|
|
|
|
2019-06-22 22:13:45 -07:00
|
|
|
void EnumProfiles(function<bool(const char *, const char *)> &&cb);
|
|
|
|
void EnumSceneCollections(function<bool(const char *, const char *)> &&cb);
|
2016-08-28 14:24:14 -07:00
|
|
|
|
2019-02-26 06:37:01 -08:00
|
|
|
extern volatile bool streaming_active;
|
|
|
|
extern volatile bool recording_active;
|
2019-07-07 15:47:29 -07:00
|
|
|
extern volatile bool recording_paused;
|
2019-02-26 06:37:01 -08:00
|
|
|
extern volatile bool replaybuf_active;
|
2020-12-07 12:39:02 -08:00
|
|
|
extern volatile bool virtualcam_active;
|
2019-02-26 06:37:01 -08:00
|
|
|
|
2016-08-28 14:24:14 -07:00
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
template<typename T> struct OBSStudioCallback {
|
|
|
|
T callback;
|
|
|
|
void *private_data;
|
|
|
|
|
2019-06-22 22:13:45 -07:00
|
|
|
inline OBSStudioCallback(T cb, void *p) : callback(cb), private_data(p)
|
|
|
|
{
|
|
|
|
}
|
2016-08-28 14:24:14 -07:00
|
|
|
};
|
|
|
|
|
2019-06-22 22:13:45 -07:00
|
|
|
template<typename T>
|
|
|
|
inline size_t GetCallbackIdx(vector<OBSStudioCallback<T>> &callbacks,
|
|
|
|
T callback, void *private_data)
|
2016-08-28 14:24:14 -07:00
|
|
|
{
|
|
|
|
for (size_t i = 0; i < callbacks.size(); i++) {
|
|
|
|
OBSStudioCallback<T> curCB = callbacks[i];
|
2019-06-22 22:13:45 -07:00
|
|
|
if (curCB.callback == callback &&
|
2016-08-28 14:24:14 -07:00
|
|
|
curCB.private_data == private_data)
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (size_t)-1;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct OBSStudioAPI : obs_frontend_callbacks {
|
|
|
|
OBSBasic *main;
|
|
|
|
vector<OBSStudioCallback<obs_frontend_event_cb>> callbacks;
|
|
|
|
vector<OBSStudioCallback<obs_frontend_save_cb>> saveCallbacks;
|
2017-12-25 13:23:39 -08:00
|
|
|
vector<OBSStudioCallback<obs_frontend_save_cb>> preloadCallbacks;
|
2016-08-28 14:24:14 -07:00
|
|
|
|
|
|
|
inline OBSStudioAPI(OBSBasic *main_) : main(main_) {}
|
|
|
|
|
|
|
|
void *obs_frontend_get_main_window(void) override
|
|
|
|
{
|
2019-06-22 22:13:45 -07:00
|
|
|
return (void *)main;
|
2016-08-28 14:24:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void *obs_frontend_get_main_window_handle(void) override
|
|
|
|
{
|
2019-06-22 22:13:45 -07:00
|
|
|
return (void *)main->winId();
|
2016-08-28 14:24:14 -07:00
|
|
|
}
|
|
|
|
|
2019-04-03 22:03:21 -07:00
|
|
|
void *obs_frontend_get_system_tray(void) override
|
|
|
|
{
|
2019-06-22 22:13:45 -07:00
|
|
|
return (void *)main->trayIcon.data();
|
2019-04-03 22:03:21 -07:00
|
|
|
}
|
|
|
|
|
2016-08-28 14:24:14 -07:00
|
|
|
void obs_frontend_get_scenes(
|
2019-06-22 22:13:45 -07:00
|
|
|
struct obs_frontend_source_list *sources) override
|
2016-08-28 14:24:14 -07:00
|
|
|
{
|
|
|
|
for (int i = 0; i < main->ui->scenes->count(); i++) {
|
|
|
|
QListWidgetItem *item = main->ui->scenes->item(i);
|
|
|
|
OBSScene scene = GetOBSRef<OBSScene>(item);
|
|
|
|
obs_source_t *source = obs_scene_get_source(scene);
|
|
|
|
|
2022-01-24 11:26:04 -08:00
|
|
|
if (obs_source_get_ref(source) != nullptr)
|
|
|
|
da_push_back(sources->sources, &source);
|
2016-08-28 14:24:14 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
obs_source_t *obs_frontend_get_current_scene(void) override
|
|
|
|
{
|
|
|
|
if (main->IsPreviewProgramMode()) {
|
2022-01-24 11:26:04 -08:00
|
|
|
return obs_weak_source_get_source(main->programScene);
|
2016-08-28 14:24:14 -07:00
|
|
|
} else {
|
2022-01-24 11:26:04 -08:00
|
|
|
OBSSource source = main->GetCurrentSceneSource();
|
|
|
|
return obs_source_get_ref(source);
|
2016-08-28 14:24:14 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void obs_frontend_set_current_scene(obs_source_t *scene) override
|
|
|
|
{
|
|
|
|
if (main->IsPreviewProgramMode()) {
|
2019-06-22 22:13:45 -07:00
|
|
|
QMetaObject::invokeMethod(
|
|
|
|
main, "TransitionToScene", WaitConnection(),
|
|
|
|
Q_ARG(OBSSource, OBSSource(scene)));
|
2016-08-28 14:24:14 -07:00
|
|
|
} else {
|
2019-06-22 22:13:45 -07:00
|
|
|
QMetaObject::invokeMethod(
|
|
|
|
main, "SetCurrentScene", WaitConnection(),
|
|
|
|
Q_ARG(OBSSource, OBSSource(scene)),
|
|
|
|
Q_ARG(bool, false));
|
2016-08-28 14:24:14 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void obs_frontend_get_transitions(
|
2019-06-22 22:13:45 -07:00
|
|
|
struct obs_frontend_source_list *sources) override
|
2016-08-28 14:24:14 -07:00
|
|
|
{
|
|
|
|
for (int i = 0; i < main->ui->transitions->count(); i++) {
|
2021-07-21 03:18:44 -07:00
|
|
|
obs_source_t *tr = main->ui->transitions->itemData(i)
|
|
|
|
.value<OBSSource>();
|
2016-08-28 14:24:14 -07:00
|
|
|
|
2020-08-23 01:07:52 -07:00
|
|
|
if (!tr)
|
|
|
|
continue;
|
|
|
|
|
2022-01-24 11:26:04 -08:00
|
|
|
if (obs_source_get_ref(tr) != nullptr)
|
|
|
|
da_push_back(sources->sources, &tr);
|
2016-08-28 14:24:14 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
obs_source_t *obs_frontend_get_current_transition(void) override
|
|
|
|
{
|
|
|
|
OBSSource tr = main->GetCurrentTransition();
|
2022-01-24 11:26:04 -08:00
|
|
|
return obs_source_get_ref(tr);
|
2016-08-28 14:24:14 -07:00
|
|
|
}
|
|
|
|
|
2019-06-22 22:13:45 -07:00
|
|
|
void
|
|
|
|
obs_frontend_set_current_transition(obs_source_t *transition) override
|
2016-08-28 14:24:14 -07:00
|
|
|
{
|
|
|
|
QMetaObject::invokeMethod(main, "SetTransition",
|
2019-06-22 22:13:45 -07:00
|
|
|
Q_ARG(OBSSource,
|
|
|
|
OBSSource(transition)));
|
2016-08-28 14:24:14 -07:00
|
|
|
}
|
|
|
|
|
2019-05-08 23:17:04 -07:00
|
|
|
int obs_frontend_get_transition_duration(void) override
|
|
|
|
{
|
|
|
|
return main->ui->transitionDuration->value();
|
|
|
|
}
|
|
|
|
|
|
|
|
void obs_frontend_set_transition_duration(int duration) override
|
|
|
|
{
|
2019-06-22 22:13:45 -07:00
|
|
|
QMetaObject::invokeMethod(main->ui->transitionDuration,
|
|
|
|
"setValue", Q_ARG(int, duration));
|
2019-05-08 23:17:04 -07:00
|
|
|
}
|
|
|
|
|
2020-05-12 23:34:55 -07:00
|
|
|
void obs_frontend_release_tbar(void) override
|
|
|
|
{
|
|
|
|
QMetaObject::invokeMethod(main, "TBarReleased");
|
|
|
|
}
|
|
|
|
|
|
|
|
void obs_frontend_set_tbar_position(int position) override
|
|
|
|
{
|
|
|
|
QMetaObject::invokeMethod(main, "TBarChanged",
|
|
|
|
Q_ARG(int, position));
|
|
|
|
}
|
|
|
|
|
2021-03-02 15:32:17 -08:00
|
|
|
int obs_frontend_get_tbar_position(void) override
|
|
|
|
{
|
|
|
|
return main->tBar->value();
|
|
|
|
}
|
|
|
|
|
2016-08-28 14:24:14 -07:00
|
|
|
void obs_frontend_get_scene_collections(
|
2019-06-22 22:13:45 -07:00
|
|
|
std::vector<std::string> &strings) override
|
2016-08-28 14:24:14 -07:00
|
|
|
{
|
2019-06-22 22:13:45 -07:00
|
|
|
auto addCollection = [&](const char *name, const char *) {
|
2016-08-28 14:24:14 -07:00
|
|
|
strings.emplace_back(name);
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
|
|
|
|
EnumSceneCollections(addCollection);
|
|
|
|
}
|
|
|
|
|
|
|
|
char *obs_frontend_get_current_scene_collection(void) override
|
|
|
|
{
|
2019-06-22 22:13:45 -07:00
|
|
|
const char *cur_name = config_get_string(
|
|
|
|
App()->GlobalConfig(), "Basic", "SceneCollection");
|
2016-08-28 14:24:14 -07:00
|
|
|
return bstrdup(cur_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
void obs_frontend_set_current_scene_collection(
|
2019-06-22 22:13:45 -07:00
|
|
|
const char *collection) override
|
2016-08-28 14:24:14 -07:00
|
|
|
{
|
2019-06-22 22:13:45 -07:00
|
|
|
QList<QAction *> menuActions =
|
2016-08-28 14:24:14 -07:00
|
|
|
main->ui->sceneCollectionMenu->actions();
|
|
|
|
QString qstrCollection = QT_UTF8(collection);
|
|
|
|
|
|
|
|
for (int i = 0; i < menuActions.count(); i++) {
|
|
|
|
QAction *action = menuActions[i];
|
|
|
|
QVariant v = action->property("file_name");
|
|
|
|
|
|
|
|
if (v.typeName() != nullptr) {
|
|
|
|
if (action->text() == qstrCollection) {
|
|
|
|
action->trigger();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-22 22:13:45 -07:00
|
|
|
bool obs_frontend_add_scene_collection(const char *name) override
|
2018-05-04 15:36:01 -07:00
|
|
|
{
|
|
|
|
bool success = false;
|
2019-06-22 22:13:45 -07:00
|
|
|
QMetaObject::invokeMethod(main, "AddSceneCollection",
|
|
|
|
WaitConnection(),
|
|
|
|
Q_RETURN_ARG(bool, success),
|
|
|
|
Q_ARG(bool, true),
|
|
|
|
Q_ARG(QString, QT_UTF8(name)));
|
2018-05-04 15:36:01 -07:00
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
2019-06-22 22:13:45 -07:00
|
|
|
void
|
|
|
|
obs_frontend_get_profiles(std::vector<std::string> &strings) override
|
2016-08-28 14:24:14 -07:00
|
|
|
{
|
2019-06-22 22:13:45 -07:00
|
|
|
auto addProfile = [&](const char *name, const char *) {
|
2016-08-28 14:24:14 -07:00
|
|
|
strings.emplace_back(name);
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
|
|
|
|
EnumProfiles(addProfile);
|
|
|
|
}
|
|
|
|
|
|
|
|
char *obs_frontend_get_current_profile(void) override
|
|
|
|
{
|
|
|
|
const char *name = config_get_string(App()->GlobalConfig(),
|
2019-06-22 22:13:45 -07:00
|
|
|
"Basic", "Profile");
|
2016-08-28 14:24:14 -07:00
|
|
|
return bstrdup(name);
|
|
|
|
}
|
|
|
|
|
2021-04-13 16:49:01 -07:00
|
|
|
char *obs_frontend_get_current_profile_path(void) override
|
|
|
|
{
|
|
|
|
char profilePath[512];
|
|
|
|
int ret = GetProfilePath(profilePath, sizeof(profilePath), "");
|
|
|
|
if (ret <= 0)
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
return bstrdup(profilePath);
|
|
|
|
}
|
|
|
|
|
2016-08-28 14:24:14 -07:00
|
|
|
void obs_frontend_set_current_profile(const char *profile) override
|
|
|
|
{
|
2019-06-22 22:13:45 -07:00
|
|
|
QList<QAction *> menuActions = main->ui->profileMenu->actions();
|
2016-08-28 14:24:14 -07:00
|
|
|
QString qstrProfile = QT_UTF8(profile);
|
|
|
|
|
|
|
|
for (int i = 0; i < menuActions.count(); i++) {
|
|
|
|
QAction *action = menuActions[i];
|
|
|
|
QVariant v = action->property("file_name");
|
|
|
|
|
|
|
|
if (v.typeName() != nullptr) {
|
|
|
|
if (action->text() == qstrProfile) {
|
|
|
|
action->trigger();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-14 08:26:54 -07:00
|
|
|
void obs_frontend_create_profile(const char *name) override
|
|
|
|
{
|
|
|
|
QMetaObject::invokeMethod(main, "NewProfile",
|
|
|
|
Q_ARG(QString, name));
|
|
|
|
}
|
|
|
|
|
|
|
|
void obs_frontend_duplicate_profile(const char *name) override
|
|
|
|
{
|
|
|
|
QMetaObject::invokeMethod(main, "DuplicateProfile",
|
|
|
|
Q_ARG(QString, name));
|
|
|
|
}
|
|
|
|
|
|
|
|
void obs_frontend_delete_profile(const char *profile) override
|
|
|
|
{
|
|
|
|
QMetaObject::invokeMethod(main, "DeleteProfile",
|
|
|
|
Q_ARG(QString, profile));
|
|
|
|
}
|
|
|
|
|
2016-08-28 14:24:14 -07:00
|
|
|
void obs_frontend_streaming_start(void) override
|
|
|
|
{
|
|
|
|
QMetaObject::invokeMethod(main, "StartStreaming");
|
|
|
|
}
|
|
|
|
|
|
|
|
void obs_frontend_streaming_stop(void) override
|
|
|
|
{
|
|
|
|
QMetaObject::invokeMethod(main, "StopStreaming");
|
|
|
|
}
|
|
|
|
|
|
|
|
bool obs_frontend_streaming_active(void) override
|
|
|
|
{
|
2019-02-26 06:37:01 -08:00
|
|
|
return os_atomic_load_bool(&streaming_active);
|
2016-08-28 14:24:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void obs_frontend_recording_start(void) override
|
|
|
|
{
|
|
|
|
QMetaObject::invokeMethod(main, "StartRecording");
|
|
|
|
}
|
|
|
|
|
|
|
|
void obs_frontend_recording_stop(void) override
|
|
|
|
{
|
|
|
|
QMetaObject::invokeMethod(main, "StopRecording");
|
|
|
|
}
|
|
|
|
|
|
|
|
bool obs_frontend_recording_active(void) override
|
|
|
|
{
|
2019-02-26 06:37:01 -08:00
|
|
|
return os_atomic_load_bool(&recording_active);
|
2016-08-28 14:24:14 -07:00
|
|
|
}
|
|
|
|
|
2019-07-07 15:47:29 -07:00
|
|
|
void obs_frontend_recording_pause(bool pause) override
|
|
|
|
{
|
|
|
|
QMetaObject::invokeMethod(main, pause ? "PauseRecording"
|
|
|
|
: "UnpauseRecording");
|
|
|
|
}
|
|
|
|
|
|
|
|
bool obs_frontend_recording_paused(void) override
|
|
|
|
{
|
|
|
|
return os_atomic_load_bool(&recording_paused);
|
|
|
|
}
|
|
|
|
|
2016-12-09 14:40:04 -08:00
|
|
|
void obs_frontend_replay_buffer_start(void) override
|
|
|
|
{
|
|
|
|
QMetaObject::invokeMethod(main, "StartReplayBuffer");
|
|
|
|
}
|
|
|
|
|
2017-10-19 04:14:14 -07:00
|
|
|
void obs_frontend_replay_buffer_save(void) override
|
|
|
|
{
|
|
|
|
QMetaObject::invokeMethod(main, "ReplayBufferSave");
|
|
|
|
}
|
|
|
|
|
2016-12-09 14:40:04 -08:00
|
|
|
void obs_frontend_replay_buffer_stop(void) override
|
|
|
|
{
|
|
|
|
QMetaObject::invokeMethod(main, "StopReplayBuffer");
|
|
|
|
}
|
|
|
|
|
|
|
|
bool obs_frontend_replay_buffer_active(void) override
|
|
|
|
{
|
2019-02-26 06:37:01 -08:00
|
|
|
return os_atomic_load_bool(&replaybuf_active);
|
2016-12-09 14:40:04 -08:00
|
|
|
}
|
|
|
|
|
2016-08-28 14:24:14 -07:00
|
|
|
void *obs_frontend_add_tools_menu_qaction(const char *name) override
|
|
|
|
{
|
|
|
|
main->ui->menuTools->setEnabled(true);
|
2019-06-22 22:13:45 -07:00
|
|
|
return (void *)main->ui->menuTools->addAction(QT_UTF8(name));
|
2016-08-28 14:24:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void obs_frontend_add_tools_menu_item(const char *name,
|
2019-06-22 22:13:45 -07:00
|
|
|
obs_frontend_cb callback,
|
|
|
|
void *private_data) override
|
2016-08-28 14:24:14 -07:00
|
|
|
{
|
|
|
|
main->ui->menuTools->setEnabled(true);
|
|
|
|
|
2019-06-22 22:13:45 -07:00
|
|
|
auto func = [private_data, callback]() {
|
2016-08-28 14:24:14 -07:00
|
|
|
callback(private_data);
|
|
|
|
};
|
|
|
|
|
|
|
|
QAction *action = main->ui->menuTools->addAction(QT_UTF8(name));
|
|
|
|
QObject::connect(action, &QAction::triggered, func);
|
|
|
|
}
|
|
|
|
|
2019-06-13 21:12:49 -07:00
|
|
|
void *obs_frontend_add_dock(void *dock) override
|
|
|
|
{
|
2019-06-22 22:13:45 -07:00
|
|
|
return (void *)main->AddDockWidget((QDockWidget *)dock);
|
2019-06-13 21:12:49 -07:00
|
|
|
}
|
|
|
|
|
2016-08-28 14:24:14 -07:00
|
|
|
void obs_frontend_add_event_callback(obs_frontend_event_cb callback,
|
2019-06-22 22:13:45 -07:00
|
|
|
void *private_data) override
|
2016-08-28 14:24:14 -07:00
|
|
|
{
|
|
|
|
size_t idx = GetCallbackIdx(callbacks, callback, private_data);
|
|
|
|
if (idx == (size_t)-1)
|
|
|
|
callbacks.emplace_back(callback, private_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
void obs_frontend_remove_event_callback(obs_frontend_event_cb callback,
|
2019-06-22 22:13:45 -07:00
|
|
|
void *private_data) override
|
2016-08-28 14:24:14 -07:00
|
|
|
{
|
|
|
|
size_t idx = GetCallbackIdx(callbacks, callback, private_data);
|
|
|
|
if (idx == (size_t)-1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
callbacks.erase(callbacks.begin() + idx);
|
|
|
|
}
|
|
|
|
|
|
|
|
obs_output_t *obs_frontend_get_streaming_output(void) override
|
|
|
|
{
|
2021-11-26 01:25:39 -08:00
|
|
|
OBSOutput output = main->outputHandler->streamOutput.Get();
|
2022-01-24 11:26:04 -08:00
|
|
|
return obs_output_get_ref(output);
|
2016-08-28 14:24:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
obs_output_t *obs_frontend_get_recording_output(void) override
|
|
|
|
{
|
2021-11-26 01:25:39 -08:00
|
|
|
OBSOutput out = main->outputHandler->fileOutput.Get();
|
2022-01-24 11:26:04 -08:00
|
|
|
return obs_output_get_ref(out);
|
2016-08-28 14:24:14 -07:00
|
|
|
}
|
|
|
|
|
2016-12-09 14:40:04 -08:00
|
|
|
obs_output_t *obs_frontend_get_replay_buffer_output(void) override
|
|
|
|
{
|
2021-11-26 01:25:39 -08:00
|
|
|
OBSOutput out = main->outputHandler->replayBuffer.Get();
|
2022-01-24 11:26:04 -08:00
|
|
|
return obs_output_get_ref(out);
|
2016-12-09 14:40:04 -08:00
|
|
|
}
|
|
|
|
|
2016-08-28 14:24:14 -07:00
|
|
|
config_t *obs_frontend_get_profile_config(void) override
|
|
|
|
{
|
|
|
|
return main->basicConfig;
|
|
|
|
}
|
|
|
|
|
|
|
|
config_t *obs_frontend_get_global_config(void) override
|
|
|
|
{
|
|
|
|
return App()->GlobalConfig();
|
|
|
|
}
|
|
|
|
|
2019-05-31 20:13:24 -07:00
|
|
|
void obs_frontend_open_projector(const char *type, int monitor,
|
|
|
|
const char *geometry,
|
|
|
|
const char *name) override
|
|
|
|
{
|
|
|
|
SavedProjectorInfo proj = {
|
|
|
|
ProjectorType::Preview,
|
|
|
|
monitor,
|
|
|
|
geometry ? geometry : "",
|
|
|
|
name ? name : "",
|
|
|
|
};
|
|
|
|
if (type) {
|
|
|
|
if (astrcmpi(type, "Source") == 0)
|
|
|
|
proj.type = ProjectorType::Source;
|
|
|
|
else if (astrcmpi(type, "Scene") == 0)
|
|
|
|
proj.type = ProjectorType::Scene;
|
|
|
|
else if (astrcmpi(type, "StudioProgram") == 0)
|
|
|
|
proj.type = ProjectorType::StudioProgram;
|
|
|
|
else if (astrcmpi(type, "Multiview") == 0)
|
|
|
|
proj.type = ProjectorType::Multiview;
|
|
|
|
}
|
|
|
|
QMetaObject::invokeMethod(main, "OpenSavedProjector",
|
|
|
|
WaitConnection(),
|
|
|
|
Q_ARG(SavedProjectorInfo *, &proj));
|
|
|
|
}
|
|
|
|
|
2019-06-22 22:13:45 -07:00
|
|
|
void obs_frontend_save(void) override { main->SaveProject(); }
|
2016-08-28 14:24:14 -07:00
|
|
|
|
2018-02-04 13:36:56 -08:00
|
|
|
void obs_frontend_defer_save_begin(void) override
|
|
|
|
{
|
|
|
|
QMetaObject::invokeMethod(main, "DeferSaveBegin");
|
|
|
|
}
|
|
|
|
|
|
|
|
void obs_frontend_defer_save_end(void) override
|
|
|
|
{
|
|
|
|
QMetaObject::invokeMethod(main, "DeferSaveEnd");
|
|
|
|
}
|
|
|
|
|
2016-08-28 14:24:14 -07:00
|
|
|
void obs_frontend_add_save_callback(obs_frontend_save_cb callback,
|
2019-06-22 22:13:45 -07:00
|
|
|
void *private_data) override
|
2016-08-28 14:24:14 -07:00
|
|
|
{
|
2019-06-22 22:13:45 -07:00
|
|
|
size_t idx =
|
|
|
|
GetCallbackIdx(saveCallbacks, callback, private_data);
|
2016-08-28 14:24:14 -07:00
|
|
|
if (idx == (size_t)-1)
|
|
|
|
saveCallbacks.emplace_back(callback, private_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
void obs_frontend_remove_save_callback(obs_frontend_save_cb callback,
|
2019-06-22 22:13:45 -07:00
|
|
|
void *private_data) override
|
2016-08-28 14:24:14 -07:00
|
|
|
{
|
2019-06-22 22:13:45 -07:00
|
|
|
size_t idx =
|
|
|
|
GetCallbackIdx(saveCallbacks, callback, private_data);
|
2016-08-28 14:24:14 -07:00
|
|
|
if (idx == (size_t)-1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
saveCallbacks.erase(saveCallbacks.begin() + idx);
|
|
|
|
}
|
|
|
|
|
2017-12-25 13:23:39 -08:00
|
|
|
void obs_frontend_add_preload_callback(obs_frontend_save_cb callback,
|
2019-06-22 22:13:45 -07:00
|
|
|
void *private_data) override
|
2017-12-25 13:23:39 -08:00
|
|
|
{
|
|
|
|
size_t idx = GetCallbackIdx(preloadCallbacks, callback,
|
2019-06-22 22:13:45 -07:00
|
|
|
private_data);
|
2017-12-25 13:23:39 -08:00
|
|
|
if (idx == (size_t)-1)
|
|
|
|
preloadCallbacks.emplace_back(callback, private_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
void obs_frontend_remove_preload_callback(obs_frontend_save_cb callback,
|
2019-06-22 22:13:45 -07:00
|
|
|
void *private_data) override
|
2017-12-25 13:23:39 -08:00
|
|
|
{
|
|
|
|
size_t idx = GetCallbackIdx(preloadCallbacks, callback,
|
2019-06-22 22:13:45 -07:00
|
|
|
private_data);
|
2017-12-25 13:23:39 -08:00
|
|
|
if (idx == (size_t)-1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
preloadCallbacks.erase(preloadCallbacks.begin() + idx);
|
|
|
|
}
|
|
|
|
|
2016-08-28 14:24:14 -07:00
|
|
|
void obs_frontend_push_ui_translation(
|
2019-06-22 22:13:45 -07:00
|
|
|
obs_frontend_translate_ui_cb translate) override
|
2016-08-28 14:24:14 -07:00
|
|
|
{
|
|
|
|
App()->PushUITranslation(translate);
|
|
|
|
}
|
|
|
|
|
|
|
|
void obs_frontend_pop_ui_translation(void) override
|
|
|
|
{
|
|
|
|
App()->PopUITranslation();
|
|
|
|
}
|
|
|
|
|
2017-04-26 00:16:37 -07:00
|
|
|
void obs_frontend_set_streaming_service(obs_service_t *service) override
|
|
|
|
{
|
|
|
|
main->SetService(service);
|
|
|
|
}
|
|
|
|
|
|
|
|
obs_service_t *obs_frontend_get_streaming_service(void) override
|
|
|
|
{
|
|
|
|
return main->GetService();
|
|
|
|
}
|
|
|
|
|
|
|
|
void obs_frontend_save_streaming_service(void) override
|
|
|
|
{
|
|
|
|
main->SaveService();
|
|
|
|
}
|
|
|
|
|
2017-05-03 14:17:52 -07:00
|
|
|
bool obs_frontend_preview_program_mode_active(void) override
|
|
|
|
{
|
|
|
|
return main->IsPreviewProgramMode();
|
|
|
|
}
|
|
|
|
|
|
|
|
void obs_frontend_set_preview_program_mode(bool enable) override
|
|
|
|
{
|
|
|
|
main->SetPreviewProgramMode(enable);
|
|
|
|
}
|
|
|
|
|
2019-05-08 23:29:31 -07:00
|
|
|
void obs_frontend_preview_program_trigger_transition(void) override
|
|
|
|
{
|
|
|
|
QMetaObject::invokeMethod(main, "TransitionClicked");
|
|
|
|
}
|
|
|
|
|
2017-12-06 18:12:19 -08:00
|
|
|
bool obs_frontend_preview_enabled(void) override
|
|
|
|
{
|
|
|
|
return main->previewEnabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
void obs_frontend_set_preview_enabled(bool enable) override
|
|
|
|
{
|
|
|
|
if (main->previewEnabled != enable)
|
|
|
|
main->EnablePreviewDisplay(enable);
|
|
|
|
}
|
|
|
|
|
2017-05-03 14:17:52 -07:00
|
|
|
obs_source_t *obs_frontend_get_current_preview_scene(void) override
|
|
|
|
{
|
|
|
|
if (main->IsPreviewProgramMode()) {
|
2022-01-24 11:26:04 -08:00
|
|
|
OBSSource source = main->GetCurrentSceneSource();
|
|
|
|
return obs_source_get_ref(source);
|
2017-05-03 14:17:52 -07:00
|
|
|
}
|
|
|
|
|
2022-01-24 11:26:04 -08:00
|
|
|
return nullptr;
|
2017-05-03 14:17:52 -07:00
|
|
|
}
|
|
|
|
|
2019-06-22 22:13:45 -07:00
|
|
|
void
|
|
|
|
obs_frontend_set_current_preview_scene(obs_source_t *scene) override
|
2017-05-03 14:17:52 -07:00
|
|
|
{
|
|
|
|
if (main->IsPreviewProgramMode()) {
|
|
|
|
QMetaObject::invokeMethod(main, "SetCurrentScene",
|
2019-06-22 22:13:45 -07:00
|
|
|
Q_ARG(OBSSource,
|
|
|
|
OBSSource(scene)),
|
|
|
|
Q_ARG(bool, false));
|
2017-05-03 14:17:52 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-23 06:53:21 -07:00
|
|
|
void obs_frontend_take_screenshot(void) override
|
|
|
|
{
|
|
|
|
QMetaObject::invokeMethod(main, "Screenshot");
|
|
|
|
}
|
|
|
|
|
|
|
|
void obs_frontend_take_source_screenshot(obs_source_t *source) override
|
|
|
|
{
|
|
|
|
QMetaObject::invokeMethod(main, "Screenshot",
|
|
|
|
Q_ARG(OBSSource, OBSSource(source)));
|
|
|
|
}
|
|
|
|
|
2020-12-07 12:39:02 -08:00
|
|
|
obs_output_t *obs_frontend_get_virtualcam_output(void) override
|
|
|
|
{
|
2021-11-26 01:25:39 -08:00
|
|
|
OBSOutput output = main->outputHandler->virtualCam.Get();
|
2022-01-24 11:26:04 -08:00
|
|
|
return obs_output_get_ref(output);
|
2020-12-07 12:39:02 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void obs_frontend_start_virtualcam(void) override
|
|
|
|
{
|
|
|
|
QMetaObject::invokeMethod(main, "StartVirtualCam");
|
|
|
|
}
|
|
|
|
|
|
|
|
void obs_frontend_stop_virtualcam(void) override
|
|
|
|
{
|
|
|
|
QMetaObject::invokeMethod(main, "StopVirtualCam");
|
|
|
|
}
|
|
|
|
|
|
|
|
bool obs_frontend_virtualcam_active(void) override
|
|
|
|
{
|
|
|
|
return os_atomic_load_bool(&virtualcam_active);
|
|
|
|
}
|
|
|
|
|
2021-02-01 05:48:51 -08:00
|
|
|
void obs_frontend_reset_video(void) override { main->ResetVideo(); }
|
|
|
|
|
2021-08-09 13:35:30 -07:00
|
|
|
void obs_frontend_open_source_properties(obs_source_t *source) override
|
|
|
|
{
|
|
|
|
QMetaObject::invokeMethod(main, "OpenProperties",
|
|
|
|
Q_ARG(OBSSource, OBSSource(source)));
|
|
|
|
}
|
|
|
|
|
|
|
|
void obs_frontend_open_source_filters(obs_source_t *source) override
|
|
|
|
{
|
|
|
|
QMetaObject::invokeMethod(main, "OpenFilters",
|
|
|
|
Q_ARG(OBSSource, OBSSource(source)));
|
|
|
|
}
|
|
|
|
|
2021-12-28 16:50:43 -08:00
|
|
|
void obs_frontend_open_source_interaction(obs_source_t *source) override
|
|
|
|
{
|
|
|
|
QMetaObject::invokeMethod(main, "OpenInteraction",
|
|
|
|
Q_ARG(OBSSource, OBSSource(source)));
|
|
|
|
}
|
|
|
|
|
2021-11-13 00:51:22 -08:00
|
|
|
char *obs_frontend_get_current_record_output_path(void) override
|
|
|
|
{
|
|
|
|
const char *recordOutputPath = main->GetCurrentOutputPath();
|
|
|
|
|
|
|
|
return bstrdup(recordOutputPath);
|
|
|
|
}
|
|
|
|
|
2022-03-09 02:24:33 -08:00
|
|
|
const char *obs_frontend_get_locale_string(const char *string) override
|
|
|
|
{
|
|
|
|
return Str(string);
|
|
|
|
}
|
|
|
|
|
2016-08-28 14:24:14 -07:00
|
|
|
void on_load(obs_data_t *settings) override
|
|
|
|
{
|
2017-12-25 13:26:28 -08:00
|
|
|
for (size_t i = saveCallbacks.size(); i > 0; i--) {
|
|
|
|
auto cb = saveCallbacks[i - 1];
|
2016-08-28 14:24:14 -07:00
|
|
|
cb.callback(settings, false, cb.private_data);
|
2017-12-25 13:23:39 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void on_preload(obs_data_t *settings) override
|
|
|
|
{
|
|
|
|
for (size_t i = preloadCallbacks.size(); i > 0; i--) {
|
|
|
|
auto cb = preloadCallbacks[i - 1];
|
|
|
|
cb.callback(settings, false, cb.private_data);
|
|
|
|
}
|
2016-08-28 14:24:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void on_save(obs_data_t *settings) override
|
|
|
|
{
|
2017-12-25 13:26:28 -08:00
|
|
|
for (size_t i = saveCallbacks.size(); i > 0; i--) {
|
|
|
|
auto cb = saveCallbacks[i - 1];
|
2016-08-28 14:24:14 -07:00
|
|
|
cb.callback(settings, true, cb.private_data);
|
2017-12-25 13:26:28 -08:00
|
|
|
}
|
2016-08-28 14:24:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void on_event(enum obs_frontend_event event) override
|
|
|
|
{
|
2021-04-11 23:01:09 -07:00
|
|
|
if (main->disableSaving &&
|
2021-08-15 06:43:17 -07:00
|
|
|
event != OBS_FRONTEND_EVENT_SCENE_COLLECTION_CLEANUP &&
|
2021-08-15 06:54:52 -07:00
|
|
|
event != OBS_FRONTEND_EVENT_EXIT)
|
2016-08-28 14:24:14 -07:00
|
|
|
return;
|
|
|
|
|
2017-12-25 13:26:28 -08:00
|
|
|
for (size_t i = callbacks.size(); i > 0; i--) {
|
|
|
|
auto cb = callbacks[i - 1];
|
2016-08-28 14:24:14 -07:00
|
|
|
cb.callback(event, cb.private_data);
|
2017-12-25 13:26:28 -08:00
|
|
|
}
|
2016-08-28 14:24:14 -07:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
obs_frontend_callbacks *InitializeAPIInterface(OBSBasic *main)
|
|
|
|
{
|
|
|
|
obs_frontend_callbacks *api = new OBSStudioAPI(main);
|
|
|
|
obs_frontend_set_callbacks_internal(api);
|
|
|
|
return api;
|
|
|
|
}
|