Merge branch 'devel' of github.com:neutrinolabs/xrdp into devel

ulab-next-nosound
Jay Sorg 10 years ago
commit b61b58b1ad

@ -72,7 +72,7 @@
(bpp==8?COLOR8(HRED(c),HGREEN(c),HBLUE(c)): \
(bpp==15?COLOR15(HRED(c),HGREEN(c),HBLUE(c)): \
(bpp==16?COLOR16(HRED(c),HGREEN(c),HBLUE(c)): \
(bpp==24?COLOR24BGR(HRED(c),HGREEN(c),HBLUE(c)):c) \
(bpp>=24?COLOR24BGR(HRED(c),HGREEN(c),HBLUE(c)):c) \
) \
) \
) \
@ -101,4 +101,10 @@
/* use crc for bitmap cache lookups */
#define USE_CRC
#define XR_RGB2BGR(a_ulColor) \
(a_ulColor & 0xFF000000) | \
((a_ulColor & 0x00FF0000) >> 16) | \
(a_ulColor & 0x0000FF00) | \
((a_ulColor & 0x000000FF) << 16)
#endif

@ -43,22 +43,10 @@ AC_ARG_ENABLE(tjpeg, AS_HELP_STRING([--enable-tjpeg],
[Build turbo jpeg module (default: no)]),
[tjpeg=true], [tjpeg=false])
AM_CONDITIONAL(XRDP_TJPEG, [test x$tjpeg = xtrue])
AC_ARG_ENABLE(simplesound, AS_HELP_STRING([--enable-simplesound],
[Build simple pulse audio interface (default: no)]),
[simplesound=true], [simplesound=false])
AM_CONDITIONAL(XRDP_SIMPLESOUND, [test x$simplesound = xtrue])
AC_ARG_ENABLE(fuse, AS_HELP_STRING([--enable-fuse],
[Build fuse(clipboard file / drive redir) (default: no)]),
[fuse=true], [fuse=false])
AM_CONDITIONAL(XRDP_FUSE, [test x$fuse = xtrue])
AC_ARG_ENABLE(loadpulsemodules, AS_HELP_STRING([--enable-loadpulsemodules],
[Build code to load pulse audio modules (default: no)]),
[loadpulsemodules=true], [loadpulsemodules=false])
AM_CONDITIONAL(XRDP_LOAD_PULSE_MODULES, [test x$loadpulsemodules = xtrue])
AC_ARG_ENABLE(xrdpvr, AS_HELP_STRING([--enable-xrdpvr],
[Build xrdpvr module (default: no)]),
[xrdpvr=true], [xrdpvr=false])
@ -113,20 +101,6 @@ then
[#define _FILE_OFFSET_BITS 64])
fi
# checking for libpulse
if ! test -z "$enable_loadpulsemodules"
then
AC_CHECK_HEADER([pulse/util.h], [],
[AC_MSG_ERROR([please install libpulse-dev or libpulse-devel])])
fi
# checking for libpulse libpulse-simple
if ! test -z "$enable_simplesound"
then
AC_CHECK_HEADER([pulse/simple.h], [],
[AC_MSG_ERROR([please install libpulse-dev or libpulse-devel])])
fi
# checking for TurboJPEG
if ! test -z "$enable_tjpeg"
then

@ -117,9 +117,10 @@ struct xrdp_sec
void *decrypt_rc4_info;
void *encrypt_rc4_info;
char pub_exp[4];
char pub_mod[64];
char pub_mod[256];
char pub_sig[64];
char pri_exp[64];
char pri_exp[256];
int rsa_key_bytes; /* 64 or 256 */
int channel_code;
int multimon;
char fips_encrypt_key[24];
@ -509,7 +510,7 @@ int APP_CC
xrdp_bitmap32_compress(char *in_data, int width, int height,
struct stream *s, int bpp, int byte_limit,
int start_line, struct stream *temp_s,
int e);
int e, int flags);
int APP_CC
xrdp_jpeg_compress(void *handle, char *in_data, int width, int height,
struct stream *s, int bpp, int byte_limit,

@ -19,14 +19,499 @@
* 32 bpp compression
*/
/*
RDP 6.0 Bitmap Compression
http://msdn.microsoft.com/en-us/library/cc241877.aspx
*/
#include "libxrdp.h"
#define FLAGS_RLE 0x10
#define FLAGS_NOALPHA 0x20
#define LLOG_LEVEL 1
#define LLOGLN(_level, _args) \
do { if (_level < LLOG_LEVEL) { g_writeln _args ; } } while (0)
#define LHEXDUMP(_level, _args) \
do { if (_level < LLOG_LEVEL) { g_hexdump _args ; } } while (0)
/*****************************************************************************/
/* split ARGB */
static int APP_CC
fsplit4(char *in_data, int start_line, int width, int e,
char *alpha_data, char *red_data, char *green_data, char *blue_data)
{
#if defined(L_ENDIAN)
int alpha;
int red;
int green;
int blue;
#endif
int index;
int out_index;
int pixel;
int cy;
int *ptr32;
cy = 0;
out_index = 0;
while (start_line >= 0)
{
ptr32 = (int *) (in_data + start_line * width * 4);
index = 0;
#if defined(L_ENDIAN)
while (index + 4 <= width)
{
pixel = *ptr32;
ptr32++;
alpha = (pixel >> 24) & 0x000000ff;
red = (pixel >> 16) & 0x000000ff;
green = (pixel >> 8) & 0x000000ff;
blue = (pixel >> 0) & 0x000000ff;
pixel = *ptr32;
ptr32++;
alpha |= (pixel >> 16) & 0x0000ff00;
red |= (pixel >> 8) & 0x0000ff00;
green |= (pixel << 0) & 0x0000ff00;
blue |= (pixel << 8) & 0x0000ff00;
pixel = *ptr32;
ptr32++;
alpha |= (pixel >> 8) & 0x00ff0000;
red |= (pixel >> 0) & 0x00ff0000;
green |= (pixel << 8) & 0x00ff0000;
blue |= (pixel << 16) & 0x00ff0000;
pixel = *ptr32;
ptr32++;
alpha |= (pixel << 0) & 0xff000000;
red |= (pixel << 8) & 0xff000000;
green |= (pixel << 16) & 0xff000000;
blue |= (pixel << 24) & 0xff000000;
*((int*)(alpha_data + out_index)) = alpha;
*((int*)(red_data + out_index)) = red;
*((int*)(green_data + out_index)) = green;
*((int*)(blue_data + out_index)) = blue;
out_index += 4;
index += 4;
}
#endif
while (index < width)
{
pixel = *ptr32;
ptr32++;
alpha_data[out_index] = pixel >> 24;
red_data[out_index] = pixel >> 16;
green_data[out_index] = pixel >> 8;
blue_data[out_index] = pixel >> 0;
out_index++;
index++;
}
for (index = 0; index < e; index++)
{
alpha_data[out_index] = alpha_data[out_index - 1];
red_data[out_index] = red_data[out_index - 1];
green_data[out_index] = green_data[out_index - 1];
blue_data[out_index] = blue_data[out_index - 1];
out_index++;
}
start_line--;
cy++;
}
return cy;
}
/*****************************************************************************/
/* split RGB */
static int APP_CC
fsplit3(char *in_data, int start_line, int width, int e,
char *red_data, char *green_data, char *blue_data)
{
#if defined(L_ENDIAN)
int red;
int green;
int blue;
#endif
int index;
int out_index;
int pixel;
int cy;
int *ptr32;
cy = 0;
out_index = 0;
while (start_line >= 0)
{
ptr32 = (int *) (in_data + start_line * width * 4);
index = 0;
#if defined(L_ENDIAN)
while (index + 4 <= width)
{
pixel = *ptr32;
ptr32++;
red = (pixel >> 16) & 0x000000ff;
green = (pixel >> 8) & 0x000000ff;
blue = (pixel >> 0) & 0x000000ff;
pixel = *ptr32;
ptr32++;
red |= (pixel >> 8) & 0x0000ff00;
green |= (pixel << 0) & 0x0000ff00;
blue |= (pixel << 8) & 0x0000ff00;
pixel = *ptr32;
ptr32++;
red |= (pixel >> 0) & 0x00ff0000;
green |= (pixel << 8) & 0x00ff0000;
blue |= (pixel << 16) & 0x00ff0000;
pixel = *ptr32;
ptr32++;
red |= (pixel << 8) & 0xff000000;
green |= (pixel << 16) & 0xff000000;
blue |= (pixel << 24) & 0xff000000;
*((int*)(red_data + out_index)) = red;
*((int*)(green_data + out_index)) = green;
*((int*)(blue_data + out_index)) = blue;
out_index += 4;
index += 4;
}
#endif
while (index < width)
{
pixel = *ptr32;
ptr32++;
red_data[out_index] = pixel >> 16;
green_data[out_index] = pixel >> 8;
blue_data[out_index] = pixel >> 0;
out_index++;
index++;
}
for (index = 0; index < e; index++)
{
red_data[out_index] = red_data[out_index - 1];
green_data[out_index] = green_data[out_index - 1];
blue_data[out_index] = blue_data[out_index - 1];
out_index++;
}
start_line--;
cy++;
}
return cy;
}
/*****************************************************************************/
static int APP_CC
fdelta(char *in_plane, char *out_plane, int cx, int cy)
{
char delta;
char *src8;
char *dst8;
int index;
int jndex;
g_memcpy(out_plane, in_plane, cx);
for (jndex = cy - 2; jndex >= 0; jndex--)
{
src8 = in_plane + jndex * cx;
dst8 = out_plane + jndex * cx;
for (index = 0; index < cx; index++)
{
delta = src8[cx] - src8[0];
if (delta & 0x80)
{
delta = (((~delta) + 1) << 1) - 1;
}
else
{
delta = delta << 1;
}
dst8[cx] = delta;
src8++;
dst8++;
}
}
return 0;
}
/*****************************************************************************/
static int APP_CC
fout(int collen, int replen, char *colptr, struct stream *s)
{
int code;
int lcollen;
int lreplen;
int cont;
LLOGLN(10, ("fout: collen %d replen %d", collen, replen));
cont = collen > 13;
while (cont)
{
lcollen = collen;
if (lcollen > 15)
{
lcollen = 15;
}
code = lcollen << 4;
out_uint8(s, code);
out_uint8a(s, colptr, lcollen);
colptr += lcollen;
collen -= lcollen;
cont = collen > 13;
}
cont = (collen > 0) || (replen > 0);
while (cont)
{
lreplen = replen;
if ((collen == 0) && (lreplen > 15))
{
/* big run */
if (lreplen > 47)
{
lreplen = 47;
}
LLOGLN(10, ("fout: big run lreplen %d", lreplen));
replen -= lreplen;
code = ((lreplen & 0xF) << 4) | ((lreplen & 0xF0) >> 4);
}
else
{
if (lreplen > 15)
{
lreplen = 15;
}
replen -= lreplen;
if (lreplen < 3)
{
collen += lreplen;
lreplen = 0;
}
code = (collen << 4) | lreplen;
}
out_uint8(s, code);
out_uint8a(s, colptr, collen);
colptr += collen + lreplen;
collen = 0;
cont = replen > 0;
}
return 0;
}
/*****************************************************************************/
static int APP_CC
fpack(char *plane, int cx, int cy, struct stream *s)
{
char *ptr8;
char *colptr;
char *lend;
char *holdp;
int jndex;
int collen;
int replen;
LLOGLN(10, ("fpack:"));
holdp = s->p;
for (jndex = 0; jndex < cy; jndex++)
{
LLOGLN(10, ("line start line %d cx %d cy %d", jndex, cx, cy));
ptr8 = plane + jndex * cx;
LHEXDUMP(10, (ptr8, cx));
lend = ptr8 + (cx - 1);
colptr = ptr8;
if (colptr[0] == 0)
{
collen = 0;
replen = 1;
}
else
{
collen = 1;
replen = 0;
}
while (ptr8 < lend)
{
if (ptr8[0] == ptr8[1])
{
replen++;
}
else
{
if (replen > 0)
{
if (replen < 3)
{
collen += replen + 1;
replen = 0;
}
else
{
fout(collen, replen, colptr, s);
colptr = ptr8 + 1;
replen = 0;
collen = 1;
}
}
else
{
collen++;
}
}
ptr8++;
}
/* end of line */
fout(collen, replen, colptr, s);
}
return (int) (s->p - holdp);
}
/*****************************************************************************/
static int APP_CC
foutraw3(struct stream *s, int bytes, int header,
char *red_data, char *green_data, char *blue_data)
{
out_uint8(s, header);
out_uint8a(s, red_data, bytes);
out_uint8a(s, green_data, bytes);
out_uint8a(s, blue_data, bytes);
/* pad if no RLE */
out_uint8(s, 0x00);
return 0;
}
/*****************************************************************************/
static int APP_CC
foutraw4(struct stream *s, int bytes, int header,
char *alpha_data, char *red_data, char *green_data, char *blue_data)
{
out_uint8(s, header);
out_uint8a(s, alpha_data, bytes);
out_uint8a(s, red_data, bytes);
out_uint8a(s, green_data, bytes);
out_uint8a(s, blue_data, bytes);
/* pad if no RLE */
out_uint8(s, 0x00);
return 0;
}
/*****************************************************************************/
/* returns the number of lines compressed */
int APP_CC
xrdp_bitmap32_compress(char *in_data, int width, int height,
struct stream *s, int bpp, int byte_limit,
int start_line, struct stream *temp_s,
int e)
int e, int flags)
{
return 0;
char *alpha_data;
char *red_data;
char *green_data;
char *blue_data;
char *salpha_data;
char *sred_data;
char *sgreen_data;
char *sblue_data;
int alpha_bytes;
int red_bytes;
int green_bytes;
int blue_bytes;
int cx;
int cy;
int max_bytes;
int total_bytes;
int header;
LLOGLN(10, ("xrdp_bitmap32_compress:"));
header = flags & 0xFF;
cx = width + e;
salpha_data = temp_s->data;
sred_data = salpha_data + cx * height;
sgreen_data = sred_data + cx * height;
sblue_data = sgreen_data + cx * height;
alpha_data = sblue_data + cx * height;
red_data = alpha_data + cx * height;
green_data = red_data + cx * height;
blue_data = green_data + cx * height;
if (header & FLAGS_NOALPHA)
{
cy = fsplit3(in_data, start_line, width, e,
sred_data, sgreen_data, sblue_data);
if (header & FLAGS_RLE)
{
fdelta(sred_data, red_data, cx, cy);
fdelta(sgreen_data, green_data, cx, cy);
fdelta(sblue_data, blue_data, cx, cy);
out_uint8(s, header);
red_bytes = fpack(red_data, cx, cy, s);
green_bytes = fpack(green_data, cx, cy, s);
blue_bytes = fpack(blue_data, cx, cy, s);
total_bytes = red_bytes + green_bytes + blue_bytes;
if (1 + total_bytes > byte_limit)
{
/* failed */
LLOGLN(0, ("xrdp_bitmap32_compress: too big, rgb "
"bytes %d %d %d total_bytes %d cx %d cy %d byte_limit %d",
red_bytes, green_bytes, blue_bytes,
total_bytes, cx, cy, byte_limit));
return 0;
}
max_bytes = cx * cy * 3;
if (total_bytes > max_bytes)
{
/* raw is better */
LLOGLN(10, ("xrdp_bitmap32_compress: too big, rgb "
"bytes %d %d %d total_bytes %d cx %d cy %d max_bytes %d",
red_bytes, green_bytes, blue_bytes,
total_bytes, cx, cy, max_bytes));
init_stream(s, 0);
foutraw3(s, cx * cy, FLAGS_NOALPHA, sred_data,
sgreen_data, sblue_data);
}
}
else
{
foutraw3(s, cx * cy, FLAGS_NOALPHA, sred_data,
sgreen_data, sblue_data);
}
}
else
{
cy = fsplit4(in_data, start_line, width, e,
salpha_data, sred_data, sgreen_data, sblue_data);
if (header & FLAGS_RLE)
{
fdelta(salpha_data, alpha_data, cx, cy);
fdelta(sred_data, red_data, cx, cy);
fdelta(sgreen_data, green_data, cx, cy);
fdelta(sblue_data, blue_data, cx, cy);
out_uint8(s, header);
alpha_bytes = fpack(alpha_data, cx, cy, s);
red_bytes = fpack(red_data, cx, cy, s);
green_bytes = fpack(green_data, cx, cy, s);
blue_bytes = fpack(blue_data, cx, cy, s);
max_bytes = cx * cy * 4;
total_bytes = alpha_bytes + red_bytes + green_bytes + blue_bytes;
if (1 + total_bytes > byte_limit)
{
/* failed */
LLOGLN(0, ("xrdp_bitmap32_compress: too big, argb "
"bytes %d %d %d %d total_bytes %d cx %d cy %d byte_limit %d",
alpha_bytes, red_bytes, green_bytes, blue_bytes,
total_bytes, cx, cy, byte_limit));
return 0;
}
if (total_bytes > max_bytes)
{
/* raw is better */
LLOGLN(10, ("xrdp_bitmap32_compress: too big, argb "
"bytes %d %d %d %d total_bytes %d cx %d cy %d max_bytes %d",
alpha_bytes, red_bytes, green_bytes, blue_bytes,
total_bytes, cx, cy, max_bytes));
init_stream(s, 0);
foutraw4(s, cx * cy, 0, salpha_data, sred_data,
sgreen_data, sblue_data);
}
}
else
{
foutraw4(s, cx * cy, 0, salpha_data, sred_data,
sgreen_data, sblue_data);
}
}
return cy;
}

