Commit Graph

309 Commits (1d2e6c05a9000f83fb94c41bc1219a87c399f44e)

Author SHA1 Message Date
Andri Yngvason f566105ab5 Remove nvnc_set_render_fn 2021-09-04 21:21:23 +00:00
Andri Yngvason 981256d8d5 Add a buffer pool 2021-09-04 21:21:23 +00:00
Andri Yngvason d63feadeab Notify the user when an fb is released 2021-09-04 21:21:23 +00:00
Andri Yngvason 031555c85d fb: Add hold/release logic 2021-09-04 21:21:23 +00:00
Ryan Farley b320723049 Support UNIX sockets
Adds support for UNIX domain sockets with `nvnc_open_unix()` function.
Closes #1.
2021-04-04 20:24:33 +00:00
Andri Yngvason 1359b987a3 Translate XT keycodes to linux keycodes 2020-11-29 20:48:31 +00:00
Andri Yngvason f547ed72f9 Decrement pending requests when sending pseudo frames 2020-11-29 18:36:48 +00:00
Andri Yngvason ea98af75de Notify client about qemu key capability 2020-11-29 18:36:48 +00:00
Andri Yngvason dbe35bc3ad Add qemu extended key events 2020-11-29 18:36:48 +00:00
Andri Yngvason e69006fc48 tight: Hold fb and client refs while encoding 2020-09-27 17:17:22 +00:00
Andri Yngvason af38a643d9 tight: Don't block 1 worker while encoding tiles 2020-09-27 12:37:00 +00:00
Andri Yngvason 9e84000e0a server: Extract finish_fb_update() from on_client_update_fb_done() 2020-09-26 22:29:02 +00:00
Andri Yngvason add8d8e8db server: Move pixel format conversion out of do_client_update_fb 2020-09-26 22:17:02 +00:00
Andri Yngvason 7e2b4fef8c server: Refactor schedule_client_update_fb 2020-09-26 22:00:53 +00:00
Andri Yngvason 24a6e29cf2 raw-encoder: Use encder utils 2020-09-26 16:19:02 +00:00
Andri Yngvason 413e6e7e72 zrle: Use encoder utils 2020-09-26 16:16:36 +00:00
Andri Yngvason 31b7077bc5 tight: Use encoder utils 2020-09-26 16:13:17 +00:00
Andri Yngvason 25a533e22b Add common utilities for encoders 2020-09-26 16:10:25 +00:00
Scott Moreau 81a8ba9d0e server: Handle cut text messages of up to 10MB 2020-09-25 21:47:59 +00:00
Scott Moreau 783807c0b9 server: Fix possible crash on fragmented packet messages
The packets sent from the client especially for client cut text,
are typically sent in two packets, one for the message containing
the type and length and the other for the actual data. Sometimes
the first message is read but we still don't have the data yet.
We need to continue reading data to use the structure but this
revealed a bug. The client event handler was calling memmove()
with buffer_index as the size argument. This meant that it was
copying the wrong amount of data, resulting in garbage at the
end of the expected data. This patch fixes the problem by first
subtracting buffer_index from buffer_len and then moving buffer_len
worth of data, which is what was read into msg_buffer. The problem
possibly manifested itself with random crashes, after reading
random data.
2020-09-21 21:15:45 +00:00
Scott Moreau 6d29937e15 server: Add remaining support for simple copy/paste
- Add function to set callback for client_cut_text
- Add server_cut_text structure and function

