Commit Graph

130 Commits

Author SHA1 Message Date
Frediano Ziglio
7e56fc9fd9 Send real time to client
Do not offset the time attempting to fix client latency.
Client should handle it by itself.

This remove entirely the delay introduced by the server.
This avoids surely possible time drifts in the client.
The server just sends it's concept of time without trying to force any
delay. Only one end should handle this delay in an attempt to
synchronize audio and video instead that doing it in both ends.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2024-06-04 20:32:25 +01:00
Frediano Ziglio
f6f998004b Wrap spice.h in order to do some adjustment
Instead of including spice.h directly include an header that wraps
it. This allows to remove the SPICE_SERVER_INTERNAL define.
Currently is used to rename SpiceCharDeviceInstance to RedCharDevice
and reduce its visibility to hidden. This remove some warnings
and some weird code in the source.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
bd4b1caeb8 Use template to make adding timers/watches safer
Instead of forcibly cast functions cast only if data pointer and
function pointers match. This also allows to remove dangerous
casts all over the place.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
e0b395fb68 Declare exported functions as C
Allows to be used by both C and C++ code.
So to leave part of the code in C and part move to C++.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:08 +01:00
Frediano Ziglio
5308ab84b9 event-loop: Change internal core interface
Allow to modify/cancel timers/watches without having to retrieve
the code interface.
This will make sure that you are not using the wrong interface.
Simplify code to deal with timers/watches.
Remove the requirement to have the core interface available
for removing timers/watches.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-10-10 10:55:52 +01:00
Kevin Pouget
321c5cb7f6 reds: Add ability to query the video-codecs currently enabled
spice_server_get_video_codecs: new public function to query the video
encoders/codecs currently enabled in the spice server. It returns a
string that can be fed to the setter counter
(spice_server_set_video_codecs). The string returned by this function
should be released with spice_server_free_video_codecs.

spice_server_free_video_codecs: new public function to free the the
video codec list returned by spice_server_get_video_codecs.

video_codecs_to_string: new private function to transform an array of
RedVideoCodec into a string.

Signed-off-by: Kevin Pouget <kpouget@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-07-05 11:11:57 +01:00
Frediano Ziglio
3838f5470b reds: Factor out a function to marshal VDAgentGraphicsDeviceInfo message
Instead of scanning the monitor twice (one to compute the size
and another to build the message) use a single function to
marshal the message.
This also fixes big endian machines (which are not supported).
Marshal function is exported to make easier to test (see following
patch).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2019-02-12 21:24:54 +00:00
Frediano Ziglio
b69fe6cb33 reds: Explicitly include inttypes.h
MingW does not include this header while including stdint.h so
on Windows you need to include it.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2019-01-31 10:49:54 +00:00
Frediano Ziglio
f8e8ac4910 windows: Do not include headers not available on Windows
This is a preparatory patch for next portability patches

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2019-01-31 10:48:34 +00:00
Lukáš Hrázký
852ae0255c Send the graphics device info to the vd_agent
Sends the device address and device display IDs to the vdagent. The
message is sent either in reaction to the SPICE_MSGC_MAIN_AGENT_START
message or when the graphics device info changes.

Signed-off-by: Lukáš Hrázký <lhrazky@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2019-01-29 15:46:28 +01:00
Frediano Ziglio
c67876757f Reuse SPICE_UPCAST instead of SPICE_CONTAINEROF where possible
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2019-01-17 16:34:23 +00:00
Frediano Ziglio
ebcfa426e4 reds: Fix typo in declaration
recs -> reds

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2017-12-12 07:03:02 +00:00
Frediano Ziglio
343ac9f78d reds: Remove leak allocating migration state
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-10-13 17:10:53 +01:00
Frediano Ziglio
dd871c01a8 Avoid using global variable for channel IDs
This patch allocates VMC IDs by finding the first ID not used
instead of using a global variable and incrementing the value
for each channel created.
This solves some potential issues:
- remove the global state potentially making possible
  to use multiple SpiceServer on the same process;
- don't potentially overflow the variable. This can happen if
  channels are allocated/deallocated multiple times
  (currently not done by Qemu).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-09-02 08:20:56 +01:00
