window-basic-settings-stream.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727
  1. #include <QMessageBox>
  2. #include <QUrl>
  3. #include "window-basic-settings.hpp"
  4. #include "obs-frontend-api.h"
  5. #include "obs-app.hpp"
  6. #include "window-basic-main.hpp"
  7. #include "qt-wrappers.hpp"
  8. #include "url-push-button.hpp"
  9. #ifdef BROWSER_AVAILABLE
  10. #include <browser-panel.hpp>
  11. #include "auth-oauth.hpp"
  12. #endif
  13. struct QCef;
  14. struct QCefCookieManager;
  15. extern QCef *cef;
  16. extern QCefCookieManager *panel_cookies;
  17. enum class ListOpt : int {
  18. ShowAll = 1,
  19. Custom,
  20. };
  21. enum class Section : int {
  22. Connect,
  23. StreamKey,
  24. };
  25. inline bool OBSBasicSettings::IsCustomService() const
  26. {
  27. return ui->service->currentData().toInt() == (int)ListOpt::Custom;
  28. }
  29. void OBSBasicSettings::InitStreamPage()
  30. {
  31. ui->connectAccount2->setVisible(false);
  32. ui->disconnectAccount->setVisible(false);
  33. ui->bandwidthTestEnable->setVisible(false);
  34. ui->twitchAddonDropdown->setVisible(false);
  35. ui->twitchAddonLabel->setVisible(false);
  36. int vertSpacing = ui->topStreamLayout->verticalSpacing();
  37. QMargins m = ui->topStreamLayout->contentsMargins();
  38. m.setBottom(vertSpacing / 2);
  39. ui->topStreamLayout->setContentsMargins(m);
  40. m = ui->loginPageLayout->contentsMargins();
  41. m.setTop(vertSpacing / 2);
  42. ui->loginPageLayout->setContentsMargins(m);
  43. m = ui->streamkeyPageLayout->contentsMargins();
  44. m.setTop(vertSpacing / 2);
  45. ui->streamkeyPageLayout->setContentsMargins(m);
  46. LoadServices(false);
  47. ui->twitchAddonDropdown->addItem(
  48. QTStr("Basic.Settings.Stream.TTVAddon.None"));
  49. ui->twitchAddonDropdown->addItem(
  50. QTStr("Basic.Settings.Stream.TTVAddon.BTTV"));
  51. ui->twitchAddonDropdown->addItem(
  52. QTStr("Basic.Settings.Stream.TTVAddon.FFZ"));
  53. ui->twitchAddonDropdown->addItem(
  54. QTStr("Basic.Settings.Stream.TTVAddon.Both"));
  55. connect(ui->service, SIGNAL(currentIndexChanged(int)), this,
  56. SLOT(UpdateServerList()));
  57. connect(ui->service, SIGNAL(currentIndexChanged(int)), this,
  58. SLOT(UpdateKeyLink()));
  59. connect(ui->service, SIGNAL(currentIndexChanged(int)), this,
  60. SLOT(UpdateVodTrackSetting()));
  61. connect(ui->service, SIGNAL(currentIndexChanged(int)), this,
  62. SLOT(UpdateServiceRecommendations()));
  63. connect(ui->customServer, SIGNAL(textChanged(const QString &)), this,
  64. SLOT(UpdateKeyLink()));
  65. connect(ui->ignoreRecommended, SIGNAL(clicked(bool)), this,
  66. SLOT(DisplayEnforceWarning(bool)));
  67. connect(ui->customServer, SIGNAL(editingFinished(const QString &)),
  68. this, SLOT(UpdateKeyLink()));
  69. connect(ui->service, SIGNAL(currentIndexChanged(int)), this,
  70. SLOT(UpdateMoreInfoLink()));
  71. }
  72. void OBSBasicSettings::LoadStream1Settings()
  73. {
  74. bool ignoreRecommended =
  75. config_get_bool(main->Config(), "Stream1", "IgnoreRecommended");
  76. obs_service_t *service_obj = main->GetService();
  77. const char *type = obs_service_get_type(service_obj);
  78. loading = true;
  79. obs_data_t *settings = obs_service_get_settings(service_obj);
  80. const char *service = obs_data_get_string(settings, "service");
  81. const char *server = obs_data_get_string(settings, "server");
  82. const char *key = obs_data_get_string(settings, "key");
  83. if (strcmp(type, "rtmp_custom") == 0) {
  84. ui->service->setCurrentIndex(0);
  85. ui->customServer->setText(server);
  86. bool use_auth = obs_data_get_bool(settings, "use_auth");
  87. const char *username =
  88. obs_data_get_string(settings, "username");
  89. const char *password =
  90. obs_data_get_string(settings, "password");
  91. ui->authUsername->setText(QT_UTF8(username));
  92. ui->authPw->setText(QT_UTF8(password));
  93. ui->useAuth->setChecked(use_auth);
  94. } else {
  95. int idx = ui->service->findText(service);
  96. if (idx == -1) {
  97. if (service && *service)
  98. ui->service->insertItem(1, service);
  99. idx = 1;
  100. }
  101. ui->service->setCurrentIndex(idx);
  102. bool bw_test = obs_data_get_bool(settings, "bwtest");
  103. ui->bandwidthTestEnable->setChecked(bw_test);
  104. idx = config_get_int(main->Config(), "Twitch", "AddonChoice");
  105. ui->twitchAddonDropdown->setCurrentIndex(idx);
  106. }
  107. UpdateServerList();
  108. if (strcmp(type, "rtmp_common") == 0) {
  109. int idx = ui->server->findData(server);
  110. if (idx == -1) {
  111. if (server && *server)
  112. ui->server->insertItem(0, server, server);
  113. idx = 0;
  114. }
  115. ui->server->setCurrentIndex(idx);
  116. }
  117. ui->key->setText(key);
  118. lastService.clear();
  119. on_service_currentIndexChanged(0);
  120. obs_data_release(settings);
  121. UpdateKeyLink();
  122. UpdateMoreInfoLink();
  123. UpdateVodTrackSetting();
  124. UpdateServiceRecommendations();
  125. bool streamActive = obs_frontend_streaming_active();
  126. ui->streamPage->setEnabled(!streamActive);
  127. ui->ignoreRecommended->setChecked(ignoreRecommended);
  128. loading = false;
  129. }
  130. void OBSBasicSettings::SaveStream1Settings()
  131. {
  132. bool customServer = IsCustomService();
  133. const char *service_id = customServer ? "rtmp_custom" : "rtmp_common";
  134. obs_service_t *oldService = main->GetService();
  135. OBSData hotkeyData = obs_hotkeys_save_service(oldService);
  136. obs_data_release(hotkeyData);
  137. OBSData settings = obs_data_create();
  138. obs_data_release(settings);
  139. if (!customServer) {
  140. obs_data_set_string(settings, "service",
  141. QT_TO_UTF8(ui->service->currentText()));
  142. obs_data_set_string(
  143. settings, "server",
  144. QT_TO_UTF8(ui->server->currentData().toString()));
  145. } else {
  146. obs_data_set_string(settings, "server",
  147. QT_TO_UTF8(ui->customServer->text()));
  148. obs_data_set_bool(settings, "use_auth",
  149. ui->useAuth->isChecked());
  150. if (ui->useAuth->isChecked()) {
  151. obs_data_set_string(
  152. settings, "username",
  153. QT_TO_UTF8(ui->authUsername->text()));
  154. obs_data_set_string(settings, "password",
  155. QT_TO_UTF8(ui->authPw->text()));
  156. }
  157. }
  158. if (!!auth && strcmp(auth->service(), "Twitch") == 0) {
  159. bool choiceExists = config_has_user_value(
  160. main->Config(), "Twitch", "AddonChoice");
  161. int currentChoice =
  162. config_get_int(main->Config(), "Twitch", "AddonChoice");
  163. int newChoice = ui->twitchAddonDropdown->currentIndex();
  164. config_set_int(main->Config(), "Twitch", "AddonChoice",
  165. newChoice);
  166. if (choiceExists && currentChoice != newChoice)
  167. forceAuthReload = true;
  168. obs_data_set_bool(settings, "bwtest",
  169. ui->bandwidthTestEnable->isChecked());
  170. } else {
  171. obs_data_set_bool(settings, "bwtest", false);
  172. }
  173. obs_data_set_string(settings, "key", QT_TO_UTF8(ui->key->text()));
  174. OBSService newService = obs_service_create(
  175. service_id, "default_service", settings, hotkeyData);
  176. obs_service_release(newService);
  177. if (!newService)
  178. return;
  179. main->SetService(newService);
  180. main->SaveService();
  181. main->auth = auth;
  182. if (!!main->auth)
  183. main->auth->LoadUI();
  184. SaveCheckBox(ui->ignoreRecommended, "Stream1", "IgnoreRecommended");
  185. }
  186. void OBSBasicSettings::UpdateMoreInfoLink()
  187. {
  188. if (IsCustomService()) {
  189. ui->moreInfoButton->hide();
  190. return;
  191. }
  192. QString serviceName = ui->service->currentText();
  193. obs_properties_t *props = obs_get_service_properties("rtmp_common");
  194. obs_property_t *services = obs_properties_get(props, "service");
  195. OBSData settings = obs_data_create();
  196. obs_data_release(settings);
  197. obs_data_set_string(settings, "service", QT_TO_UTF8(serviceName));
  198. obs_property_modified(services, settings);
  199. const char *more_info_link =
  200. obs_data_get_string(settings, "more_info_link");
  201. if (!more_info_link || (*more_info_link == '\0')) {
  202. ui->moreInfoButton->hide();
  203. } else {
  204. ui->moreInfoButton->setTargetUrl(QUrl(more_info_link));
  205. ui->moreInfoButton->show();
  206. }
  207. obs_properties_destroy(props);
  208. }
  209. void OBSBasicSettings::UpdateKeyLink()
  210. {
  211. QString serviceName = ui->service->currentText();
  212. QString customServer = ui->customServer->text();
  213. QString streamKeyLink;
  214. if (serviceName == "Twitch") {
  215. streamKeyLink = "https://dashboard.twitch.tv/settings/stream";
  216. } else if (serviceName.startsWith("YouTube")) {
  217. streamKeyLink = "https://www.youtube.com/live_dashboard";
  218. } else if (serviceName.startsWith("Restream.io")) {
  219. streamKeyLink =
  220. "https://restream.io/settings/streaming-setup?from=OBS";
  221. } else if (serviceName == "Facebook Live" ||
  222. (customServer.contains("fbcdn.net") && IsCustomService())) {
  223. streamKeyLink =
  224. "https://www.facebook.com/live/producer?ref=OBS";
  225. } else if (serviceName.startsWith("Twitter")) {
  226. streamKeyLink = "https://www.pscp.tv/account/producer";
  227. } else if (serviceName.startsWith("YouStreamer")) {
  228. streamKeyLink = "https://app.youstreamer.com/stream/";
  229. } else if (serviceName == "Trovo") {
  230. streamKeyLink = "https://studio.trovo.live/mychannel/stream";
  231. }
  232. if (QString(streamKeyLink).isNull()) {
  233. ui->getStreamKeyButton->hide();
  234. } else {
  235. ui->getStreamKeyButton->setTargetUrl(QUrl(streamKeyLink));
  236. ui->getStreamKeyButton->show();
  237. }
  238. }
  239. void OBSBasicSettings::LoadServices(bool showAll)
  240. {
  241. obs_properties_t *props = obs_get_service_properties("rtmp_common");
  242. OBSData settings = obs_data_create();
  243. obs_data_release(settings);
  244. obs_data_set_bool(settings, "show_all", showAll);
  245. obs_property_t *prop = obs_properties_get(props, "show_all");
  246. obs_property_modified(prop, settings);
  247. ui->service->blockSignals(true);
  248. ui->service->clear();
  249. QStringList names;
  250. obs_property_t *services = obs_properties_get(props, "service");
  251. size_t services_count = obs_property_list_item_count(services);
  252. for (size_t i = 0; i < services_count; i++) {
  253. const char *name = obs_property_list_item_string(services, i);
  254. names.push_back(name);
  255. }
  256. if (showAll)
  257. names.sort(Qt::CaseInsensitive);
  258. for (QString &name : names)
  259. ui->service->addItem(name);
  260. if (!showAll) {
  261. ui->service->addItem(
  262. QTStr("Basic.AutoConfig.StreamPage.Service.ShowAll"),
  263. QVariant((int)ListOpt::ShowAll));
  264. }
  265. ui->service->insertItem(
  266. 0, QTStr("Basic.AutoConfig.StreamPage.Service.Custom"),
  267. QVariant((int)ListOpt::Custom));
  268. if (!lastService.isEmpty()) {
  269. int idx = ui->service->findText(lastService);
  270. if (idx != -1)
  271. ui->service->setCurrentIndex(idx);
  272. }
  273. obs_properties_destroy(props);
  274. ui->service->blockSignals(false);
  275. }
  276. static inline bool is_auth_service(const std::string &service)
  277. {
  278. return Auth::AuthType(service) != Auth::Type::None;
  279. }
  280. void OBSBasicSettings::on_service_currentIndexChanged(int)
  281. {
  282. bool showMore = ui->service->currentData().toInt() ==
  283. (int)ListOpt::ShowAll;
  284. if (showMore)
  285. return;
  286. std::string service = QT_TO_UTF8(ui->service->currentText());
  287. bool custom = IsCustomService();
  288. ui->disconnectAccount->setVisible(false);
  289. ui->bandwidthTestEnable->setVisible(false);
  290. ui->twitchAddonDropdown->setVisible(false);
  291. ui->twitchAddonLabel->setVisible(false);
  292. #ifdef BROWSER_AVAILABLE
  293. if (cef) {
  294. if (lastService != service.c_str()) {
  295. QString key = ui->key->text();
  296. bool can_auth = is_auth_service(service);
  297. int page = can_auth && (!loading || key.isEmpty())
  298. ? (int)Section::Connect
  299. : (int)Section::StreamKey;
  300. ui->streamStackWidget->setCurrentIndex(page);
  301. ui->streamKeyWidget->setVisible(true);
  302. ui->streamKeyLabel->setVisible(true);
  303. ui->connectAccount2->setVisible(can_auth);
  304. }
  305. } else {
  306. ui->connectAccount2->setVisible(false);
  307. }
  308. #else
  309. ui->connectAccount2->setVisible(false);
  310. #endif
  311. ui->useAuth->setVisible(custom);
  312. ui->authUsernameLabel->setVisible(custom);
  313. ui->authUsername->setVisible(custom);
  314. ui->authPwLabel->setVisible(custom);
  315. ui->authPwWidget->setVisible(custom);
  316. if (custom) {
  317. ui->streamkeyPageLayout->insertRow(1, ui->serverLabel,
  318. ui->serverStackedWidget);
  319. ui->serverStackedWidget->setCurrentIndex(1);
  320. ui->serverStackedWidget->setVisible(true);
  321. ui->serverLabel->setVisible(true);
  322. on_useAuth_toggled();
  323. } else {
  324. ui->serverStackedWidget->setCurrentIndex(0);
  325. }
  326. #ifdef BROWSER_AVAILABLE
  327. auth.reset();
  328. if (!!main->auth &&
  329. service.find(main->auth->service()) != std::string::npos) {
  330. auth = main->auth;
  331. OnAuthConnected();
  332. }
  333. #endif
  334. }
  335. void OBSBasicSettings::UpdateServerList()
  336. {
  337. QString serviceName = ui->service->currentText();
  338. bool showMore = ui->service->currentData().toInt() ==
  339. (int)ListOpt::ShowAll;
  340. if (showMore) {
  341. LoadServices(true);
  342. ui->service->showPopup();
  343. return;
  344. } else {
  345. lastService = serviceName;
  346. }
  347. obs_properties_t *props = obs_get_service_properties("rtmp_common");
  348. obs_property_t *services = obs_properties_get(props, "service");
  349. OBSData settings = obs_data_create();
  350. obs_data_release(settings);
  351. obs_data_set_string(settings, "service", QT_TO_UTF8(serviceName));
  352. obs_property_modified(services, settings);
  353. obs_property_t *servers = obs_properties_get(props, "server");
  354. ui->server->clear();
  355. size_t servers_count = obs_property_list_item_count(servers);
  356. for (size_t i = 0; i < servers_count; i++) {
  357. const char *name = obs_property_list_item_name(servers, i);
  358. const char *server = obs_property_list_item_string(servers, i);
  359. ui->server->addItem(name, server);
  360. }
  361. obs_properties_destroy(props);
  362. }
  363. void OBSBasicSettings::on_show_clicked()
  364. {
  365. if (ui->key->echoMode() == QLineEdit::Password) {
  366. ui->key->setEchoMode(QLineEdit::Normal);
  367. ui->show->setText(QTStr("Hide"));
  368. } else {
  369. ui->key->setEchoMode(QLineEdit::Password);
  370. ui->show->setText(QTStr("Show"));
  371. }
  372. }
  373. void OBSBasicSettings::on_authPwShow_clicked()
  374. {
  375. if (ui->authPw->echoMode() == QLineEdit::Password) {
  376. ui->authPw->setEchoMode(QLineEdit::Normal);
  377. ui->authPwShow->setText(QTStr("Hide"));
  378. } else {
  379. ui->authPw->setEchoMode(QLineEdit::Password);
  380. ui->authPwShow->setText(QTStr("Show"));
  381. }
  382. }
  383. OBSService OBSBasicSettings::SpawnTempService()
  384. {
  385. bool custom = IsCustomService();
  386. const char *service_id = custom ? "rtmp_custom" : "rtmp_common";
  387. OBSData settings = obs_data_create();
  388. obs_data_release(settings);
  389. if (!custom) {
  390. obs_data_set_string(settings, "service",
  391. QT_TO_UTF8(ui->service->currentText()));
  392. obs_data_set_string(
  393. settings, "server",
  394. QT_TO_UTF8(ui->server->currentData().toString()));
  395. } else {
  396. obs_data_set_string(settings, "server",
  397. QT_TO_UTF8(ui->customServer->text()));
  398. }
  399. obs_data_set_string(settings, "key", QT_TO_UTF8(ui->key->text()));
  400. OBSService newService = obs_service_create(service_id, "temp_service",
  401. settings, nullptr);
  402. obs_service_release(newService);
  403. return newService;
  404. }
  405. void OBSBasicSettings::OnOAuthStreamKeyConnected()
  406. {
  407. #ifdef BROWSER_AVAILABLE
  408. OAuthStreamKey *a = reinterpret_cast<OAuthStreamKey *>(auth.get());
  409. if (a) {
  410. bool validKey = !a->key().empty();
  411. if (validKey)
  412. ui->key->setText(QT_UTF8(a->key().c_str()));
  413. ui->streamKeyWidget->setVisible(false);
  414. ui->streamKeyLabel->setVisible(false);
  415. ui->connectAccount2->setVisible(false);
  416. ui->disconnectAccount->setVisible(true);
  417. if (strcmp(a->service(), "Twitch") == 0) {
  418. ui->bandwidthTestEnable->setVisible(true);
  419. ui->twitchAddonLabel->setVisible(true);
  420. ui->twitchAddonDropdown->setVisible(true);
  421. } else {
  422. ui->bandwidthTestEnable->setChecked(false);
  423. }
  424. }
  425. ui->streamStackWidget->setCurrentIndex((int)Section::StreamKey);
  426. #endif
  427. }
  428. void OBSBasicSettings::OnAuthConnected()
  429. {
  430. std::string service = QT_TO_UTF8(ui->service->currentText());
  431. Auth::Type type = Auth::AuthType(service);
  432. if (type == Auth::Type::OAuth_StreamKey) {
  433. OnOAuthStreamKeyConnected();
  434. }
  435. if (!loading) {
  436. stream1Changed = true;
  437. EnableApplyButton(true);
  438. }
  439. }
  440. void OBSBasicSettings::on_connectAccount_clicked()
  441. {
  442. #ifdef BROWSER_AVAILABLE
  443. std::string service = QT_TO_UTF8(ui->service->currentText());
  444. OAuth::DeleteCookies(service);
  445. auth = OAuthStreamKey::Login(this, service);
  446. if (!!auth)
  447. OnAuthConnected();
  448. #endif
  449. }
  450. #define DISCONNECT_COMFIRM_TITLE \
  451. "Basic.AutoConfig.StreamPage.DisconnectAccount.Confirm.Title"
  452. #define DISCONNECT_COMFIRM_TEXT \
  453. "Basic.AutoConfig.StreamPage.DisconnectAccount.Confirm.Text"
  454. void OBSBasicSettings::on_disconnectAccount_clicked()
  455. {
  456. QMessageBox::StandardButton button;
  457. button = OBSMessageBox::question(this, QTStr(DISCONNECT_COMFIRM_TITLE),
  458. QTStr(DISCONNECT_COMFIRM_TEXT));
  459. if (button == QMessageBox::No) {
  460. return;
  461. }
  462. main->auth.reset();
  463. auth.reset();
  464. std::string service = QT_TO_UTF8(ui->service->currentText());
  465. #ifdef BROWSER_AVAILABLE
  466. OAuth::DeleteCookies(service);
  467. #endif
  468. ui->bandwidthTestEnable->setChecked(false);
  469. ui->streamKeyWidget->setVisible(true);
  470. ui->streamKeyLabel->setVisible(true);
  471. ui->connectAccount2->setVisible(true);
  472. ui->disconnectAccount->setVisible(false);
  473. ui->bandwidthTestEnable->setVisible(false);
  474. ui->twitchAddonDropdown->setVisible(false);
  475. ui->twitchAddonLabel->setVisible(false);
  476. ui->key->setText("");
  477. }
  478. void OBSBasicSettings::on_useStreamKey_clicked()
  479. {
  480. ui->streamStackWidget->setCurrentIndex((int)Section::StreamKey);
  481. }
  482. void OBSBasicSettings::on_useAuth_toggled()
  483. {
  484. if (!IsCustomService())
  485. return;
  486. bool use_auth = ui->useAuth->isChecked();
  487. ui->authUsernameLabel->setVisible(use_auth);
  488. ui->authUsername->setVisible(use_auth);
  489. ui->authPwLabel->setVisible(use_auth);
  490. ui->authPwWidget->setVisible(use_auth);
  491. }
  492. void OBSBasicSettings::UpdateVodTrackSetting()
  493. {
  494. bool enableVodTrack = ui->service->currentText() == "Twitch";
  495. bool wasEnabled = !!vodTrackCheckbox;
  496. if (enableVodTrack == wasEnabled)
  497. return;
  498. if (!enableVodTrack) {
  499. delete vodTrackCheckbox;
  500. delete vodTrackContainer;
  501. return;
  502. }
  503. vodTrackCheckbox = new QCheckBox(
  504. QTStr("Basic.Settings.Output.Adv.TwitchVodTrack"));
  505. vodTrackCheckbox->setLayoutDirection(Qt::RightToLeft);
  506. vodTrackContainer = new QWidget();
  507. QHBoxLayout *vodTrackLayout = new QHBoxLayout();
  508. for (int i = 0; i < MAX_AUDIO_MIXES; i++) {
  509. vodTrack[i] = new QRadioButton(QString::number(i + 1));
  510. vodTrackLayout->addWidget(vodTrack[i]);
  511. HookWidget(vodTrack[i], SIGNAL(clicked(bool)),
  512. SLOT(OutputsChanged()));
  513. }
  514. HookWidget(vodTrackCheckbox, SIGNAL(clicked(bool)),
  515. SLOT(OutputsChanged()));
  516. vodTrackLayout->addStretch();
  517. vodTrackLayout->setContentsMargins(0, 0, 0, 0);
  518. vodTrackContainer->setLayout(vodTrackLayout);
  519. ui->advOutTopLayout->insertRow(2, vodTrackCheckbox, vodTrackContainer);
  520. bool vodTrackEnabled =
  521. config_get_bool(main->Config(), "AdvOut", "VodTrackEnabled");
  522. vodTrackCheckbox->setChecked(vodTrackEnabled);
  523. vodTrackContainer->setEnabled(vodTrackEnabled);
  524. connect(vodTrackCheckbox, SIGNAL(clicked(bool)), vodTrackContainer,
  525. SLOT(setEnabled(bool)));
  526. int trackIndex =
  527. config_get_int(main->Config(), "AdvOut", "VodTrackIndex");
  528. for (int i = 0; i < MAX_AUDIO_MIXES; i++) {
  529. vodTrack[i]->setChecked((i + 1) == trackIndex);
  530. }
  531. }
  532. OBSService OBSBasicSettings::GetStream1Service()
  533. {
  534. return stream1Changed ? SpawnTempService()
  535. : OBSService(main->GetService());
  536. }
  537. void OBSBasicSettings::UpdateServiceRecommendations()
  538. {
  539. bool customServer = IsCustomService();
  540. ui->ignoreRecommended->setVisible(!customServer);
  541. ui->enforceSettingsLabel->setVisible(!customServer);
  542. OBSService service = GetStream1Service();
  543. int vbitrate, abitrate;
  544. obs_service_get_max_bitrate(service, &vbitrate, &abitrate);
  545. QString text;
  546. #define ENFORCE_TEXT(x) QTStr("Basic.Settings.Stream.Recommended." x)
  547. if (vbitrate)
  548. text += ENFORCE_TEXT("MaxVideoBitrate")
  549. .arg(QString::number(vbitrate));
  550. if (abitrate) {
  551. if (!text.isEmpty())
  552. text += "\n";
  553. text += ENFORCE_TEXT("MaxAudioBitrate")
  554. .arg(QString::number(abitrate));
  555. }
  556. #undef ENFORCE_TEXT
  557. ui->enforceSettingsLabel->setText(text);
  558. }
  559. void OBSBasicSettings::DisplayEnforceWarning(bool checked)
  560. {
  561. if (IsCustomService())
  562. return;
  563. if (!checked) {
  564. SimpleRecordingEncoderChanged();
  565. return;
  566. }
  567. QMessageBox::StandardButton button;
  568. #define ENFORCE_WARNING(x) \
  569. QTStr("Basic.Settings.Stream.IgnoreRecommended.Warn." x)
  570. button = OBSMessageBox::question(this, ENFORCE_WARNING("Title"),
  571. ENFORCE_WARNING("Text"));
  572. #undef ENFORCE_WARNING
  573. if (button == QMessageBox::No) {
  574. QMetaObject::invokeMethod(ui->ignoreRecommended, "setChecked",
  575. Qt::QueuedConnection,
  576. Q_ARG(bool, false));
  577. return;
  578. }
  579. SimpleRecordingEncoderChanged();
  580. }