@ -2322,13 +2322,22 @@ xrdp_orders_send_bitmap(struct xrdp_orders *self,
}
make_stream(s);
init_stream(s, 16384);
init_stream(s, 16384 * 2);
make_stream(temp_s);
init_stream(temp_s, 16384);
init_stream(temp_s, 16384 * 2);
p = s->p;
i = height;
lines_sending = xrdp_bitmap_compress(data, width, height, s, bpp, 16384,
i - 1, temp_s, e);
if (bpp > 24)
{
lines_sending = xrdp_bitmap32_compress(data, width, height, s,
bpp, 16384,
i - 1, temp_s, e, 0x30);
}
else
{
lines_sending = xrdp_bitmap_compress(data, width, height, s, bpp, 16384,
i - 1, temp_s, e);
}
if (lines_sending != height)
{
@ -2582,15 +2591,16 @@ xrdp_orders_send_bitmap2(struct xrdp_orders *self,
}
make_stream(s);
init_stream(s, 16384);
init_stream(s, 16384 * 2);
make_stream(temp_s);
init_stream(temp_s, 16384);
init_stream(temp_s, 16384 * 2);
p = s->p;
i = height;
if (bpp > 24)
{
lines_sending = xrdp_bitmap32_compress(data, width, height, s, bpp, 16384,
i - 1, temp_s, e);
lines_sending = xrdp_bitmap32_compress(data, width, height, s,
bpp, 16384,
i - 1, temp_s, e, 0x30);
}
else
{

@ -16,21 +16,11 @@ EXTRA_INCLUDES =
EXTRA_LIBS =
EXTRA_FLAGS =
if XRDP_SIMPLESOUND
EXTRA_DEFINES += -DXRDP_SIMPLESOUND
EXTRA_LIBS += -lpthread -lpulse -lpulse-simple
endif
if XRDP_FUSE
EXTRA_DEFINES += -DXRDP_FUSE
EXTRA_LIBS += -lfuse
endif
if XRDP_LOAD_PULSE_MODULES
EXTRA_DEFINES += -DXRDP_LOAD_PULSE_MODULES
EXTRA_LIBS += -lpulse
endif
AM_CFLAGS = \
-DXRDP_CFG_PATH=\"${sysconfdir}/xrdp\" \
-DXRDP_SBIN_PATH=\"${sbindir}\" \

@ -1,7 +1,7 @@
/**
* xrdp: A Remote Desktop Protocol server.
*
* Copyright (C) Jay Sorg 2009-2013
* Copyright (C) Jay Sorg 2009-2014
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -23,10 +23,6 @@
#include <signal.h>
#include <sys/un.h>
#ifdef XRDP_LOAD_PULSE_MODULES
#include <pulse/util.h>
#endif
#include "sound.h"
#include "thread_calls.h"
#include "defines.h"
@ -56,11 +52,6 @@ int g_buf_index = 0;
int g_sent_time[256];
int g_sent_flag[256];
#if defined(XRDP_SIMPLESOUND)
static void *DEFAULT_CC
read_raw_audio_data(void *arg);
#endif
#define CHANSRV_PORT_OUT_STR "/tmp/.xrdp/xrdp_chansrv_audio_out_socket_%d"
#define CHANSRV_PORT_IN_STR "/tmp/.xrdp/xrdp_chansrv_audio_in_socket_%d"
@ -655,11 +646,6 @@ sound_init(void)
g_memset(g_sent_flag, 0, sizeof(g_sent_flag));
#ifdef XRDP_LOAD_PULSE_MODULES
if (load_pulse_modules())
LOG(0, ("Audio and microphone redirection will not work!"));
#endif
/* init sound output */
sound_send_server_output_formats();
@ -685,13 +671,6 @@ sound_init(void)
/* save data from sound_server_source */
fifo_init(&in_fifo, 100);
#if defined(XRDP_SIMPLESOUND)
/* start thread to read raw audio data from pulseaudio device */
tc_thread_create(read_raw_audio_data, 0);
#endif
return 0;
}
@ -726,10 +705,6 @@ sound_deinit(void)
fifo_deinit(&in_fifo);
#ifdef XRDP_LOAD_PULSE_MODULES
system("pulseaudio --kill");
#endif
return 0;
}
@ -841,158 +816,6 @@ sound_check_wait_objs(void)
return 0;
}
/**
* Load xrdp pulseaudio sink and source modules
*
* @return 0 on success, -1 on failure
*****************************************************************************/
#ifdef XRDP_LOAD_PULSE_MODULES
static int APP_CC
load_pulse_modules()
{
struct sockaddr_un sa;
pid_t pid;
char* cli;
int fd;
int i;
int rv;
char buf[1024];
/* is pulse audio daemon running? */
if (pa_pid_file_check_running(&pid, "pulseaudio") < 0)
{
LOG(0, ("load_pulse_modules: No PulseAudio daemon running, "
"or not running as session daemon"));
}
/* get name of unix domain socket used by pulseaudio for CLI */
if ((cli = (char *) pa_runtime_path("cli")) == NULL)
{
LOG(0, ("load_pulse_modules: Error getting PulesAudio runtime path"));
return -1;
}
/* open a socket */
if ((fd = socket(PF_LOCAL, SOCK_STREAM, 0)) < 0)
{
pa_xfree(cli);
LOG(0, ("load_pulse_modules: Socket open error"));
return -1;
}
/* set it up */
memset(&sa, 0, sizeof(struct sockaddr_un));
sa.sun_family = AF_UNIX;
pa_strlcpy(sa.sun_path, cli, sizeof(sa.sun_path));
pa_xfree(cli);
for (i = 0; i < 20; i++)
{
if (pa_pid_file_kill(SIGUSR2, NULL, "pulseaudio") < 0)
LOG(0, ("load_pulse_modules: Failed to kill PulseAudio daemon"));
if ((rv = connect(fd, (struct sockaddr*) &sa, sizeof(sa))) < 0 &&
(errno != ECONNREFUSED && errno != ENOENT))
{
LOG(0, ("load_pulse_modules: connect() failed with error: %s",
strerror(errno)));
return -1;
}
if (rv >= 0)
break;
pa_msleep(300);
}
if (i >= 20)
{
LOG(0, ("load_pulse_modules: Daemon not responding"));
return -1;
}
LOG(0, ("load_pulse_modules: connected to pulseaudio daemon"));
/* read back PulseAudio sign on message */
memset(buf, 0, 1024);
recv(fd, buf, 1024, 0);
/* send cmd to load source module */
memset(buf, 0, 1024);
sprintf(buf, "load-module module-xrdp-source\n");
send(fd, buf, strlen(buf), 0);
/* read back response */
memset(buf, 0, 1024);
recv(fd, buf, 1024, 0);
if (strcasestr(buf, "Module load failed") != 0)
{
LOG(0, ("load_pulse_modules: Error loading module-xrdp-source"));
}
else
{
LOG(0, ("load_pulse_modules: Loaded module-xrdp-source"));
/* success, set it as the default source */
memset(buf, 0, 1024);
sprintf(buf, "set-default-source xrdp-source\n");
send(fd, buf, strlen(buf), 0);
memset(buf, 0, 1024);
recv(fd, buf, 1024, 0);
if (strcasestr(buf, "does not exist") != 0)
{
LOG(0, ("load_pulse_modules: Error setting default source"));
}
else
{
LOG(0, ("load_pulse_modules: set default source"));
}
}
/* send cmd to load sink module */
memset(buf, 0, 1024);
sprintf(buf, "load-module module-xrdp-sink\n");
send(fd, buf, strlen(buf), 0);
/* read back response */
memset(buf, 0, 1024);
recv(fd, buf, 1024, 0);
if (strcasestr(buf, "Module load failed") != 0)
{
LOG(0, ("load_pulse_modules: Error loading module-xrdp-sink"));
}
else
{
LOG(0, ("load_pulse_modules: Loaded module-xrdp-sink"));
/* success, set it as the default sink */
memset(buf, 0, 1024);
sprintf(buf, "set-default-sink xrdp-sink\n");
send(fd, buf, strlen(buf), 0);
memset(buf, 0, 1024);
recv(fd, buf, 1024, 0);
if (strcasestr(buf, "does not exist") != 0)
{
LOG(0, ("load_pulse_modules: Error setting default sink"));
}
else
{
LOG(0, ("load_pulse_modules: set default sink"));
}
}
close(fd);
return 0;
}
#endif
/******************************************************************************
** **
** Microphone releated code **
@ -1326,131 +1149,3 @@ sound_sndsrvr_source_data_in(struct trans *trans)
return 0;
}
/*****************************************************************************/
#if defined(XRDP_SIMPLESOUND)
#define AUDIO_BUF_SIZE 2048
static int DEFAULT_CC
sttrans_data_in(struct trans *self)
{
LOG(0, ("sttrans_data_in:\n"));
return 0;
}
/**
* read raw audio data from pulseaudio device and write it
* to a unix domain socket on which trans server is listening
*/
static void *DEFAULT_CC
read_raw_audio_data(void *arg)
{
pa_sample_spec samp_spec;
pa_simple *simple = NULL;
uint32_t bytes_read;
char *cptr;
int i;
int error;
struct trans *strans;
char path[256];
struct stream *outs;
strans = trans_create(TRANS_MODE_UNIX, 8192, 8192);
if (strans == 0)
{
LOG(0, ("read_raw_audio_data: trans_create failed\n"));
return 0;
}
strans->trans_data_in = sttrans_data_in;
g_snprintf(path, 255, CHANSRV_PORT_OUT_STR, g_display_num);
if (trans_connect(strans, "", path, 100) != 0)
{
LOG(0, ("read_raw_audio_data: trans_connect failed\n"));
trans_delete(strans);
return 0;
}
/* setup audio format */
samp_spec.format = PA_SAMPLE_S16LE;
samp_spec.rate = 44100;
samp_spec.channels = 2;
/* if we are root, then for first 8 seconds connection to pulseaudo server
fails; if we are non-root, then connection succeeds on first attempt;
for now we have changed code to be non-root, but this may change in the
future - so pretend we are root and try connecting to pulseaudio server
for upto one minute */
for (i = 0; i < 60; i++)
{
simple = pa_simple_new(NULL, "xrdp", PA_STREAM_RECORD, NULL,
"record", &samp_spec, NULL, NULL, &error);
if (simple)
{
/* connected to pulseaudio server */
LOG(0, ("read_raw_audio_data: connected to pulseaudio server\n"));
break;
}
LOG(0, ("read_raw_audio_data: ERROR creating PulseAudio async interface\n"));
LOG(0, ("read_raw_audio_data: %s\n", pa_strerror(error)));
g_sleep(1000);
}
if (i == 60)
{
/* failed to connect to audio server */
trans_delete(strans);
return NULL;
}
/* insert header just once */
outs = trans_get_out_s(strans, 8192);
out_uint32_le(outs, 0);
out_uint32_le(outs, AUDIO_BUF_SIZE + 8);
cptr = outs->p;
out_uint8s(outs, AUDIO_BUF_SIZE);
s_mark_end(outs);
while (1)
{
/* read a block of raw audio data... */
g_memset(cptr, 0, 4);
bytes_read = pa_simple_read(simple, cptr, AUDIO_BUF_SIZE, &error);
if (bytes_read < 0)
{
LOG(0, ("read_raw_audio_data: ERROR reading from pulseaudio stream\n"));
LOG(0, ("read_raw_audio_data: %s\n", pa_strerror(error)));
break;
}
/* bug workaround:
even when there is no audio data, pulseaudio is returning without
errors but the data itself is zero; we use this zero data to
determine that there is no audio data present */
if (*cptr == 0 && *(cptr + 1) == 0 && *(cptr + 2) == 0 && *(cptr + 3) == 0)
{
g_sleep(10);
continue;
}
if (trans_force_write_s(strans, outs) != 0)
{
LOG(0, ("read_raw_audio_data: ERROR writing audio data to server\n"));
break;
}
}
pa_simple_free(simple);
trans_delete(strans);
return NULL;
}
#endif

