Commit Graph

362 Commits (b043f004a882cf21ad4c5ea43609e8e2a2eee064)

Author SHA1 Message Date
Andri Yngvason 73e1089f06 zrle: Unref result in destroy 2022-10-30 13:53:10 +00:00
Andri Yngvason b525608a06 raw: Unref result in destroy 2022-10-30 13:52:52 +00:00
Andri Yngvason b3c1d5d1dc stream: Use MSG_NOSIGNAL
Without MSG_NOSIGNAL, sending to closed sockets will generate SIGPIPE.
2022-10-30 13:07:13 +00:00
Andri Yngvason 95742676c9 zrle: Keep reference to encoder while encoding 2022-10-30 12:44:05 +00:00
Andri Yngvason 91dc5da243 raw: Keep reference to encoder while encoding 2022-10-30 12:44:05 +00:00
Andri Yngvason 727b2f727e tight: Keep reference to encoder while encoding 2022-10-30 12:44:05 +00:00
Andri Yngvason 8f2d137046 server: Make encoder inert when closing client 2022-10-30 12:44:05 +00:00
Andri Yngvason baaf84eab9 Reference count encoders 2022-10-30 12:44:05 +00:00
Andri Yngvason 48b070af5a server: Free cursor buffers on close 2022-10-30 12:44:05 +00:00
Andri Yngvason adef210252 fb-pool: Add setter for fb allocator 2022-10-29 18:40:02 +00:00
Andri Yngvason efb5ab956c Add debug logging for tcp address binding 2022-10-24 20:55:38 +00:00
Andri Yngvason 3588670c81 server: Replace abort() with NVNC_LOG_PANIC 2022-10-24 09:16:59 +00:00
Andri Yngvason 3c4a069ba2 tight: Disable chroma subsampling at q=9
This avoids color banding at the highest quality level.
2022-10-23 19:05:32 +00:00
Philipp Zabel df84f371fe Fix fallthrough warnings in murmurhash
Fix two -Wimplicit-fallthrough warnings in the murmurhash function:

  ../src/murmurhash.c: In function 'murmurhash':
  ../src/murmurhash.c:71:15: warning: this statement may fall through [-Wimplicit-fallthrough=]
     71 |     case 3: k ^= (tail[2] << 16);
        |             ~~^~~~~~~~~~~~~~~~~~
  ../src/murmurhash.c:72:5: note: here
     72 |     case 2: k ^= (tail[1] << 8);
        |     ^~~~
  ../src/murmurhash.c:72:15: warning: this statement may fall through [-Wimplicit-fallthrough=]
     72 |     case 2: k ^= (tail[1] << 8);
        |             ~~^~~~~~~~~~~~~~~~~
  ../src/murmurhash.c:74:5: note: here
     74 |     case 1:
        |     ^~~~
2022-10-15 10:00:43 +00:00
Jeroen Hofstee 5b2a062f0e don't resize an encoder if it is not set 2022-10-15 09:59:05 +00:00
Andri Yngvason b932f3e2e0 h264-encoder: Set async_depth=1
This fixes stalling during encoding. The FFmpeg devs seem to think that it's
normal to change the default behaviour or their code, so this needs to be
fixed here instead.

Fixes #73
2022-09-10 15:48:15 +00:00
Andri Yngvason 19538c9435 server: Fix encoding selection for sw frames
This fixes encoding selection when not using the --gpu option. Before this
change, raw encoding would always be selected.

Reported-by: Consolatis
Suggested-by: Consolatis
2022-08-23 22:34:56 +00:00
Andri Yngvason c0e1159a53 Revert "h264-encoder: Add 30 bit color depth formats"
This reverts commit 613761cf5f.

