red-channel: Move config_socket vfunc to RedChannelClient

config_socket is configuring the client stream socket.
As is responsibility of RedChannelClient to handle the stream
it make more sense to have the function in this object.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
This commit is contained in:
Frediano Ziglio 2017-03-08 11:20:35 +00:00
parent 312c0aadf0
commit 4f7fbb3113
10 changed files with 26 additions and 25 deletions

View File

@ -120,7 +120,7 @@ common_graphics_channel_set_property(GObject *object,
}
}
int common_channel_config_socket(RedChannelClient *rcc)
int common_channel_client_config_socket(RedChannelClient *rcc)
{
RedClient *client = red_channel_client_get_client(rcc);
MainChannelClient *mcc = red_client_get_main(client);
@ -155,15 +155,12 @@ static void
common_graphics_channel_class_init(CommonGraphicsChannelClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS(klass);
RedChannelClass *channel_class = RED_CHANNEL_CLASS(klass);
g_type_class_add_private(klass, sizeof(CommonGraphicsChannelPrivate));
object_class->get_property = common_graphics_channel_get_property;
object_class->set_property = common_graphics_channel_set_property;
channel_class->config_socket = common_channel_config_socket;
g_object_class_install_property(object_class,
PROP_QXL,
g_param_spec_pointer("qxl",
@ -208,6 +205,7 @@ common_graphics_channel_client_class_init(CommonGraphicsChannelClientClass *klas
g_type_class_add_private(klass, sizeof(CommonGraphicsChannelClientPrivate));
client_class->config_socket = common_channel_client_config_socket;
client_class->alloc_recv_buf = common_alloc_recv_buf;
client_class->release_recv_buf = common_release_recv_buf;
}

View File

@ -25,7 +25,7 @@
G_BEGIN_DECLS
int common_channel_config_socket(RedChannelClient *rcc);
int common_channel_client_config_socket(RedChannelClient *rcc);
#define COMMON_CLIENT_TIMEOUT (NSEC_PER_SEC * 30)

View File

@ -41,6 +41,7 @@ enum
};
static void on_display_video_codecs_update(GObject *gobject, GParamSpec *pspec, gpointer user_data);
static int dcc_config_socket(RedChannelClient *rcc);
static void
display_channel_client_get_property(GObject *object,
@ -124,12 +125,15 @@ static void
display_channel_client_class_init(DisplayChannelClientClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS(klass);
RedChannelClientClass *client_class = RED_CHANNEL_CLIENT_CLASS(klass);
object_class->get_property = display_channel_client_get_property;
object_class->set_property = display_channel_client_set_property;
object_class->constructed = display_channel_client_constructed;
object_class->finalize = display_channel_client_finalize;
client_class->config_socket = dcc_config_socket;
g_object_class_install_property(object_class,
PROP_IMAGE_COMPRESSION,
g_param_spec_enum("image-compression",
@ -1417,14 +1421,14 @@ void dcc_set_max_stream_bit_rate(DisplayChannelClient *dcc, uint64_t rate)
dcc->priv->streams_max_bit_rate = rate;
}
int dcc_config_socket(RedChannelClient *rcc)
static int dcc_config_socket(RedChannelClient *rcc)
{
RedClient *client = red_channel_client_get_client(rcc);
MainChannelClient *mcc = red_client_get_main(client);
DISPLAY_CHANNEL_CLIENT(rcc)->is_low_bandwidth = main_channel_client_is_low_bandwidth(mcc);
return common_channel_config_socket(rcc);
return common_channel_client_config_socket(rcc);
}
gboolean dcc_is_low_bandwidth(DisplayChannelClient *dcc)

View File

@ -197,7 +197,6 @@ uint32_t dcc_get_max_stream_latency(DisplayChannelClient *dcc);
void dcc_set_max_stream_latency(DisplayChannelClient *dcc, uint32_t latency);
uint64_t dcc_get_max_stream_bit_rate(DisplayChannelClient *dcc);
void dcc_set_max_stream_bit_rate(DisplayChannelClient *dcc, uint64_t rate);
int dcc_config_socket(RedChannelClient *rcc);
gboolean dcc_is_low_bandwidth(DisplayChannelClient *dcc);
GArray *dcc_get_preferred_video_codecs_for_encoding(DisplayChannelClient *dcc);

View File

@ -2237,7 +2237,6 @@ display_channel_class_init(DisplayChannelClass *klass)
channel_class->handle_migrate_flush_mark = handle_migrate_flush_mark;
channel_class->handle_migrate_data = handle_migrate_data;
channel_class->handle_migrate_data_get_serial = handle_migrate_data_get_serial;
channel_class->config_socket = dcc_config_socket;
g_object_class_install_property(object_class,
PROP_N_SURFACES,

View File

@ -158,6 +158,7 @@ static const SpiceDataHeaderOpaque mini_header_wrapper;
static void red_channel_client_clear_sent_item(RedChannelClient *rcc);
static void red_channel_client_initable_interface_init(GInitableIface *iface);
static void red_channel_client_set_message_serial(RedChannelClient *channel, uint64_t);
static int red_channel_client_config_socket(RedChannelClient *rcc);
/*
* When an error occurs over a channel, we treat it as a warning
@ -931,7 +932,7 @@ static gboolean red_channel_client_initable_init(GInitable *initable,
SpiceCoreInterfaceInternal *core;
RedChannelClient *self = RED_CHANNEL_CLIENT(initable);
if (!red_channel_config_socket(self->priv->channel, self)) {
if (!red_channel_client_config_socket(self)) {
g_set_error_literal(&local_error,
SPICE_SERVER_ERROR,
SPICE_SERVER_ERROR_FAILED,
@ -1053,6 +1054,17 @@ void red_channel_client_shutdown(RedChannelClient *rcc)
}
}
static int red_channel_client_config_socket(RedChannelClient *rcc)
{
RedChannelClientClass *klass = RED_CHANNEL_CLIENT_GET_CLASS(rcc);
if (!klass->config_socket) {
return TRUE;
}
return klass->config_socket(rcc);
}
static uint8_t *red_channel_client_alloc_msg_buf(RedChannelClient *rcc,
uint16_t type, uint32_t size)
{

View File

@ -169,6 +169,8 @@ struct RedChannelClientClass
{
GObjectClass parent_class;
/* configure socket connected to the client */
int (*config_socket)(RedChannelClient *rcc);
uint8_t *(*alloc_recv_buf)(RedChannelClient *channel, uint16_t type, uint32_t size);
void (*release_recv_buf)(RedChannelClient *channel, uint16_t type, uint32_t size, uint8_t *msg);
};

View File

@ -709,17 +709,6 @@ SpiceCoreInterfaceInternal* red_channel_get_core_interface(RedChannel *channel)
return channel->priv->core;
}
int red_channel_config_socket(RedChannel *self, RedChannelClient *rcc)
{
RedChannelClass *klass = RED_CHANNEL_GET_CLASS(self);
if (!klass->config_socket) {
return TRUE;
}
return klass->config_socket(rcc);
}
void red_channel_on_disconnect(RedChannel *self, RedChannelClient *rcc)
{
RedChannelClass *klass = RED_CHANNEL_GET_CLASS(self);

View File

@ -115,7 +115,6 @@ struct RedChannelClass
* callbacks that are triggered from channel client stream events.
* They are called from the thread that listen to the stream events.
*/
channel_configure_socket_proc config_socket;
channel_disconnect_proc on_disconnect;
channel_send_pipe_item_proc send_item;
channel_handle_migrate_flush_mark_proc handle_migrate_flush_mark;
@ -224,7 +223,6 @@ struct RedsState* red_channel_get_server(RedChannel *channel);
SpiceCoreInterfaceInternal* red_channel_get_core_interface(RedChannel *channel);
/* channel callback function */
int red_channel_config_socket(RedChannel *self, RedChannelClient *rcc);
void red_channel_on_disconnect(RedChannel *self, RedChannelClient *rcc);
void red_channel_send_item(RedChannel *self, RedChannelClient *rcc, RedPipeItem *item);
void red_channel_reset_thread_id(RedChannel *self);

View File

@ -732,7 +732,7 @@ static void record_channel_send_item(RedChannelClient *rcc, G_GNUC_UNUSED RedPip
snd_send(client);
}
static int snd_channel_config_socket(RedChannelClient *rcc)
static int snd_channel_client_config_socket(RedChannelClient *rcc)
{
int delay_val;
#ifdef SO_PRIORITY
@ -1332,7 +1332,6 @@ snd_channel_class_init(SndChannelClass *klass)
object_class->finalize = snd_channel_finalize;
channel_class->config_socket = snd_channel_config_socket;
channel_class->on_disconnect = snd_channel_on_disconnect;
}
@ -1486,6 +1485,7 @@ snd_channel_client_class_init(SndChannelClientClass *klass)
{
RedChannelClientClass *client_class = RED_CHANNEL_CLIENT_CLASS(klass);
client_class->config_socket = snd_channel_client_config_socket;
client_class->alloc_recv_buf = snd_channel_client_alloc_recv_buf;
client_class->release_recv_buf = snd_channel_client_release_recv_buf;
}