ENH: liveview remote protocols with agora
Change-Id: Id86aa4bfa5f5e09675a6fe627668c63d20c7d1bf Jira: none (cherry picked from commit 46eba0048b73f1741b4b7b57f788830c08a8d7f1)
This commit is contained in:
parent
8b33119640
commit
6385a4d170
15 changed files with 87 additions and 54 deletions
|
@ -6,10 +6,10 @@
|
|||
"resolution_supported": [ "720p", "1080p" ],
|
||||
"virtual_camera": "enabled",
|
||||
"liveview": {
|
||||
"remote": "enabled"
|
||||
"remote": "tutk"
|
||||
},
|
||||
"file": {
|
||||
"remote": "enabled",
|
||||
"remote": "tutk",
|
||||
"model_download": "enabled"
|
||||
}
|
||||
},
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
"resolution_supported": [ "720p", "1080p" ],
|
||||
"virtual_camera": "enabled",
|
||||
"liveview": {
|
||||
"remote": "enabled"
|
||||
"remote": "tutk"
|
||||
},
|
||||
"file": {
|
||||
"remote": "enabled",
|
||||
"remote": "tutk",
|
||||
"model_download": "enabled"
|
||||
}
|
||||
},
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
"print": {
|
||||
"ipcam": {
|
||||
"liveview": {
|
||||
"remote": "enabled"
|
||||
"remote": "tutk"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -79,7 +79,7 @@
|
|||
"print": {
|
||||
"ipcam": {
|
||||
"file": {
|
||||
"remote": "enabled"
|
||||
"remote": "tutk"
|
||||
}
|
||||
},
|
||||
"support_user_preset":true
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
"print": {
|
||||
"ipcam": {
|
||||
"liveview": {
|
||||
"remote": "enabled"
|
||||
"remote": "tutk"
|
||||
}
|
||||
},
|
||||
"support_mqtt_alive":true,
|
||||
|
@ -71,7 +71,7 @@
|
|||
"print": {
|
||||
"ipcam": {
|
||||
"file": {
|
||||
"remote": "enabled"
|
||||
"remote": "tutk"
|
||||
}
|
||||
},
|
||||
"support_user_preset":true
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
"resolution_supported": [ "720p", "1080p" ],
|
||||
"virtual_camera": "enabled",
|
||||
"liveview": {
|
||||
"remote": "enabled"
|
||||
"remote": "tutk"
|
||||
},
|
||||
"file": {
|
||||
"remote": "enabled",
|
||||
"remote": "tutk",
|
||||
"model_download": "enabled"
|
||||
}
|
||||
},
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"resolution_supported": [ "720p" ],
|
||||
"liveview": {
|
||||
"local": "local",
|
||||
"remote": "enabled"
|
||||
"remote": "tutk"
|
||||
}
|
||||
},
|
||||
"support_motor_noise_cali":true,
|
||||
|
@ -53,7 +53,7 @@
|
|||
"print": {
|
||||
"ipcam": {
|
||||
"file": {
|
||||
"remote": "enabled"
|
||||
"remote": "tutk"
|
||||
}
|
||||
},
|
||||
"support_user_preset":true
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"resolution_supported": [ "720p" ],
|
||||
"liveview": {
|
||||
"local": "local",
|
||||
"remote": "enabled"
|
||||
"remote": "tutk"
|
||||
}
|
||||
},
|
||||
"support_motor_noise_cali":true,
|
||||
|
@ -53,7 +53,7 @@
|
|||
"print": {
|
||||
"ipcam": {
|
||||
"file": {
|
||||
"remote": "enabled"
|
||||
"remote": "tutk"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1429,6 +1429,10 @@ void MachineObject::parse_status(int flag)
|
|||
}
|
||||
|
||||
sdcard_state = MachineObject::SdcardState((flag >> 8) & 0x11);
|
||||
|
||||
is_support_agora = ((flag >> 30) & 0x1) != 0;
|
||||
if (is_support_agora)
|
||||
is_support_tunnel_mqtt = false;
|
||||
}
|
||||
|
||||
PrintingSpeedLevel MachineObject::_parse_printing_speed_lvl(int lvl)
|
||||
|
@ -2900,7 +2904,7 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
|
|||
}
|
||||
|
||||
if (!key_field_only) {
|
||||
if (!DeviceManager::EnableMultiMachine) {
|
||||
if (!DeviceManager::EnableMultiMachine && !is_support_agora) {
|
||||
if (jj.contains("support_tunnel_mqtt")) {
|
||||
if (jj["support_tunnel_mqtt"].is_boolean()) {
|
||||
is_support_tunnel_mqtt = jj["support_tunnel_mqtt"].get<bool>();
|
||||
|
@ -3698,11 +3702,18 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
|
|||
if (ipcam.contains("liveview")) {
|
||||
char const *local_protos[] = {"none", "disabled", "local", "rtsps", "rtsp"};
|
||||
liveview_local = enum_index_of(ipcam["liveview"].value<std::string>("local", "none").c_str(), local_protos, 5, LiveviewLocal::LVL_None);
|
||||
liveview_remote = ipcam["liveview"].value<std::string>("remote", "disabled") == "enabled";
|
||||
char const *remote_protos[] = {"none", "tutk", "agora", "tutk_agaro"};
|
||||
liveview_remote = enum_index_of(ipcam["liveview"].value<std::string>("remote", "none").c_str(), remote_protos, 4, LiveviewRemote::LVR_None);
|
||||
if (is_support_agora)
|
||||
liveview_remote = liveview_remote == LVR_None ? LVR_Agora : liveview_remote == LVR_Tutk ? LVR_TutkAgora : liveview_remote;
|
||||
}
|
||||
if (ipcam.contains("file")) {
|
||||
file_local = ipcam["file"].value<std::string>("local", "disabled") == "enabled";
|
||||
file_remote = ipcam["file"].value<std::string>("remote", "disabled") == "enabled";
|
||||
char const *local_protos[] = {"none", "local"};
|
||||
file_local = enum_index_of(ipcam["file"].value<std::string>("local", "none").c_str(), local_protos, 2, FileLocal::FL_None);
|
||||
char const *remote_protos[] = {"none", "tutk", "agora", "tutk_agaro"};
|
||||
file_remote = enum_index_of(ipcam["file"].value<std::string>("remote", "none").c_str(), remote_protos, 4, FileRemote::FR_None);
|
||||
if (is_support_agora)
|
||||
file_remote = file_remote == FR_None ? FR_Agora : file_remote == FR_Tutk ? FR_TutkAgora : file_remote;
|
||||
file_model_download = ipcam["file"].value<std::string>("model_download", "disabled") == "enabled";
|
||||
}
|
||||
virtual_camera = ipcam.value<std::string>("virtual_camera", "disabled") == "enabled";
|
||||
|
|
|
@ -708,9 +708,22 @@ public:
|
|||
LVL_Rtsps,
|
||||
LVL_Rtsp
|
||||
} liveview_local{ LVL_None };
|
||||
bool liveview_remote{false};
|
||||
bool file_local{false};
|
||||
bool file_remote{false};
|
||||
enum LiveviewRemote {
|
||||
LVR_None,
|
||||
LVR_Tutk,
|
||||
LVR_Agora,
|
||||
LVR_TutkAgora
|
||||
} liveview_remote{ LVR_None };
|
||||
enum FileLocal {
|
||||
FL_None,
|
||||
FL_Local
|
||||
} file_local{ FL_None };
|
||||
enum FileRemote {
|
||||
FR_None,
|
||||
FR_Tutk,
|
||||
FR_Agora,
|
||||
FR_TutkAgora
|
||||
} file_remote{ FR_None };
|
||||
bool file_model_download{false};
|
||||
bool virtual_camera{false};
|
||||
|
||||
|
@ -763,6 +776,7 @@ public:
|
|||
bool is_support_nozzle_blob_detection{false};
|
||||
bool is_support_air_print_detection{false};
|
||||
bool is_support_filament_setting_inprinting{false};
|
||||
bool is_support_agora{false};
|
||||
|
||||
int nozzle_max_temperature = -1;
|
||||
int bed_temperature_limit = -1;
|
||||
|
|
|
@ -1024,9 +1024,11 @@ void GUI_App::post_init()
|
|||
for (auto& it : boost::filesystem::directory_iterator(log_folder)) {
|
||||
auto temp_path = it.path();
|
||||
try {
|
||||
std::time_t lw_t = boost::filesystem::last_write_time(temp_path) ;
|
||||
files_vec.push_back({ lw_t, temp_path.filename().string() });
|
||||
} catch (const std::exception &) {
|
||||
if (it.status().type() == boost::filesystem::regular_file) {
|
||||
std::time_t lw_t = boost::filesystem::last_write_time(temp_path) ;
|
||||
files_vec.push_back({ lw_t, temp_path.filename().string() });
|
||||
}
|
||||
} catch (const std::exception &ex) {
|
||||
}
|
||||
}
|
||||
std::sort(files_vec.begin(), files_vec.end(), [](
|
||||
|
|
|
@ -219,10 +219,10 @@ void MediaFilePanel::SetMachineObject(MachineObject* obj)
|
|||
m_lan_ip = obj->dev_ip;
|
||||
m_lan_passwd = obj->get_access_code();
|
||||
m_dev_ver = obj->get_ota_version();
|
||||
m_device_busy = obj->is_camera_busy_off();
|
||||
m_device_busy = obj->is_camera_busy_off();
|
||||
m_sdcard_exist = obj->has_sdcard();
|
||||
m_local_support = obj->file_local;
|
||||
m_remote_support = obj->file_remote;
|
||||
m_local_proto = obj->file_local;
|
||||
m_remote_proto = obj->file_remote;
|
||||
m_model_download_support = obj->file_model_download;
|
||||
} else {
|
||||
m_lan_mode = false;
|
||||
|
@ -231,13 +231,13 @@ void MediaFilePanel::SetMachineObject(MachineObject* obj)
|
|||
m_dev_ver.clear();
|
||||
m_sdcard_exist = false;
|
||||
m_device_busy = false;
|
||||
m_local_support = false;
|
||||
m_remote_support = false;
|
||||
m_local_proto = 0;
|
||||
m_remote_proto = 0;
|
||||
m_model_download_support = false;
|
||||
}
|
||||
Enable(obj && obj->is_connected() && obj->m_push_count > 0);
|
||||
if (machine == m_machine) {
|
||||
if ((m_waiting_enable && IsEnabled()) || (m_waiting_support && (m_local_support || m_remote_support))) {
|
||||
if ((m_waiting_enable && IsEnabled()) || (m_waiting_support && (m_local_proto || m_remote_proto))) {
|
||||
auto fs = m_image_grid->GetFileSystem();
|
||||
if (fs) fs->Retry();
|
||||
}
|
||||
|
@ -433,7 +433,7 @@ void MediaFilePanel::fetchUrl(boost::weak_ptr<PrinterFileSystem> wfs)
|
|||
return;
|
||||
}
|
||||
m_waiting_enable = false;
|
||||
if (!m_local_support && !m_remote_support) {
|
||||
if (!m_local_proto && !m_remote_proto) {
|
||||
m_waiting_support = true;
|
||||
m_image_grid->SetStatus(m_bmp_failed, _L("Browsing file in SD card is not supported in current firmware. Please update the printer firmware."));
|
||||
fs->SetUrl("0");
|
||||
|
@ -452,7 +452,7 @@ void MediaFilePanel::fetchUrl(boost::weak_ptr<PrinterFileSystem> wfs)
|
|||
m_waiting_support = false;
|
||||
NetworkAgent *agent = wxGetApp().getAgent();
|
||||
std::string agent_version = agent ? agent->get_version() : "";
|
||||
if ((m_lan_mode || !m_remote_support) && m_local_support && !m_lan_ip.empty()) {
|
||||
if ((m_lan_mode || !m_remote_proto) && m_local_proto && !m_lan_ip.empty()) {
|
||||
std::string url = "bambu:///local/" + m_lan_ip + ".?port=6000&user=" + m_lan_user + "&passwd=" + m_lan_passwd;
|
||||
url += "&device=" + m_machine;
|
||||
url += "&net_ver=" + agent_version;
|
||||
|
@ -462,7 +462,7 @@ void MediaFilePanel::fetchUrl(boost::weak_ptr<PrinterFileSystem> wfs)
|
|||
fs->SetUrl(url);
|
||||
return;
|
||||
}
|
||||
if (!m_remote_support && m_local_support) { // not support tutk
|
||||
if (!m_remote_proto && m_local_proto) { // not support tutk
|
||||
m_image_grid->SetStatus(m_bmp_failed, _L("Please enter the IP of printer to connect."));
|
||||
fs->SetUrl("0");
|
||||
fs.reset();
|
||||
|
@ -478,12 +478,14 @@ void MediaFilePanel::fetchUrl(boost::weak_ptr<PrinterFileSystem> wfs)
|
|||
return;
|
||||
}
|
||||
if (agent) {
|
||||
agent->get_camera_url(m_machine,
|
||||
[this, wfs, m = m_machine, v = agent->get_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, wfs, 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);
|
||||
}
|
||||
|
|
|
@ -83,8 +83,8 @@ private:
|
|||
std::string m_dev_ver;
|
||||
bool m_lan_mode = false;
|
||||
bool m_sdcard_exist = false;
|
||||
bool m_local_support = false;
|
||||
bool m_remote_support = false;
|
||||
int m_local_proto = false;
|
||||
int m_remote_proto = false;
|
||||
bool m_model_download_support = false;
|
||||
bool m_device_busy = false;
|
||||
bool m_waiting_enable = false;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ protected:
|
|||
|
||||
void Play();
|
||||
|
||||
void Stop(wxString const &msg = {});
|
||||
void Stop(wxString const &msg = {}, wxString const &msg2 = {});
|
||||
|
||||
void TogglePlay();
|
||||
|
||||
|
@ -83,7 +83,7 @@ private:
|
|||
std::string m_tutk_state;
|
||||
bool m_camera_exists = false;
|
||||
bool m_lan_mode = false;
|
||||
bool m_remote_support = false;
|
||||
int m_remote_proto = 0;
|
||||
bool m_device_busy = false;
|
||||
bool m_disable_lan = false;
|
||||
wxString m_url;
|
||||
|
|
|
@ -226,6 +226,7 @@ public:
|
|||
|
||||
int get_mw_user_preference(std::function<void(std::string)> callback);
|
||||
int get_mw_user_4ulist(int seed, int limit, std::function<void(std::string)> callback);
|
||||
void *get_network_agent() { return network_agent; }
|
||||
|
||||
private:
|
||||
bool enable_track = false;
|
||||
|
|
Loading…
Reference in a new issue