Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GUACAMOLE-1140: Address RDP pipe svc race condition. #471

Closed
wants to merge 123 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
bce1d2a
GUACAMOLE-1436: Add winpr file.h dependencies as required.
necouchman Dec 27, 2021
c716a07
Merge 1.5.0 changes back to master.
necouchman Mar 17, 2022
9cbd768
GUACAMOLE-1312: Added fr_ca keymap
Feb 20, 2020
a175a3d
GUACAMOLE-1312: Merge add Canadian French RDP keymap
necouchman Mar 23, 2022
df4e5c6
GUACAMOLE-1595: Ensure all mouse buttons are initially released when …
mike-jumper May 3, 2022
8130005
GUACAMOLE-1595: Merge mouse mask initialization fix.
jmuehlner May 3, 2022
c469300
GUACAMOLE-377: Support for RDPGFX.
mike-jumper Jul 5, 2021
c795bf9
GUACAMOLE-377: Control RemoteFX / GFX support with "enable-gfx" param…
mike-jumper Sep 3, 2021
dd85c54
GUACAMOLE-377: Add handling for EndPaint required by software GDI imp…
mike-jumper Jul 13, 2021
c19eab9
GUACAMOLE-377: Revise processing lag calculations to consider cumulat…
mike-jumper Aug 31, 2021
52c8683
GUACAMOLE-377: Add protocol-level support for reporting remote frame …
mike-jumper Sep 2, 2021
669e02b
GUACAMOLE-377: Leverage RDPGFX to report remote frame statistics to t…
mike-jumper Sep 3, 2021
bde8cde
GUACAMOLE-377: Add general RDP support for frame markers.
mike-jumper Sep 3, 2021
a0e9f6e
GUACAMOLE-377: Leverage client timestamp tracking for RDP frame durat…
mike-jumper Sep 3, 2021
28396ae
GUACAMOLE-377: Expect explicit RDP frame boundaries only after at lea…
mike-jumper May 18, 2022
da80163
GUACAMOLE-377: Enable graphics pipeline extension by default.
mike-jumper May 18, 2022
b26f9d6
GUACAMOLE-377: Clarify usage of EndPaint to detect frames.
mike-jumper May 18, 2022
d5761ad
GUACAMOLE-377: Warn about required color depth only if actually overr…
mike-jumper May 18, 2022
b7f05b9
GUACAMOLE-377: Ensure backing surface of underlying FreeRDP GDI imple…
mike-jumper Jun 6, 2022
ce27936
GUACAMOLE-377: Add frame boundaries around cursor set operations if o…
mike-jumper Jun 6, 2022
31f1b2c
GUACAMOLE-377: Rename single-letter "e" event arguments variable to "…
mike-jumper Jun 9, 2022
d4cd9b3
GUACAMOLE-377: Merge support for RemoteFX.
jmuehlner Jun 10, 2022
1e9cd91
GUACAMOLE-1622: Added margins to ssh sessions.
aleitner Jun 3, 2022
a5834fd
GUACAMOLE-1622: Separated logic into single responsibility functions.
aleitner Jun 16, 2022
64ea9c4
GUACAMOLE-1622: Clarified comments to describe if param is a pointer.
aleitner Jun 21, 2022
ffb6c80
GUACAMOLE-1622: Merge addition of margins to ssh sessions.
jmuehlner Jun 22, 2022
9642afc
GUACAMOLE-377: Update unit tests for new prototype of guac_protocol_s…
mike-jumper Jul 5, 2022
4cf1bfa
GUACAMOLE-377: Merge update unit tests for new prototype of guac_prot…
necouchman Jul 5, 2022
51c640f
GUACAMOLE-1436: Merge addition of missing FreeRDP winpr headers.
mike-jumper Jul 5, 2022
523532a
GUACAMOLE-1636: Fix a typo mistake `offscren`.
myjimmy Jul 13, 2022
e8d966a
GUACAMOLE-1636: Fix a typo mistake `Versoin`.
myjimmy Jul 13, 2022
f438a36
GUACAMOLE-1636: Fix a typo mistake `synchonize`.
myjimmy Jul 13, 2022
98556fb
GUACAMOLE-1636: Fix a typo mistake `coordinare`.
myjimmy Jul 13, 2022
4048dd4
GUACAMOLE-1636: Fix a typo mistake `assicated`.
myjimmy Jul 13, 2022
cba5484
GUACAMOLE-1636: Fix a typo mistake `recieved`.
myjimmy Jul 13, 2022
6d994db
GUACAMOLE-1636: Fix a typo mistake `invokved`.
myjimmy Jul 13, 2022
0aae5ee
GUACAMOLE-1636: Merge corrections to typos within RDP comments/docume…
mike-jumper Jul 13, 2022
5bb56ed
GUACAMOLE-1622: Restructured code to resolve scrollbar resizing bug w…
aleitner Jul 7, 2022
eee3ac0
GUACAMOLE-1622: Merge correction to terminal resize regression.
mike-jumper Jul 13, 2022
cdee93a
GUACAMOLE-1652: Only call SSL init functions when the library version…
jmuehlner Jul 30, 2022
9c93337
GUACAMOLE-1652: Migrate OpenSSL initialization to modern methods for …
jmuehlner Jul 30, 2022
6ab8244
GUACAMOLE-1652: Merge only call SSL init functions when the library v…
necouchman Jul 30, 2022
15f6e9f
Merge 1.5.0 changes back to master.
jmuehlner Aug 16, 2022
5dbf482
Merge 1.5.0 changes back to master.
necouchman Aug 19, 2022
1971a9d
GUACAMOLE-1669: Prefer FIPS compliant ciphers and algorithms when FIP…
jmuehlner Aug 23, 2022
0361adc
GUACAMOLE-1669: Merge FIPS support for SSH connections.
mike-jumper Aug 24, 2022
dffbeac
GUACAMOLE-1674: Warn about NLA mode if FIPS mode is enabled, or disab…
jmuehlner Aug 30, 2022
4d211e0
GUACAMOLE-1674: Merge changes removing NLA from negotiation if FIPS i…
mike-jumper Sep 8, 2022
b096e47
GUACAMOLE-1669: Include ext-info-c in preferred KEX algorithms to ens…
jmuehlner Sep 13, 2022
b20afa2
GUACAMOLE-1669: Merge fix for RSA key upgrade failure if FIPS mode is…
mike-jumper Sep 13, 2022
bc52485
GUACAMOLE-1682: Normalize conflicting newline encodings in clipboards…
aleitner Oct 7, 2022
067f2a9
GUACAMOLE-1682: Merge automatic newline normalization of terminal cli…
mike-jumper Oct 18, 2022
6171da6
GUACAMOLE-1708: Added Czech keyboard keymap for RDP
mnaiman Nov 1, 2022
bad381c
GUACAMOLE-1708: Merge RDP support for Czech keyboard layout.
mike-jumper Nov 5, 2022
457a169
GUACAMOLE-1708: Added Czech keyboard keymap fix missing char
mnaiman Nov 6, 2022
3ca6bb0
GUACAMOLE-1708: Merge correction to missing Czech keyboard character …
mike-jumper Nov 6, 2022
5cf408e
GUACAMOLE-1714: Adapt to const parameters of ffmpeg 5.0.
dfandrich Mar 20, 2022
5594182
Merge 1.5.0 changes back to master.
mike-jumper Nov 26, 2022
add7ce3
Merge 1.5.0 changes back to master.
jmuehlner Nov 29, 2022
4afc1d8
Merge 1.5.0 changes back to master.
necouchman Jan 4, 2023
f6893ed
Merge 1.5.0 changes back to master.
mike-jumper Jan 11, 2023
3b0a9ba
GUACAMOLE-377: Send a sync instruction to users when synchronizing su…
aleitner Jan 18, 2023
98c2a6a
GUACAMOLE-377: Merge correction ensuring users receive a proper frame…
mike-jumper Jan 24, 2023
47b9360
GUACAMOLE-1714: Merge update guacenc for const parameters/values intr…
necouchman Feb 3, 2023
1ff7dd5
Merge 1.5.1 changes back to master.
mike-jumper Mar 15, 2023
23e42fb
GUACAMOLE-1717: Fix RDP cursor use of uninitialized memory
khoek Mar 17, 2023
a59af51
GUACAMOLE-1717: Merge fix RDP cursor use of uninitialized memory
necouchman Mar 20, 2023
07b9698
GUACAMOLE-377: Correct frame start and frame end timestamps when read…
aleitner Mar 8, 2023
77ec058
GUACAMOLE-377: Merge corrections to RDP frame boundary logic.
mike-jumper Mar 22, 2023
1d0b421
GUACAMOLE-600: Add support for setting the Telnet connection timeout.
necouchman Feb 16, 2023
e2e78e7
GUACAMOLE-1754: Run docker build for PR CI.
jmuehlner Mar 22, 2023
75a7039
GUACAMOLE-1761: Fix hungarian keymap
maraid Apr 3, 2023
a1d6d45
GUACAMOLE-1505: Avoid null pointer dereference in RDP protocol when d…
necouchman Apr 3, 2023
51dce6f
GUACAMOLE-1505: Merge correction to pointer cleanup within user leave…
mike-jumper Apr 3, 2023
6033bfc
GUACAMOLE-1754: Merge automatic PR verification builds.
mike-jumper Apr 4, 2023
49bddcf
GUACAMOLE-1761: Merge fix Latin i in Hungarian keymap
necouchman Apr 4, 2023
caade9e
Merge 1.5.1 changes back to master.
jmuehlner Apr 6, 2023
5314ec0
Merge 1.5.1 changes back to master.
necouchman Apr 10, 2023
8b93c34
GUACAMOLE-1771: add Portuguese keymap to RDP
vanntile Apr 13, 2023
ea17263
GUACAMOLE-1771: Merge add Portuguese keymap to RDP
necouchman Apr 13, 2023
6182685
GUACAMOLE-1770: add Romanian keymap to RDP
vanntile Apr 13, 2023
daffc29
GUACAMOLE-1770: Merge add Romanian keymap to RDP
necouchman Apr 14, 2023
f81b70f
Merge 1.5.2 changes back to master.
jmuehlner May 9, 2023
f378132
Merge 1.5.2 changes back to master.
jmuehlner May 17, 2023
cc50915
Merge 1.5.2 changes back to master.
jmuehlner May 17, 2023
d60177e
GUACAMOLE-1776: Batch up base64 encoding to reduce syscalls.
neandrake Apr 24, 2023
d9f7210
Merge 1.5.2 change back to master.
mike-jumper May 18, 2023
463831f
GUACAMOLE-1754: Run unit tests within Docker build.
mike-jumper May 18, 2023
fb2ef39
GUACAMOLE-1754: Merge change to run unit tests within Docker build.
jmuehlner May 18, 2023
7a092b0
GUACAMOLE-1776: Merge buffered base64 encoder.
mike-jumper May 18, 2023
48ac067
Merge 1.5.3 changes back to master.
mike-jumper Jun 7, 2023
162a75f
GUACAMOLE-1804: Support mac style paste shortcut.
jmuehlner Jun 7, 2023
98f9221
GUACAMOLE-1804: Merge support for pasting in terminal via Mac-style "…
mike-jumper Jun 8, 2023
c73c37b
GUACAMOLE-1805: Ignore unhandled copy shortcuts in terminal to avoid …
jmuehlner Jun 8, 2023
1aeba8b
GUACAMOLE-1805: Merge ignore unhandled copy shortcuts in terminal to …
necouchman Jun 8, 2023
b43b2d9
GUACAMOLE-1113: Support right hand modifiers in terminal.
jmuehlner Jun 8, 2023
e94b0a9
GUACAMOLE-1113: Merge support for right hand modifiers in terminal em…
mike-jumper Jun 13, 2023
1f14982
GUACAMOLE-1473: Disable AltGr handling for RDP keyboard layouts that …
jmuehlner Jun 14, 2023
1e9777a
GUACAMOLE-1473: Merge removal of AltGr from RDP keyboard layouts that…
mike-jumper Jun 16, 2023
f2b9aaf
GUACAMOLE-1290: Add support for ssh certificate authentication
Tejaswikandula Jun 28, 2023
870cc5f
Merge 1.5.3 changes back to master.
mike-jumper Jul 4, 2023
766b9f6
GUACAMOLE-1290: Minor changes to comments
Tejaswikandula Jul 11, 2023
80598ae
GUACAMOLE-1290: Merge support for ssh public certificate authentication
necouchman Aug 1, 2023
eae2428
Merge 1.5.4 changes back to master.
mike-jumper Aug 29, 2023
d44815d
Merge 1.5.4 changes back to master.
mike-jumper Aug 30, 2023
d7ad603
GUACAMOLE-377: Correct guac_common_display_dup() for compatibility wi…
mike-jumper Aug 30, 2023
fe24e2d
GUACAMOLE-377: Merge correct guac_common_display_dup() for compatibil…
necouchman Aug 30, 2023
694b3fc
GUACAMOLE-600: Merge support for setting the Telnet connection timeout.
mike-jumper Sep 6, 2023
fa4209c
GUACAMOLE-1332: Add support for certificate fingerprints and auto-acc…
necouchman Jul 20, 2023
d592106
GUACAMOLE-1332: Merge support for RDP certificate fingerprints and au…
mike-jumper Sep 11, 2023
125e33c
Merge 1.5.4 changes back to master.
mike-jumper Sep 13, 2023
9787017
Merge 1.5.4 changes back to master.
necouchman Sep 30, 2023
bb14ee9
Merge 1.5.4 changes back to master.
jmuehlner Oct 26, 2023
5b2eb7b
Merge 1.5.4 changes back to master.
necouchman Oct 26, 2023
8d3414e
Merge 1.5.4 changes back to master.
necouchman Oct 26, 2023
4c467d5
GUACAMOLE-1290: Migrate SSH certificate auth support to new memory ma…
mike-jumper Oct 26, 2023
f339b48
GUACAMOLE-1290: Merge migration of SSH certificate auth support to ne…
jmuehlner Oct 26, 2023
96704c5
GUACAMOLE-1869: Aligned library names
sbluhm Oct 20, 2023
c60f40c
GUACAMOLE-1875: Check return values of WebP API functions.
vrabaud Oct 26, 2023
88ece72
GUACAMOLE-1875: Merge check return values of WebP API functions.
necouchman Nov 7, 2023
8e3d759
GUACAMOLE-1869: Merge aligned library names in ./configure output
necouchman Nov 7, 2023
f0ab665
Merge 1.5.4 changes back to master.
necouchman Nov 22, 2023
2363681
GUACAMOLE-1140: Fix RDP pipe svc race condition with lock and null ch…
necouchman Dec 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Pull request CI build