This in conjunction with wayvnc #66 closes #4.
2020-09-21 21:15:45 +00:00
Andri Yngvason addcc50483 Bake version info into library 2020-07-26 11:43:29 +00:00
Andri Yngvason e1c0923915 stream: Add byte counters 2020-07-26 11:43:29 +00:00
Andri Yngvason b52f5cd6c9 Resize tight encoder on frame resize 2020-07-19 16:58:55 +00:00
Andri Yngvason 76beec6415 tight: Add method to resize encoder grid 2020-07-19 16:57:44 +00:00
Andri Yngvason d4a5ed4133 stream: Ignore events after close instead of aborting
Aborting places an unnecessary restriction on the event loop library.
2020-07-19 13:22:57 +00:00
Andri Yngvason a0801f04e4 Implement server-side resizing 2020-07-19 11:54:39 +00:00
Andri Yngvason eb4b9d71a4 Return failure if display buffer is not set in on_connect 2020-07-18 14:04:12 +00:00
Andri Yngvason 683776cdf0 server: Assert that a client has a stream open when processing a message 2020-07-16 18:14:52 +00:00
Andri Yngvason 33eda8c5d0 Always enable tight, encoding but allow disabling lossy tight encoding 2020-07-11 20:16:27 +00:00
Andri Yngvason 497f9adb29 tight: Re-implement with threads 2020-07-11 20:06:45 +00:00
Andri Yngvason 9b54f6d936 Clean up dispatch hander on exit 2020-07-06 16:43:53 +00:00
Andri Yngvason 52e30e795b Align with neatvnc API changes 2020-07-06 16:43:15 +00:00
Andri Yngvason 7fb2215c0f Use raw encoding by default if no encoding has been selected
This complies with the standard.
2020-05-31 22:56:27 +00:00
Andri Yngvason 569ad287c5 Fix version error handling 2020-05-29 20:18:05 +00:00
Andri Yngvason 91bd49848f Build benchmarks again 2020-05-27 21:59:34 +00:00
Stefan Agner d2527e57f0 fix build warnings when building without tls
Fix trivial build warnings when building without TLS support.
2020-05-22 20:54:53 +00:00
Stefan Agner 8f9c71bb33 fix below zero message count check
size_t is unsigned and hence can't be below zero, triggering this gcc
warning with gcc 10:
  warning: comparison of unsigned expression in ‘< 0’ is always false [-Wtype-limits]

It seems this if statement is meant to check if there are messages to
process (larger than 0). If there are no messages, we should jump out
early.
2020-05-21 17:44:31 +00:00
Stefan Agner a37eed4a4a remove fb_lock/unlock
The two functions have been removed from the external header file.
Remove them and the now unnecessary field is_locked.
2020-05-21 17:44:31 +00:00
Stefan Agner 8316994dfa use static for functions not used outside this compile unit
Add static for all functions only used inside the individual compile
units. This helps the compiler to potentially inline these functions.

This allows to use neatvnc as a Meson subproject in Weston which has
-Wmissing-prototypes enabled by default.
2020-05-21 17:44:31 +00:00
Andri Yngvason 477ab4c481 tight: Allow lossy encoding with 16 bpp 2020-05-05 21:34:45 +00:00
Andri Yngvason f3e09fd622 Prepare API for multi-display support
These changes are made now to make it possible to add multi-display
support in the future while keeping the public interface stable.
2020-04-12 18:16:19 +00:00
Andri Yngvason 737dd311a0 Remove nvnc_set_dimensions()
This information is now figured out based on the nvnc_fb passed into
nvnc_set_buffer()
2020-04-12 16:08:33 +00:00
Andri Yngvason d12e66b043 raw-encoding: Add copyright notice 2020-04-12 13:18:42 +00:00
Andri Yngvason 2b2d12c755 damage: Add copyright notice 2020-04-12 13:18:28 +00:00
Andri Yngvason a616423c49 fb: Add copyright notice 2020-04-12 13:17:54 +00:00
Andri Yngvason c6f1ab616e tight: Replace an assert with return -1 2020-04-10 12:40:57 +00:00
Andri Yngvason 0350ba1d16 zrle: Replace an assert with return -1 2020-04-10 12:36:51 +00:00
Andri Yngvason 297e22b588 Don't render when a client is still encoding 2020-04-10 12:07:35 +00:00
Andri Yngvason 1c2a2231d6 tight: Don't drop MSB when encoding rect size 2020-04-10 11:51:40 +00:00
Andri Yngvason 77b866096d Redesign framebuffer update loop
Rendering may now only happen inside the rendering callback. The user is
also allowed to change out the entire buffer in the callback.

The callback is triggered by nvnc_damage_region(), nvnc_damage_whole()
and/or framebuffer update requests.

This fixes #26
2020-04-07 23:35:57 +00:00
Andri Yngvason 048b796ff5 Enable SO_REUSEADDR again 2020-04-06 18:29:17 +00:00
Andri Yngvason 11a73c5cb0 Revert "tight: Limit rectangle max width according to spec"
This reverts commit 999c1ef255.

