Commit Graph

1016 Commits

Author SHA1 Message Date
Michael Scherle
e3846145e5 gstreamer decoder: set alignment=au for h264/h265 so that the parser does not buffer frames. 2024-04-16 11:36:41 +02:00
Frediano Ziglio
581ca654ff gstreamer: Fallback to S/W decoder if H/W one is not working
In case the H/W decoder is not able to decode the stream (like too high
profile) try the S/W version.
This is done detecting the failure and trying to recreate the pipeline
in case:
- we are using a H/W pipeline;
- we didn't decode any frame (otherwise it means we lost the beginning
  or it was not a problem of H/W decoder).

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Vivek Kasireddy <vivek.kasireddy@intel.com>
2023-11-05 15:25:31 +00:00
Frediano Ziglio
d29a0a04da gstreamer: Fix leak using GstBus watch
This patch fixes a leak due to not freeing GstBus watch.
The watch is attached (as GSource) to the main loop and retains
a pointer to the bus so we need to remove it to release the bus
when we release the pipeline.
This was detected forcibly creating and destroying lot of streams.
After a while the client program consumed all file descriptors
and stopped working. This as GstBus retains a GPoll which,
under Unix, uses 2 file descriptors.
For some reasons using gst_pipeline_get_bus again in free_pipeline
do not fix entirely the leak so keep a pointer to the exact
bus we set our watch on.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Vivek Kasireddy <vivek.kasireddy@intel.com>
2023-11-05 15:23:46 +00:00
Vivek Kasireddy
a5ff1b1414 channel-display-gst: Use h/w based decoders with Intel GPUs if possible
We first try to detect if an Intel GPU is available (by looking into
udev's database) and then probe Gstreamer's registry cache to see
if there is h/w based decoder (element) available for the incoming
video codec format. If both these conditions are satisfied (i.e,
Intel Media SDK Gstreamer plugin (libgstmsdk.so) and associated
libraries are properly installed), we then create a simple decode
pipeline using appropriate h/w based decoder and post-processor
elements instead of relying on playbin -- which may not be able to
auto-select these elements.

For example, if the incoming codec format is h264, we then create
a pipeline using msdkh264dec and vaapipostproc elements instead of
avdec_h264 and videoconvert.

Cc: Frediano Ziglio <freddy77@gmail.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
Cc: Dongwon Kim <dongwon.kim@intel.com>
Signed-off-by: Vivek Kasireddy <vivek.kasireddy@intel.com>
Signed-off-by: Hazwan Arif Mazlan <hazwan.arif.mazlan@intel.com>
Signed-off-by: Jin Chung Teng <jin.chung.teng@intel.com>
Acked-by: Frediano Ziglio <freddy77@gmail.com>
2023-11-03 08:31:41 +00:00
Frediano Ziglio
e2bcf5727b gstreamer: Avoid dangling pointers in free_pipeline
Although currently after free_pipeline we free the entire structure
the name and the function suggests that we only free the pipeline.
Also this is fixing a future possible problem with the series
from Vivek Kasireddy reusing the SpiceGstDecoder for another
pipeline if H/W encoder pipeline creation fails.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Vivek Kasireddy <vivek.kasireddy@intel.com>
2023-11-03 08:31:06 +00:00
Jin Chung Teng
2a8dc65b9b channel-display-gst: Prefer playbin3 to playbin
If playbin3 is available (checked in Gstreamer registry), it
makes sense to prefer it given the major improvements and
features it offers including the capability to handle higher
bitrates.

Cc: Frediano Ziglio <freddy77@gmail.com>
Cc: Dongwon Kim <dongwon.kim@intel.com>
Cc: Hazwan Arif Mazlan <hazwan.arif.mazlan@intel.com>
Signed-off-by: Jin Chung Teng <jin.chung.teng@intel.com>
Signed-off-by: Vivek Kasireddy <vivek.kasireddy@intel.com>
Acked-by: Frediano Ziglio <freddy77@gmail.com>
2023-10-06 09:03:26 +01:00
Vivek Kasireddy
20c414f88a channel-display-gst: Add "byte-stream" as the stream format for h264
Adding the string "stream-format=byte-stream" to decoder capabilities
(dec_caps) for h264/h265 codecs stops Gstreamer from complaining
about missing stream format.

Cc: Frediano Ziglio <freddy77@gmail.com>
Cc: Dongwon Kim <dongwon.kim@intel.com>
Cc: Jin Chung Teng <jin.chung.teng@intel.com>
Cc: Hazwan Arif Mazlan <hazwan.arif.mazlan@intel.com>
Signed-off-by: Vivek Kasireddy <vivek.kasireddy@intel.com>
Acked-by: Frediano Ziglio <freddy77@gmail.com>
2023-09-18 09:18:58 +01:00
Frediano Ziglio
9f1a9bec6c Use single version of double exported functions
Solve double export issue of some functions between spice-gtk
and spice-glib libraries.
Some functions are exported by both spice-gtk and spice-glib.
As the state of these function can be duplicate this can create
some issues. Specifically you can enable debug but get only partly
enabled.
So to solve this and have a consistent behaviour across system
add new functions in spice-glib (where these functions where supposed
to be) and use them (we need to keep providing old functions for
ABI compatibility).

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2023-07-25 11:37:17 +01:00
Frediano Ziglio
3892983eda Use visibility instead of just filtering using version script
In case version script support is not available we can still
able to filter symbols exported.
This for instance will work with linkers not supporting
--version-script (like system MacOS one).
Use new version macros similar to Glib to detect also
deprecated function.
Tested that exported symbols remains the same from both Linux
and Windows shared libraries.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2023-07-09 08:25:14 +01:00
Frediano Ziglio
11149e5d4e Remove not private function declaration
Already declared in spice-audio.h.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2023-07-02 18:12:01 +01:00
Frediano Ziglio
004ff13af1 Fix some minor versions documentation
Fix some "Since" field in function documentation.
Nobody should nowadays use versions old like these but good to
have them fixed.
Function presence was checked looking at map-file and code
presence.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2023-07-02 17:36:01 +01:00
Frediano Ziglio
7e87382b58 Split symbol file in 2 files
One file for spice-glib and another for spice-gtk.
This avoid having duplicate exports in the future.
spice_g_signal_connect_object, spice_util_get_debug,
spice_util_get_version_string, spice_util_set_debug and
spice_uuid_to_string are exported by both libraries to keep ABI
compatibility.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2023-06-26 13:53:37 +01:00
Frediano Ziglio
1511f0ad5e Do not use libtool -export-symbols option
This option is intended for libtool, not for any linker.
Check the support of --version-script option using an empty
list of symbols to catch some faulty linker supporting that
option but not allowing not existing symbols (some buggy mold
versions).

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2023-06-22 19:22:04 +01:00
Biswapriyo Nath
7471e3e5ad usb-backend: Fix compiling with i686 clang in mingw
This adds the stdcall attribute to match the function prototype which
is used with SetWindowSubclass Win32 API. Otherwise, clang 16 targeting
i686-w64-windows-gnu shows the following compiler error:

../src/usb-backend.c:269:38: error: incompatible function pointer types passing
'LRESULT (HWND, UINT, WPARAM, LPARAM, UINT_PTR, DWORD_PTR)' (aka 'long (struct HWND__ *, unsigned int, unsigned int, long, unsigned int, unsigned long)') to parameter of type
'SUBCLASSPROC' (aka 'long (*)(structHWND__ *, unsigned int, unsigned int, long, unsigned int, unsigned long) __attribute__((stdcall))') [-Wincompatible-function-pointer-types]
    if (!SetWindowSubclass(be->hWnd, subclass_proc, 0, (DWORD_PTR)be)) {
                                     ^~~~~~~~~~~~~

Acked-by: Frediano Ziglio <freddy77@gmail.com>
2023-04-21 19:11:39 +01:00
Marc-André Lureau
f04479c16f Release v0.42
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2023-01-23 14:04:11 +04:00
Marc-André Lureau
795318c8fa meson: fix keymap-gen exec on msys
meson wraps python scripts already on win32:

"C:/msys64/mingw64/bin/meson" "--internal" "exe" "--capture" "src/vncdisplaykeymap_xorgevdev2xtkbd.h" "--" "C:/msys64/mingw64/bin/python.exe" "python" "C:/msys64/home/marca/src/spice-gtk/subprojects/keycodemapdb/tools/keymap-gen" "code-m
ap" "--lang" "glib2" "--varname" "keymap_xorgevdev2xtkbd" "../subprojects/keycodemapdb/data/keymaps.csv" "xorgevdev" "xtkbd"
--- stderr ---
C:/msys64/mingw64/bin/python.exe: can't open file 'C:\\msys64\\home\\marca\\src\\spice-gtk\\build\\python': [Errno 2] No such file or directory

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2023-01-23 11:55:06 +04:00
Marc-André Lureau
57733fe6ef meson: drop needless comments about unused protocols
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2023-01-23 11:54:16 +04:00
Marc-André Lureau
245c325a85 Fix compilation on win32 when EGL is enabled
../src/spice-widget-egl.c:204:17: error: unused variable 'gdk_dpy' [-Werror=unused-variable]
  204 |     GdkDisplay *gdk_dpy = gdk_display_get_default();

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2023-01-23 11:08:42 +04:00
Marc-André Lureau
a0f7d49fa4 meson: update EGL option
Adjust `#ifdef` statements to use the single define.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2023-01-23 10:34:20 +04:00
Marc-André Lureau
53a7a40190 Rename near and far, reserved keywords on win32
Win32 has #define for those.

Change variable names `near` and `far` to `_near` and `_far`.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2023-01-23 10:28:44 +04:00
msizanoen1
5e88a10dc8 spice-widget: fix hotspot position on Wayland/HiDPI
Same as a945a3c24b but for Wayland.

Fixes breakage caused by GTK behavior change in
https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/5159.
2023-01-09 15:48:16 +00:00
Frediano Ziglio
2ed5f940f6 usb-device-cd: Detect Apple H/W CD support better
Hardware support for Apple iOS is not available, check correctly
and not try to use it.

Signed-off-by: osy <osy@turing.llc>
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Tested-by: osy <osy@turing.llc>
2022-11-20 17:49:30 +00:00
Victor Toso
a39a3acc06 usb-backend: Fix devices not being enumerated
This patch fixes bad filtering of USB devices.

The logic was introduced for windows clients in commit b838937 but was
moved in 2e19014 and executed also by non windows clients, resulting
in this bug.

Fixes: 2e19014 "usb-redir: isolate usage of libusb and usbredirhost"
Fixes: https://gitlab.freedesktop.org/spice/spice-gtk/-/issues/157
Signed-off-by: Victor Toso <victortoso@redhat.com>
2022-10-07 13:47:47 +00:00
Marc-André Lureau
74e673d7c3 Release v0.41
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-07-04 14:53:04 +00:00
Marc-André Lureau
7cf19eeef6 channel: use openssl 3.0 API
Fix compilation warnings when building against openssl 3.0

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-07-04 15:40:02 +04:00
Eli Schwartz
b3eb04485c fix invalid use of subprojects
The keycodemapdb Meson subproject provides a program and a source input.
Since it is a subproject, Meson wants to sandbox that and requires it to
be explicitly exported. But this never happened -- instead, we manually
poked at files using the actual string path "subprojects/......"

This was always a Meson sandbox violation, but Meson 0.63.0 started
noticing it and erroring out.

Instead, do the right thing. Update the subproject to a version that has
a meson.build with actually meaningful contents -- namely, a files
variable and a found program. Then use these in order to run the needed
custom_target.

In the process, it is also necessary to correct the argument ordering
when running keymap-gen.

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-06-27 10:56:45 +04:00
osy
fa812c8849 coroutine: add support for libucontext
libucontext is a lightweight implementation of ucontext for platforms
that do not have a built-in implementation. This allows us to use the
same code to support libucontext as ucontext.
2022-03-04 21:56:12 -08:00
Victor Toso
9f3b720e2f Release v0.40
Signed-off-by: Victor Toso <victortoso@redhat.com>
2022-02-07 14:43:23 +01:00
Iordan Iordanov
9a0cec4b2f Implemented the ability to allocate SpiceUsbDevice instances
by passing an open file descriptor in order to support the modern
Android USB device permissioning scheme.

During the process, a handle obtained by a call to
libusb_wrap_sys_device() is stored in the SpiceUsbDevice instance.

A call to libusb_open() is skipped if there is already a handle
present in the SpiceUsbDevice instance.

Finally, on Android, the option LIBUSB_OPTION_NO_DEVICE_DISCOVERY
must be set prior to the call to libusb_init() as per libusb
documentation.

Acked-by: Frediano Ziglio <freddy77@gmail.com>
2022-01-28 12:20:46 +00:00
Frediano Ziglio
d5c01a322f channel-main: Remove unused code
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2022-01-28 10:26:24 +00:00
Kevin Pouget
fe6469a27f Capture and forward side mouse buttons (BTN_SIDE and BTN_EXTRA)
Adds support for capturing and forwarding the side mouse buttons some mouses
have, typically used in web browsers for previous/next website in history.
(Those are presented by GDK as buttons 8 and 9.)

spice-vdagent requires a corresponding patch to handle the buttons.

At the spice and protocol level, the required changes were previously merged:
* https://gitlab.freedesktop.org/spice/spice/-/issues/45
* https://gitlab.freedesktop.org/spice/spice/-/merge_requests/140
* https://gitlab.freedesktop.org/spice/spice-protocol/-/merge_requests/22

This commit is a rebased and revised version of the patch by Kevin Pouget:
https://www.spinics.net/lists/spice-devel/msg42582.html
(I have confirmed with him that it's OK that I submit the updated patches.)

Co-Authored-By: Kevin Pouget <kpouget@redhat.com>
Co-Authored-By: Joan Bruguera <joanbrugueram@gmail.com>
2022-01-18 00:59:56 +01:00
Frediano Ziglio
0031c57fcc Add support for SNI connecting trough TLS
This will pass hostname.
This fixes https://gitlab.freedesktop.org/spice/spice-gtk/-/issues/137.

You can easily verify the change with a network capture program running
something like

    remote-viewer spice+tls://www.spice-space.org:443

you will see the hostname in the initial exchange.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2021-08-23 09:45:39 +01:00
Frediano Ziglio
151d920418 Support USB emulation for MacOS
Use proper ioctls for MacOS.
Import new spice-common to solve an issue detecting Python3.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2021-08-20 08:15:04 +01:00
Frediano Ziglio
dbdb46b505 Use Glib macros for endian management
Resolve some portability issue, like MacOS.
Macros from <endian.h> were used but not all systems have
this header.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2021-08-20 08:14:59 +01:00
Marc-André Lureau
61002aaa3b Remove incorrect volatile usage
See also: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2021-06-28 12:25:08 +04:00
Marc-André Lureau
edba707b32 Fix potential div0 crash
gdk_monitor_get_geometry() may return 0-size, and leads to crash:
https://bugzilla.redhat.com/show_bug.cgi?id=1941627

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2021-06-28 12:12:21 +04:00
Marc-André Lureau
7f1c4578be main: annotate some signal pointers
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2021-04-23 00:13:08 +04:00
Bastien Orivel
2fca24cc23 Fix parsing the usbids file
This fixes a regression from 032ca202f8
where a check on whether the usbids file contained anything but the
wrong variable was checked. This is visible on windows when trying to
share a USB device as devices won't get named based on the usbids file.
Same thing on linux if we can't read the name from the sysfs.

`usbids_vendor_info` is only initialized to something not NULL after it
was checked to be different from NULL which is obviously wrong. The
patch wanted to check that the `usbids_vendor_count` was different from
0 instead.

Acked-by: Frediano Ziglio <freddy77@gmail.com>
2021-04-17 09:57:24 +01:00
Marc-André Lureau
8f4e35a25e Annotate spice_uuid_to_string
Note: that unusual function seems problematic for GI in general, we may want a simple pointer instead..
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2021-04-13 17:42:08 +00:00
Marc-André Lureau
a3db2b4d04 Annotate SpiceDisplayChannel:monitors
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2021-04-13 17:42:08 +00:00
Marc-André Lureau
e6c5b917a1 Annotate a few DispayChannel methods taking Channel as argument
Help bindings by setting those functions as DisplayChannel methods.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2021-04-13 17:42:08 +00:00
Paul Donohue
ea81b97f74 spice-widget: add spice_display_keyboard_ungrab()
Internally, spice-widget has separate try_keyboard_ungrab() and
try_mouse_ungrab() functions to ungrab the keyboard and mouse
respectively.  Both of these functions are called when the grab
sequence is pressed.

spice-widget exposes try_mouse_ungrab() as spice_display_mouse_ungrab()
to allow callers to explicitly ungrab.  However, it does not currently
expose try_keyboard_ungrab(), so callers can only ungrab the mouse and
cannot ungrab the keyboard.

Correct this by exposing try_keyboard_ungrab() as
spice_display_keyboard_ungrab().

Fixes #73
2021-04-10 08:53:34 -04:00
Marc-André Lureau
c83d09ba10 Add clipboard function array annotations
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2021-04-09 21:20:13 +04:00
Marc-André Lureau
cce47d9410 Fix spice_display_channel_change_preferred_video_codec_types annotations
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2021-04-09 21:20:13 +04:00
Marc-André Lureau
84a88176b1 Fix g-i class size binding
gir fails to compute the size of the array, which results in invalid
class size. Deprecate usage of SPICE_RESERVED_PADDING, which isn't that
useful anyway.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2021-04-09 21:20:13 +04:00
Marc-André Lureau
94717418e5 Add some ABI size checks for what we are modifying next
We are about to modify the struct fields, let's make sure we don't break
the ABI.

Once check-abi is added to our CI, this shouldn't be needed, and can
probably be reverted.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2021-04-09 21:20:05 +04:00
Marc-André Lureau
a36184001c Rename spice_cairo_is_scaled -> allow_scaling
As it is just a getter for allow_scaling.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2021-04-09 21:08:46 +04:00
Jakub Janků
0ad07adc3e gstaudio: remove record bus watch to release GstBus
The GSource added by gst_bus_add_watch() apparently holds
a reference to the GstBus. This can be seen by running
GST_DEBUG="GST_TRACER:7" GST_TRACERS="leaks" spicy:

GST_TRACER :0:: object-alive, type-name=(string)GstBus, address=(gpointer)0x1e76db0, description=(string)<bus6>, ref-count=(uint)1, trace=(string);

(note that gst_deinit() must be called for this output to be shown,
 which doesn't happen in virt-viewer; see 0381e62)

To fix this, save the source's id returned by gst_bus_add_watch()
and remove the source when the pipe is unreferenced.

Signed-off-by: Jakub Janků <jjanku@redhat.com>
2021-02-19 12:44:23 +01:00
Marc-André Lureau
223f93c1d9 widget: notify about existing gl scanouts on registering channel
Show the current GL scanout, if any already.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2021-01-29 17:09:18 +04:00
Marc-André Lureau
2e4e3b7ba2 egl: don't call gl_make_current if context isn't ready
This avoids a critical warning. The function will eventually be called again on realize.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2021-01-29 17:08:30 +04:00