FIX: live_view: check camera exist and show ttcode request error

Change-Id: I036006ec4efddf0a5801a6b1d304c9e81555a284
This commit is contained in:
chunmao.guo 2022-09-30 17:54:12 +08:00 committed by Lane.Wei
parent ccd7b7fd7b
commit e87860e033
2 changed files with 23 additions and 12 deletions

View file

@ -71,11 +71,13 @@ void MediaPlayCtrl::SetMachineObject(MachineObject* obj)
{ {
std::string machine = obj ? obj->dev_id : ""; std::string machine = obj ? obj->dev_id : "";
if (obj && obj->is_function_supported(PrinterFunction::FUNC_CAMERA_VIDEO)) { if (obj && obj->is_function_supported(PrinterFunction::FUNC_CAMERA_VIDEO)) {
m_lan_mode = obj->is_lan_mode_printer(); m_camera_exists = obj->has_ipcam;
m_lan_mode = obj->is_lan_mode_printer();
m_lan_ip = obj->is_function_supported(PrinterFunction::FUNC_LOCAL_TUNNEL) ? obj->dev_ip : ""; m_lan_ip = obj->is_function_supported(PrinterFunction::FUNC_LOCAL_TUNNEL) ? obj->dev_ip : "";
m_lan_passwd = obj->access_code; m_lan_passwd = obj->is_function_supported(PrinterFunction::FUNC_LOCAL_TUNNEL) ? obj->access_code : "";
m_tutk_support = obj->is_function_supported(PrinterFunction::FUNC_REMOTE_TUNNEL); m_tutk_support = obj->is_function_supported(PrinterFunction::FUNC_REMOTE_TUNNEL);
} else { } else {
m_camera_exists = false;
m_lan_mode = false; m_lan_mode = false;
m_lan_ip.clear(); m_lan_ip.clear();
m_lan_passwd.clear(); m_lan_passwd.clear();
@ -102,12 +104,15 @@ void MediaPlayCtrl::Play()
return; return;
if (!IsShownOnScreen()) if (!IsShownOnScreen())
return; return;
if (m_last_state != MEDIASTATE_IDLE) {
return;
}
if (m_machine.empty()) { if (m_machine.empty()) {
Stop();
SetStatus(_L("Initialize failed (No Device)!")); SetStatus(_L("Initialize failed (No Device)!"));
return; return;
} }
if (m_last_state != MEDIASTATE_IDLE) { if (!m_camera_exists) {
SetStatus(_L("Initialize failed (No Camera Device)!"));
return; return;
} }
@ -135,9 +140,15 @@ void MediaPlayCtrl::Play()
return; return;
} }
if (m_lan_mode && !m_tutk_support) { // not support tutk if (m_lan_mode) {
Stop(); SetStatus(m_lan_passwd.empty()
SetStatus(_L("Initialize failed (Not supported)!")); ? _L("Initialize failed (Not supported with LAN-only mode)!")
: _L("Initialize failed (Not accessible in LAN-only mode)!"));
return;
}
if (!m_tutk_support) { // not support tutk
SetStatus(_L("Initialize failed (Not supported without remote video tunnel)!"));
return; return;
} }
@ -145,14 +156,13 @@ void MediaPlayCtrl::Play()
if (agent) { if (agent) {
agent->get_camera_url(m_machine, [this, m = m_machine](std::string url) { agent->get_camera_url(m_machine, [this, m = m_machine](std::string url) {
BOOST_LOG_TRIVIAL(info) << "camera_url: " << url; BOOST_LOG_TRIVIAL(info) << "camera_url: " << url;
if (m != m_machine) return; CallAfter([this, m, url] {
CallAfter([this, url] { if (m != m_machine) return;
m_url = url; m_url = url;
if (m_last_state == MEDIASTATE_INITIALIZING) { if (m_last_state == MEDIASTATE_INITIALIZING) {
if (url.empty()) { if (url.empty() || !boost::algorithm::starts_with(url, "bambu:///")) {
Stop(); Stop();
m_failed_code = 1; SetStatus(wxString::Format(_L("Initialize failed (%s)!"), url.empty() ? _L("Network unreachable") : from_u8(url)));
SetStatus(_L("Initialize failed [%d]!"));
} else { } else {
m_last_state = MEDIASTATE_LOADING; m_last_state = MEDIASTATE_LOADING;
SetStatus(_L("Loading...")); SetStatus(_L("Loading..."));

View file

@ -61,6 +61,7 @@ private:
std::string m_lan_ip; std::string m_lan_ip;
std::string m_lan_user; std::string m_lan_user;
std::string m_lan_passwd; std::string m_lan_passwd;
bool m_camera_exists = false;
bool m_lan_mode = false; bool m_lan_mode = false;
bool m_tutk_support = false; bool m_tutk_support = false;
wxString m_url; wxString m_url;