采用比zlib更快的压缩库zstd

远程桌面帧率提高到12;补充上传zlib.lib。
This commit is contained in:
yuanyuanxiang
2019-01-17 11:58:26 +08:00
parent c54d75505e
commit 16741545a9
17 changed files with 3607 additions and 20 deletions

View File

@@ -659,6 +659,8 @@ void CMy2015RemoteDlg::OnOnlineMessage()
void CMy2015RemoteDlg::OnOnlineDelete()
{
// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EEB4A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (IDYES != MessageBox(_T("ȷ<EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><EFBFBD>ؼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>?"), _T("<EFBFBD><EFBFBD>ʾ"), MB_ICONQUESTION | MB_YESNO))
return;
BYTE bToken = COMMAND_BYE; //<2F>򱻿ض˷<D8B6><CBB7><EFBFBD>һ<EFBFBD><D2BB>COMMAND_SYSTEM
SendSelectedCommand(&bToken, sizeof(BYTE)); //Context PreSending PostSending
@@ -1066,7 +1068,7 @@ LRESULT CMy2015RemoteDlg::OnUserOfflineMsg(WPARAM wParam, LPARAM lParam)
LeaveCriticalSection(&m_cs);
dlgInfo *p = (dlgInfo *)wParam;
if (p && p->v1 > 0)
if (p)
{
switch(p->v1)
{
@@ -1124,8 +1126,10 @@ LRESULT CMy2015RemoteDlg::OnUserOfflineMsg(WPARAM wParam, LPARAM lParam)
//delete Dlg; //<2F><><EFBFBD><EFBFBD><E2B4A6>
break;
}
default:break;
}
delete p;
p = NULL;
}
return S_OK;

View File

@@ -3,8 +3,18 @@
#include "2015Remote.h"
#include <iostream>
#if USING_ZLIB
#include "zlib.h"
#include "zconf.h"
#define Z_FAILED(p) (Z_OK != (p))
#define Z_SUCCESS(p) (!Z_FAILED(p))
#else
#include "zstd/zstd.h"
#pragma comment(lib, "zstd/zstd.lib")
#define Z_FAILED(p) ZSTD_isError(p)
#define Z_SUCCESS(p) (!Z_FAILED(p))
#define compress(dest, destLen, source, sourceLen) ZSTD_compress(dest, *(destLen), source, sourceLen, ZSTD_CLEVEL_DEFAULT)
#define uncompress(dest, destLen, source, sourceLen) ZSTD_decompress(dest, *(destLen), source, sourceLen)
#endif
using namespace std;
CRITICAL_SECTION IOCPServer::m_cs = {0};
@@ -452,13 +462,14 @@ BOOL IOCPServer::OnClientReceiving(PCONTEXT_OBJECT ContextObject, DWORD dwTrans
//<2F><><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD><DDB0><EFBFBD>ǰ<EFBFBD><C7B0>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD>û<EFBFBD>н<EFBFBD>ѹ<EFBFBD><D1B9>ȡ<EFBFBD><C8A1>pData 448
ContextObject->InCompressedBuffer.ReadBuffer(CompressedBuffer, ulCompressedLength);
int iRet = uncompress(DeCompressedBuffer, &ulOriginalLength, CompressedBuffer, ulCompressedLength);
if (iRet == Z_OK)
if (Z_SUCCESS(iRet))
{
ContextObject->InDeCompressedBuffer.ClearBuffer();
ContextObject->InCompressedBuffer.ClearBuffer();
ContextObject->InDeCompressedBuffer.WriteBuffer(DeCompressedBuffer, ulOriginalLength);
m_NotifyProc(ContextObject); //֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD>
}else{
OutputDebugStringA("[ERROR] uncompress failed \n");
throw "Bad Buffer";
}
delete [] CompressedBuffer;
@@ -486,15 +497,23 @@ VOID IOCPServer::OnClientPreSending(CONTEXT_OBJECT* ContextObject, PBYTE szBuffe
{
if (ulOriginalLength > 0)
{
#if USING_ZLIB
unsigned long ulCompressedLength = (double)ulOriginalLength * 1.001 + 12;
#else
unsigned long ulCompressedLength = ZSTD_compressBound(ulOriginalLength);
#endif
LPBYTE CompressedBuffer = new BYTE[ulCompressedLength];
int iRet = compress(CompressedBuffer, &ulCompressedLength, (LPBYTE)szBuffer, ulOriginalLength);
if (iRet != Z_OK)
if (Z_FAILED(iRet))
{
OutputDebugStringA("[ERROR] compress failed \n");
delete [] CompressedBuffer;
return;
}
#if !USING_ZLIB
ulCompressedLength = iRet;
#endif
ULONG ulPackTotalLength = ulCompressedLength + HDR_LENGTH;
ContextObject->OutCompressedBuffer.WriteBuffer((LPBYTE)m_szPacketFlag,FLAG_LENGTH);
ContextObject->OutCompressedBuffer.WriteBuffer((PBYTE)&ulPackTotalLength, sizeof(ULONG));

View File

@@ -148,7 +148,7 @@ public:
OVERLAPPEDPLUS(IOType ioType)
{
#ifdef _DEBUG
#if 0
char szLog[100];
sprintf_s(szLog, "=> [new] OVERLAPPEDPLUS %x by thread [%d].\n", this, GetCurrentThreadId());
OutputDebugStringA(szLog);
@@ -159,7 +159,7 @@ public:
~OVERLAPPEDPLUS()
{
#ifdef _DEBUG
#if 0
char szLog[100];
sprintf_s(szLog, "=> [delete] OVERLAPPEDPLUS %x by thread [%d].\n", this, GetCurrentThreadId());
OutputDebugStringA(szLog);

View File

@@ -5,6 +5,8 @@
#pragma once
#define USING_ZLIB 0
#ifndef _SECURE_ATL
#define _SECURE_ATL 1
#endif

BIN
server/2015Remote/zlib.lib Normal file

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.