This sends more rects than the original rect count allows for.
2020-04-06 00:01:32 +00:00
Andri Yngvason 1976221afe Resolve host names in nvnc_open()
This fixes #23
2020-04-04 22:26:00 +00:00
Andri Yngvason 8fc5c18b28 Don't show partial frames to new clients 2020-04-04 14:00:03 +00:00
Andri Yngvason f45f90ed9b nvnc_fb: Add a mechanism for signaling that a frame is in use 2020-04-04 12:33:18 +00:00
Andri Yngvason b0799f7490 server: Add dtrace probe for stream_send inside update_fb_done 2020-04-03 23:11:12 +00:00
Andri Yngvason a54b9ddd8e tight: Check quality level at start of each frame 2020-04-03 22:54:46 +00:00
Andri Yngvason b44d1a1f58 Replace miniz with system provided zlib
miniz is simply broken, so I can't use it.
2020-04-03 22:39:55 +00:00
Andri Yngvason 25626a9048 tight: Implement quality control 2020-04-03 20:09:26 +00:00
Andri Yngvason 17e0d6036f tight: Implement bare minimum "basic" encoding 2020-04-03 00:18:54 +00:00
Andri Yngvason cfb2abfc58 tight: Prepare for "basic" encoding method 2020-04-02 21:52:04 +00:00
Andri Yngvason 999c1ef255 tight: Limit rectangle max width according to spec 2020-04-02 21:26:12 +00:00
Andri Yngvason 1724797a27 tight: Add some error handling 2020-04-02 21:12:09 +00:00
Andri Yngvason 10a3fd6238 Add dtrace probes for framebuffer updates 2020-04-01 22:53:22 +00:00
Andri Yngvason 22eba2bed8 Make sure framebuffers are properly aligned 2020-03-29 13:16:05 +00:00
Andri Yngvason f0974e5af6 stream: Close if read() == 0 2020-03-24 19:15:27 +00:00
John Axel Eriksson d1c7402acd
Remove libuv header include 2020-03-24 07:04:05 +01:00
Andri Yngvason a77eb34fba Spawn as many workers as there are CPU cores 2020-03-21 17:27:30 +00:00
Andri Yngvason 76e721c4cd Replace libuv with aml 2020-03-21 16:59:10 +00:00
Andri Yngvason 992b4445ed tight: Add copyright notice 2020-02-09 12:03:14 +00:00
Andri Yngvason 61efca48f0 damage: Increment/decrement reference count before/after check
This is prudent. The user might throw away these buffers before the
damage check finishes.
2020-01-29 21:33:13 +00:00
Andri Yngvason 10473597c5 stream: Fix flushing when tls is disabled 2020-01-29 17:03:55 +00:00
Stefan Agner 1e0612a81e Remove unused/unexisting include util.h
The header file util.h has been remvoed from the codebase with
commit caf9fe0130 ("Remove unused code"), remove it from pngfb.c as
well. This allows to build the examples again.
2020-01-26 12:45:06 +01:00
Andri Yngvason 7d2b295b4a server: Read messages straight into message buffer
This avoids extra copying and removes a possible error condition that
would cause the connection to be closed
2020-01-25 16:42:10 +00:00
Andri Yngvason 547387f549 server: Close after sending VeNCrypt failure message 2020-01-25 16:04:04 +00:00
Andri Yngvason b30a5516d3 server: Send the proper reason string on security handshake failure 2020-01-25 15:59:04 +00:00
Andri Yngvason 1687b8c701 server: Apply stream API change 2020-01-25 15:52:44 +00:00
Andri Yngvason fef9ca1d7c stream: Change api for stream_write 2020-01-25 15:46:52 +00:00
Andri Yngvason caf9fe0130 Remove unused code 2020-01-25 15:39:23 +00:00
Andri Yngvason 19e4e42036 Implement VeNCrypt with x509 plain authentication 2020-01-25 15:35:14 +00:00
Andri Yngvason 2f99659077 Create a network stream object with TLS support 2020-01-25 15:33:36 +00:00
Andri Yngvason f8d53635e4 Create a reference counted buffer 2020-01-25 15:29:25 +00:00
Andri Yngvason 01522559d6 zrle: Fix pixel conversion for bits-per-pixel < 32 2020-01-24 23:16:08 +00:00
Andri Yngvason 230acf0560 zrle: Remove unused variable 2020-01-24 23:02:47 +00:00
Andri Yngvason 4ebd60b8cc pixels: Delete useless code 2020-01-24 22:29:29 +00:00
Scott Moreau 1d897b2ba1 Swap red and blue colors with tight encoding 2020-01-20 14:29:02 -07:00
Andri Yngvason 450ea90306 pixels: Fix rfb_pixfmt_from_fourcc 2020-01-19 23:13:12 +00:00
Andri Yngvason a80b314eea server: Set the pixel format for the client if it hasn't specified one 2020-01-19 22:54:52 +00:00
Andri Yngvason 4e919c69ce Unbreak raw encoding 2020-01-19 21:31:55 +00:00
Andri Yngvason aa917decf3 pixels: Make it work for 4 bytes per cpixel 2020-01-19 21:30:49 +00:00
Andri Yngvason 7fa074e60b server: Close client if no frame encoding method is available 2020-01-19 21:27:17 +00:00
Andri Yngvason ebfe4382ee server: Use size_t for encoding indices 2020-01-19 19:17:15 +00:00
Scott Moreau db6c063aea Include sys/param.h for MIN definition
Fixes #11.
2020-01-19 12:00:18 -07:00
Jan Beich 928d0c20ac Drop unused platform-specific header
../src/zrle.c:29:10: fatal error: 'endian.h' file not found
 #include <endian.h>
          ^~~~~~~~~~
