mirror of
https://github.com/kasmtech/KasmVNC.git
synced 2025-06-27 21:21:56 +02:00
Merge branch 'feature/KASM-3380_udp_frame_id' into 'master'
Resolve KASM-3380 "Feature/ udp frame" Closes KASM-3380 See merge request kasm-technologies/internal/KasmVNC!114
This commit is contained in:
commit
0de752f65e
@ -40,7 +40,7 @@ using namespace network;
|
|||||||
static rfb::LogWriter vlog("WebUdp");
|
static rfb::LogWriter vlog("WebUdp");
|
||||||
static WuHost *host = NULL;
|
static WuHost *host = NULL;
|
||||||
|
|
||||||
rfb::IntParameter udpSize("udpSize", "UDP packet data size", 1300, 500, 1400);
|
rfb::IntParameter udpSize("udpSize", "UDP packet data size", 1296, 500, 1400);
|
||||||
|
|
||||||
extern settings_t settings;
|
extern settings_t settings;
|
||||||
|
|
||||||
@ -95,10 +95,11 @@ void *udpserver(void *nport) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Send one packet, split into N UDP-sized pieces
|
// Send one packet, split into N UDP-sized pieces
|
||||||
static uint8_t udpsend(WuClient *client, const uint8_t *data, unsigned len, uint32_t *id) {
|
static uint8_t udpsend(WuClient *client, const uint8_t *data, unsigned len, uint32_t *id,
|
||||||
|
const uint32_t *frame) {
|
||||||
const uint32_t DATA_MAX = udpSize;
|
const uint32_t DATA_MAX = udpSize;
|
||||||
|
|
||||||
uint8_t buf[1400 + sizeof(uint32_t) * 4];
|
uint8_t buf[1400 + sizeof(uint32_t) * 5];
|
||||||
const uint32_t pieces = (len / DATA_MAX) + ((len % DATA_MAX) ? 1 : 0);
|
const uint32_t pieces = (len / DATA_MAX) + ((len % DATA_MAX) ? 1 : 0);
|
||||||
|
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
@ -111,12 +112,13 @@ static uint8_t udpsend(WuClient *client, const uint8_t *data, unsigned len, uint
|
|||||||
memcpy(&buf[4], &i, sizeof(uint32_t));
|
memcpy(&buf[4], &i, sizeof(uint32_t));
|
||||||
memcpy(&buf[8], &pieces, sizeof(uint32_t));
|
memcpy(&buf[8], &pieces, sizeof(uint32_t));
|
||||||
memcpy(&buf[12], &hash, sizeof(uint32_t));
|
memcpy(&buf[12], &hash, sizeof(uint32_t));
|
||||||
|
memcpy(&buf[16], frame, sizeof(uint32_t));
|
||||||
|
|
||||||
memcpy(&buf[16], data, curlen);
|
memcpy(&buf[20], data, curlen);
|
||||||
data += curlen;
|
data += curlen;
|
||||||
len -= curlen;
|
len -= curlen;
|
||||||
|
|
||||||
if (WuHostSendBinary(host, client, buf, curlen + sizeof(uint32_t) * 4) < 0)
|
if (WuHostSendBinary(host, client, buf, curlen + sizeof(uint32_t) * 5) < 0)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,7 +127,8 @@ static uint8_t udpsend(WuClient *client, const uint8_t *data, unsigned len, uint
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
UdpStream::UdpStream(): OutStream(), client(NULL), total_len(0), id(0), failed(false) {
|
UdpStream::UdpStream(): OutStream(), client(NULL), total_len(0), id(0), failed(false),
|
||||||
|
frame(0) {
|
||||||
ptr = data;
|
ptr = data;
|
||||||
end = data + UDPSTREAM_BUFSIZE;
|
end = data + UDPSTREAM_BUFSIZE;
|
||||||
|
|
||||||
@ -137,7 +140,7 @@ void UdpStream::flush() {
|
|||||||
total_len += len;
|
total_len += len;
|
||||||
|
|
||||||
if (client) {
|
if (client) {
|
||||||
if (udpsend(client, data, len, &id)) {
|
if (udpsend(client, data, len, &id, &frame)) {
|
||||||
vlog.error("Error sending udp, client gone?");
|
vlog.error("Error sending udp, client gone?");
|
||||||
failed = true;
|
failed = true;
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,10 @@ namespace network {
|
|||||||
client = cli;
|
client = cli;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setFrameNumber(const unsigned in) {
|
||||||
|
frame = in;
|
||||||
|
}
|
||||||
|
|
||||||
bool isFailed() const;
|
bool isFailed() const;
|
||||||
void clearFailed();
|
void clearFailed();
|
||||||
private:
|
private:
|
||||||
@ -48,6 +52,7 @@ namespace network {
|
|||||||
size_t total_len;
|
size_t total_len;
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
bool failed;
|
bool failed;
|
||||||
|
uint32_t frame;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,6 +363,9 @@ void EncodeManager::doUpdate(bool allowLossy, const Region& changed_,
|
|||||||
unsigned screenArea;
|
unsigned screenArea;
|
||||||
|
|
||||||
updates++;
|
updates++;
|
||||||
|
if (conn->cp.supportsUdp)
|
||||||
|
((network::UdpStream *) conn->getOutStream(conn->cp.supportsUdp))->setFrameNumber(updates);
|
||||||
|
|
||||||
|
|
||||||
// The video resolution may have changed, check it
|
// The video resolution may have changed, check it
|
||||||
if (conn->cp.kasmPassed[ConnParams::KASM_MAX_VIDEO_RESOLUTION])
|
if (conn->cp.kasmPassed[ConnParams::KASM_MAX_VIDEO_RESOLUTION])
|
||||||
|
@ -39,7 +39,7 @@ static LogWriter vlog("SMsgWriter");
|
|||||||
|
|
||||||
SMsgWriter::SMsgWriter(ConnParams* cp_, rdr::OutStream* os_, rdr::OutStream* udps_)
|
SMsgWriter::SMsgWriter(ConnParams* cp_, rdr::OutStream* os_, rdr::OutStream* udps_)
|
||||||
: cp(cp_), os(os_), udps(udps_),
|
: cp(cp_), os(os_), udps(udps_),
|
||||||
nRectsInUpdate(0), nRectsInHeader(0),
|
nRectsInUpdate(0), dataRectsInUpdate(0), nRectsInHeader(0),
|
||||||
needSetDesktopSize(false), needExtendedDesktopSize(false),
|
needSetDesktopSize(false), needExtendedDesktopSize(false),
|
||||||
needSetDesktopName(false), needSetCursor(false),
|
needSetDesktopName(false), needSetCursor(false),
|
||||||
needSetXCursor(false), needSetCursorWithAlpha(false),
|
needSetXCursor(false), needSetCursorWithAlpha(false),
|
||||||
@ -340,7 +340,7 @@ void SMsgWriter::writeFramebufferUpdateStart(int nRects)
|
|||||||
|
|
||||||
os->writeU16(nRects);
|
os->writeU16(nRects);
|
||||||
|
|
||||||
nRectsInUpdate = 0;
|
nRectsInUpdate = dataRectsInUpdate = 0;
|
||||||
if (nRects == 0xFFFF)
|
if (nRects == 0xFFFF)
|
||||||
nRectsInHeader = 0;
|
nRectsInHeader = 0;
|
||||||
else
|
else
|
||||||
@ -365,7 +365,7 @@ void SMsgWriter::writeFramebufferUpdateEnd()
|
|||||||
|
|
||||||
// Send an UDP flip marker, if needed
|
// Send an UDP flip marker, if needed
|
||||||
if (cp->supportsUdp) {
|
if (cp->supportsUdp) {
|
||||||
udps->writeS16(0);
|
udps->writeS16(dataRectsInUpdate);
|
||||||
udps->writeS16(0);
|
udps->writeS16(0);
|
||||||
udps->writeU16(0);
|
udps->writeU16(0);
|
||||||
udps->writeU16(0);
|
udps->writeU16(0);
|
||||||
@ -394,6 +394,7 @@ void SMsgWriter::startRect(const Rect& r, int encoding)
|
|||||||
{
|
{
|
||||||
if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
|
if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
|
||||||
throw Exception("SMsgWriter::startRect: nRects out of sync");
|
throw Exception("SMsgWriter::startRect: nRects out of sync");
|
||||||
|
++dataRectsInUpdate;
|
||||||
|
|
||||||
if (cp->supportsUdp) {
|
if (cp->supportsUdp) {
|
||||||
udps->writeS16(r.tl.x);
|
udps->writeS16(r.tl.x);
|
||||||
|
@ -165,6 +165,7 @@ namespace rfb {
|
|||||||
rdr::OutStream* udps;
|
rdr::OutStream* udps;
|
||||||
|
|
||||||
int nRectsInUpdate;
|
int nRectsInUpdate;
|
||||||
|
int dataRectsInUpdate;
|
||||||
int nRectsInHeader;
|
int nRectsInHeader;
|
||||||
|
|
||||||
bool needSetDesktopSize;
|
bool needSetDesktopSize;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user