@ -1,7 +1,7 @@
/**
* xrdp: A Remote Desktop Protocol server.
*
* Copyright (C) Jay Sorg 2009-2013
* Copyright (C) Jay Sorg 2009-2014
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -19,11 +19,6 @@
#ifndef _SOUND_H_
#define _SOUND_H_
#if defined(XRDP_SIMPLESOUND)
#include <pulse/simple.h>
#include <pulse/error.h>
#endif
#include "arch.h"
#include "parse.h"
#include "os_calls.h"
@ -75,5 +70,5 @@ static int APP_CC sound_input_start_recording();
static int APP_CC sound_input_stop_recording();
static int APP_CC sound_process_input_data(struct stream *s, int bytes);
static int DEFAULT_CC sound_sndsrvr_source_data_in(struct trans *trans);
static int APP_CC load_pulse_modules();
#endif

@ -1563,7 +1563,7 @@ convert_pixel(int in_pixel)
if (g_rdpScreen.depth == 24)
{
if (g_rdpScreen.rdp_bpp == 24)
if (g_rdpScreen.rdp_bpp >= 24)
{
rv = in_pixel;
SPLITCOLOR32(red, green, blue, rv);
@ -1619,7 +1619,7 @@ convert_pixels(void *src, void *dst, int num_pixels)
{
src32 = (unsigned int *)src;
if (g_rdpScreen.rdp_bpp == 24)
if (g_rdpScreen.rdp_bpp >= 24)
{
dst32 = (unsigned int *)dst;

@ -68,6 +68,9 @@ ls_height=430
# login screen background color in RGB format
ls_bg_color=dedede
# optional background image filename (bmp format).
#ls_background_image=
# logo
# full path to bmp-file or file in shared folder
ls_logo_filename=

@ -679,7 +679,7 @@ xrdp_bitmap_get_pixel(struct xrdp_bitmap *self, int x, int y)
{
return GETPIXEL16(self->data, x, y, self->width);
}
else if (self->bpp == 24)
else if (self->bpp >= 24)
{
return GETPIXEL32(self->data, x, y, self->width);
}
@ -712,7 +712,7 @@ xrdp_bitmap_set_pixel(struct xrdp_bitmap *self, int x, int y, int pixel)
{
SETPIXEL16(self->data, x, y, self->width, pixel);
}
else if (self->bpp == 24)
else if (self->bpp >= 24)
{
SETPIXEL32(self->data, x, y, self->width, pixel);
}
@ -779,7 +779,7 @@ xrdp_bitmap_copy_box(struct xrdp_bitmap *self,
return 1;
}
if (self->bpp == 24)
if (self->bpp >= 24)
{
s32 = ((tui32 *)(self->data)) + (self->width * y + x);
d32 = ((tui32 *)(dest->data)) + (dest->width * desty + destx);
@ -849,7 +849,7 @@ xrdp_bitmap_hash_crc(struct xrdp_bitmap *self)
int index;
char hash_data[16];
if (self->bpp == 24)
if (self->bpp >= 24)
{
bytes = self->width * self->height * 4;
}
@ -953,7 +953,76 @@ xrdp_bitmap_copy_box_with_crc(struct xrdp_bitmap *self,
CRC_PASS(self->height, crc);
CRC_PASS(self->height >> 8, crc);
if (self->bpp == 24)
if (self->bpp == 32)
{
s32 = ((tui32 *)(self->data)) + (self->width * y + x);
d32 = ((tui32 *)(dest->data)) + (dest->width * desty + destx);
incs = self->width - cx;
incd = dest->width - cx;
for (i = 0; i < cy; i++)
{
j = 0;
while (j < cx - 4)
{
pixel = *s32;
*d32 = pixel;
CRC_PASS(pixel, crc);
CRC_PASS(pixel >> 8, crc);
CRC_PASS(pixel >> 16, crc);
CRC_PASS(pixel >> 24, crc);
s32++;
d32++;
pixel = *s32;
*d32 = pixel;
CRC_PASS(pixel, crc);
CRC_PASS(pixel >> 8, crc);
CRC_PASS(pixel >> 16, crc);
CRC_PASS(pixel >> 24, crc);
s32++;
d32++;
pixel = *s32;
*d32 = pixel;
CRC_PASS(pixel, crc);
CRC_PASS(pixel >> 8, crc);
CRC_PASS(pixel >> 16, crc);
CRC_PASS(pixel >> 24, crc);
s32++;
d32++;
pixel = *s32;
*d32 = pixel;
CRC_PASS(pixel, crc);
CRC_PASS(pixel >> 8, crc);
CRC_PASS(pixel >> 16, crc);
CRC_PASS(pixel >> 24, crc);
s32++;
d32++;
j += 4;
}
while (j < cx)
{
pixel = *s32;
*d32 = pixel;
CRC_PASS(pixel, crc);
CRC_PASS(pixel >> 8, crc);
CRC_PASS(pixel >> 16, crc);
CRC_PASS(pixel >> 24, crc);
s32++;
d32++;
j += 1;
}
s32 += incs;
d32 += incd;
}
}
else if (self->bpp == 24)
{
s32 = ((tui32 *)(self->data)) + (self->width * y + x);
d32 = ((tui32 *)(dest->data)) + (dest->width * desty + destx);

@ -576,6 +576,23 @@ xrdp_login_wnd_create(struct xrdp_wm *self)
if (regular)
{
// Load the background image.
// If no file is specified no default image will be loaded.
// We only load the image if bpp > 8
if (globals->ls_background_image[0] != 0 && self->screen->bpp > 8)
{
char fileName[256] ;
but = xrdp_bitmap_create(4, 4, self->screen->bpp, WND_TYPE_IMAGE, self);
g_snprintf(fileName, 255, "%s/%s", XRDP_SHARE_PATH, globals->ls_background_image);
log_message(LOG_LEVEL_DEBUG, "We try to load the following background file: %s", fileName);
xrdp_bitmap_load(but, fileName, self->palette);
but->parent = self->screen;
but->owner = self->screen;
but->left = self->screen->width - but->width;
but->top = self->screen->height - but->height;
list_add_item(self->screen->child_list, (long)but);
}
/* if logo image not specified, use default */
if (globals->ls_logo_filename[0] == 0)
g_snprintf(globals->ls_logo_filename, 255, "%s/xrdp_logo.bmp", XRDP_SHARE_PATH);
@ -848,7 +865,11 @@ load_xrdp_config(struct xrdp_config *config, int bpp)
g_strncpy(globals->ls_logo_filename, v, 255);
globals->ls_logo_filename[255] = 0;
}
else if (g_strncmp(n, "ls_background_image", 255) == 0)
{
g_strncpy(globals->ls_background_image, v, 255);
globals->ls_background_image[255] = 0;
}
else if (g_strncmp(n, "ls_logo_x_pos", 64) == 0)
globals->ls_logo_x_pos = g_atoi(v);

