libxrdp: add our own mppc compression instead of using the freerdp mppc

This commit is contained in:
Jay Sorg 2012-12-28 22:37:48 -08:00
parent f91b33ed13
commit b3dcfdaa37
4 changed files with 1079 additions and 12 deletions

View File

@ -51,7 +51,8 @@ libxrdp_la_SOURCES = \
xrdp_tcp.c \
xrdp_bitmap_compress.c \
xrdp_jpeg_compress.c \
xrdp_orders_rail.c
xrdp_orders_rail.c \
xrdp_mppc_enc.c
libxrdp_la_LDFLAGS = \
$(EXTRA_FLAGS)

View File

@ -116,7 +116,7 @@ struct xrdp_rdp
int share_id;
int mcs_channel;
struct xrdp_client_info client_info;
void* mppc_enc;
struct xrdp_mppc_enc* mppc_enc;
void* rfx_enc;
};
@ -213,6 +213,31 @@ struct xrdp_orders
struct xrdp_orders_state orders_state;
};
#define PROTO_RDP_40 1
#define PROTO_RDP_50 2
struct xrdp_mppc_enc
{
int protocol_type; /* PROTO_RDP_40, PROTO_RDP_50 etc */
char *historyBuffer; /* contains uncompressed data */
char *outputBuffer; /* contains compressed data */
char *outputBufferPlus;
int historyOffset; /* next free slot in historyBuffer */
int buf_len; /* length of historyBuffer, protocol dependant */
int bytes_in_opb; /* compressed bytes available in outputBuffer */
int flags; /* PACKET_COMPRESSED, PACKET_AT_FRONT, PACKET_FLUSHED etc */
int flagsHold;
int first_pkt; /* this is the first pkt passing through enc */
tui16 *hash_table;
};
int APP_CC
compress_rdp(struct xrdp_mppc_enc *enc, tui8 *srcData, int len);
struct xrdp_mppc_enc * APP_CC
mppc_enc_new(int protocol_type);
void APP_CC
mppc_enc_free(struct xrdp_mppc_enc *enc);
/* xrdp_tcp.c */
struct xrdp_tcp* APP_CC
xrdp_tcp_create(struct xrdp_iso* owner, struct trans* trans);

1047
libxrdp/xrdp_mppc_enc.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -21,7 +21,6 @@
#include "libxrdp.h"
#if defined(XRDP_FREERDP1)
#include <freerdp/codec/mppc_enc.h>
#include <freerdp/codec/rfx.h>
#endif
@ -229,8 +228,8 @@ xrdp_rdp_create(struct xrdp_session *session, struct trans *trans)
/* load client ip info */
bytes = sizeof(self->client_info.client_ip) - 1;
g_write_ip_address(trans->sck, self->client_info.client_ip, bytes);
#if defined(XRDP_FREERDP1)
self->mppc_enc = mppc_enc_new(PROTO_RDP_50);
#if defined(XRDP_FREERDP1)
self->rfx_enc = rfx_context_new();
rfx_context_set_cpu_opt(self->rfx_enc, xrdp_rdp_detect_cpu());
#endif
@ -249,8 +248,8 @@ xrdp_rdp_delete(struct xrdp_rdp *self)
}
xrdp_sec_delete(self->sec_layer);
mppc_enc_free(self->mppc_enc);
#if defined(XRDP_FREERDP1)
mppc_enc_free((struct rdp_mppc_enc *)(self->mppc_enc));
rfx_context_free((RFX_CONTEXT *)(self->rfx_enc));
#endif
g_free(self);
@ -403,9 +402,7 @@ xrdp_rdp_send_data(struct xrdp_rdp *self, struct stream *s,
int sec_offset;
int rdp_offset;
struct stream ls;
#if defined(XRDP_FREERDP1)
struct rdp_mppc_enc *mppc_enc;
#endif
struct xrdp_mppc_enc *mppc_enc;
DEBUG(("in xrdp_rdp_send_data"));
s_pop_layer(s, rdp_hdr);
@ -416,12 +413,10 @@ xrdp_rdp_send_data(struct xrdp_rdp *self, struct stream *s,
ctype = 0;
clen = len;
tocomplen = pdulen - 18;
#if defined(XRDP_FREERDP1)
if (self->client_info.rdp_compression && self->session->up_and_running)
{
mppc_enc = (struct rdp_mppc_enc *)(self->mppc_enc);
mppc_enc = self->mppc_enc;
if (compress_rdp(mppc_enc, (tui8 *)(s->p + 18), tocomplen))
{
DEBUG(("mppc_encode ok flags 0x%x bytes_in_opb %d historyOffset %d "
@ -458,7 +453,6 @@ xrdp_rdp_send_data(struct xrdp_rdp *self, struct stream *s,
}
}
#endif
out_uint16_le(s, pdulen);
out_uint16_le(s, pdutype);
out_uint16_le(s, self->mcs_channel);