window-basic-main-profiles.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  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. RefreshProfiles();
  203. if (create_new)
  204. ResetProfileData();
  205. blog(LOG_INFO, "Created profile '%s' (%s, %s)", newName.c_str(),
  206. create_new ? "clean" : "duplicate", newDir.c_str());
  207. blog(LOG_INFO, "------------------------------------------------");
  208. config_save_safe(App()->GlobalConfig(), "tmp", nullptr);
  209. UpdateTitleBar();
  210. if (api) {
  211. api->on_event(OBS_FRONTEND_EVENT_PROFILE_LIST_CHANGED);
  212. api->on_event(OBS_FRONTEND_EVENT_PROFILE_CHANGED);
  213. }
  214. return true;
  215. }
  216. void OBSBasic::DeleteProfile(const char *profileName, const char *profileDir)
  217. {
  218. char profilePath[512];
  219. char basePath[512];
  220. int ret = GetConfigPath(basePath, 512, "obs-studio/basic/profiles");
  221. if (ret <= 0) {
  222. blog(LOG_WARNING, "Failed to get profiles config path");
  223. return;
  224. }
  225. ret = snprintf(profilePath, 512, "%s/%s/*", basePath, profileDir);
  226. if (ret <= 0) {
  227. blog(LOG_WARNING, "Failed to get path for profile dir '%s'",
  228. profileDir);
  229. return;
  230. }
  231. os_glob_t *glob;
  232. if (os_glob(profilePath, 0, &glob) != 0) {
  233. blog(LOG_WARNING, "Failed to glob profile dir '%s'",
  234. profileDir);
  235. return;
  236. }
  237. for (size_t i = 0; i < glob->gl_pathc; i++) {
  238. const char *filePath = glob->gl_pathv[i].path;
  239. if (glob->gl_pathv[i].directory)
  240. continue;
  241. os_unlink(filePath);
  242. }
  243. os_globfree(glob);
  244. ret = snprintf(profilePath, 512, "%s/%s", basePath, profileDir);
  245. if (ret <= 0) {
  246. blog(LOG_WARNING, "Failed to get path for profile dir '%s'",
  247. profileDir);
  248. return;
  249. }
  250. os_rmdir(profilePath);
  251. blog(LOG_INFO, "------------------------------------------------");
  252. blog(LOG_INFO, "Removed profile '%s' (%s)",
  253. profileName, profileDir);
  254. blog(LOG_INFO, "------------------------------------------------");
  255. }
  256. void OBSBasic::RefreshProfiles()
  257. {
  258. QList<QAction*> menuActions = ui->profileMenu->actions();
  259. int count = 0;
  260. for (int i = 0; i < menuActions.count(); i++) {
  261. QVariant v = menuActions[i]->property("file_name");
  262. if (v.typeName() != nullptr)
  263. delete menuActions[i];
  264. }
  265. const char *curName = config_get_string(App()->GlobalConfig(),
  266. "Basic", "Profile");
  267. auto addProfile = [&](const char *name, const char *path)
  268. {
  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,
  273. this, &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 = config_get_string(basicConfig, "Audio",
  294. "MonitoringDeviceName");
  295. const char *device_id = config_get_string(basicConfig, "Audio",
  296. "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 = config_get_string(App()->GlobalConfig(),
  313. "Basic", "ProfileDir");
  314. std::string curName = config_get_string(App()->GlobalConfig(),
  315. "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(), true);
  319. if (success) {
  320. DeleteProfile(curName.c_str(), curDir.c_str());
  321. RefreshProfiles();
  322. }
  323. if (api) {
  324. api->on_event(OBS_FRONTEND_EVENT_PROFILE_LIST_CHANGED);
  325. api->on_event(OBS_FRONTEND_EVENT_PROFILE_CHANGED);
  326. }
  327. }
  328. void OBSBasic::on_actionRemoveProfile_triggered()
  329. {
  330. std::string newName;
  331. std::string newPath;
  332. ConfigFile config;
  333. std::string oldDir = config_get_string(App()->GlobalConfig(),
  334. "Basic", "ProfileDir");
  335. std::string oldName = config_get_string(App()->GlobalConfig(),
  336. "Basic", "Profile");
  337. auto cb = [&](const char *name, const char *filePath)
  338. {
  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(this,
  353. 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",
  368. newDir);
  369. Auth::Save();
  370. auth.reset();
  371. DestroyPanelCookieManager();
  372. config.Swap(basicConfig);
  373. InitBasicConfigDefaults();
  374. ResetProfileData();
  375. DeleteProfile(oldName.c_str(), oldDir.c_str());
  376. RefreshProfiles();
  377. config_save_safe(App()->GlobalConfig(), "tmp", nullptr);
  378. blog(LOG_INFO, "Switched to profile '%s' (%s)",
  379. newName.c_str(), newDir);
  380. blog(LOG_INFO, "------------------------------------------------");
  381. UpdateTitleBar();
  382. Auth::Load();
  383. if (api) {
  384. api->on_event(OBS_FRONTEND_EVENT_PROFILE_LIST_CHANGED);
  385. api->on_event(OBS_FRONTEND_EVENT_PROFILE_CHANGED);
  386. }
  387. }
  388. void OBSBasic::on_actionImportProfile_triggered()
  389. {
  390. char path[512];
  391. QString home = QDir::homePath();
  392. int ret = GetConfigPath(path, 512, "obs-studio/basic/profiles/");
  393. if (ret <= 0) {
  394. blog(LOG_WARNING, "Failed to get profile config path");
  395. return;
  396. }
  397. QString dir = QFileDialog::getExistingDirectory(
  398. this,
  399. QTStr("Basic.MainMenu.Profile.Import"),
  400. home,
  401. QFileDialog::ShowDirsOnly |
  402. QFileDialog::DontResolveSymlinks);
  403. if (!dir.isEmpty() && !dir.isNull()) {
  404. QString inputPath = QString::fromUtf8(path);
  405. QFileInfo finfo(dir);
  406. QString directory = finfo.fileName();
  407. QString profileDir = inputPath + directory;
  408. QDir folder(profileDir);
  409. if (!folder.exists()) {
  410. folder.mkpath(profileDir);
  411. QFile::copy(dir + "/basic.ini",
  412. profileDir + "/basic.ini");
  413. QFile::copy(dir + "/service.json",
  414. profileDir + "/service.json");
  415. QFile::copy(dir + "/streamEncoder.json",
  416. profileDir + "/streamEncoder.json");
  417. QFile::copy(dir + "/recordEncoder.json",
  418. profileDir + "/recordEncoder.json");
  419. RefreshProfiles();
  420. } else {
  421. OBSMessageBox::information(this,
  422. QTStr("Basic.MainMenu.Profile.Import"),
  423. QTStr("Basic.MainMenu.Profile.Exists"));
  424. }
  425. }
  426. }
  427. void OBSBasic::on_actionExportProfile_triggered()
  428. {
  429. char path[512];
  430. QString home = QDir::homePath();
  431. QString currentProfile =
  432. QString::fromUtf8(config_get_string(App()->GlobalConfig(),
  433. "Basic", "ProfileDir"));
  434. int ret = GetConfigPath(path, 512, "obs-studio/basic/profiles/");
  435. if (ret <= 0) {
  436. blog(LOG_WARNING, "Failed to get profile config path");
  437. return;
  438. }
  439. QString dir = QFileDialog::getExistingDirectory(
  440. this,
  441. QTStr("Basic.MainMenu.Profile.Export"),
  442. home,
  443. QFileDialog::ShowDirsOnly |
  444. QFileDialog::DontResolveSymlinks);
  445. if (!dir.isEmpty() && !dir.isNull()) {
  446. QString outputDir = dir + "/" + currentProfile;
  447. QString inputPath = QString::fromUtf8(path);
  448. QDir folder(outputDir);
  449. if (!folder.exists()) {
  450. folder.mkpath(outputDir);
  451. } else {
  452. if (QFile::exists(outputDir + "/basic.ini"))
  453. QFile::remove(outputDir + "/basic.ini");
  454. if (QFile::exists(outputDir + "/service.json"))
  455. QFile::remove(outputDir + "/service.json");
  456. if (QFile::exists(outputDir + "/streamEncoder.json"))
  457. QFile::remove(outputDir + "/streamEncoder.json");
  458. if (QFile::exists(outputDir + "/recordEncoder.json"))
  459. QFile::remove(outputDir + "/recordEncoder.json");
  460. }
  461. QFile::copy(inputPath + currentProfile + "/basic.ini",
  462. outputDir + "/basic.ini");
  463. QFile::copy(inputPath + currentProfile + "/service.json",
  464. outputDir + "/service.json");
  465. QFile::copy(inputPath + currentProfile + "/streamEncoder.json",
  466. outputDir + "/streamEncoder.json");
  467. QFile::copy(inputPath + currentProfile + "/recordEncoder.json",
  468. outputDir + "/recordEncoder.json");
  469. }
  470. }
  471. void OBSBasic::ChangeProfile()
  472. {
  473. QAction *action = reinterpret_cast<QAction*>(sender());
  474. ConfigFile config;
  475. std::string path;
  476. if (!action)
  477. return;
  478. path = QT_TO_UTF8(action->property("file_name").value<QString>());
  479. if (path.empty())
  480. return;
  481. const char *oldName = config_get_string(App()->GlobalConfig(),
  482. "Basic", "Profile");
  483. if (action->text().compare(QT_UTF8(oldName)) == 0) {
  484. action->setChecked(true);
  485. return;
  486. }
  487. size_t path_len = path.size();
  488. path += "/basic.ini";
  489. if (config.Open(path.c_str(), CONFIG_OPEN_ALWAYS) != 0) {
  490. blog(LOG_ERROR, "ChangeProfile: Failed to load file '%s'",
  491. path.c_str());
  492. return;
  493. }
  494. path.resize(path_len);
  495. const char *newName = config_get_string(config, "General", "Name");
  496. const char *newDir = strrchr(path.c_str(), '/') + 1;
  497. config_set_string(App()->GlobalConfig(), "Basic", "Profile", newName);
  498. config_set_string(App()->GlobalConfig(), "Basic", "ProfileDir",
  499. newDir);
  500. Auth::Save();
  501. auth.reset();
  502. DestroyPanelCookieManager();
  503. config.Swap(basicConfig);
  504. InitBasicConfigDefaults();
  505. ResetProfileData();
  506. RefreshProfiles();
  507. config_save_safe(App()->GlobalConfig(), "tmp", nullptr);
  508. UpdateTitleBar();
  509. Auth::Load();
  510. CheckForSimpleModeX264Fallback();
  511. blog(LOG_INFO, "Switched to profile '%s' (%s)",
  512. newName, newDir);
  513. blog(LOG_INFO, "------------------------------------------------");
  514. if (api)
  515. api->on_event(OBS_FRONTEND_EVENT_PROFILE_CHANGED);
  516. }
  517. void OBSBasic::CheckForSimpleModeX264Fallback()
  518. {
  519. const char *curStreamEncoder = config_get_string(basicConfig,
  520. "SimpleOutput", "StreamEncoder");
  521. const char *curRecEncoder = config_get_string(basicConfig,
  522. "SimpleOutput", "RecEncoder");
  523. bool qsv_supported = false;
  524. bool amd_supported = false;
  525. bool nve_supported = false;
  526. bool changed = false;
  527. size_t idx = 0;
  528. const char *id;
  529. while (obs_enum_encoder_types(idx++, &id)) {
  530. if (strcmp(id, "amd_amf_h264") == 0)
  531. amd_supported = true;
  532. else if (strcmp(id, "obs_qsv11") == 0)
  533. qsv_supported = true;
  534. else if (strcmp(id, "ffmpeg_nvenc") == 0)
  535. nve_supported = true;
  536. }
  537. auto CheckEncoder = [&] (const char *&name)
  538. {
  539. if (strcmp(name, SIMPLE_ENCODER_QSV) == 0) {
  540. if (!qsv_supported) {
  541. changed = true;
  542. name = SIMPLE_ENCODER_X264;
  543. return false;
  544. }
  545. } else if (strcmp(name, SIMPLE_ENCODER_NVENC) == 0) {
  546. if (!nve_supported) {
  547. changed = true;
  548. name = SIMPLE_ENCODER_X264;
  549. return false;
  550. }
  551. } else if (strcmp(name, SIMPLE_ENCODER_AMD) == 0) {
  552. if (!amd_supported) {
  553. changed = true;
  554. name = SIMPLE_ENCODER_X264;
  555. return false;
  556. }
  557. }
  558. return true;
  559. };
  560. if (!CheckEncoder(curStreamEncoder))
  561. config_set_string(basicConfig,
  562. "SimpleOutput", "StreamEncoder",
  563. curStreamEncoder);
  564. if (!CheckEncoder(curRecEncoder))
  565. config_set_string(basicConfig,
  566. "SimpleOutput", "RecEncoder",
  567. curRecEncoder);
  568. if (changed)
  569. config_save_safe(basicConfig, "tmp", nullptr);
  570. }