Commit Graph

33 Commits

Author SHA1 Message Date
Frediano Ziglio
e788e6e476 Remove conversion warnings
Use casts to avoid all that warning.
They should go away once you use more type safe types.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:08 +01:00
Frediano Ziglio
d8b1519c35 Remove -Wliteral-suffix warnings
Avoids warnings like

main-channel-client.cpp:538:27: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix]
    "net test: latency %f ms, bitrate %"G_GUINT64_FORMAT" bps (%f Mbps)%s",
    ^

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:08 +01:00
Frediano Ziglio
271dd5de41 video-encoder: Use enumeration for encode_frame result type
Better clear the result type instead of a generic "int".

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Kevin Pouget <kpouget@redhat.com>
2020-03-24 08:38:05 +00:00
Frediano Ziglio
1a3c0b1ee6 jpeg: Support big endian machines
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2019-06-19 10:36:10 +01:00
Frediano Ziglio
47cbfd4c59 Use SPICE_CONTAINEROF to avoid some possible alignment warnings on MIPS
This patch came from some experiments using an emulated MIPS machine.
On such architecture due to not supporting alignment access the
compiler is more strict about conversion complaining with some
pointer casts. Use different conversion to avoid these warnings.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <uril@redhat.com>
2019-06-18 09:48:28 +01:00
Francois Gouget
3d7f1cc512 mjpeg: Pull more code in get_min_required_playback_delay()
This reduces code duplication and passing the MJpegEncoder object
makes it possible to modify the playback calculation without adding
more arguments.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-05-21 09:05:50 +01:00
Francois Gouget
7515a0ac57 mjpeg: Constify some MJpegEncoder* parameters
Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-05-21 09:05:47 +01:00
Francois Gouget
a9c5bb974a mjpeg: Remove the unused MJPEG_LOW_FPS_RATE_TH constant
Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2019-05-16 08:23:05 +01:00
Frediano Ziglio
ed68d491fd Do not check for HAVE_CONFIG_H
This should always be defined and including config.h is a requirement.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2019-04-30 09:26:55 +01:00
Frediano Ziglio
98b8c725f2 Use proper format strings for spice_log
Formatting string should be compatible with GLib.
GLib uses formatting types compatible with GNU.
For Linux this is not an issue as both systems (like a printf) and
GLib one uses the same formatting type.  However on Windows they
differs potentially causing issues.
This is also make worse as GLib 2.58 changed format attribute from
__printf__ to gnu_printf (Microsoft compatibility formats like %I64d
are still supported but you'll get warnings using GCC/Clang
compilers).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2019-03-05 13:55:47 +00:00
Frediano Ziglio
8a9c51bd4f mjpeg-encoder: Fix some typos
unexected -> unexpected
esitimation -> estimation

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-11-29 11:17:21 +00:00
Frediano Ziglio
c9cbbd6196 mjpeg: Use GLib memory functions
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-10-11 12:52:17 +01:00
Frediano Ziglio
b84d5d0124 mjpeg: Reuse realloc instead of implementing it manually
This potentially can also save the copy if there is enough
space to resize the buffer in place.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-09-11 21:05:50 +01:00
Christophe Fergeau
1569d429b7 Remove use of spice_debug(NULL)
This is causing issues with potential improvements to the logging
system, and I've always found this usage a bit odd anyway.
Using spice_debug(""); was not possible as this triggers
-Wformat-zero-length warnings from our use of -Wall.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-06-15 16:40:25 +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
91668cdaab Sort include order in source files
Sort based on coding style.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-12-16 08:16:21 +00:00
Francois Gouget
97fcad82eb streaming: Always delegate bit rate control to the video encoder
The video encoders already have sophisticated bit rate control code that
can react to both stream reports sent by the client, and server frame
drop notifications. Furthermore they can adjust both the frame rate and
the image quality to best match the network conditions.

But if the client cannot send stream reports all this is bypassed and
instead the streaming code performs its own primitive bit rate control
that can only adjust the frame rate.

