1
0

window-basic-main-profiles.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696
  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. extern void DeleteCookies();
  27. void EnumProfiles(std::function<bool(const char *, const char *)> &&cb)
  28. {
  29. char path[512];
  30. os_glob_t *glob;
  31. int ret = GetConfigPath(path, sizeof(path),
  32. "obs-studio/basic/profiles/*");
  33. if (ret <= 0) {
  34. blog(LOG_WARNING, "Failed to get profiles config path");
  35. return;
  36. }
  37. if (os_glob(path, 0, &glob) != 0) {
  38. blog(LOG_WARNING, "Failed to glob profiles");
  39. return;
  40. }
  41. for (size_t i = 0; i < glob->gl_pathc; i++) {
  42. const char *filePath = glob->gl_pathv[i].path;
  43. const char *dirName = strrchr(filePath, '/') + 1;
  44. if (!glob->gl_pathv[i].directory)
  45. continue;
  46. if (strcmp(dirName, ".") == 0 || 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. if (strcmp(name, findName) == 0) {
  67. found = true;
  68. return false;
  69. }
  70. return true;
  71. };
  72. EnumProfiles(func);
  73. return found;
  74. }
  75. static bool GetProfileName(QWidget *parent, std::string &name,
  76. std::string &file, const char *title,
  77. const char *text, const char *oldName = nullptr)
  78. {
  79. char path[512];
  80. int ret;
  81. for (;;) {
  82. bool success = NameDialog::AskForName(parent, title, text, name,
  83. QT_UTF8(oldName));
  84. if (!success) {
  85. return false;
  86. }
  87. if (name.empty()) {
  88. OBSMessageBox::warning(parent,
  89. QTStr("NoNameEntered.Title"),
  90. QTStr("NoNameEntered.Text"));
  91. continue;
  92. }
  93. if (ProfileExists(name.c_str())) {
  94. OBSMessageBox::warning(parent,
  95. QTStr("NameExists.Title"),
  96. QTStr("NameExists.Text"));
  97. continue;
  98. }
  99. break;
  100. }
  101. if (!GetFileSafeName(name.c_str(), file)) {
  102. blog(LOG_WARNING, "Failed to create safe file name for '%s'",
  103. name.c_str());
  104. return false;
  105. }
  106. ret = GetConfigPath(path, sizeof(path), "obs-studio/basic/profiles/");
  107. if (ret <= 0) {
  108. blog(LOG_WARNING, "Failed to get profiles config path");
  109. return false;
  110. }
  111. file.insert(0, path);
  112. if (!GetClosestUnusedFileName(file, nullptr)) {
  113. blog(LOG_WARNING, "Failed to get closest file name for %s",
  114. file.c_str());
  115. return false;
  116. }
  117. file.erase(0, ret);
  118. return true;
  119. }
  120. static bool CopyProfile(const char *fromPartial, const char *to)
  121. {
  122. os_glob_t *glob;
  123. char path[514];
  124. char dir[512];
  125. int ret;
  126. ret = GetConfigPath(dir, sizeof(dir), "obs-studio/basic/profiles/");
  127. if (ret <= 0) {
  128. blog(LOG_WARNING, "Failed to get profiles config path");
  129. return false;
  130. }
  131. snprintf(path, sizeof(path), "%s%s/*", dir, fromPartial);
  132. if (os_glob(path, 0, &glob) != 0) {
  133. blog(LOG_WARNING, "Failed to glob profile '%s'", fromPartial);
  134. return false;
  135. }
  136. for (size_t i = 0; i < glob->gl_pathc; i++) {
  137. const char *filePath = glob->gl_pathv[i].path;
  138. if (glob->gl_pathv[i].directory)
  139. continue;
  140. ret = snprintf(path, sizeof(path), "%s/%s", to,
  141. strrchr(filePath, '/') + 1);
  142. if (ret > 0) {
  143. if (os_copyfile(filePath, path) != 0) {
  144. blog(LOG_WARNING,
  145. "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 =
  164. config_get_string(App()->GlobalConfig(), "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. basicConfig.SaveSafe("tmp");
  200. config.SaveSafe("tmp");
  201. config.Swap(basicConfig);
  202. InitBasicConfigDefaults();
  203. InitBasicConfigDefaults2();
  204. RefreshProfiles();
  205. if (create_new)
  206. ResetProfileData();
  207. blog(LOG_INFO, "Created profile '%s' (%s, %s)", newName.c_str(),
  208. create_new ? "clean" : "duplicate", newDir.c_str());
  209. blog(LOG_INFO, "------------------------------------------------");
  210. config_save_safe(App()->GlobalConfig(), "tmp", nullptr);
  211. UpdateTitleBar();
  212. if (api) {
  213. api->on_event(OBS_FRONTEND_EVENT_PROFILE_LIST_CHANGED);
  214. api->on_event(OBS_FRONTEND_EVENT_PROFILE_CHANGED);
  215. }
  216. return true;
  217. }
  218. void OBSBasic::DeleteProfile(const char *profileName, const char *profileDir)
  219. {
  220. char profilePath[512];
  221. char basePath[512];
  222. int ret = GetConfigPath(basePath, 512, "obs-studio/basic/profiles");
  223. if (ret <= 0) {
  224. blog(LOG_WARNING, "Failed to get profiles config path");
  225. return;
  226. }
  227. ret = snprintf(profilePath, 512, "%s/%s/*", basePath, profileDir);
  228. if (ret <= 0) {
  229. blog(LOG_WARNING, "Failed to get path for profile dir '%s'",
  230. profileDir);
  231. return;
  232. }
  233. os_glob_t *glob;
  234. if (os_glob(profilePath, 0, &glob) != 0) {
  235. blog(LOG_WARNING, "Failed to glob profile dir '%s'",
  236. profileDir);
  237. return;
  238. }
  239. for (size_t i = 0; i < glob->gl_pathc; i++) {
  240. const char *filePath = glob->gl_pathv[i].path;
  241. if (glob->gl_pathv[i].directory)
  242. continue;
  243. os_unlink(filePath);
  244. }
  245. os_globfree(glob);
  246. ret = snprintf(profilePath, 512, "%s/%s", basePath, profileDir);
  247. if (ret <= 0) {
  248. blog(LOG_WARNING, "Failed to get path for profile dir '%s'",
  249. profileDir);
  250. return;
  251. }
  252. os_rmdir(profilePath);
  253. blog(LOG_INFO, "------------------------------------------------");
  254. blog(LOG_INFO, "Removed profile '%s' (%s)", 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 =
  267. config_get_string(App()->GlobalConfig(), "Basic", "Profile");
  268. auto addProfile = [&](const char *name, const char *path) {
  269. std::string file = strrchr(path, '/') + 1;
  270. QAction *action = new QAction(QT_UTF8(name), this);
  271. action->setProperty("file_name", QT_UTF8(path));
  272. connect(action, &QAction::triggered, this,
  273. &OBSBasic::ChangeProfile);
  274. action->setCheckable(true);
  275. action->setChecked(strcmp(name, curName) == 0);
  276. ui->profileMenu->addAction(action);
  277. count++;
  278. return true;
  279. };
  280. EnumProfiles(addProfile);
  281. ui->actionRemoveProfile->setEnabled(count > 1);
  282. }
  283. void OBSBasic::ResetProfileData()
  284. {
  285. ResetVideo();
  286. service = nullptr;
  287. InitService();
  288. ResetOutputs();
  289. ClearHotkeys();
  290. CreateHotkeys();
  291. /* load audio monitoring */
  292. #if defined(_WIN32) || defined(__APPLE__) || HAVE_PULSEAUDIO
  293. const char *device_name =
  294. config_get_string(basicConfig, "Audio", "MonitoringDeviceName");
  295. const char *device_id =
  296. config_get_string(basicConfig, "Audio", "MonitoringDeviceId");
  297. obs_set_audio_monitoring_device(device_name, device_id);
  298. blog(LOG_INFO, "Audio monitoring device:\n\tname: %s\n\tid: %s",
  299. device_name, device_id);
  300. #endif
  301. }
  302. void OBSBasic::on_actionNewProfile_triggered()
  303. {
  304. AddProfile(true, Str("AddProfile.Title"), Str("AddProfile.Text"));
  305. }
  306. void OBSBasic::on_actionDupProfile_triggered()
  307. {
  308. AddProfile(false, Str("AddProfile.Title"), Str("AddProfile.Text"));
  309. }
  310. void OBSBasic::on_actionRenameProfile_triggered()
  311. {
  312. std::string curDir =
  313. config_get_string(App()->GlobalConfig(), "Basic", "ProfileDir");
  314. std::string curName =
  315. config_get_string(App()->GlobalConfig(), "Basic", "Profile");
  316. /* Duplicate and delete in case there are any issues in the process */
  317. bool success = AddProfile(false, Str("RenameProfile.Title"),
  318. Str("AddProfile.Text"), curName.c_str(),
  319. 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 =
  335. config_get_string(App()->GlobalConfig(), "Basic", "ProfileDir");
  336. std::string oldName =
  337. config_get_string(App()->GlobalConfig(), "Basic", "Profile");
  338. auto cb = [&](const char *name, const char *filePath) {
  339. if (strcmp(oldName.c_str(), name) != 0) {
  340. newName = name;
  341. newPath = filePath;
  342. return false;
  343. }
  344. return true;
  345. };
  346. EnumProfiles(cb);
  347. /* this should never be true due to menu item being grayed out */
  348. if (newPath.empty())
  349. return;
  350. QString text = QTStr("ConfirmRemove.Text");
  351. text.replace("$1", QT_UTF8(oldName.c_str()));
  352. QMessageBox::StandardButton button = OBSMessageBox::question(
  353. this, QTStr("ConfirmRemove.Title"), text);
  354. if (button == QMessageBox::No)
  355. return;
  356. size_t newPath_len = newPath.size();
  357. newPath += "/basic.ini";
  358. if (config.Open(newPath.c_str(), CONFIG_OPEN_ALWAYS) != 0) {
  359. blog(LOG_ERROR, "ChangeProfile: Failed to load file '%s'",
  360. newPath.c_str());
  361. return;
  362. }
  363. newPath.resize(newPath_len);
  364. const char *newDir = strrchr(newPath.c_str(), '/') + 1;
  365. config_set_string(App()->GlobalConfig(), "Basic", "Profile",
  366. newName.c_str());
  367. config_set_string(App()->GlobalConfig(), "Basic", "ProfileDir", newDir);
  368. Auth::Save();
  369. auth.reset();
  370. DeleteCookies();
  371. DestroyPanelCookieManager();
  372. config.Swap(basicConfig);
  373. InitBasicConfigDefaults();
  374. InitBasicConfigDefaults2();
  375. ResetProfileData();
  376. DeleteProfile(oldName.c_str(), oldDir.c_str());
  377. RefreshProfiles();
  378. config_save_safe(App()->GlobalConfig(), "tmp", nullptr);
  379. blog(LOG_INFO, "Switched to profile '%s' (%s)", newName.c_str(),
  380. newDir);
  381. blog(LOG_INFO, "------------------------------------------------");
  382. UpdateTitleBar();
  383. Auth::Load();
  384. if (api) {
  385. api->on_event(OBS_FRONTEND_EVENT_PROFILE_LIST_CHANGED);
  386. api->on_event(OBS_FRONTEND_EVENT_PROFILE_CHANGED);
  387. }
  388. }
  389. void OBSBasic::on_actionImportProfile_triggered()
  390. {
  391. char path[512];
  392. QString home = QDir::homePath();
  393. int ret = GetConfigPath(path, 512, "obs-studio/basic/profiles/");
  394. if (ret <= 0) {
  395. blog(LOG_WARNING, "Failed to get profile config path");
  396. return;
  397. }
  398. QString dir = QFileDialog::getExistingDirectory(
  399. this, QTStr("Basic.MainMenu.Profile.Import"), home,
  400. QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
  401. if (!dir.isEmpty() && !dir.isNull()) {
  402. QString inputPath = QString::fromUtf8(path);
  403. QFileInfo finfo(dir);
  404. QString directory = finfo.fileName();
  405. QString profileDir = inputPath + directory;
  406. QDir folder(profileDir);
  407. if (!folder.exists()) {
  408. folder.mkpath(profileDir);
  409. QFile::copy(dir + "/basic.ini",
  410. profileDir + "/basic.ini");
  411. QFile::copy(dir + "/service.json",
  412. profileDir + "/service.json");
  413. QFile::copy(dir + "/streamEncoder.json",
  414. profileDir + "/streamEncoder.json");
  415. QFile::copy(dir + "/recordEncoder.json",
  416. profileDir + "/recordEncoder.json");
  417. RefreshProfiles();
  418. } else {
  419. OBSMessageBox::warning(
  420. this, QTStr("Basic.MainMenu.Profile.Import"),
  421. QTStr("Basic.MainMenu.Profile.Exists"));
  422. }
  423. }
  424. }
  425. void OBSBasic::on_actionExportProfile_triggered()
  426. {
  427. char path[512];
  428. QString home = QDir::homePath();
  429. QString currentProfile = QString::fromUtf8(config_get_string(
  430. App()->GlobalConfig(), "Basic", "ProfileDir"));
  431. int ret = GetConfigPath(path, 512, "obs-studio/basic/profiles/");
  432. if (ret <= 0) {
  433. blog(LOG_WARNING, "Failed to get profile config path");
  434. return;
  435. }
  436. QString dir = QFileDialog::getExistingDirectory(
  437. this, QTStr("Basic.MainMenu.Profile.Export"), home,
  438. QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
  439. if (!dir.isEmpty() && !dir.isNull()) {
  440. QString outputDir = dir + "/" + currentProfile;
  441. QString inputPath = QString::fromUtf8(path);
  442. QDir folder(outputDir);
  443. if (!folder.exists()) {
  444. folder.mkpath(outputDir);
  445. } else {
  446. if (QFile::exists(outputDir + "/basic.ini"))
  447. QFile::remove(outputDir + "/basic.ini");
  448. if (QFile::exists(outputDir + "/service.json"))
  449. QFile::remove(outputDir + "/service.json");
  450. if (QFile::exists(outputDir + "/streamEncoder.json"))
  451. QFile::remove(outputDir +
  452. "/streamEncoder.json");
  453. if (QFile::exists(outputDir + "/recordEncoder.json"))
  454. QFile::remove(outputDir +
  455. "/recordEncoder.json");
  456. }
  457. QFile::copy(inputPath + currentProfile + "/basic.ini",
  458. outputDir + "/basic.ini");
  459. QFile::copy(inputPath + currentProfile + "/service.json",
  460. outputDir + "/service.json");
  461. QFile::copy(inputPath + currentProfile + "/streamEncoder.json",
  462. outputDir + "/streamEncoder.json");
  463. QFile::copy(inputPath + currentProfile + "/recordEncoder.json",
  464. outputDir + "/recordEncoder.json");
  465. }
  466. }
  467. void OBSBasic::ChangeProfile()
  468. {
  469. QAction *action = reinterpret_cast<QAction *>(sender());
  470. ConfigFile config;
  471. std::string path;
  472. if (!action)
  473. return;
  474. path = QT_TO_UTF8(action->property("file_name").value<QString>());
  475. if (path.empty())
  476. return;
  477. const char *oldName =
  478. config_get_string(App()->GlobalConfig(), "Basic", "Profile");
  479. if (action->text().compare(QT_UTF8(oldName)) == 0) {
  480. action->setChecked(true);
  481. return;
  482. }
  483. size_t path_len = path.size();
  484. path += "/basic.ini";
  485. if (config.Open(path.c_str(), CONFIG_OPEN_ALWAYS) != 0) {
  486. blog(LOG_ERROR, "ChangeProfile: Failed to load file '%s'",
  487. path.c_str());
  488. return;
  489. }
  490. path.resize(path_len);
  491. const char *newName = config_get_string(config, "General", "Name");
  492. const char *newDir = strrchr(path.c_str(), '/') + 1;
  493. config_set_string(App()->GlobalConfig(), "Basic", "Profile", newName);
  494. config_set_string(App()->GlobalConfig(), "Basic", "ProfileDir", newDir);
  495. Auth::Save();
  496. auth.reset();
  497. DestroyPanelCookieManager();
  498. config.Swap(basicConfig);
  499. InitBasicConfigDefaults();
  500. InitBasicConfigDefaults2();
  501. ResetProfileData();
  502. RefreshProfiles();
  503. config_save_safe(App()->GlobalConfig(), "tmp", nullptr);
  504. UpdateTitleBar();
  505. Auth::Load();
  506. CheckForSimpleModeX264Fallback();
  507. blog(LOG_INFO, "Switched to profile '%s' (%s)", newName, newDir);
  508. blog(LOG_INFO, "------------------------------------------------");
  509. if (api)
  510. api->on_event(OBS_FRONTEND_EVENT_PROFILE_CHANGED);
  511. }
  512. void OBSBasic::CheckForSimpleModeX264Fallback()
  513. {
  514. const char *curStreamEncoder =
  515. config_get_string(basicConfig, "SimpleOutput", "StreamEncoder");
  516. const char *curRecEncoder =
  517. config_get_string(basicConfig, "SimpleOutput", "RecEncoder");
  518. bool qsv_supported = false;
  519. bool amd_supported = false;
  520. bool nve_supported = false;
  521. bool changed = false;
  522. size_t idx = 0;
  523. const char *id;
  524. while (obs_enum_encoder_types(idx++, &id)) {
  525. if (strcmp(id, "amd_amf_h264") == 0)
  526. amd_supported = true;
  527. else if (strcmp(id, "obs_qsv11") == 0)
  528. qsv_supported = true;
  529. else if (strcmp(id, "ffmpeg_nvenc") == 0)
  530. nve_supported = true;
  531. }
  532. auto CheckEncoder = [&](const char *&name) {
  533. if (strcmp(name, SIMPLE_ENCODER_QSV) == 0) {
  534. if (!qsv_supported) {
  535. changed = true;
  536. name = SIMPLE_ENCODER_X264;
  537. return false;
  538. }
  539. } else if (strcmp(name, SIMPLE_ENCODER_NVENC) == 0) {
  540. if (!nve_supported) {
  541. changed = true;
  542. name = SIMPLE_ENCODER_X264;
  543. return false;
  544. }
  545. } else if (strcmp(name, SIMPLE_ENCODER_AMD) == 0) {
  546. if (!amd_supported) {
  547. changed = true;
  548. name = SIMPLE_ENCODER_X264;
  549. return false;
  550. }
  551. }
  552. return true;
  553. };
  554. if (!CheckEncoder(curStreamEncoder))
  555. config_set_string(basicConfig, "SimpleOutput", "StreamEncoder",
  556. curStreamEncoder);
  557. if (!CheckEncoder(curRecEncoder))
  558. config_set_string(basicConfig, "SimpleOutput", "RecEncoder",
  559. curRecEncoder);
  560. if (changed)
  561. config_save_safe(basicConfig, "tmp", nullptr);
  562. }