summaryrefslogtreecommitdiff
path: root/server/dcc.cpp
diff options
context:
space:
mode:
authorFrediano Ziglio <fziglio@redhat.com>2019-05-28 05:03:01 +0100
committerFrediano Ziglio <freddy77@gmail.com>2020-05-01 06:58:09 +0100
commit874e7450887375730a4b3675b9b1b7002b440ea8 (patch)
tree1c8a78bf253ea909caf969ba92ff6b802012e9e2 /server/dcc.cpp
parent2b078c44d7acf2fd26af789eda0869cd337f6621 (diff)
Move all red_channel_client_* functions in header as methods
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Diffstat (limited to 'server/dcc.cpp')
-rw-r--r--server/dcc.cpp97
1 files changed, 46 insertions, 51 deletions
diff --git a/server/dcc.cpp b/server/dcc.cpp
index f478001d..606e6873 100644
--- a/server/dcc.cpp
+++ b/server/dcc.cpp
@@ -233,7 +233,7 @@ bool dcc_clear_surface_drawables_from_pipe(DisplayChannelClient *dcc, int surfac
/* removing the newest drawables that their destination is surface_id and
no other drawable depends on them */
- for (l = red_channel_client_get_pipe(dcc)->head; l != NULL; ) {
+ for (l = dcc->get_pipe()->head; l != NULL; ) {
Drawable *drawable;
RedDrawablePipeItem *dpi = NULL;
int depend_found = FALSE;
@@ -251,7 +251,7 @@ bool dcc_clear_surface_drawables_from_pipe(DisplayChannelClient *dcc, int surfac
}
if (drawable->surface_id == surface_id) {
- red_channel_client_pipe_remove_and_release_pos(dcc, item_pos);
+ dcc->pipe_remove_and_release_pos(item_pos);
continue;
}
@@ -267,8 +267,7 @@ bool dcc_clear_surface_drawables_from_pipe(DisplayChannelClient *dcc, int surfac
if (!wait_if_used) {
return TRUE;
}
- return red_channel_client_wait_pipe_item_sent(dcc, item_pos,
- COMMON_CLIENT_TIMEOUT);
+ return dcc->wait_pipe_item_sent(item_pos, COMMON_CLIENT_TIMEOUT);
}
}
@@ -280,7 +279,7 @@ bool dcc_clear_surface_drawables_from_pipe(DisplayChannelClient *dcc, int surfac
* in case that the pipe didn't contain any item that is dependent on the surface, but
* there is one during sending. Use a shorter timeout, since it is just one item
*/
- return red_channel_client_wait_outgoing_item(dcc, DISPLAY_CLIENT_SHORT_TIMEOUT);
+ return dcc->wait_outgoing_item(DISPLAY_CLIENT_SHORT_TIMEOUT);
}
void dcc_create_surface(DisplayChannelClient *dcc, int surface_id)
@@ -308,7 +307,7 @@ void dcc_create_surface(DisplayChannelClient *dcc, int surface_id)
surface->context.height,
surface->context.format, flags);
dcc->priv->surface_client_created[surface_id] = TRUE;
- red_channel_client_pipe_add(dcc, &create->base);
+ dcc->pipe_add(&create->base);
}
// adding the pipe item after pos. If pos == NULL, adding to head.
@@ -366,9 +365,9 @@ RedImageItem *dcc_add_surface_area_image(DisplayChannelClient *dcc,
}
if (pipe_item_pos) {
- red_channel_client_pipe_add_after_pos(dcc, &item->base, pipe_item_pos);
+ dcc->pipe_add_after_pos(&item->base, pipe_item_pos);
} else {
- red_channel_client_pipe_add(dcc, &item->base);
+ dcc->pipe_add(&item->base);
}
return item;
@@ -456,7 +455,7 @@ void dcc_prepend_drawable(DisplayChannelClient *dcc, Drawable *drawable)
RedDrawablePipeItem *dpi = red_drawable_pipe_item_new(dcc, drawable);
add_drawable_surface_images(dcc, drawable);
- red_channel_client_pipe_add(dcc, &dpi->base);
+ dcc->pipe_add(&dpi->base);
}
void dcc_append_drawable(DisplayChannelClient *dcc, Drawable *drawable)
@@ -464,7 +463,7 @@ void dcc_append_drawable(DisplayChannelClient *dcc, Drawable *drawable)
RedDrawablePipeItem *dpi = red_drawable_pipe_item_new(dcc, drawable);
add_drawable_surface_images(dcc, drawable);
- red_channel_client_pipe_add_tail(dcc, &dpi->base);
+ dcc->pipe_add_tail(&dpi->base);
}
void dcc_add_drawable_after(DisplayChannelClient *dcc, Drawable *drawable, RedPipeItem *pos)
@@ -472,7 +471,7 @@ void dcc_add_drawable_after(DisplayChannelClient *dcc, Drawable *drawable, RedPi
RedDrawablePipeItem *dpi = red_drawable_pipe_item_new(dcc, drawable);
add_drawable_surface_images(dcc, drawable);
- red_channel_client_pipe_add_after(dcc, &dpi->base, pos);
+ dcc->pipe_add_after(&dpi->base, pos);
}
static void dcc_init_stream_agents(DisplayChannelClient *dcc)
@@ -537,8 +536,8 @@ static bool display_channel_client_wait_for_init(DisplayChannelClient *dcc)
dcc->priv->expect_init = TRUE;
uint64_t end_time = spice_get_monotonic_time_ns() + COMMON_CLIENT_TIMEOUT;
for (;;) {
- red_channel_client_receive(dcc);
- if (!red_channel_client_is_connected(dcc)) {
+ dcc->receive();
+ if (!dcc->is_connected()) {
break;
}
if (dcc->priv->pixmap_cache && dcc->priv->encoders.glz_dict) {
@@ -552,7 +551,7 @@ static bool display_channel_client_wait_for_init(DisplayChannelClient *dcc)
}
if (spice_get_monotonic_time_ns() > end_time) {
spice_warning("timeout");
- red_channel_client_disconnect(dcc);
+ dcc->disconnect();
break;
}
usleep(DISPLAY_CLIENT_RETRY_INTERVAL);
@@ -564,29 +563,29 @@ void dcc_start(DisplayChannelClient *dcc)
{
DisplayChannel *display = DCC_TO_DC(dcc);
- red_channel_client_push_set_ack(dcc);
+ dcc->push_set_ack();
- if (red_channel_client_is_waiting_for_migrate_data(dcc))
+ if (dcc->is_waiting_for_migrate_data())
return;
if (!display_channel_client_wait_for_init(dcc))
return;
g_object_ref(dcc);
- red_channel_client_ack_zero_messages_window(dcc);
+ dcc->ack_zero_messages_window();
if (display->priv->surfaces[0].context.canvas) {
display_channel_current_flush(display, 0);
- red_channel_client_pipe_add_type(dcc, RED_PIPE_ITEM_TYPE_INVAL_PALETTE_CACHE);
+ dcc->pipe_add_type(RED_PIPE_ITEM_TYPE_INVAL_PALETTE_CACHE);
dcc_create_surface(dcc, 0);
dcc_push_surface_image(dcc, 0);
dcc_push_monitors_config(dcc);
- red_channel_client_pipe_add_empty_msg(dcc, SPICE_MSG_DISPLAY_MARK);
+ dcc->pipe_add_empty_msg(SPICE_MSG_DISPLAY_MARK);
dcc_create_all_streams(dcc);
}
- if (red_stream_is_plain_unix(red_channel_client_get_stream(dcc)) &&
- red_channel_client_test_remote_cap(dcc, SPICE_DISPLAY_CAP_GL_SCANOUT)) {
- red_channel_client_pipe_add(dcc, dcc_gl_scanout_item_new(dcc, NULL, 0));
+ if (red_stream_is_plain_unix(dcc->get_stream()) &&
+ dcc->test_remote_cap(SPICE_DISPLAY_CAP_GL_SCANOUT)) {
+ dcc->pipe_add(dcc_gl_scanout_item_new(dcc, NULL, 0));
dcc_push_monitors_config(dcc);
}
g_object_unref(dcc);
@@ -627,7 +626,7 @@ void dcc_video_stream_agent_clip(DisplayChannelClient* dcc, VideoStreamAgent *ag
{
VideoStreamClipItem *item = video_stream_clip_item_new(agent);
- red_channel_client_pipe_add(dcc, &item->base);
+ dcc->pipe_add(&item->base);
}
static void red_monitors_config_item_free(RedPipeItem *pipe_item)
@@ -662,14 +661,13 @@ void dcc_push_monitors_config(DisplayChannelClient *dcc)
return;
}
- if (!red_channel_client_test_remote_cap(dcc,
- SPICE_DISPLAY_CAP_MONITORS_CONFIG)) {
+ if (!dcc->test_remote_cap(SPICE_DISPLAY_CAP_MONITORS_CONFIG)) {
return;
}
- mci = red_monitors_config_item_new(red_channel_client_get_channel(dcc),
+ mci = red_monitors_config_item_new(dcc->get_channel(),
monitors_config);
- red_channel_client_pipe_add(dcc, &mci->base);
+ dcc->pipe_add(&mci->base);
}
static RedSurfaceDestroyItem *red_surface_destroy_item_new(uint32_t surface_id)
@@ -688,11 +686,11 @@ RedPipeItem *dcc_gl_scanout_item_new(RedChannelClient *rcc, void *data, int num)
RedGlScanoutUnixItem *item;
/* FIXME: on !unix peer, start streaming with a video codec */
- if (!red_stream_is_plain_unix(red_channel_client_get_stream(rcc)) ||
- !red_channel_client_test_remote_cap(rcc, SPICE_DISPLAY_CAP_GL_SCANOUT)) {
- red_channel_warning(red_channel_client_get_channel(rcc),
+ if (!red_stream_is_plain_unix(rcc->get_stream()) ||
+ !rcc->test_remote_cap(SPICE_DISPLAY_CAP_GL_SCANOUT)) {
+ red_channel_warning(rcc->get_channel(),
"FIXME: client does not support GL scanout");
- red_channel_client_disconnect(rcc);
+ rcc->disconnect();
return NULL;
}
@@ -708,11 +706,11 @@ RedPipeItem *dcc_gl_draw_item_new(RedChannelClient *rcc, void *data, int num)
const SpiceMsgDisplayGlDraw *draw = (const SpiceMsgDisplayGlDraw *) data;
RedGlDrawItem *item;
- if (!red_stream_is_plain_unix(red_channel_client_get_stream(rcc)) ||
- !red_channel_client_test_remote_cap(rcc, SPICE_DISPLAY_CAP_GL_SCANOUT)) {
- red_channel_warning(red_channel_client_get_channel(rcc),
+ if (!red_stream_is_plain_unix(rcc->get_stream()) ||
+ !rcc->test_remote_cap(SPICE_DISPLAY_CAP_GL_SCANOUT)) {
+ red_channel_warning(rcc->get_channel(),
"FIXME: client does not support GL scanout");
- red_channel_client_disconnect(rcc);
+ rcc->disconnect();
return NULL;
}
@@ -742,7 +740,7 @@ void dcc_destroy_surface(DisplayChannelClient *dcc, uint32_t surface_id)
dcc->priv->surface_client_created[surface_id] = FALSE;
destroy = red_surface_destroy_item_new(surface_id);
- red_channel_client_pipe_add(dcc, &destroy->base);
+ dcc->pipe_add(&destroy->base);
}
#define MIN_DIMENSION_TO_QUIC 3
@@ -866,8 +864,7 @@ int dcc_compress_image(DisplayChannelClient *dcc,
goto lz_compress;
#ifdef USE_LZ4
case SPICE_IMAGE_COMPRESSION_LZ4:
- if (red_channel_client_test_remote_cap(dcc,
- SPICE_DISPLAY_CAP_LZ4_COMPRESSION)) {
+ if (dcc->test_remote_cap(SPICE_DISPLAY_CAP_LZ4_COMPRESSION)) {
success = image_encoders_compress_lz4(&dcc->priv->encoders, dest, src, o_comp_data);
break;
}
@@ -949,12 +946,11 @@ bool dcc_pixmap_cache_unlocked_add(DisplayChannelClient *dcc, uint64_t id,
spice_assert(size > 0);
item = g_new(NewCacheItem, 1);
- serial = red_channel_client_get_message_serial(dcc);
+ serial = dcc->get_message_serial();
if (cache->generation != dcc->priv->pixmap_cache_generation) {
if (!dcc->priv->pending_pixmaps_sync) {
- red_channel_client_pipe_add_type(dcc,
- RED_PIPE_ITEM_TYPE_PIXMAP_SYNC);
+ dcc->pipe_add_type(RED_PIPE_ITEM_TYPE_PIXMAP_SYNC);
dcc->priv->pending_pixmaps_sync = TRUE;
}
g_free(item);
@@ -1007,7 +1003,7 @@ bool dcc_pixmap_cache_unlocked_add(DisplayChannelClient *dcc, uint64_t id,
static bool dcc_handle_init(DisplayChannelClient *dcc, SpiceMsgcDisplayInit *init)
{
gboolean success;
- RedClient *client = red_channel_client_get_client(dcc);
+ RedClient *client = dcc->get_client();
spice_return_val_if_fail(dcc->priv->expect_init, FALSE);
dcc->priv->expect_init = FALSE;
@@ -1211,7 +1207,7 @@ bool dcc_handle_message(RedChannelClient *rcc, uint16_t type, uint32_t size, voi
return dcc_handle_preferred_video_codec_type(dcc,
(SpiceMsgcDisplayPreferredVideoCodecType *)msg);
default:
- return red_channel_client_handle_message(rcc, type, size, msg);
+ return RedChannelClient::handle_message(rcc, type, size, msg);
}
}
@@ -1220,7 +1216,7 @@ static int dcc_handle_migrate_glz_dictionary(DisplayChannelClient *dcc,
{
GlzEncDictRestoreData glz_dict_data = migrate->glz_dict_data;
return image_encoders_restore_glz_dictionary(&dcc->priv->encoders,
- red_channel_client_get_client(dcc),
+ dcc->get_client(),
migrate->glz_dict_id,
&glz_dict_data);
}
@@ -1296,7 +1292,7 @@ bool dcc_handle_migrate_data(DisplayChannelClient *dcc, uint32_t size, void *mes
* channel client that froze the cache on the src size receives the migrate
* data and unfreezes the cache by setting its size > 0 and by triggering
* pixmap_cache_reset */
- dcc->priv->pixmap_cache = pixmap_cache_get(red_channel_client_get_client(dcc),
+ dcc->priv->pixmap_cache = pixmap_cache_get(dcc->get_client(),
migrate_data->pixmap_cache_id, -1);
spice_return_val_if_fail(dcc->priv->pixmap_cache, FALSE);
@@ -1311,7 +1307,7 @@ bool dcc_handle_migrate_data(DisplayChannelClient *dcc, uint32_t size, void *mes
/* activating the cache. The cache will start to be active after
* pixmap_cache_reset is called, when handling RED_PIPE_ITEM_TYPE_PIXMAP_RESET */
dcc->priv->pixmap_cache->size = migrate_data->pixmap_cache_size;
- red_channel_client_pipe_add_type(dcc, RED_PIPE_ITEM_TYPE_PIXMAP_RESET);
+ dcc->pipe_add_type(RED_PIPE_ITEM_TYPE_PIXMAP_RESET);
}
if (dcc_handle_migrate_glz_dictionary(dcc, migrate_data)) {
@@ -1323,7 +1319,7 @@ bool dcc_handle_migrate_data(DisplayChannelClient *dcc, uint32_t size, void *mes
dcc->is_low_bandwidth = migrate_data->low_bandwidth_setting;
if (migrate_data->low_bandwidth_setting) {
- red_channel_client_ack_set_client_window(dcc, WIDE_CLIENT_ACK_WINDOW);
+ dcc->ack_set_client_window(WIDE_CLIENT_ACK_WINDOW);
if (dcc->priv->jpeg_state == SPICE_WAN_COMPRESSION_AUTO) {
display->priv->enable_jpeg = TRUE;
}
@@ -1339,10 +1335,9 @@ bool dcc_handle_migrate_data(DisplayChannelClient *dcc, uint32_t size, void *mes
spice_return_val_if_fail(surfaces_restored, FALSE);
- red_channel_client_pipe_add_type(dcc,
- RED_PIPE_ITEM_TYPE_INVAL_PALETTE_CACHE);
+ dcc->pipe_add_type(RED_PIPE_ITEM_TYPE_INVAL_PALETTE_CACHE);
/* enable sending messages */
- red_channel_client_ack_zero_messages_window(dcc);
+ dcc->ack_zero_messages_window();
return TRUE;
}
@@ -1388,7 +1383,7 @@ void dcc_set_max_stream_bit_rate(DisplayChannelClient *dcc, uint64_t rate)
static bool dcc_config_socket(RedChannelClient *rcc)
{
- RedClient *client = red_channel_client_get_client(rcc);
+ RedClient *client = rcc->get_client();
MainChannelClient *mcc = red_client_get_main(client);
DISPLAY_CHANNEL_CLIENT(rcc)->is_low_bandwidth = main_channel_client_is_low_bandwidth(mcc);