char/char-rtc-obs
git clone https://git.t4t.associates/char/char-rtc-obs
35e5e7d
main
1#include <obs-module.h> 2#include <obs-frontend-api.h> 3 4#include <QAction> 5#include <QInputDialog> 6#include <QMessageBox> 7 8static void whip_setup_service (const char * key ) 9{ 10obs_service_t * current_service = obs_frontend_get_streaming_service (); 11obs_data_t * data = obs_data_create (); 12 13obs_data_set_string (data ,"server" , 14"https://live.umm.gay/api/wish-server/whip" ); 15obs_data_set_string (data ,"bearer_token" ,key ); 16 17obs_data_t * hotkey_data = obs_hotkeys_save_service (current_service ); 18 19obs_service_t * new_service = obs_service_create ( 20"whip_custom" ,"live.umm.gay" ,data ,hotkey_data ); 21 22obs_frontend_set_streaming_service (new_service ); 23} 24 25extern "C" void whip_register_setup_item () 26{ 27QAction * menuAction = (QAction * )obs_frontend_add_tools_menu_qaction ( 28"Use live.umm.gay" ); 29QObject ::connect (menuAction ,& QAction ::triggered , [] { 30QInputDialog * dlg = new QInputDialog (nullptr ); 31dlg -> setWindowFlag (Qt ::WindowStaysOnTopHint , true); 32dlg -> setWindowFlag (Qt ::WindowContextHelpButtonHint , false); 33 34dlg -> setWindowTitle ("live.umm.gay: Enter Stream Key" ); 35dlg -> setTextEchoMode (QLineEdit ::Password ); 36dlg -> setLabelText ("Enter your stream key for live.umm.gay:" ); 37if (QLineEdit * edit = dlg -> findChild < QLineEdit *> ()) { 38edit -> setPlaceholderText ("channel:stream-key" ); 39edit -> setStyleSheet ("QLineEdit { color: #7f7f7f; }" ); 40 41QObject ::connect (edit ,& QLineEdit ::textChanged , [edit ] { 42if (edit -> text ().isEmpty ()) { 43edit -> setStyleSheet ( 44"QLineEdit { color: #7f7f7f; }" ); 45 }else { 46edit -> setStyleSheet (nullptr ); 47 } 48 }); 49 } 50 51QObject ::connect (dlg ,& QInputDialog ::finished , [dlg ](int result ) { 52if (result == QDialog ::Accepted ) { 53whip_setup_service ( 54dlg -> textValue ().toUtf8 ().constData ()); 55 56QMessageBox mb ( 57QMessageBox ::Information , 58"live.umm.gay: Success" , 59"Your stream details have been successfully applied." , 60QMessageBox ::NoButton , 61 (QWidget * ) 62obs_frontend_get_main_window ()); 63mb .addButton ("OK" ,QMessageBox ::AcceptRole ); 64mb .exec (); 65 } 66 }); 67dlg -> open (); 68 }); 69}