These are not available on older libav version and they don't event work.
2022-08-23 21:13:13 +00:00
Andri Yngvason 5e5d5d6e29 resampler: Use transformed width as destination stride
Fixes #72
2022-08-23 20:23:12 +00:00
Philipp Zabel affd7f3f6d Allow to query client-side cursor support
Add a function nvnc_client_supports_cursor() to enable the API user to
make an informed decision whether nvnc_set_cursor() can be expected to
make the client draw the cursor, or whether it has to be rendered into
the framebuffer.
2022-07-29 08:37:29 +00:00
Andri Yngvason 263990f5ef stream: Remove stray ampersand in tls handshake failure code path 2022-07-17 20:17:19 +00:00
Andri Yngvason b9a5b9a3f1 h264: Set quality according to client's wishes 2022-07-10 13:53:32 +00:00
Andri Yngvason 528eac51a3 Fix jpeg quality setting
The encoding identifiers are supposed to be interpreted as a range. I
interpreted the upper and lower limits as two discrete quality settings
instead, which is wrong.
2022-07-10 12:41:20 +00:00
Jan Beich 4baeaa43fd server: add missing header after f20ffb5e1e
src/server.c:1119:17: error: use of undeclared identifier 'IPPROTO_TCP'
        setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one));
                       ^
2022-07-09 20:04:53 +00:00
Andri Yngvason d85347cfe3 h264-encoder: Set quality
This is to get libav to stop complaining about quality not being set
2022-07-09 17:19:46 +00:00
Andri Yngvason 362918a8cf Integrate libav into logging framework 2022-07-09 17:15:35 +00:00
Andri Yngvason 863fb0ce80 h264-encoder: Add dtrace probes 2022-07-09 16:30:25 +00:00
Andri Yngvason f20ffb5e1e server: Turn off Nagle's algorithm 2022-07-09 16:29:18 +00:00
Andri Yngvason d86af88573 server: Log encoder choices 2022-07-09 16:28:09 +00:00
Andri Yngvason dc82b3f29d h264-encoder: Clean up current_packet in destroy 2022-06-29 11:39:46 +00:00
Andri Yngvason b8122725e2 server: Reset encoder callback on frame done 2022-06-29 11:36:05 +00:00
Andri Yngvason 4eb7a3a559 h264-encoder: Call on_packet_ready last in on_work_done
The callback can result in the encoder being destroyed, so we can't
dereference access the encoder object after calling it.
2022-06-29 11:34:12 +00:00
Andri Yngvason e8f2481aa4 open-h264: unref result when finished with it 2022-06-26 14:12:37 +00:00
Andri Yngvason 8bde568112 server: Add dtrace probes with pts 2022-06-26 13:57:32 +00:00
Andri Yngvason 1e3819b6fb open-h264: Add dtrace probes 2022-06-26 13:57:32 +00:00
Andri Yngvason e05e812d93 resampler: Add dtrace probes 2022-06-26 13:57:32 +00:00
Andri Yngvason ee64bc2722 display: Add dtrace probes 2022-06-26 13:57:32 +00:00
Andri Yngvason 4e9eb98301 open-h264: Convert to normal encoder
The push/pull code path is buggy.
2022-06-26 13:56:17 +00:00
Andri Yngvason e6a12ffda7 server: Promote some log levels 2022-06-25 16:32:05 +00:00
Andri Yngvason ad4a834cfc Use new logging system 2022-06-25 16:15:32 +00:00
Andri Yngvason 45da0fc157 Add simple logging system 2022-06-25 16:15:32 +00:00
Andri Yngvason 9285594e9d Call encoder.on_done in a function 2022-06-11 11:44:51 +00:00
Andri Yngvason d4258a0aab cursor: Handle rotated cursors 2022-06-11 11:44:51 +00:00
Andri Yngvason bab78857e1 resampler: Extract function: resample_now() 2022-06-11 11:44:51 +00:00
Harm te Hennepe 7205139b11 Don't call gbm symbols when they are not available 2022-05-24 22:55:34 +00:00
Jan Beich da290abc25 server: consistently use builtin byteswap after 53f88894d5
src/server.c:48:10: fatal error: 'byteswap.h' file not found
 #include <byteswap.h>
          ^~~~~~~~~~~~
