window-basic-main-profiles.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707
  1. /******************************************************************************
  2. Copyright (C) 2015 by Hugh Bailey <[email protected]>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. ******************************************************************************/
  14. #include <obs.hpp>
  15. #include <util/platform.h>
  16. #include <util/util.hpp>
  17. #include <QMessageBox>
  18. #include <QVariant>
  19. #include <QFileDialog>
  20. #include "window-basic-main.hpp"
  21. #include "window-namedialog.hpp"
  22. #include "qt-wrappers.hpp"
  23. extern void DestroyPanelCookieManager();
  24. extern void DuplicateCurrentCookieProfile(ConfigFile &config);
  25. extern void CheckExistingCookieId();
  26. void EnumProfiles(std::function<bool (const char *, const char *)> &&cb)
  27. {
  28. char path[512];
  29. os_glob_t *glob;
  30. int ret = GetConfigPath(path, sizeof(path),
  31. "obs-studio/basic/profiles/*");
  32. if (ret <= 0) {
  33. blog(LOG_WARNING, "Failed to get profiles config path");
  34. return;
  35. }
  36. if (os_glob(path, 0, &glob) != 0) {
  37. blog(LOG_WARNING, "Failed to glob profiles");
  38. return;
  39. }
  40. for (size_t i = 0; i < glob->gl_pathc; i++) {
  41. const char *filePath = glob->gl_pathv[i].path;
  42. const char *dirName = strrchr(filePath, '/') + 1;
  43. if (!glob->gl_pathv[i].directory)
  44. continue;
  45. if (strcmp(dirName, ".") == 0 ||
  46. strcmp(dirName, "..") == 0)
  47. continue;
  48. std::string file = filePath;
  49. file += "/basic.ini";
  50. ConfigFile config;
  51. int ret = config.Open(file.c_str(), CONFIG_OPEN_EXISTING);
  52. if (ret != CONFIG_SUCCESS)
  53. continue;
  54. const char *name = config_get_string(config, "General", "Name");
  55. if (!name)
  56. name = strrchr(filePath, '/') + 1;
  57. if (!cb(name, filePath))
  58. break;
  59. }
  60. os_globfree(glob);
  61. }
  62. static bool ProfileExists(const char *findName)
  63. {
  64. bool found = false;
  65. auto func = [&](const char *name, const char*)
  66. {
  67. if (strcmp(name, findName) == 0) {
  68. found = true;
  69. return false;
  70. }
  71. return true;
  72. };
  73. EnumProfiles(func);
  74. return found;
  75. }
  76. static bool GetProfileName(QWidget *parent, std::string &name,
  77. std::string &file, const char *title, const char *text,
  78. const char *oldName = nullptr)
  79. {
  80. char path[512];
  81. int ret;
  82. for (;;) {
  83. bool success = NameDialog::AskForName(parent, title, text,
  84. name, QT_UTF8(oldName));
  85. if (!success) {
  86. return false;
  87. }
  88. if (name.empty()) {
  89. OBSMessageBox::information(parent,
  90. QTStr("NoNameEntered.Title"),
  91. QTStr("NoNameEntered.Text"));
  92. continue;
  93. }
  94. if (ProfileExists(name.c_str())) {
  95. OBSMessageBox::information(parent,
  96. QTStr("NameExists.Title"),
  97. QTStr("NameExists.Text"));
  98. continue;
  99. }
  100. break;
  101. }
  102. if (!GetFileSafeName(name.c_str(), file)) {
  103. blog(LOG_WARNING, "Failed to create safe file name for '%s'",
  104. name.c_str());
  105. return false;
  106. }
  107. ret = GetConfigPath(path, sizeof(path), "obs-studio/basic/profiles/");
  108. if (ret <= 0) {
  109. blog(LOG_WARNING, "Failed to get profiles config path");
  110. return false;
  111. }
  112. file.insert(0, path);
  113. if (!GetClosestUnusedFileName(file, nullptr)) {
  114. blog(LOG_WARNING, "Failed to get closest file name for %s",
  115. file.c_str());
  116. return false;
  117. }
  118. file.erase(0, ret);
  119. return true;
  120. }
  121. static bool CopyProfile(const char *fromPartial, const char *to)
  122. {
  123. os_glob_t *glob;
  124. char path[514];
  125. char dir[512];
  126. int ret;
  127. ret = GetConfigPath(dir, sizeof(dir), "obs-studio/basic/profiles/");
  128. if (ret <= 0) {
  129. blog(LOG_WARNING, "Failed to get profiles config path");
  130. return false;
  131. }
  132. snprintf(path, sizeof(path), "%s%s/*", dir, fromPartial);
  133. if (os_glob(path, 0, &glob) != 0) {
  134. blog(LOG_WARNING, "Failed to glob profile '%s'", fromPartial);
  135. return false;
  136. }
  137. for (size_t i = 0; i < glob->gl_pathc; i++) {
  138. const char *filePath = glob->gl_pathv[i].path;
  139. if (glob->gl_pathv[i].directory)
  140. continue;
  141. ret = snprintf(path, sizeof(path), "%s/%s",
  142. to, strrchr(filePath, '/') + 1);
  143. if (ret > 0) {
  144. if (os_copyfile(filePath, path) != 0) {
  145. blog(LOG_WARNING, "CopyProfile: Failed to "
  146. "copy file %s to %s",
  147. filePath, path);
  148. }
  149. }
  150. }
  151. os_globfree(glob);
  152. return true;
  153. }
  154. bool OBSBasic::AddProfile(bool create_new, const char *title, const char *text,
  155. const char *init_text, bool rename)
  156. {
  157. std::string newName;
  158. std::string newDir;
  159. std::string newPath;
  160. ConfigFile config;
  161. if (!GetProfileName(this, newName, newDir, title, text, init_text))
  162. return false;
  163. std::string curDir = config_get_string(App()->GlobalConfig(),
  164. "Basic", "ProfileDir");
  165. char baseDir[512];
  166. int ret = GetConfigPath(baseDir, sizeof(baseDir),
  167. "obs-studio/basic/profiles/");
  168. if (ret <= 0) {
  169. blog(LOG_WARNING, "Failed to get profiles config path");
  170. return false;
  171. }
  172. newPath = baseDir;
  173. newPath += newDir;
  174. if (os_mkdir(newPath.c_str()) < 0) {
  175. blog(LOG_WARNING, "Failed to create profile directory '%s'",
  176. newDir.c_str());
  177. return false;
  178. }
  179. if (!create_new)
  180. CopyProfile(curDir.c_str(), newPath.c_str());
  181. newPath += "/basic.ini";
  182. if (config.Open(newPath.c_str(), CONFIG_OPEN_ALWAYS) != 0) {
  183. blog(LOG_ERROR, "Failed to open new config file '%s'",
  184. newDir.c_str());
  185. return false;
  186. }
  187. config_set_string(App()->GlobalConfig(), "Basic", "Profile",
  188. newName.c_str());
  189. config_set_string(App()->GlobalConfig(), "Basic", "ProfileDir",
  190. newDir.c_str());
  191. Auth::Save();
  192. if (create_new) {
  193. auth.reset();
  194. DestroyPanelCookieManager();
  195. } else if (!rename) {
  196. DuplicateCurrentCookieProfile(config);
  197. }
  198. config_set_string(config, "General", "Name", newName.c_str());
  199. config.SaveSafe("tmp");
  200. config.Swap(basicConfig);
  201. InitBasicConfigDefaults();
  202. InitBasicConfigDefaults2();
  203. RefreshProfiles();
  204. if (create_new)
  205. ResetProfileData();
  206. blog(LOG_INFO, "Created profile '%s' (%s, %s)", newName.c_str(),
  207. create_new ? "clean" : "duplicate", newDir.c_str());
  208. blog(LOG_INFO, "------------------------------------------------");
  209. config_save_safe(App()->GlobalConfig(), "tmp", nullptr);
  210. UpdateTitleBar();
  211. if (api) {
  212. api->on_event(OBS_FRONTEND_EVENT_PROFILE_LIST_CHANGED);
  213. api->on_event(OBS_FRONTEND_EVENT_PROFILE_CHANGED);
  214. }
  215. return true;
  216. }
  217. void OBSBasic::DeleteProfile(const char *profileName, const char *profileDir)
  218. {
  219. char profilePath[512];
  220. char basePath[512];
  221. int ret = GetConfigPath(basePath, 512, "obs-studio/basic/profiles");
  222. if (ret <= 0) {
  223. blog(LOG_WARNING, "Failed to get profiles config path");
  224. return;
  225. }
  226. ret = snprintf(profilePath, 512, "%s/%s/*", basePath, profileDir);
  227. if (ret <= 0) {
  228. blog(LOG_WARNING, "Failed to get path for profile dir '%s'",
  229. profileDir);
  230. return;
  231. }
  232. os_glob_t *glob;
  233. if (os_glob(profilePath, 0, &glob) != 0) {
  234. blog(LOG_WARNING, "Failed to glob profile dir '%s'",
  235. profileDir);
  236. return;
  237. }
  238. for (size_t i = 0; i < glob->gl_pathc; i++) {
  239. const char *filePath = glob->gl_pathv[i].path;
  240. if (glob->gl_pathv[i].directory)
  241. continue;
  242. os_unlink(filePath);
  243. }
  244. os_globfree(glob);
  245. ret = snprintf(profilePath, 512, "%s/%s", basePath, profileDir);
  246. if (ret <= 0) {
  247. blog(LOG_WARNING, "Failed to get path for profile dir '%s'",
  248. profileDir);
  249. return;
  250. }
  251. os_rmdir(profilePath);
  252. blog(LOG_INFO, "------------------------------------------------");
  253. blog(LOG_INFO, "Removed profile '%s' (%s)",
  254. profileName, profileDir);
  255. blog(LOG_INFO, "------------------------------------------------");
  256. }
  257. void OBSBasic::RefreshProfiles()
  258. {
  259. QList<QAction*> menuActions = ui->profileMenu->actions();
  260. int count = 0;
  261. for (int i = 0; i < menuActions.count(); i++) {
  262. QVariant v = menuActions[i]->property("file_name");
  263. if (v.typeName() != nullptr)
  264. delete menuActions[i];
  265. }
  266. const char *curName = config_get_string(App()->GlobalConfig(),
  267. "Basic", "Profile");
  268. auto addProfile = [&](const char *name, const char *path)
  269. {
  270. std::string file = strrchr(path, '/') + 1;
  271. QAction *action = new QAction(QT_UTF8(name), this);
  272. action->setProperty("file_name", QT_UTF8(path));
  273. connect(action, &QAction::triggered,
  274. this, &OBSBasic::ChangeProfile);
  275. action->setCheckable(true);
  276. action->setChecked(strcmp(name, curName) == 0);
  277. ui->profileMenu->addAction(action);
  278. count++;
  279. return true;
  280. };
  281. EnumProfiles(addProfile);
  282. ui->actionRemoveProfile->setEnabled(count > 1);
  283. }
  284. void OBSBasic::ResetProfileData()
  285. {
  286. ResetVideo();
  287. service = nullptr;
  288. InitService();
  289. ResetOutputs();
  290. ClearHotkeys();
  291. CreateHotkeys();
  292. /* load audio monitoring */
  293. #if defined(_WIN32) || defined(__APPLE__) || HAVE_PULSEAUDIO
  294. const char *device_name = config_get_string(basicConfig, "Audio",
  295. "MonitoringDeviceName");
  296. const char *device_id = config_get_string(basicConfig, "Audio",
  297. "MonitoringDeviceId");
  298. obs_set_audio_monitoring_device(device_name, device_id);
  299. blog(LOG_INFO, "Audio monitoring device:\n\tname: %s\n\tid: %s",
  300. device_name, device_id);
  301. #endif
  302. }
  303. void OBSBasic::on_actionNewProfile_triggered()
  304. {
  305. AddProfile(true, Str("AddProfile.Title"), Str("AddProfile.Text"));
  306. }
  307. void OBSBasic::on_actionDupProfile_triggered()
  308. {
  309. AddProfile(false, Str("AddProfile.Title"), Str("AddProfile.Text"));
  310. }
  311. void OBSBasic::on_actionRenameProfile_triggered()
  312. {
  313. std::string curDir = config_get_string(App()->GlobalConfig(),
  314. "Basic", "ProfileDir");
  315. std::string curName = config_get_string(App()->GlobalConfig(),
  316. "Basic", "Profile");
  317. /* Duplicate and delete in case there are any issues in the process */
  318. bool success = AddProfile(false, Str("RenameProfile.Title"),
  319. Str("AddProfile.Text"), curName.c_str(), true);
  320. if (success) {
  321. DeleteProfile(curName.c_str(), curDir.c_str());
  322. RefreshProfiles();
  323. }
  324. if (api) {
  325. api->on_event(OBS_FRONTEND_EVENT_PROFILE_LIST_CHANGED);
  326. api->on_event(OBS_FRONTEND_EVENT_PROFILE_CHANGED);
  327. }
  328. }
  329. void OBSBasic::on_actionRemoveProfile_triggered()
  330. {
  331. std::string newName;
  332. std::string newPath;
  333. ConfigFile config;
  334. std::string oldDir = config_get_string(App()->GlobalConfig(),
  335. "Basic", "ProfileDir");
  336. std::string oldName = config_get_string(App()->GlobalConfig(),
  337. "Basic", "Profile");
  338. auto cb = [&](const char *name, const char *filePath)
  339. {
  340. if (strcmp(oldName.c_str(), name) != 0) {
  341. newName = name;
  342. newPath = filePath;
  343. return false;
  344. }
  345. return true;
  346. };
  347. EnumProfiles(cb);
  348. /* this should never be true due to menu item being grayed out */
  349. if (newPath.empty())
  350. return;
  351. QString text = QTStr("ConfirmRemove.Text");
  352. text.replace("$1", QT_UTF8(oldName.c_str()));
  353. QMessageBox::StandardButton button = OBSMessageBox::question(this,
  354. QTStr("ConfirmRemove.Title"), text);
  355. if (button == QMessageBox::No)
  356. return;
  357. size_t newPath_len = newPath.size();
  358. newPath += "/basic.ini";
  359. if (config.Open(newPath.c_str(), CONFIG_OPEN_ALWAYS) != 0) {
  360. blog(LOG_ERROR, "ChangeProfile: Failed to load file '%s'",
  361. newPath.c_str());
  362. return;
  363. }
  364. newPath.resize(newPath_len);
  365. const char *newDir = strrchr(newPath.c_str(), '/') + 1;
  366. config_set_string(App()->GlobalConfig(), "Basic", "Profile",
  367. newName.c_str());
  368. config_set_string(App()->GlobalConfig(), "Basic", "ProfileDir",
  369. newDir);
  370. Auth::Save();
  371. auth.reset();
  372. DestroyPanelCookieManager();
  373. config.Swap(basicConfig);
  374. InitBasicConfigDefaults();
  375. InitBasicConfigDefaults2();
  376. ResetProfileData();
  377. DeleteProfile(oldName.c_str(), oldDir.c_str());
  378. RefreshProfiles();
  379. config_save_safe(App()->GlobalConfig(), "tmp", nullptr);
  380. blog(LOG_INFO, "Switched to profile '%s' (%s)",
  381. newName.c_str(), newDir);
  382. blog(LOG_INFO, "------------------------------------------------");
  383. UpdateTitleBar();
  384. Auth::Load();
  385. if (api) {
  386. api->on_event(OBS_FRONTEND_EVENT_PROFILE_LIST_CHANGED);
  387. api->on_event(OBS_FRONTEND_EVENT_PROFILE_CHANGED);
  388. }
  389. }
  390. void OBSBasic::on_actionImportProfile_triggered()
  391. {
  392. char path[512];
  393. QString home = QDir::homePath();
  394. int ret = GetConfigPath(path, 512, "obs-studio/basic/profiles/");
  395. if (ret <= 0) {
  396. blog(LOG_WARNING, "Failed to get profile config path");
  397. return;
  398. }
  399. QString dir = QFileDialog::getExistingDirectory(
  400. this,
  401. QTStr("Basic.MainMenu.Profile.Import"),
  402. home,
  403. QFileDialog::ShowDirsOnly |
  404. QFileDialog::DontResolveSymlinks);
  405. if (!dir.isEmpty() && !dir.isNull()) {
  406. QString inputPath = QString::fromUtf8(path);
  407. QFileInfo finfo(dir);
  408. QString directory = finfo.fileName();
  409. QString profileDir = inputPath + directory;
  410. QDir folder(profileDir);
  411. if (!folder.exists()) {
  412. folder.mkpath(profileDir);
  413. QFile::copy(dir + "/basic.ini",
  414. profileDir + "/basic.ini");
  415. QFile::copy(dir + "/service.json",
  416. profileDir + "/service.json");
  417. QFile::copy(dir + "/streamEncoder.json",
  418. profileDir + "/streamEncoder.json");
  419. QFile::copy(dir + "/recordEncoder.json",
  420. profileDir + "/recordEncoder.json");
  421. RefreshProfiles();
  422. } else {
  423. OBSMessageBox::information(this,
  424. QTStr("Basic.MainMenu.Profile.Import"),
  425. QTStr("Basic.MainMenu.Profile.Exists"));
  426. }
  427. }
  428. }
  429. void OBSBasic::on_actionExportProfile_triggered()
  430. {
  431. char path[512];
  432. QString home = QDir::homePath();
  433. QString currentProfile =
  434. QString::fromUtf8(config_get_string(App()->GlobalConfig(),
  435. "Basic", "ProfileDir"));
  436. int ret = GetConfigPath(path, 512, "obs-studio/basic/profiles/");
  437. if (ret <= 0) {
  438. blog(LOG_WARNING, "Failed to get profile config path");
  439. return;
  440. }
  441. QString dir = QFileDialog::getExistingDirectory(
  442. this,
  443. QTStr("Basic.MainMenu.Profile.Export"),
  444. home,
  445. QFileDialog::ShowDirsOnly |
  446. QFileDialog::DontResolveSymlinks);
  447. if (!dir.isEmpty() && !dir.isNull()) {
  448. QString outputDir = dir + "/" + currentProfile;
  449. QString inputPath = QString::fromUtf8(path);
  450. QDir folder(outputDir);
  451. if (!folder.exists()) {
  452. folder.mkpath(outputDir);
  453. } else {
  454. if (QFile::exists(outputDir + "/basic.ini"))
  455. QFile::remove(outputDir + "/basic.ini");
  456. if (QFile::exists(outputDir + "/service.json"))
  457. QFile::remove(outputDir + "/service.json");
  458. if (QFile::exists(outputDir + "/streamEncoder.json"))
  459. QFile::remove(outputDir + "/streamEncoder.json");
  460. if (QFile::exists(outputDir + "/recordEncoder.json"))
  461. QFile::remove(outputDir + "/recordEncoder.json");
  462. }
  463. QFile::copy(inputPath + currentProfile + "/basic.ini",
  464. outputDir + "/basic.ini");
  465. QFile::copy(inputPath + currentProfile + "/service.json",
  466. outputDir + "/service.json");
  467. QFile::copy(inputPath + currentProfile + "/streamEncoder.json",
  468. outputDir + "/streamEncoder.json");
  469. QFile::copy(inputPath + currentProfile + "/recordEncoder.json",
  470. outputDir + "/recordEncoder.json");
  471. }
  472. }
  473. void OBSBasic::ChangeProfile()
  474. {
  475. QAction *action = reinterpret_cast<QAction*>(sender());
  476. ConfigFile config;
  477. std::string path;
  478. if (!action)
  479. return;
  480. path = QT_TO_UTF8(action->property("file_name").value<QString>());
  481. if (path.empty())
  482. return;
  483. const char *oldName = config_get_string(App()->GlobalConfig(),
  484. "Basic", "Profile");
  485. if (action->text().compare(QT_UTF8(oldName)) == 0) {
  486. action->setChecked(true);
  487. return;
  488. }
  489. size_t path_len = path.size();
  490. path += "/basic.ini";
  491. if (config.Open(path.c_str(), CONFIG_OPEN_ALWAYS) != 0) {
  492. blog(LOG_ERROR, "ChangeProfile: Failed to load file '%s'",
  493. path.c_str());
  494. return;
  495. }
  496. path.resize(path_len);
  497. const char *newName = config_get_string(config, "General", "Name");
  498. const char *newDir = strrchr(path.c_str(), '/') + 1;
  499. config_set_string(App()->GlobalConfig(), "Basic", "Profile", newName);
  500. config_set_string(App()->GlobalConfig(), "Basic", "ProfileDir",
  501. newDir);
  502. Auth::Save();
  503. auth.reset();
  504. DestroyPanelCookieManager();
  505. config.Swap(basicConfig);
  506. InitBasicConfigDefaults();
  507. InitBasicConfigDefaults2();
  508. ResetProfileData();
  509. RefreshProfiles();
  510. config_save_safe(App()->GlobalConfig(), "tmp", nullptr);
  511. UpdateTitleBar();
  512. Auth::Load();
  513. CheckForSimpleModeX264Fallback();
  514. blog(LOG_INFO, "Switched to profile '%s' (%s)",
  515. newName, newDir);
  516. blog(LOG_INFO, "------------------------------------------------");
  517. if (api)
  518. api->on_event(OBS_FRONTEND_EVENT_PROFILE_CHANGED);
  519. }
  520. void OBSBasic::CheckForSimpleModeX264Fallback()
  521. {
  522. const char *curStreamEncoder = config_get_string(basicConfig,
  523. "SimpleOutput", "StreamEncoder");
  524. const char *curRecEncoder = config_get_string(basicConfig,
  525. "SimpleOutput", "RecEncoder");
  526. bool qsv_supported = false;
  527. bool amd_supported = false;
  528. bool nve_supported = false;
  529. bool changed = false;
  530. size_t idx = 0;
  531. const char *id;
  532. while (obs_enum_encoder_types(idx++, &id)) {
  533. if (strcmp(id, "amd_amf_h264") == 0)
  534. amd_supported = true;
  535. else if (strcmp(id, "obs_qsv11") == 0)
  536. qsv_supported = true;
  537. else if (strcmp(id, "ffmpeg_nvenc") == 0)
  538. nve_supported = true;
  539. }
  540. auto CheckEncoder = [&] (const char *&name)
  541. {
  542. if (strcmp(name, SIMPLE_ENCODER_QSV) == 0) {
  543. if (!qsv_supported) {
  544. changed = true;
  545. name = SIMPLE_ENCODER_X264;
  546. return false;
  547. }
  548. } else if (strcmp(name, SIMPLE_ENCODER_NVENC) == 0) {
  549. if (!nve_supported) {
  550. changed = true;
  551. name = SIMPLE_ENCODER_X264;
  552. return false;
  553. }
  554. } else if (strcmp(name, SIMPLE_ENCODER_AMD) == 0) {
  555. if (!amd_supported) {
  556. changed = true;
  557. name = SIMPLE_ENCODER_X264;
  558. return false;
  559. }
  560. }
  561. return true;
  562. };
  563. if (!CheckEncoder(curStreamEncoder))
  564. config_set_string(basicConfig,
  565. "SimpleOutput", "StreamEncoder",
  566. curStreamEncoder);
  567. if (!CheckEncoder(curRecEncoder))
  568. config_set_string(basicConfig,
  569. "SimpleOutput", "RecEncoder",
  570. curRecEncoder);
  571. if (changed)
  572. config_save_safe(basicConfig, "tmp", nullptr);
  573. }