@ -580,6 +580,7 @@ struct xrdp_cfg_globals
int ls_height; /* window height */
int ls_bg_color; /* background color */
char ls_logo_filename[256]; /* logo filename */
char ls_background_image[256]; /* background image file name */
int ls_logo_x_pos; /* logo x co-ordinate */
int ls_logo_y_pos; /* logo y co-ordinate */
int ls_label_x_pos; /* x pos of labels */

@ -178,11 +178,11 @@ lib_mod_connect(struct mod *mod)
mod->server_msg(mod, "started connecting", 0);
/* only support 8, 15, 16, and 24 bpp connections from rdp client */
if (mod->bpp != 8 && mod->bpp != 15 && mod->bpp != 16 && mod->bpp != 24)
/* only support 8, 15, 16, 24, and 32 bpp connections from rdp client */
if (mod->bpp != 8 && mod->bpp != 15 && mod->bpp != 16 && mod->bpp != 24 && mod->bpp != 32)
{
mod->server_msg(mod,
"error - only supporting 8, 15, 16, and 24 bpp rdp connections", 0);
"error - only supporting 8, 15, 16, 24, and 32 bpp rdp connections", 0);
LIB_DEBUG(mod, "out lib_mod_connect error");
return 1;
}

Loading…
Cancel
Save