2022-04-24 17:56:03 +00:00
Andri Yngvason 53f88894d5 Add presentation timestamps 2022-04-14 18:10:09 +00:00
Andri Yngvason e2e117b02f h264-encoder: Fully flush output packets 2022-04-10 16:21:28 +00:00
Andri Yngvason 3ea068b90c server: Decrement n_pending_requests after dispathing encoding job
The request is as good as handled at that point. We don't want to squeeze
in another frame that the client didn't request before the encoding job
finishes. That would cause a negative pending count and the client would
stop getting updates.
2022-04-03 20:52:24 +00:00
Andri Yngvason 9d8c956983 h264-encoder: Fix copy-pasta 2022-03-06 11:24:33 +00:00
Andri Yngvason aca09358ea Add back damage argument to nvnc_set_cursor
It's better to keep feeding buffers to keep buffers in rotation for damage
tracking purposes.
2022-02-21 21:43:41 +00:00
Andri Yngvason 9c02e6afaf Implement hiding cursors 2022-02-20 14:48:24 +00:00
Andri Yngvason 1553c88f5e Add width and height arguments to nvnc_set_cursor 2022-02-19 23:06:15 +00:00
Andri Yngvason afc0f018da cursor: Use the right scan-line length when width != stride 2022-02-19 21:51:24 +00:00
Andri Yngvason cb282c57c4 cursor: Map cursor buffers before access 2022-02-13 18:44:27 +00:00
Andri Yngvason c876b91541 pixels: Add function to get rfb pixel format name 2022-02-12 13:15:30 +00:00
Andri Yngvason 0e0fe5b73a pixels: Add function to convert drm format to string 2022-02-12 12:30:12 +00:00
Andri Yngvason 70784e1bcc cursor: Fix alpha mask stride 2022-02-10 21:53:33 +00:00
Andri Yngvason 9a292afd52 pixels: Handle different endianness for alpha mask 2022-02-10 21:53:33 +00:00
Andri Yngvason 48baf74560 Implement client side cursor rendering 2022-02-06 16:33:46 +00:00
Andri Yngvason 258dccd768 Add a cursor encoder 2022-02-06 16:33:46 +00:00
Andri Yngvason 0cc6be091c pixels: Add function to extract alpha mask 2022-02-06 15:01:33 +00:00
Andri Yngvason 613761cf5f h264-encoder: Add 30 bit color depth formats 2022-01-27 22:31:32 +00:00
Andri Yngvason 648255769a pixels: Add 10-bits-per-colour formats 2022-01-27 22:11:51 +00:00
Andri Yngvason fd23cb8c2f enc-util: Round up division in calc_bytes_per_cpixel
Otherwise 10 bit formats will be mistaken for 8 bit formats.
2022-01-27 22:10:37 +00:00
Andri Yngvason 5dc6a28828 h264-encoder: Automatically find a render node 2021-12-26 13:10:41 +00:00
Andri Yngvason 5a75fdf2bc display: Only run damage refinery when it's needed 2021-12-26 13:10:41 +00:00
Andri Yngvason c5a5437a9e server: Keep a count of clients that use damage 2021-12-26 13:10:41 +00:00
Andri Yngvason 55beea3464 open-h264: Set "ignores-damage" flag 2021-12-26 13:10:41 +00:00
Andri Yngvason 90f61f03c6 Plug open h264 2021-12-26 13:10:41 +00:00
Andri Yngvason 0a70f7fa6a encoder: Add push/pull encoder interface 2021-12-26 13:10:41 +00:00
Andri Yngvason e1ba4e1085 API: Add nvnc_fb_get_type 2021-12-26 13:10:41 +00:00
Andri Yngvason 15c14d7d4b Create an Open h.264 encoder 2021-12-26 13:10:41 +00:00
Andri Yngvason b71598b334 Create h264-encoder 2021-12-26 13:10:41 +00:00
Andri Yngvason 65c0e91c37 Move update header out of encoders 2021-12-12 16:05:29 +00:00
Andri Yngvason 8b2c81c3dd Add offset coordinates to encoders 2021-12-11 21:55:56 +00:00
Andri Yngvason 42b102df0c Remove unused headers 2021-12-11 21:07:41 +00:00
Andri Yngvason a7241658b0 Create encoder abstraction 2021-12-11 21:03:18 +00:00
Andri Yngvason 66942ab913 display: Clean up transformed damage region
This fixes a memory leak
2021-12-11 20:58:17 +00:00
Andri Yngvason 783ac9d99d fb: Unmap released fbs 2021-09-20 22:06:08 +00:00
Andri Yngvason 10c0b9131c fb: Fix mapped gbm buffer stride 2021-09-20 21:57:56 +00:00
Andri Yngvason 26ff812ea6 Add damage refinery from wayvnc 2021-09-20 21:40:21 +00:00
Andri Yngvason ff3dc13f0b resampler: Track buffer damage 2021-09-20 21:40:21 +00:00
Andri Yngvason 943bd33993 resampler: Make resampler object opaque 2021-09-20 21:40:21 +00:00
Andri Yngvason 3b24dbd6a4 resampler: Transform output buffer dimensions based on input transform 2021-09-20 21:40:21 +00:00
Andri Yngvason 0d4ab56568 transform-util: Add dimensions transform function 2021-09-19 21:11:54 +00:00
Andri Yngvason 02559a7f7e Re-sample transformed framebuffers 2021-09-19 20:12:30 +00:00
Andri Yngvason 691e835d1b fb: Add transform attribute 2021-09-19 19:56:56 +00:00
Andri Yngvason 784af9fa5d Add transform utility functions from wayvnc 2021-09-19 19:54:59 +00:00
Andri Yngvason dad7312814 pixels: Add fourcc_to_pixman_fmt 2021-09-19 19:54:23 +00:00
Andri Yngvason cf42f76f56 Add gbm_bo nvnc_fb type 2021-09-12 18:51:22 +00:00
Andri Yngvason a14b829743 fb: Fix buffer allocation
Width and height got mixed up.
2021-09-11 18:17:01 +00:00
Andri Yngvason dad1948e98 Remove nvnc_fb_flags 2021-09-05 00:46:24 +00:00
Andri Yngvason b75eeac03d Add API function for creating nvnc_fb from an pre-allocated buffer 2021-09-05 00:46:24 +00:00
Andri Yngvason 96886e21d5 Add a API function to get the pixel size of nvnc_fb 2021-09-05 00:46:24 +00:00
Andri Yngvason c7dd062498 Add a stride parameter to nvnc_fb 2021-09-05 00:46:24 +00:00
Andri Yngvason e8e4a9469a Remove damage checker
There's a much better one in wayvnc
2021-09-05 00:46:24 +00:00
Andri Yngvason 2095913688 display & fb_pool: Clean up memory leaks 2021-09-04 21:21:23 +00:00
Andri Yngvason 77d8efcbe3 fb_pool: Return true from resize when dimensions change 2021-09-04 21:21:23 +00:00
Andri Yngvason 1b7b51af44 Add a cleanup callback to nvnc_set_userdata 2021-09-04 21:21:23 +00:00
Andri Yngvason 41c9ebe960 server: process fb update requests in fb update request message handler
Otherwise, the client won't get the initial frame
2021-09-04 21:21:23 +00:00
Andri Yngvason e16a64a67d fb_pool: Fix reference counting error 2021-09-04 21:21:23 +00:00
Andri Yngvason f5b0f508f0 fb: Use special context pointer for release callback 2021-09-04 21:21:23 +00:00
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