Commit Graph

92 Commits

Author SHA1 Message Date
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
Frediano Ziglio
81f3d44ee7 Move image_encoders_compress_glz to dcc-encoders.c
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-14 15:07:31 +01:00
Frediano Ziglio
cb8e832c87 Make dcc_compress_image_glz independent to DisplayChannelClient
Also rename to image_encoders_compress_glz

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-14 15:07:31 +01:00
Frediano Ziglio
108d11f4aa Move others glz fields to dcc-encoders
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-14 15:07:31 +01:00
Frediano Ziglio
41231aa4f8 Change dcc_encoders_init to take ImageEncoders instead of DisplayChannelClient
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-14 15:07:29 +01:00
Frediano Ziglio
b46984ed30 Move some glz fields to ImageEncoders
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-14 15:07:28 +01:00
Frediano Ziglio
86b702a7d0 Add a structure to hold ImageEncoders shared data
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-14 15:07:23 +01:00
Frediano Ziglio
9c5a8d5bce More encapsulation for dcc_encoders_free
Encoders function should not use DisplayChannelClient

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-10 09:15:24 +01:00
Frediano Ziglio
c2bc754559 Encapsulate zlib information in ImageEncoders structure
This change is less clean the other similar patches as zlib and
glz require more steps.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-10 09:15:17 +01:00
Frediano Ziglio
21a90ae986 Move image_encoders_compress_lz4 to dcc-encoders.c
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-09 22:50:12 +01:00
Frediano Ziglio
aa10a2ca2a Prepare to move dcc_compress_image_lz4 to ImageEncoders
Remove all DisplayChannel(Client) dependencies.
Rename function.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-09 22:50:10 +01:00
Frediano Ziglio
6d70d15d64 Encapsulate lz4 information in ImageEncoders structure
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-09 22:50:02 +01:00
Frediano Ziglio
25c0b204c4 Move image_encoders_compress_jpeg to dcc-encoders.c
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-09 22:32:50 +01:00
Frediano Ziglio
9d92a2edc8 Prepare to move dcc_compress_image_jpeg to ImageEncoders
Remove all DisplayChannel(Client) dependencies.
Rename function.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-09 22:32:48 +01:00
Frediano Ziglio
7b6cb37cc0 Encapsulate jpeg information in ImageEncoders structure
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-09 22:32:26 +01:00
Frediano Ziglio
cff7950aa3 Move image_encoders_compress_lz to dcc-encoders.c
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-09 22:11:30 +01:00
Frediano Ziglio
c5caf0dddd Prepare to move dcc_compress_image_lz to ImageEncoders
Remove all DisplayChannel(Client) dependencies.
Rename function.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-09 22:11:27 +01:00
Frediano Ziglio
a25182f060 Encapsulate lz information in ImageEncoders structure
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-09 22:11:20 +01:00
Frediano Ziglio
fa0a579a65 Move image_encoders_compress_quic to dcc-encoders.c
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-09 21:14:43 +01:00
Frediano Ziglio
645b8af35b Prepare to move dcc_compress_image_quic to ImageEncoders
Remove all DisplayChannel(Client) dependencies.
Rename function.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-09 21:12:43 +01:00
Frediano Ziglio
d7fb16c80e Encapsulate quic information in a new ImageEncoders structure
Start putting all encoding code into dcc-encoders.c.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-09 21:12:34 +01:00
Frediano Ziglio
a051a4d884 Move dcc glz field initialization into dcc_new
There is no reason to initialize these fields in two different places.
Note that an usage between dcc_new and the function where these
field were initialised would have resulted in a crash.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-07 23:09:45 +01:00
Frediano Ziglio
4c171dbd0c Remove unused parameter
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
2016-06-04 10:10:08 +01:00
Frediano Ziglio
e8d7fecbc2 Remove only written field
EncoderData::dcc field is never read back.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-06-03 16:31:20 +01:00
Frediano Ziglio
02adcf354e Introduce SPICE_UPCAST macro
This was proposed by Christophe as improvement over some typesafe
patches.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-05-24 18:00:51 +01:00
Frediano Ziglio
8782bb3211 Make some function static
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-05-24 13:39:48 +01:00
Frediano Ziglio
70f04bdab3 Get code more typesafe
Scan remaining code searching for problems with structure
layout assumptions in the code.
Where code required some restructuring put some verify checks
to make sure code won't compile if these assumptions are not
in place anymore.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-21 04:14:13 +01:00
Frediano Ziglio
fb655ff481 reduce casts to RedPipeItem and RingItem
Make code more type safe. This allow to move or delete structure
fields more safely

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-21 04:11:12 +01:00
Frediano Ziglio
8d764488ca make red_pipe_item_init_full more typesafe
Use a proper type for free callback

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-21 04:11:12 +01:00
Frediano Ziglio
44352ca846 Remove dcc_release_item
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-17 23:53:27 +01:00
Frediano Ziglio
8dbd52f42a Simplify dcc_release_item
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-17 23:52:33 +01:00
Frediano Ziglio
ce9a770dd9 Simplify release_item_after_push
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-17 23:52:28 +01:00
Frediano Ziglio
767818da66 Handle STREAM_CREATE and STREAM_DESTROY pipe items more coherently
The items of these pipe items were allocated staticaly inside the
StreamAgent structure. All others RedPipeItem are allocated dynamically.
This could solve possible future maintenance as the life of these
item is more easier to understand.
It's more easier to understand why reference where incremented.
It also make the StreamAgent structure a bit smaller.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-17 23:52:06 +01:00
Frediano Ziglio
f94ef59de8 Simplify release of STREAM_CREATE and STREAM_DESTROY pipe items
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-17 23:52:03 +01:00
Frediano Ziglio
68c6d52e32 Simplify release of CREATE_SURFACE and DESTROY_SURFACE pipe items
Putting base as first item the default free function is fine.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-17 23:49:24 +01:00
Frediano Ziglio
9ecff9e061 Call red_pipe_item_unref instead of free
This is the standard way to release a RedPipeItem

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-17 23:49:16 +01:00
Frediano Ziglio
d26648404a Simplify RED_PIPE_ITEM_TYPE_DRAW item release
Move ring_remove to the function to release this type of item.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2016-05-17 23:49:05 +01: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
Francois Gouget
8a5ba34c01 server: Correctly handle and trace stream report errors
We may get stream reports after the stream has been closed, and even, in
extreme cases, after a new stream has started reusing the same stream
id. Neither case should cause the server to crash.
So restore dcc_handle_stream_report() to how it was before being moved
to dcc.c.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2016-05-04 10:49:13 +01:00
Jonathon Jongsma
920e117c24 Rename all RedPipeItem subclasses
Use 'Red' prefix to match internal type naming convention

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-04-27 10:22:26 -05:00
Jonathon Jongsma
b9720d80e0 Rename PipeItem to RedPipeItem
Following internal type naming conventions

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-04-27 10:22:01 -05:00
Jonathon Jongsma
18d3876b78 UpgradeItem: use base PipeItem for refcounting
No need to re-implement refcounting in this subclass.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-04-27 09:40:57 -05:00
Jonathon Jongsma
50a2c2fce2 Store display in Drawable struct
If the Drawable keeps a pointer to the Display channel that it is
associated with, we can unref it directly and not need to pass the
'display' parameter separately to the unref function

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-04-27 09:40:43 -05:00
Jonathon Jongsma
521dd24ffb dcc: Use refcounting for MonitorsConfigItem 2016-04-15 11:14:34 -05:00
Jonathon Jongsma
e09598ec75 StreamClipItem: use base class refcounting
PipeItem already implements refcounting. Use it.
2016-04-15 09:59:10 -05:00
Jonathon Jongsma
889a0b880f DrawablePipeItem: use base class for refcounting
Since PipeItem already implements refcounting, there's no need to
re-implement it here.
2016-04-15 09:59:08 -05:00
Jonathon Jongsma
3bd6b215d3 dcc: use PipeItem refcounting for ImageItem
Since the base class now implements refcounting, there's no need to
re-invent it here.
2016-04-15 09:53:19 -05:00
Christophe Fergeau
a653044011 Rename red_channel_pipe_item_init to pipe_item_init
The RedChannel argument is not used by pipe_item_init. Removing it
will make code simpler in places where we don't have a RedChannel
directly available.
This is acting on a PipeItem object so correct name is pipe_item_init.

Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-03-10 11:36:52 +00:00
Marc-André Lureau
acd53b97fb Fix dcc_start() regression
Commit e9ed125d introduced a dead-lock regression by taking twice the
same lock recursively. The previous code checked if a dmabuf was set
without taking the lock, for queuing scanout messages. Since the message
is being processed later on, it make sense to queue and delay until it
is sent to check if there is a scanout.

backtrace:
 #0  red_qxl_get_gl_scanout (qxl_state=0x5555582373c0) at red-qxl.c:828
 #1  0x00007fffec1ae654 in marshall_gl_scanout (rcc=0x7fffda6a7010,
 #m=0x7fff44025e60, item=0x7fff440958a0) at dcc-send.c:2310
 #2  0x00007fffec1aec7b in dcc_send_item (dcc=0x7fffda6a7010,
 #pipe_item=0x7fff440958a0) at dcc-send.c:2441
 #3  0x00007fffec1730f6 in send_item (rcc=0x7fffda6a7010,
 #item=0x7fff440958a0) at display-channel.c:1963
 #4  0x00007fffec1504c3 in
 #red_channel_client_send_item (rcc=0x7fffda6a7010, item=0x7fff440958a0)
 #at red-channel.c:578
 #5  0x00007fffec152d98 in red_channel_client_push (rcc=0x7fffda6a7010)
 #at red-channel.c:1365
 #6  0x00007fffec1a387e in dcc_push_monitors_config (dcc=0x7fffda6a7010)
 #at dcc.c:563
 #7  0x00007fffec1a3489 in dcc_start (dcc=0x7fffda6a7010) at dcc.c:475

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-03-08 15:24:56 +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