# Run build for all pull requests
on:
pull_request:

# Limit to only one build for a given PR source branch at a time,
# cancelling any in-progress builds
concurrency:
group: guacamole-server-pr-${{ github.head_ref }}
cancel-in-progress: true

jobs:

docker_build:
name: Run docker build
runs-on: ubuntu-latest
steps:

- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 0
persist-credentials: false

- name: Build Docker container
shell: sh
run: |
docker build --pull --no-cache --force-rm .
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ RUN apk add --no-cache \
build-base \
cairo-dev \
cmake \
cunit-dev \
git \
grep \
libjpeg-turbo-dev \
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1243,7 +1243,7 @@ $PACKAGE_NAME version $PACKAGE_VERSION
freerdp2 ............ ${have_freerdp2}
pango ............... ${have_pango}
libavcodec .......... ${have_libavcodec}
libavformat.......... ${have_libavformat}
libavformat ......... ${have_libavformat}
libavutil ........... ${have_libavutil}
libssh2 ............. ${have_libssh2}
libssl .............. ${have_ssl}
Expand Down
24 changes: 24 additions & 0 deletions src/common-ssh/common-ssh/user.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ typedef struct guac_common_ssh_user {
*/
guac_common_ssh_key* private_key;

/**
* The public key which should be used to authenticate this user, if any,
* or NULL if a password or just a private key will be used instead.
*/
char* public_key;

} guac_common_ssh_user;