So this patch removes the code duplication and lets the video encoders
do their job.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-21 16:47:51 +00:00
Frediano Ziglio
4c23b55e7e syntax-check: Silent a wrong positive
Due to syntax-check limitation this free calls results in
a syntax error.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-11-09 16:20:22 +00:00
Uri Lublin
44624ed8bf mjpeg_encoder_new: allocate memory after sanity check
This patch prevents a leak in case the function returns early

Found by coverity.

Signed-off-by: Uri Lublin <uril@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-10-17 10:49:41 +01:00
Francois Gouget
49036e6aae streaming: Avoid copying the input frame in the GStreamer encoder
Note that we can only avoid copies for the first 1 Mpixels or so.
That's because Spice splits larger frames into more chunks than we can
fit GstMemory fragments in a GStreamer buffer. So if there are more
pixels we will avoid copies for the first 3840 KB and copy the rest.
Furthermore, while in practice the GStreamer encoder will only modify
the RedDrawable refcount during the encode_frame(), in theory the
refcount could be decremented from the GStreamer thread after
encode_frame() returns.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
2016-06-14 17:04:40 +02:00
Francois Gouget
2db59fef3a streaming: Let the video encoder manage the compressed buffer
This way the video encoder is not forced to use malloc()/free().
This also allows more flexibility in how the video encoder manages the
buffer which allows for a zero-copy implementation in both video
encoders.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
2016-06-14 17:04:40 +02: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
Francois Gouget
1b69198c4e streaming: Remove the width/height encode_frame() parameters
encode_frame() needs the QXL_DRAW_COPY operation's SpiceCopy.src_area
field anyway, so the width and height parameters were redundant.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
2016-06-14 17:04:40 +02:00
Francois Gouget
032cb0ce85 mjpeg: Use src_area as the authoritative source for the frame dimensions
Video frames correspond to QXL_DRAW_COPY operations where the frame area
is defined by the SpiceCopy.src_area field.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
2016-06-14 17:04:40 +02:00
Francois Gouget
0e10629d70 server: Enable adding alternative MJPEG video encoders
This replaces the original mjpeg_encoder API with a VideoEncoder base
class which can be reimplemented by other encoders.
This also renames the members and enums from mjpeg_* to video_*.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-05-04 10:51:55 +01:00
Christophe Fergeau
26f874e738 mjpeg: Add missing space to debug string 2016-04-01 15:16:27 +02:00
Francois Gouget
aa5a5fa630 server: Store the opaque pointer in VideoEncoderRateControlCbs
It has the same lifetime as the corresponding structure so this
simplifies keeping track of it.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-03-03 11:47:49 +00:00
Francois Gouget
8bddb1444e server: Add time constants to go with spice_get_monotonic_time_ms()
They clarify the time unit being used and simplify calculations.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2015-12-14 11:24:47 +00:00
Francois Gouget
5c9fb9a0f3 server: Add time constants to go with spice_get_monotonic_time_ns()
They clarify the time unit being used, reduce the need for casts and
simplify calculations.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2015-12-14 11:24:34 +00:00
Francois Gouget
65b60250d0 server: Rename red_get_monotonic_time() to spice_get_monotonic_time_ns()
This is a generic function not tied to the red_xxx functionality and the
new name clarifies that it returns the time in nanoseconds (unlike
g_get_monotonic_time()).

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2015-12-11 12:43:26 +00:00
Francois Gouget
c8d5120ff0 server: Define the MJPEG encoder warmup time in nanoseconds
Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
2015-12-08 15:08:44 -06:00
Francois Gouget
4ce4c4a525 server: Simplify the MJPEG encoder's maximum framerate estimation
Note that if frame_size == bytes_per_sec == 0 this now returns
MJPEG_MAX_FPS but this should not happen anyway.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
2015-12-08 16:22:41 +01:00
Frediano Ziglio
525cd67be7 server: rename files
Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2015-12-03 23:54:32 +00:00