70 lines
2.1 KiB
C++
70 lines
2.1 KiB
C++
#include <obs-module.h>
|
|
#include <obs-frontend-api.h>
|
|
|
|
#include <QAction>
|
|
#include <QInputDialog>
|
|
#include <QMessageBox>
|
|
|
|
static void whip_setup_service(const char *key)
|
|
{
|
|
obs_service_t *current_service = obs_frontend_get_streaming_service();
|
|
obs_data_t *data = obs_data_create();
|
|
|
|
obs_data_set_string(data, "server",
|
|
"https://live.umm.gay/api/wish-server/whip");
|
|
obs_data_set_string(data, "bearer_token", key);
|
|
|
|
obs_data_t *hotkey_data = obs_hotkeys_save_service(current_service);
|
|
|
|
obs_service_t *new_service = obs_service_create(
|
|
"whip_custom", "live.umm.gay", data, hotkey_data);
|
|
|
|
obs_frontend_set_streaming_service(new_service);
|
|
}
|
|
|
|
extern "C" void whip_register_setup_item()
|
|
{
|
|
QAction *menuAction = (QAction *)obs_frontend_add_tools_menu_qaction(
|
|
"Use live.umm.gay");
|
|
QObject::connect(menuAction, &QAction::triggered, [] {
|
|
QInputDialog *dlg = new QInputDialog(nullptr);
|
|
dlg->setWindowFlag(Qt::WindowStaysOnTopHint, true);
|
|
dlg->setWindowFlag(Qt::WindowContextHelpButtonHint, false);
|
|
|
|
dlg->setWindowTitle("live.umm.gay: Enter Stream Key");
|
|
dlg->setTextEchoMode(QLineEdit::Password);
|
|
dlg->setLabelText("Enter your stream key for live.umm.gay:");
|
|
if (QLineEdit *edit = dlg->findChild<QLineEdit *>()) {
|
|
edit->setPlaceholderText("channel:stream-key");
|
|
edit->setStyleSheet("QLineEdit { color: #7f7f7f; }");
|
|
|
|
QObject::connect(edit, &QLineEdit::textChanged, [edit] {
|
|
if (edit->text().isEmpty()) {
|
|
edit->setStyleSheet(
|
|
"QLineEdit { color: #7f7f7f; }");
|
|
} else {
|
|
edit->setStyleSheet(nullptr);
|
|
}
|
|
});
|
|
}
|
|
|
|
QObject::connect(dlg, &QInputDialog::finished, [dlg](int result) {
|
|
if (result == QDialog::Accepted) {
|
|
whip_setup_service(
|
|
dlg->textValue().toUtf8().constData());
|
|
|
|
QMessageBox mb(
|
|
QMessageBox::Information,
|
|
"live.umm.gay: Success",
|
|
"Your stream details have been successfully applied.",
|
|
QMessageBox::NoButton,
|
|
(QWidget *)
|
|
obs_frontend_get_main_window());
|
|
mb.addButton("OK", QMessageBox::AcceptRole);
|
|
mb.exec();
|
|
}
|
|
});
|
|
dlg->open();
|
|
});
|
|
}
|