/**
Expand Down Expand Up @@ -104,5 +110,23 @@ void guac_common_ssh_user_set_password(guac_common_ssh_user* user,
int guac_common_ssh_user_import_key(guac_common_ssh_user* user,
char* private_key, char* passphrase);

/**
* Imports the given public key, associating that key with the given user.
* If the public key is imported successfully, it will be used for
* future authentication attempts.
*
* @param user
* The user to associate with the given private key.
*
* @param public_key
* The base64-encoded public key to import.
*
* @return
* Zero if public key is successfully imported, or non-zero if the
* public key could not be imported due to an error.
*/
int guac_common_ssh_user_import_public_key(guac_common_ssh_user* user,
char* public_key);

#endif

10 changes: 8 additions & 2 deletions src/common-ssh/ssh.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,11 @@ int guac_common_ssh_init(guac_client* client) {
CRYPTO_set_locking_callback(guac_common_ssh_openssl_locking_callback);
#endif

/* Init OpenSSL */
#if OPENSSL_VERSION_NUMBER < 0x10100000L
/* Init OpenSSL - only required for OpenSSL Versions < 1.1.0 */
SSL_library_init();
ERR_load_crypto_strings();
#endif

/* Init libssh2 */
libssh2_init(0);
Expand Down Expand Up @@ -284,6 +286,8 @@ static int guac_common_ssh_authenticate(guac_common_ssh_session* common_session)
/* Get user credentials */
guac_common_ssh_key* key = user->private_key;

char* public_key = user->public_key;

/* Validate username provided */
if (user->username == NULL) {
guac_client_abort(client, GUAC_PROTOCOL_STATUS_CLIENT_UNAUTHORIZED,
Expand Down Expand Up @@ -317,9 +321,11 @@ static int guac_common_ssh_authenticate(guac_common_ssh_session* common_session)
return 1;
}

int public_key_length = public_key == NULL ? 0 : strlen(public_key);

/* Attempt public key auth */
if (libssh2_userauth_publickey_frommemory(session, user->username,
username_len, NULL, 0, key->private_key,
username_len, public_key, public_key_length, key->private_key,
key->private_key_length, key->passphrase)) {

/* Abort on failure */
Expand Down
14 changes: 14 additions & 0 deletions src/common-ssh/user.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ guac_common_ssh_user* guac_common_ssh_create_user(const char* username) {
user->username = guac_strdup(username);
user->password = NULL;
user->private_key = NULL;
user->public_key = NULL;

return user;

Expand All @@ -48,6 +49,7 @@ void guac_common_ssh_destroy_user(guac_common_ssh_user* user) {
/* Free all other data */
guac_mem_free(user->password);
guac_mem_free(user->username);
guac_mem_free(user->public_key);
guac_mem_free(user);

}
Expand Down Expand Up @@ -83,3 +85,15 @@ int guac_common_ssh_user_import_key(guac_common_ssh_user* user,

}

int guac_common_ssh_user_import_public_key(guac_common_ssh_user* user,
char* public_key) {

/* Free existing public key, if present */
guac_mem_free(user->public_key);
user->public_key = guac_strdup(public_key);

/* Fail if key could not be read */
return user->public_key == NULL;

}

4 changes: 3 additions & 1 deletion src/common/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ void guac_common_display_dup(
guac_common_display_dup_layers(display->layers, client, socket);
guac_common_display_dup_layers(display->buffers, client, socket);

/* Sends a sync instruction to mark the boundary of the first frame */
guac_protocol_send_sync(socket, client->last_sent_timestamp, 1);

pthread_mutex_unlock(&display->_lock);

}
Expand Down Expand Up @@ -386,4 +389,3 @@ void guac_common_display_free_buffer(guac_common_display* display,
pthread_mutex_unlock(&display->_lock);

}

2 changes: 1 addition & 1 deletion src/guacd-docker/bin/build-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,5 @@ install_from_git "https://github.com/warmcat/libwebsockets" "$WITH_LIBWEBSOCKETS

cd "$BUILD_DIR"
autoreconf -fi && ./configure --prefix="$PREFIX_DIR" $GUACAMOLE_SERVER_OPTS
make && make install
make && make check && make install

7 changes: 6 additions & 1 deletion src/guacd/daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,10 +426,15 @@ int main(int argc, char* argv[]) {
CRYPTO_set_locking_callback(guacd_openssl_locking_callback);
#endif

/* Init SSL */
#if OPENSSL_VERSION_NUMBER < 0x10100000L
/* Init OpenSSL for OpenSSL Versions < 1.1.0 */
SSL_library_init();
SSL_load_error_strings();
ssl_context = SSL_CTX_new(SSLv23_server_method());
#else
/* Set up OpenSSL for OpenSSL Versions >= 1.1.0 */
ssl_context = SSL_CTX_new(TLS_server_method());
#endif

/* Load key */
if (config->key_file != NULL) {
Expand Down
4 changes: 2 additions & 2 deletions src/guacenc/ffmpeg-compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ int guacenc_avcodec_encode_video(guacenc_video* video, AVFrame* frame) {
#endif
}

AVCodecContext* guacenc_build_avcodeccontext(AVStream* stream, AVCodec* codec,
AVCodecContext* guacenc_build_avcodeccontext(AVStream* stream, const AVCodec* codec,
int bitrate, int width, int height, int gop_size, int qmax, int qmin,
int pix_fmt, AVRational time_base) {

Expand Down Expand Up @@ -251,7 +251,7 @@ AVCodecContext* guacenc_build_avcodeccontext(AVStream* stream, AVCodec* codec,
}

int guacenc_open_avcodec(AVCodecContext *avcodec_context,
AVCodec *codec, AVDictionary **options,
const AVCodec *codec, AVDictionary **options,
AVStream* stream) {

int ret = avcodec_open2(avcodec_context, codec, options);
Expand Down
4 changes: 2 additions & 2 deletions src/guacenc/ffmpeg-compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ int guacenc_avcodec_encode_video(guacenc_video* video, AVFrame* frame);
* The pointer to the configured AVCodecContext.
*
*/
AVCodecContext* guacenc_build_avcodeccontext(AVStream* stream, AVCodec* codec,
AVCodecContext* guacenc_build_avcodeccontext(AVStream* stream, const AVCodec* codec,
int bitrate, int width, int height, int gop_size, int qmax, int qmin,
int pix_fmt, AVRational time_base);

Expand Down Expand Up @@ -158,7 +158,7 @@ AVCodecContext* guacenc_build_avcodeccontext(AVStream* stream, AVCodec* codec,
* Zero on success, a negative value on error.
*/
int guacenc_open_avcodec(AVCodecContext *avcodec_context,
AVCodec *codec, AVDictionary **options,
const AVCodec *codec, AVDictionary **options,
AVStream* stream);

#endif
Expand Down
4 changes: 2 additions & 2 deletions src/guacenc/video.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
guacenc_video* guacenc_video_alloc(const char* path, const char* codec_name,
int width, int height, int bitrate) {

AVOutputFormat *container_format;
const AVOutputFormat *container_format;
AVFormatContext *container_format_context;
AVStream *video_stream;
int ret;
Expand All @@ -64,7 +64,7 @@ guacenc_video* guacenc_video_alloc(const char* path, const char* codec_name,
container_format = container_format_context->oformat;

/* Pull codec based on name */
AVCodec* codec = avcodec_find_encoder_by_name(codec_name);
const AVCodec* codec = avcodec_find_encoder_by_name(codec_name);
if (codec == NULL) {
guacenc_log(GUAC_LOG_ERROR, "Failed to locate codec \"%s\".",
codec_name);
Expand Down
8 changes: 6 additions & 2 deletions src/libguac/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -702,15 +702,19 @@ void* guac_client_for_user(guac_client* client, guac_user* user,
}

int guac_client_end_frame(guac_client* client) {
return guac_client_end_multiple_frames(client, 0);
}

int guac_client_end_multiple_frames(guac_client* client, int frames) {

/* Update and send timestamp */
client->last_sent_timestamp = guac_timestamp_current();

/* Log received timestamp and calculated lag (at TRACE level only) */
guac_client_log(client, GUAC_LOG_TRACE, "Server completed "
"frame %" PRIu64 "ms.", client->last_sent_timestamp);
"frame %" PRIu64 "ms (%i logical frames)", client->last_sent_timestamp, frames);

return guac_protocol_send_sync(client->socket, client->last_sent_timestamp);
return guac_protocol_send_sync(client->socket, client->last_sent_timestamp, frames);

}

Expand Down
16 changes: 11 additions & 5 deletions src/libguac/encode-webp.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,16 +198,22 @@ int guac_webp_write(guac_socket* socket, guac_stream* stream,
config.method = 2; /* Compression method (0=fast/larger, 6=slow/smaller) */

/* Validate configuration */
WebPValidateConfig(&config);
if (!WebPValidateConfig(&config)) {
return -1;
}

/* Set up WebP picture */
WebPPictureInit(&picture);
if (!WebPPictureInit(&picture)) {
return -1;
}
picture.use_argb = 1;
picture.width = width;
picture.height = height;

/* Allocate and init writer */
WebPPictureAlloc(&picture);
if (!WebPPictureAlloc(&picture)) {
return -1;
}
picture.writer = guac_webp_stream_write;
picture.custom_ptr = &writer;
guac_webp_stream_writer_init(&writer, socket, stream);
Expand Down Expand Up @@ -244,15 +250,15 @@ int guac_webp_write(guac_socket* socket, guac_stream* stream,
}

/* Encode image */
WebPEncode(&config, &picture);
const int result = WebPEncode(&config, &picture) ? 0 : -1;

/* Free picture */
WebPPictureFree(&picture);

/* Ensure all data is written */
guac_webp_flush_data(&writer);

return 0;
return result;

}

39 changes: 34 additions & 5 deletions src/libguac/guacamole/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -586,18 +586,47 @@ void* guac_client_for_user(guac_client* client, guac_user* user,
guac_user_callback* callback, void* data);

/**
* Marks the end of the current frame by sending a "sync" instruction to
* all connected users. This instruction will contain the current timestamp.
* The last_sent_timestamp member of guac_client will be updated accordingly.
* Marks the end of the current frame by sending a "sync" instruction to all
* connected users, where the number of input frames that were considered in
* creating this frame is either unknown or inapplicable. This instruction will
* contain the current timestamp. The last_sent_timestamp member of guac_client
* will be updated accordingly.
*
* If an error occurs sending the instruction, a non-zero value is
* returned, and guac_error is set appropriately.
*
* @param client The guac_client which has finished a frame.
* @return Zero on success, non-zero on error.
* @param client
* The guac_client which has finished a frame.
*
* @return
* Zero on success, non-zero on error.
*/
int guac_client_end_frame(guac_client* client);

/**
* Marks the end of the current frame by sending a "sync" instruction to all
* connected users, where that frame may combine or otherwise represent the
* changes of an arbitrary number of input frames. This instruction will
* contain the current timestamp, as well as the number of frames that were
* considered in creating that frame. The last_sent_timestamp member of
* guac_client will be updated accordingly.
*
* If an error occurs sending the instruction, a non-zero value is
* returned, and guac_error is set appropriately.
*
* @param client
* The guac_client which has finished a frame.
*
* @param frames
* The number of distinct frames that were considered or combined when
* generating the current frame, or zero if the boundaries of relevant
* frames are unknown.
*
* @return
* Zero on success, non-zero on error.
*/
int guac_client_end_multiple_frames(guac_client* client, int frames);

/**
* Initializes the given guac_client using the initialization routine provided
* by the plugin corresponding to the named protocol. This will automatically
Expand Down
19 changes: 15 additions & 4 deletions src/libguac/guacamole/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,22 @@ int guac_protocol_send_select(guac_socket* socket, const char* protocol);
* If an error occurs sending the instruction, a non-zero value is
* returned, and guac_error is set appropriately.
*
* @param socket The guac_socket connection to use.
* @param timestamp The current timestamp (in milliseconds).
* @return Zero on success, non-zero on error.
* @param socket
* The guac_socket connection to use.
*
* @param timestamp
* The current timestamp (in milliseconds).
*
* @param frames
* The number of distinct frames that were considered or combined when
* generating the frame terminated by this instruction, or zero if the
* boundaries of relevant frames are unknown.
*
* @return
* Zero on success, non-zero on error.
*/
int guac_protocol_send_sync(guac_socket* socket, guac_timestamp timestamp);
int guac_protocol_send_sync(guac_socket* socket, guac_timestamp timestamp,
int frames);

/* OBJECT INSTRUCTIONS */

Expand Down
Loading
Loading