ENH: stop liveview track record
Change-Id: Id4f236b239740bd919f2aa2f2892c1e63ce233bd Jira: STUDIO-6131
This commit is contained in:
parent
30dc8b3117
commit
fdcd6085d2
|
@ -53,12 +53,36 @@ MediaPlayCtrl::MediaPlayCtrl(wxWindow *parent, wxMediaCtrl2 *media_ctrl, const w
|
|||
|
||||
m_label_stat = new Label(this, "");
|
||||
m_label_stat->SetForegroundColour(wxColour("#323A3C"));
|
||||
#if !BBL_RELEASE_TO_PUBLIC
|
||||
m_media_ctrl->Bind(EVT_MEDIA_CTRL_STAT, [this](auto & e) {
|
||||
#if !BBL_RELEASE_TO_PUBLIC
|
||||
wxSize size = m_media_ctrl->GetVideoSize();
|
||||
m_label_stat->SetLabel(e.GetString() + wxString::Format(" VS:%ix%i", size.x, size.y));
|
||||
});
|
||||
#endif
|
||||
wxString str = e.GetString();
|
||||
m_stat.clear();
|
||||
for (auto k : {"FPS:", "BPS:", "T:", "B:"}) {
|
||||
auto ik = str.Find(k);
|
||||
double value = 0;
|
||||
if (ik != wxString::npos) {
|
||||
ik += strlen(k);
|
||||
auto ip = str.find(' ', ik);
|
||||
if (ip == wxString::npos) ip = str.Length();
|
||||
auto v = str.Mid(ik, ip - ik);
|
||||
if (k == "T:" && v.Length() == 8) {
|
||||
long h = 0,m = 0,s = 0;
|
||||
v.Left(2).ToLong(&h);
|
||||
v.Mid(3, 2).ToLong(&m);
|
||||
v.Mid(6, 2).ToLong(&s);
|
||||
value = h * 3600. + m * 60 + s;
|
||||
} else {
|
||||
v.ToDouble(&value);
|
||||
if (v.Right(1) == "K") value *= 1024;
|
||||
else if (v.Right(1) == "%") value *= 0.01;
|
||||
}
|
||||
}
|
||||
m_stat.push_back(value);
|
||||
}
|
||||
});
|
||||
|
||||
m_button_play->Bind(wxEVT_COMMAND_BUTTON_CLICKED, [this](auto &e) { TogglePlay(); });
|
||||
m_button_play->Bind(wxEVT_RIGHT_UP, [this](auto & e) { m_media_ctrl->Play(); });
|
||||
|
@ -367,6 +391,22 @@ void MediaPlayCtrl::Stop(wxString const &msg)
|
|||
m_last_failed_codes.insert(m_failed_code);
|
||||
}
|
||||
|
||||
if (last_state == wxMEDIASTATE_PLAYING && m_stat.size() == 4) {
|
||||
json j;
|
||||
j["dev_id"] = m_machine;
|
||||
j["dev_ip"] = m_lan_ip;
|
||||
j["result"] = m_failed_code ? "failed" : "success";
|
||||
j["tunnel"] = remote ? "remote" : "local";
|
||||
j["code"] = m_failed_code;
|
||||
j["msg"] = into_u8(msg);
|
||||
j["fps"] = m_stat[0];
|
||||
j["bps"] = m_stat[1];
|
||||
j["total_time"] = m_stat[2];
|
||||
j["block_rate"] = m_stat[3];
|
||||
NetworkAgent *agent = wxGetApp().getAgent();
|
||||
if (agent) agent->track_event("stop_liveview", j.dump());
|
||||
}
|
||||
|
||||
m_url.clear();
|
||||
++m_failed_retry;
|
||||
if (m_failed_code < 0 && last_state != wxMEDIASTATE_PLAYING && !remote && (m_failed_retry > 1 || m_user_triggered)) {
|
||||
|
|
|
@ -98,6 +98,7 @@ private:
|
|||
bool m_user_triggered = false;
|
||||
int m_failed_retry = 0;
|
||||
int m_failed_code = 0;
|
||||
std::vector<double> m_stat;
|
||||
std::set<int> m_last_failed_codes;
|
||||
wxDateTime m_last_user_play;
|
||||
wxDateTime m_next_retry;
|
||||
|
|
|
@ -56,7 +56,8 @@ void wxMediaCtrl2::Load(wxURI url)
|
|||
{
|
||||
#ifdef __WIN32__
|
||||
if (m_imp == nullptr) {
|
||||
CallAfter([] {
|
||||
static bool notified = false;
|
||||
if (!notified) CallAfter([] {
|
||||
auto res = wxMessageBox(_L("Windows Media Player is required for this task! Do you want to enable 'Windows Media Player' for your operation system?"), _L("Error"), wxOK | wxCANCEL);
|
||||
if (res == wxOK) {
|
||||
wxString url = IsWindows10OrGreater()
|
||||
|
|
|
@ -32,6 +32,12 @@ void wxMediaCtrl2::bambu_log(void const * ctx, int level, char const * msg)
|
|||
if (msg2.SubString(n + 1, msg2.Length() - 2).ToLong(&val))
|
||||
ctrl->m_error = (int) val;
|
||||
}
|
||||
} else if (strstr(msg, "stat_log")) {
|
||||
wxMediaCtrl2 * ctrl = (wxMediaCtrl2 *) ctx;
|
||||
wxCommandEvent evt(EVT_MEDIA_CTRL_STAT);
|
||||
evt.SetEventObject(ctrl);
|
||||
evt.SetString(strchr(msg, ' ') + 1);
|
||||
wxPostEvent(ctrl, evt);
|
||||
}
|
||||
} else if (level < 0) {
|
||||
wxMediaCtrl2 * ctrl = (wxMediaCtrl2 *) ctx;
|
||||
|
|
Loading…
Reference in New Issue