ENH: liveview remote protocols with agora

Change-Id: Id86aa4bfa5f5e09675a6fe627668c63d20c7d1bf
Jira: none
(cherry picked from commit 46eba0048b73f1741b4b7b57f788830c08a8d7f1)
This commit is contained in:
chunmao.guo 2024-04-08 09:48:36 +08:00 committed by Noisyfox
parent 8b33119640
commit 6385a4d170
15 changed files with 87 additions and 54 deletions

View file

@ -150,7 +150,7 @@ void MediaPlayCtrl::SetMachineObject(MachineObject* obj)
m_dev_ver = obj->get_ota_version();
m_lan_mode = obj->is_lan_mode_printer();
m_lan_proto = obj->liveview_local;
m_remote_support = obj->liveview_remote;
m_remote_proto = obj->liveview_remote;
m_lan_ip = obj->dev_ip;
m_lan_passwd = obj->get_access_code();
m_device_busy = obj->is_camera_busy_off();
@ -163,7 +163,7 @@ void MediaPlayCtrl::SetMachineObject(MachineObject* obj)
m_lan_passwd.clear();
m_dev_ver.clear();
m_tutk_state.clear();
m_remote_support = true;
m_remote_proto = 0;
m_device_busy = false;
}
Enable(obj && obj->is_connected() && obj->m_push_count > 0);
@ -261,8 +261,8 @@ void MediaPlayCtrl::Play()
NetworkAgent *agent = wxGetApp().getAgent();
std::string agent_version = agent ? agent->get_version() : "";
if (m_lan_proto > MachineObject::LVL_Disable && (m_lan_mode || !m_remote_support) && !m_disable_lan && !m_lan_ip.empty()) {
m_disable_lan = m_remote_support && !m_lan_mode; // try remote next time
if (m_lan_proto > MachineObject::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;
if (m_lan_proto == MachineObject::LVL_Local)
url = "bambu:///local/" + m_lan_ip + ".?port=6000&user=" + m_lan_user + "&passwd=" + m_lan_passwd;
@ -285,12 +285,12 @@ void MediaPlayCtrl::Play()
// m_lan_mode && m_lan_proto > LVL_Disable (use local tunnel)
// m_lan_mode && m_lan_proto == LVL_Disable (*)
// m_lan_mode && m_lan_proto == LVL_None (x)
// !m_lan_mode && m_remote_support (go on)
// !m_lan_mode && !m_remote_support && m_lan_proto > LVL_None (use local tunnel)
// !m_lan_mode && !m_remote_support && m_lan_proto == LVL_Disable (*)
// !m_lan_mode && !m_remote_support && m_lan_proto == LVL_None (x)
// !m_lan_mode && m_remote_proto (go on)
// !m_lan_mode && !m_remote_proto && m_lan_proto > LVL_None (use local tunnel)
// !m_lan_mode && !m_remote_proto && m_lan_proto == LVL_Disable (*)
// !m_lan_mode && !m_remote_proto && m_lan_proto == LVL_None (x)
if (m_lan_proto <= MachineObject::LVL_Disable && (m_lan_mode || !m_remote_support)) {
if (m_lan_proto <= MachineObject::LVL_Disable && (m_lan_mode || !m_remote_proto)) {
Stop(m_lan_proto == MachineObject::LVL_None
? _L("Problem occurred. Please update the printer firmware and try again.")
: _L("LAN Only Liveview is off. Please turn on the liveview on printer screen."));
@ -312,12 +312,14 @@ void MediaPlayCtrl::Play()
SetStatus(_L("Initializing..."));
if (agent) {
agent->get_camera_url(m_machine,
[this, m = m_machine, v = agent_version, dv = m_dev_ver](std::string url) {
std::string protocols[] = {"", "\"tutk\"", "\"agora\"", "\"tutk\",\"agora\""};
agent->get_camera_url(m_machine + "|" + m_dev_ver + "|" + protocols[m_remote_proto],
[this, m = m_machine, v = agent_version, dv = m_dev_ver, agent](std::string url) {
if (boost::algorithm::starts_with(url, "bambu:///")) {
url += "&device=" + into_u8(m);
url += "&net_ver=" + v;
url += "&dev_ver=" + dv;
url += "&network_agent=" + boost::lexical_cast<std::string>(agent->get_network_agent());
url += "&cli_id=" + wxGetApp().app_config->get("slicer_uuid");
url += "&cli_ver=" + std::string(SLIC3R_VERSION);
}
@ -331,7 +333,7 @@ void MediaPlayCtrl::Play()
if (m_last_state == MEDIASTATE_INITIALIZING) {
if (url.empty() || !boost::algorithm::starts_with(url, "bambu:///")) {
m_failed_code = 3;
Stop(_L("Connection Failed. Please check the network and try again"));
Stop(_L("Connection Failed. Please check the network and try again"), from_u8(url));
} else {
m_url = url;
load();
@ -346,7 +348,7 @@ void MediaPlayCtrl::Play()
void start_ping_test();
void MediaPlayCtrl::Stop(wxString const &msg)
void MediaPlayCtrl::Stop(wxString const &msg, wxString const &msg2)
{
int last_state = m_last_state;
@ -493,7 +495,7 @@ void MediaPlayCtrl::ToggleStream()
wxGetApp().app_config->set("not_show_vcamera_stop_prev", "1");
if (res == wxID_CANCEL) return;
}
if (m_lan_proto > MachineObject::LVL_Disable && (m_lan_mode || !m_remote_support) && !m_disable_lan && !m_lan_ip.empty()) {
if (m_lan_proto > MachineObject::LVL_Disable && (m_lan_mode || !m_remote_proto) && !m_disable_lan && !m_lan_ip.empty()) {
std::string url;
if (m_lan_proto == MachineObject::LVL_Local)
url = "bambu:///local/" + m_lan_ip + ".?port=6000&user=" + m_lan_user + "&passwd=" + m_lan_passwd;
@ -514,11 +516,12 @@ void MediaPlayCtrl::ToggleStream()
}
NetworkAgent *agent = wxGetApp().getAgent();
if (!agent) return;
agent->get_camera_url(m_machine, [this, m = m_machine, v = agent->get_version(), dv = m_dev_ver](std::string url) {
agent->get_camera_url(m_machine, [this, m = m_machine, v = agent->get_version(), dv = m_dev_ver, agent](std::string url) {
if (boost::algorithm::starts_with(url, "bambu:///")) {
url += "&device=" + m;
url += "&net_ver=" + v;
url += "&dev_ver=" + dv;
url += "&network_agent=" + boost::lexical_cast<std::string>(agent->get_network_agent());
url += "&cli_id=" + wxGetApp().app_config->get("slicer_uuid");
url += "&cli_ver=" + std::string(SLIC3R_VERSION);
}