Frediano Ziglio
1026a89b78 reds: use SpiceMouseMode for RedsState::mouse_mode
Make easier to understant the value to use in the code.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-08-23 22:16:05 +01:00
Pavel Grunt
5dc55aa70d reds: Constantify agent message parameter
Make clear that the function is not changing it

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-06-02 11:20:45 +02:00
Jonathon Jongsma
332ad52143 Change playback_compression to bool type
This is a setting for determining whether to compress the audio playback
channel or not. It is variously typed as int or uint32_t. Convert it to
a 'bool' to make it more clear that it is a true/false value rather than
an enumeration or something like that.
2017-04-07 15:08:43 -05:00
Christophe Fergeau
bc5326b1ce Unify header guards
This changes the header guards in all .h files to follow this format:

/*
 * Licensing block
 */

/* ... */

Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-03-30 18:17:20 +01:00
Christophe Fergeau
6377b72d44 Use bool rather than int return values when appropriate
This commit changes all functions returning TRUE/FALSE from having an
'int' return value to 'bool'.
This way it's obvious that such a function is not going to return
anything else than TRUE or FALSE.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-03-09 18:39:29 +01:00
Frediano Ziglio
0bbfe733b8 record: Allocate recording file globally from reds.c
Allows to use recording function for multiple purposes.
This will allow to register multiple screen VM or recording
additional stuff like sound.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-03-02 16:14:10 +00:00
Frediano Ziglio
542bc47846 Remove g_smartcard_channel global
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-10-27 10:28:59 +01:00
Francois Gouget
497fcbb0a3 streaming: Let the administrator pick the video encoder and codec
The Spice server administrator can specify the encoder and codec
preferences to optimize for CPU or bandwidth usage. Preferences are
described in a semi-colon separated list of encoder:codec pairs.
The server has a default preference list which can explicitly be
selected by specifying 'auto'.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
2016-06-14 17:04:40 +02:00
Frediano Ziglio
24b3a8e73c Make some function static
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-25 15:41:58 +01:00
Frediano Ziglio
4585fa9cbd unify header include order
Use this style for include headers inside headers:

  #include <system_headers.h>
  #include <no_spice_no_system_libraries.h>
  #include <spice_protocol.h>
  #include <spice_common.h>

  #include "spice_server.h"

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-05-12 11:02:54 +01:00
Frediano Ziglio
8271168a35 Remove unused definitions
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-05-09 14:21:47 +01:00
Frediano Ziglio
1e4800507b use #include<> style for spice-common header inclusions.
The include directory is specified with the -I which is the directory
used directly by #include<>.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-05-09 12:45:27 +01:00
Christophe Fergeau
fb1ccd0f0d audio: Remove global 'playback_compression' variable
This variable belongs to SpiceServerConfig rather than being a static
global variable hidden in sound.c

Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-04-27 10:27:35 -05:00
Christophe Fergeau
8e5bacd8b1 Improve Reds/RedMainChannel interface
Instead of exporting 2 methods to get number of channels, and to fill
channel information, and use that from the main channel code, it's
better to do everything in one go in reds.c, and call that single method
from the main channel code.

Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-04-27 10:27:27 -05:00
Christophe Fergeau
b0cc5bfcbd Add _config_ to SpiceServerConfig accessors
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-04-27 10:27:23 -05:00
Christophe Fergeau
64dc3ab244 Use weak gobject ref instead of reds_on_char_device_state_destroy
RedCharDevice implementation had to callback into reds.c in order to let
it know a char device was being destroyed. Now that RedCharDevice is a
gobject, a weak reference can be used instead allowing to remove that
coupling.

Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-04-27 09:41:01 -05:00
Christophe Fergeau
e37f97a9f8 reds: Move RedsState typedef to red-common.h
This allows to stop using struct RedsState * rather than RedsState * in
headers which cannot include reds.h. This also allows to remove the
duplicate RedsState typedef in reds.h and reds-stream.h which is causing
issues with older gcc versions.
2016-04-06 10:30:00 +02:00
Jonathon Jongsma
b693eae580 Rename SpiceCharDeviceState to RedCharDevice
This is more consistent with internal type naming convention, and it
paves the way for a new char device GObject heirarchy

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-04-01 11:59:43 +01:00
Frediano Ziglio
ee4b8a1480 remove unused reds_set_mm_time
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2016-03-24 12:48:38 +00:00
Jonathon Jongsma
4f6c1765c7 Remove last usage of global 'reds' variable
This should be the final piece of removing the global reds variable. We
still need a global variable to clean up during the atexit() function,
but we use a GList of servers (even though we technically don't support
multiple servers in the same process yet).

Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-03-23 08:21:57 +00:00
Frediano Ziglio
e9ed125dbd use QXLState instead of RedDispatcher
Considering that:
- QXLState is the state of QXLInstance implementation;
- RedDispatcher is the implementation of QXL;
- qif (QXLInterface*) field can be computed really easy from QXLInstance;
- most of its state is private.
Make all structure private and use QXLState instead of RedDispatcher.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-03-04 15:47:45 +00:00
Christophe Fergeau
79cbe5ce53 Introduce reds_core_timer_* 2016-03-03 16:47:05 +00:00
Christophe Fergeau
ebbe4779fc Introduce reds_core_watch_*
These methods wrap the RedsCoreInterface::watch_add,
RedsCoreInterface::watch_remove and RedsCoreInterface::watch_update_mask
vfuncs.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-03-03 16:45:36 +00:00
Jonathon Jongsma
2a18e874a2 Remove global main_dispatcher variable
Requires changing a bunch of internal API to take MainDispatcher
arguments, etc. The main dispatcher object is now owned by RedsState,
since that is the object that previously created (initialized) it.

Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
2016-02-16 10:54:10 +00:00
Frediano Ziglio
aadb945570 Remove global 'dispatchers', 'num_active_workers' variables
Since these are server-level variables, move them into RedsState.
However, num_active_workers was removed because:
- each dispatcher always has 1 active worker, so we can determine the
  number of active workers by counting the dispatchers