2020-01-13 04:04:28 +00:00
Andri Yngvason ad0ff6b27c Make Tight encoding optional 2019-12-31 10:13:21 +00:00
Andri Yngvason ee3f2fefff server: Extract pixel format functions into pixels.c 2019-12-30 20:13:40 +00:00
Andri Yngvason a0376f2fd4 Pass entire client structure to tight encoder 2019-12-30 17:48:22 +00:00
Andri Yngvason d9f80ad196 server: Extract structure definitions into header 2019-12-30 17:22:19 +00:00
Andri Yngvason 8cd33d8a07 Add JPEG Tight encoding 2019-12-30 10:00:15 +00:00
Andri Yngvason 52f5510467 Send a correct reason string when disconnecting due to unsupported security type 2019-12-28 20:50:44 +00:00
Andri Yngvason 769107b7aa damage: Grow hint box after alignment 2019-12-27 18:04:36 +00:00
Andri Yngvason 00450e0c9d Clean up some memory leaks 2019-12-27 15:07:48 +00:00
Andri Yngvason 875cd5af7b Stop reading from a client as soon as an error occurs on the socket 2019-12-27 13:57:40 +00:00
Andri Yngvason bfb1cd9fc9 Don't buffer up multiple outgoing frames
It's pointless to send multiple frames in a single buffer. It just
overloads the client.
2019-12-23 12:11:00 +00:00
Andri Yngvason 4ebf4623cb Fix read buffer and drop older outgoing frames 2019-12-23 09:33:29 +00:00
Andri Yngvason 80b1f3cb4c Re-format using clang-format 2019-10-20 22:13:51 +00:00
Andri Yngvason de1f63573b raw-encoding: Do proper pixel conversion 2019-10-14 10:33:43 +00:00
Andri Yngvason 9f67b47e8c damage: Remove vestigial y_inversion code 2019-10-13 10:05:36 +00:00
Andri Yngvason 05ff0c1514 Don't send an update that hasn't been requested 2019-10-12 17:29:08 +00:00
Andri Yngvason 6dec7287f7 Tune deflate 2019-10-12 16:42:59 +00:00
Andri Yngvason 007578052c Use Z_BEST_SPEED for ZRLE
The default strategy loads the CPU too much when streaming at 60 FPS.
2019-10-12 15:47:38 +00:00
Andri Yngvason b54bc178f0 Fix decoding of encoding message 2019-10-08 18:12:57 +00:00
Andri Yngvason e9f200f4cc Excise y-inversion code 2019-10-08 17:58:35 +00:00
Andri Yngvason 9501a1da64 Keep a reference to the framebuffer while it is in a worker. 2019-10-08 17:53:12 +00:00
Andri Yngvason bc17fd823e pngfb: Fixup 2019-10-07 20:32:34 +00:00
Andri Yngvason 4beaf88a35 Turn around frame update model
Keeping a framebuffer for clients to request from seems to be a better fit for
the VNC standard.
2019-10-07 20:29:12 +00:00
Andri Yngvason 3196a7a46b Make nvnc_fb opaque 2019-10-07 17:39:54 +00:00
Andri Yngvason 0f840b9bb7 raw-encoding: Fix vec_reserve for destination buffer 2019-09-21 13:33:37 +00:00
Andri Yngvason 4c36a88cfd Fix y-inversion in damage tracking and raw encoding 2019-09-19 19:21:52 +00:00
Andri Yngvason 40f16fe63b Add raw encoding
It's useful for debugging
2019-09-19 18:14:26 +00:00
Andri Yngvason 7b57449e19 damage: Support y-inversion 2019-09-19 17:02:21 +00:00
Andri Yngvason 083eaaf20a Make sure that the client object outlives the encoding worker task 2019-09-18 22:16:40 +00:00
Andri Yngvason 8973ce5637 Return error from update when there are no pending clients 2019-09-18 21:21:37 +00:00
Andri Yngvason 7d4af0e741 Encode on worker threads 2019-09-15 21:53:10 +00:00
Andri Yngvason 70b2448c6e Create utility function for checking buffer damage 2019-09-15 21:53:10 +00:00
Andri Yngvason 578ee75235 zrle: Extract pixel conversion function into own file 2019-09-14 16:01:00 +00:00
Andri Yngvason b05791db4a zrle: Define tile side length in a macro 2019-09-14 16:01:00 +00:00
Andri Yngvason 3ce98968bb Add macros for compatibility with older libdrm 2019-09-10 18:17:45 +00:00
Andri Yngvason f3def21c96 Fix y-inversion 2019-09-08 23:24:01 +00:00
Andri Yngvason 55051310d6 Guard against unsupported pixel formats 2019-09-08 16:48:05 +00:00
Andri Yngvason ac2adbb721 Fix check for closing clients in fb update 2019-09-08 16:46:13 +00:00
Andri Yngvason 73987c2f17 Add modifier to do y-inversion during encoding 2019-09-08 15:19:56 +00:00
Andri Yngvason 2e359e734d zrle: Fix endianness 2019-09-08 14:41:22 +00:00
Andri Yngvason 66498bccf8 pngfb: Use correct fourcc format 2019-09-08 14:40:14 +00:00
Andri Yngvason 1a450a8e30 Explain what pngfb.c does 2019-09-07 18:44:48 +00:00
Andri Yngvason f9680148f1 Remove unused code 2019-09-07 18:42:55 +00:00
Andri Yngvason 6046949726 Add license and copyright notices 2019-09-07 16:51:07 +00:00
Andri Yngvason b6f29b036c Allocate framebuffer per client 2019-09-06 20:33:55 +00:00
Andri Yngvason 18062f08d2 Don't send anything to clients that don't have active requests 2019-09-06 20:17:03 +00:00
Andri Yngvason b10c6c2a5a Implement closing of other clients 2019-09-06 20:07:09 +00:00
Andri Yngvason 6660df4d8d Free encoded frames after sending them 2019-09-06 19:26:30 +00:00
Andri Yngvason fb335247aa zrle: Fix run-length encoding with palette 2019-09-05 23:36:07 +00:00
Andri Yngvason 3e374c97f0 zrle: Copy each tile region to a contiguous buffer before operating on it 2019-09-05 22:53:23 +00:00
Andri Yngvason 80e1093e71 zrle: Implement Palette RLE 2019-09-01 23:27:56 +00:00
Andri Yngvason ff67e2fed3 zrle: Keep the stream alive per connection
Otherwise the client doesn't want to play with the server.
2019-09-01 19:55:11 +00:00
Andri Yngvason 46dc074370 Fix encoding with offset 2019-09-01 13:01:02 +00:00
Andri Yngvason 20139f617d Add callbacks for new clients and when clients go away 2019-08-31 23:30:08 +00:00
Andri Yngvason ed5dadd203 Use client specific pointers in callbacks 2019-08-31 23:16:55 +00:00
Andri Yngvason f7ed6b6fce Use miniz instead of zlib 2019-08-31 15:50:23 +00:00
Andri Yngvason 8cb192c0ad Remove some printouts 2019-08-29 22:08:30 +00:00
Andri Yngvason fd6f47c93c Clean some things up and add more interface functions 2019-08-29 21:47:02 +00:00
Andri Yngvason 6d195dd484 Only linear framebuffers supported as is 2019-08-29 14:02:29 +00:00
Andri Yngvason 33324c9373 Create an interface 2019-08-28 22:46:47 +00:00
Andri Yngvason f31b5a6915 Add benchmark for zrle 2019-08-27 22:29:46 +00:00
Andri Yngvason b8e90d3665 zrle: Encode into vector 2019-08-27 21:49:28 +00:00
Andri Yngvason 1fc4d436a9 zrle: Extract deflate to function 2019-08-27 21:04:20 +00:00
Andri Yngvason 09d64dfbe6 zrle: Use vec for tile buffer 2019-08-27 20:28:12 +00:00
Andri Yngvason 980c437f3c Set up a directory structure 2019-08-27 19:42:52 +00:00