FIX: camera stream tool file permission problem

Change-Id: I77781d158da62c95fda0abb72e49f89340c316cb
This commit is contained in:
chunmao.guo 2022-12-07 11:35:06 +08:00 committed by Lane.Wei
parent efd55bcffe
commit 941df8ba8b
1 changed files with 18 additions and 12 deletions

View File

@ -309,19 +309,25 @@ void MediaPlayCtrl::ToggleStream()
wxString url = L"bambu:///camera/" + from_u8(file_url); wxString url = L"bambu:///camera/" + from_u8(file_url);
url.Replace("\\", "/"); url.Replace("\\", "/");
url = wxURI(url).BuildURI(); url = wxURI(url).BuildURI();
std::string configs;
try { try {
std::string configs;
boost::filesystem::load_string_file(file_ff_cfg, configs); boost::filesystem::load_string_file(file_ff_cfg, configs);
} catch (...) {} std::vector<std::string> configss;
std::vector<std::string> configss; boost::algorithm::split(configss, configs, boost::algorithm::is_any_of("\r\n"));
boost::algorithm::split(configss, configs, boost::algorithm::is_any_of("\r\n")); configss.erase(std::remove(configss.begin(), configss.end(), std::string()), configss.end());
configss.erase(std::remove(configss.begin(), configss.end(), std::string()), configss.end()); boost::process::pipe intermediate;
boost::process::pipe intermediate; #ifndef __WXMSW__
boost::process::child process_source(file_source, url.data().AsInternal(), boost::process::std_out > intermediate, detach_process(), boost::filesystem::permissions(file_source, boost::filesystem::owner_exe | boost::filesystem::add_perms);
boost::process::start_dir(boost::filesystem::path(data_dir()) / "plugins")); boost::filesystem::permissions(file_ffmpeg, boost::filesystem::owner_exe | boost::filesystem::add_perms);
boost::process::child process_ffmpeg(file_ffmpeg, configss, boost::process::std_in < intermediate, detach_process()); #endif
process_source.detach(); boost::process::child process_source(file_source, url.data().AsInternal(), boost::process::std_out > intermediate, detach_process(),
process_ffmpeg.detach(); boost::process::start_dir(boost::filesystem::path(data_dir()) / "plugins"), boost::process::limit_handles);
boost::process::child process_ffmpeg(file_ffmpeg, configss, boost::process::std_in < intermediate, detach_process(), boost::process::limit_handles);
process_source.detach();
process_ffmpeg.detach();
} catch (std::exception & e) {
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl failed to start camera stream: " << e.what();
}
} }
if (!url.empty() && wxGetApp().app_config->get("not_show_vcamera_stop_prev") != "1") { if (!url.empty() && wxGetApp().app_config->get("not_show_vcamera_stop_prev") != "1") {
MessageDialog dlg(this->GetParent(), _L("Another virtual camera is running.\nBambu Studio supports only a single virtual camera.\nDo you want to stop this virtual camera?"), _L("Warning"), MessageDialog dlg(this->GetParent(), _L("Another virtual camera is running.\nBambu Studio supports only a single virtual camera.\nDo you want to stop this virtual camera?"), _L("Warning"),
@ -431,7 +437,7 @@ bool MediaPlayCtrl::get_stream_url(std::string *url)
} }
CloseHandle(shm); CloseHandle(shm);
#elif __APPLE__ #elif __APPLE__
std::string file_url = data_dir() + "/url.txt"; std::string file_url = data_dir() + "/cameratools/url.txt";
key_t key = ::ftok(file_url.c_str(), 1000); key_t key = ::ftok(file_url.c_str(), 1000);
int shm = ::shmget(key, 1024, 0); int shm = ::shmget(key, 1024, 0);
if (shm == -1) return false; if (shm == -1) return false;