- it was never actually set correctly. Even if there was more than one
  worker, this variable was always only set to either 0 or 1.

This change required moving a bunch of helper code into RedsState as
well, an providing some RedDispatcher interfaces to access dispatcher
information from RedsState.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
2016-02-16 10:10:58 +00:00
Frediano Ziglio
e98ed23bc2 move calc_compression_level to reds
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
2016-02-16 09:39:24 +00:00
Jonathon Jongsma
41d97b037a Add RedsState arg to all stat functions
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-15 12:04:02 +00:00
Frediano Ziglio
5c1d744d85 Store 'renderers' as GArray in RedsState
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-11 19:12:53 +00:00
Jonathon Jongsma
d576c76a70 Add RedsState arg to red_on_main_agent_tokens()
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-11 13:57:39 +00:00
Jonathon Jongsma
2726e04a9a Move 'core' into RedsState struct
Also add reds_get_core_interface() accessor for external use.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-11 11:55:30 +00:00
Marc-André Lureau
7a06efde1c Handle GL_SCANOUT messages
Go through dispatcher and marshall scanout message. Since the marshaller
and the QXL state are manipulated from different threads, add a mutex to
protect the current scanout.

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
2016-02-09 14:01:17 +00:00
Marc-André Lureau
ebf461b8e6 Add new spice-gl stubs API
- spice_qxl_gl_scanout() to take the current scanout

- spice_qxl_gl_draw_async() to draw the scanout, is like other Spice async
  functions, it takes a cookie and will return in the
  QXLInterface.async_complete()

Two new fields are also added to QXLState, in order to save the current
scanout, and the pending async.

A scanout can't be updated if there are pending draw atm. Discarding
outdated draws is left as a future improvement to allow updating the
scanout without waiting for draw async to be done.

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
[make QXL function names more coherent - Frediano Ziglio]
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-09 14:01:12 +00:00
Jonathon Jongsma
b0b64bea59 Add RedsState arg to reds_handle_channel_event()
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-09 11:10:00 +00:00
Jonathon Jongsma
4b228d5c1f Move agent_mouse to RedsState struct
Required adding a RedsState arg to reds_get_agent_mouse()

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-04 08:55:43 +00:00
Jonathon Jongsma
e7e42f4126 Move streaming_video to RedsState struct
Also requires adding reds_get_streaming_video() accessor so that other
files can check this value.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-04 08:55:43 +00:00
Jonathon Jongsma
5a8ccd1ac7 Move zlib_glz_state to RedsState struct
Also required adding reds_get_zlib_glz_state() for external access.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-02-03 15:14:46 +00:00