fix: defer filesystem and camera abstractions

This commit is contained in:
Ian Chua
2026-08-25 14:34:11 +08:00
parent f16071f083
commit b2a0485139
12 changed files with 82 additions and 243 deletions
+27 -21
View File
@@ -7,6 +7,7 @@
#include "I18N.hpp"
#include "MsgDialog.hpp"
#include "DownloadProgressDialog.hpp"
#include "slic3r/Utils/BBLNetworkPlugin.hpp"
#include <boost/lexical_cast.hpp>
@@ -126,6 +127,9 @@ MediaPlayCtrl::MediaPlayCtrl(wxWindow *parent, wxMediaCtrl2 *media_ctrl, const w
parent->Bind(wxEVT_SHOW, &MediaPlayCtrl::on_show_hide, this);
parent->GetParent()->GetParent()->Bind(wxEVT_SHOW, &MediaPlayCtrl::on_show_hide, this);
m_lan_user = "bblp";
m_lan_passwd = "bblp";
}
MediaPlayCtrl::~MediaPlayCtrl()
@@ -156,10 +160,8 @@ void MediaPlayCtrl::SetMachineObject(MachineObject* obj)
m_device_busy = obj->is_camera_busy_off();
m_tutk_state = obj->tutk_state;
auto *agent = wxGetApp().getAgent();
if (agent && !agent->supports_remote_liveview(obj->printer_type)) {
// The selected printer agent may force local mode for incompatible
// plugin/printer combinations.
if (DevPrinterConfigUtil::get_printer_series_str(obj->printer_type) == "series_o" && BBLNetworkPlugin::instance().use_legacy_network()) {
// Legacy plugin cannot support remote play for H2D, force using local mode
m_remote_proto = LiveviewRemote::LVR_None;
}
} else {
@@ -287,21 +289,20 @@ void MediaPlayCtrl::Play()
return;
}
std::string agent_version = agent->get_version();
const std::string lan_user = agent->default_lan_username();
if (m_lan_proto > LiveviewLocal::LVL_Disable && (m_lan_mode || !m_remote_proto) && !m_disable_lan && !m_lan_ip.empty()) {
m_disable_lan = m_remote_proto && !m_lan_mode; // try remote next time
std::string url = agent->get_local_camera_url({
m_lan_ip,
lan_user,
m_lan_passwd,
LiveviewLocal(m_lan_proto),
into_u8(m_machine),
agent_version,
m_dev_ver,
"",
wxGetApp().app_config->get("slicer_uuid"),
SLIC3R_VERSION
});
std::string url;
if (m_lan_proto == LiveviewLocal::LVL_Local)
url = "bambu:///local/" + m_lan_ip + ".?port=6000&user=" + m_lan_user + "&passwd=" + m_lan_passwd;
else if (m_lan_proto == LiveviewLocal::LVL_Rtsps)
url = "bambu:///rtsps___" + m_lan_user + ":" + m_lan_passwd + "@" + m_lan_ip + "/streaming/live/1?proto=rtsps";
else if (m_lan_proto == LiveviewLocal::LVL_Rtsp)
url = "bambu:///rtsp___" + m_lan_user + ":" + m_lan_passwd + "@" + m_lan_ip + "/streaming/live/1?proto=rtsp";
url += "&device=" + m_machine;
url += "&net_ver=" + agent_version;
url += "&dev_ver=" + m_dev_ver;
url += "&cli_id=" + wxGetApp().app_config->get("slicer_uuid");
url += "&cli_ver=" + std::string(SLIC3R_VERSION);
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl: " << hide_passwd(hide_id_middle_string(url, url.find(m_lan_ip), m_lan_ip.length()), {m_lan_passwd});
m_url = url;
load();
@@ -527,10 +528,15 @@ void MediaPlayCtrl::ToggleStream()
if (res == wxID_CANCEL) return;
}
if (m_lan_proto > LiveviewLocal::LVL_Disable && (m_lan_mode || !m_remote_proto) && !m_disable_lan && !m_lan_ip.empty()) {
NetworkAgent *agent = wxGetApp().getAgent();
if (!agent) return;
std::string url = agent->get_local_camera_url({m_lan_ip, agent->default_lan_username(), m_lan_passwd, LiveviewLocal(m_lan_proto),
into_u8(m_machine), agent->get_version(), m_dev_ver, "", wxGetApp().app_config->get("slicer_uuid"), SLIC3R_VERSION});
std::string url;
if (m_lan_proto == LiveviewLocal::LVL_Local)
url = "bambu:///local/" + m_lan_ip + ".?port=6000&user=" + m_lan_user + "&passwd=" + m_lan_passwd;
else if (m_lan_proto == LiveviewLocal::LVL_Rtsps)
url = "bambu:///rtsps___" + m_lan_user + ":" + m_lan_passwd + "@" + m_lan_ip + "/streaming/live/1?proto=rtsps";
else if (m_lan_proto == LiveviewLocal::LVL_Rtsp)
url = "bambu:///rtsp___" + m_lan_user + ":" + m_lan_passwd + "@" + m_lan_ip + "/streaming/live/1?proto=rtsp";
url += "&device=" + into_u8(m_machine);
url += "&dev_ver=" + m_dev_ver;
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl::ToggleStream: " << hide_passwd(hide_id_middle_string(url, url.find(m_lan_ip), m_lan_ip.length()), {m_lan_passwd});
std::string file_url = data_dir() + "/cameratools/url.txt";
boost::nowide::ofstream file(file_url);