[Spice-commits] 3 commits - server/dcc-private.h server/dcc-send.c server/dcc.c server/main-channel-client.c server/spice-qxl.h
Frediano Ziglio
fziglio at kemper.freedesktop.org
Wed Nov 9 11:44:45 UTC 2016
server/dcc-private.h | 16 ++++++++++++----
server/dcc-send.c | 8 ++++----
server/dcc.c | 20 ++++++++++----------
server/main-channel-client.c | 32 +++++++++++++++++++++++++++++++-
server/spice-qxl.h | 12 ++++++++++++
5 files changed, 69 insertions(+), 19 deletions(-)
New commits:
commit 7766fbfb353de1a1c83fa075d273e7cb2f67714d
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Sun Feb 21 10:46:39 2016 +0000
build a structure to hold all DCC stream fields
try to understand streams
diff --git a/server/dcc-private.h b/server/dcc-private.h
index de6ea92..e39b097 100644
--- a/server/dcc-private.h
+++ b/server/dcc-private.h
@@ -24,6 +24,16 @@
#include "stream.h"
#include "red-channel-client.h"
+typedef struct DCCStreams {
+ uint32_t outbuf_size;
+ uint8_t *outbuf; // caution stream buffer is also used as compress bufs!!!
+
+ StreamAgent agents[NUM_STREAMS];
+ int use_video_encoder_rate_control;
+ uint32_t max_latency;
+ uint64_t max_bit_rate;
+} DCCStreams;
+
typedef struct DisplayChannelClientPrivate DisplayChannelClientPrivate;
struct DisplayChannelClientPrivate
{
@@ -54,10 +64,8 @@ struct DisplayChannelClientPrivate
uint8_t surface_client_created[NUM_SURFACES];
QRegion surface_client_lossy_region[NUM_SURFACES];
- StreamAgent stream_agents[NUM_STREAMS];
- int use_video_encoder_rate_control;
- uint32_t streams_max_latency;
- uint64_t streams_max_bit_rate;
+ DCCStreams streams;
+
bool gl_draw_ongoing;
};
diff --git a/server/dcc-send.c b/server/dcc-send.c
index 5f9ea45..9e34ff6 100644
--- a/server/dcc-send.c
+++ b/server/dcc-send.c
@@ -1688,10 +1688,10 @@ static int red_marshall_stream_data(RedChannelClient *rcc,
return FALSE;
}
- StreamAgent *agent = &dcc->priv->stream_agents[display_channel_get_stream_id(display, stream)];
+ StreamAgent *agent = &dcc->priv->streams.agents[display_channel_get_stream_id(display, stream)];
uint64_t time_now = spice_get_monotonic_time_ns();
- if (!dcc->priv->use_video_encoder_rate_control) {
+ if (!dcc->priv->streams.use_video_encoder_rate_control) {
if (time_now - agent->last_send_time < (1000 * 1000 * 1000) / agent->fps) {
agent->frames--;
#ifdef STREAM_STATS
@@ -1715,7 +1715,7 @@ static int red_marshall_stream_data(RedChannelClient *rcc,
&outbuf);
switch (ret) {
case VIDEO_ENCODER_FRAME_DROP:
- spice_assert(dcc->priv->use_video_encoder_rate_control);
+ spice_assert(dcc->priv->streams.use_video_encoder_rate_control);
#ifdef STREAM_STATS
agent->stats.num_drops_fps++;
#endif
@@ -2295,7 +2295,7 @@ static void marshall_stream_activate_report(RedChannelClient *rcc,
uint32_t stream_id)
{
DisplayChannelClient *dcc = DISPLAY_CHANNEL_CLIENT(rcc);
- StreamAgent *agent = &dcc->priv->stream_agents[stream_id];
+ StreamAgent *agent = &dcc->priv->streams.agents[stream_id];
SpiceMsgDisplayStreamActivateReport msg;
red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_STREAM_ACTIVATE_REPORT, NULL);
diff --git a/server/dcc.c b/server/dcc.c
index 17f9300..4b0b749 100644
--- a/server/dcc.c
+++ b/server/dcc.c
@@ -473,12 +473,12 @@ static void dcc_init_stream_agents(DisplayChannelClient *dcc)
DisplayChannel *display = DCC_TO_DC(dcc);
for (i = 0; i < NUM_STREAMS; i++) {
- StreamAgent *agent = &dcc->priv->stream_agents[i];
+ StreamAgent *agent = &dcc->priv->streams.agents[i];
agent->stream = &display->priv->streams_buf[i];
region_init(&agent->vis_region);
region_init(&agent->clip);
}
- dcc->priv->use_video_encoder_rate_control =
+ dcc->priv->streams.use_video_encoder_rate_control =
red_channel_client_test_remote_cap(RED_CHANNEL_CLIENT(dcc), SPICE_DISPLAY_CAP_STREAM_REPORT);
}
@@ -605,7 +605,7 @@ static void dcc_destroy_stream_agents(DisplayChannelClient *dcc)
int i;
for (i = 0; i < NUM_STREAMS; i++) {
- StreamAgent *agent = &dcc->priv->stream_agents[i];
+ StreamAgent *agent = &dcc->priv->streams.agents[i];
region_destroy(&agent->vis_region);
region_destroy(&agent->clip);
if (agent->video_encoder) {
@@ -1053,7 +1053,7 @@ static int dcc_handle_stream_report(DisplayChannelClient *dcc,
return FALSE;
}
- agent = &dcc->priv->stream_agents[report->stream_id];
+ agent = &dcc->priv->streams.agents[report->stream_id];
if (!agent->video_encoder) {
spice_info("stream_report: no encoder for stream id %u. "
"The stream has probably been destroyed",
@@ -1265,7 +1265,7 @@ int dcc_handle_migrate_data(DisplayChannelClient *dcc, uint32_t size, void *mess
StreamAgent* dcc_get_stream_agent(DisplayChannelClient *dcc, int stream_id)
{
- return &dcc->priv->stream_agents[stream_id];
+ return &dcc->priv->streams.agents[stream_id];
}
ImageEncoders* dcc_get_encoders(DisplayChannelClient *dcc)
@@ -1285,27 +1285,27 @@ spice_wan_compression_t dcc_get_zlib_glz_state(DisplayChannelClient *dcc)
gboolean dcc_use_video_encoder_rate_control(DisplayChannelClient *dcc)
{
- return dcc->priv->use_video_encoder_rate_control;
+ return dcc->priv->streams.use_video_encoder_rate_control;
}
uint32_t dcc_get_max_stream_latency(DisplayChannelClient *dcc)
{
- return dcc->priv->streams_max_latency;
+ return dcc->priv->streams.max_latency;
}
void dcc_set_max_stream_latency(DisplayChannelClient *dcc, uint32_t latency)
{
- dcc->priv->streams_max_latency = latency;
+ dcc->priv->streams.max_latency = latency;
}
uint64_t dcc_get_max_stream_bit_rate(DisplayChannelClient *dcc)
{
- return dcc->priv->streams_max_bit_rate;
+ return dcc->priv->streams.max_bit_rate;
}
void dcc_set_max_stream_bit_rate(DisplayChannelClient *dcc, uint64_t rate)
{
- dcc->priv->streams_max_bit_rate = rate;
+ dcc->priv->streams.max_bit_rate = rate;
}
int dcc_config_socket(RedChannelClient *rcc)
commit 7ef8efe104a966c77bd5413e6edc7a411b14b7d4
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Wed Feb 10 10:42:57 2016 +0000
NOTES
diff --git a/server/spice-qxl.h b/server/spice-qxl.h
index b8910bf..c8f9ea3 100644
--- a/server/spice-qxl.h
+++ b/server/spice-qxl.h
@@ -171,15 +171,19 @@ struct QXLDevSurfaceCreate {
struct QXLInterface {
SpiceBaseInterface base;
+ // ONLY QXL, used to see id
void (*attache_worker)(QXLInstance *qin, QXLWorker *qxl_worker);
void (*set_compression_level)(QXLInstance *qin, int level);
+ // REMOVED
void (*set_mm_time)(QXLInstance *qin, uint32_t mm_time) SPICE_GNUC_DEPRECATED;
+ // ONLY QXL
void (*get_init_info)(QXLInstance *qin, QXLDevInitInfo *info);
/* Retrieve the next command to be processed
* This call should be non-blocking. If no commands are available, it
* should return 0, or 1 if a command was retrieved */
+ // ONLY QXL
int (*get_command)(QXLInstance *qin, struct QXLCommandExt *cmd);
/* Request notification when new commands are available
@@ -187,13 +191,21 @@ struct QXLInterface {
* notified by calling spice_qxl_wakeup(). If commands are already
* available, this function should return false and no notification
* triggered */
+ // ONLY QXL
int (*req_cmd_notification)(QXLInstance *qin);
+ // ONLY QXL
void (*release_resource)(QXLInstance *qin, struct QXLReleaseInfoExt release_info);
+ // ONLY QXL
int (*get_cursor_command)(QXLInstance *qin, struct QXLCommandExt *cmd);
+ // ONLY QXL
int (*req_cursor_notification)(QXLInstance *qin);
+ // REMOVED
void (*notify_update)(QXLInstance *qin, uint32_t update_id);
+ // abort for display, do something in HW called in OOM
int (*flush_resources)(QXLInstance *qin);
+ // both for sure
void (*async_complete)(QXLInstance *qin, uint64_t cookie);
+ // abort for display, do something in HW spice_qxl_update_area_async, only QXL
void (*update_area_complete)(QXLInstance *qin, uint32_t surface_id,
struct QXLRect *updated_rects,
uint32_t num_updated_rects);
commit c84dc2e04c23b8e46d38e19aa4e0d9692ca2dc59
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Tue Dec 22 16:43:57 2015 +0000
channel: cap roundtrip using Linux information if available
Linux kernel already compute roundtrip.
If available use it to limit discovered one.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
diff --git a/server/main-channel-client.c b/server/main-channel-client.c
index 7304586..052764e 100644
--- a/server/main-channel-client.c
+++ b/server/main-channel-client.c
@@ -19,6 +19,7 @@
#endif
#include <inttypes.h>
+#include <netinet/tcp.h>
#include <common/generated_server_marshallers.h>
#include "main-channel-client.h"
@@ -464,9 +465,34 @@ void main_channel_client_handle_migrate_dst_do_seamless(MainChannelClient *mcc,
SPICE_MSG_MAIN_MIGRATE_DST_SEAMLESS_NACK);
}
}
+
+#ifdef __linux__
+static uint64_t reds_stream_rtt(const RedsStream *stream)
+{
+ if (!stream || stream->socket < 0) {
+ return 0;
+ }
+
+ struct tcp_info ti;
+ socklen_t ti_len = sizeof(ti);
+ if (getsockopt(stream->socket, SOL_TCP, TCP_INFO, &ti, &ti_len)) {
+ return 0;
+ }
+
+ fprintf(stderr, "RCV RTT %u\n", ti.tcpi_rttvar);
+ fprintf(stderr, "RCV MTU %u\n", ti.tcpi_pmtu);
+ return ti.tcpi_rtt;
+}
+#else
+static inline uint64_t reds_stream_rtt(const RedsStream *stream)
+{
+ return 0;
+}
+#endif
+
void main_channel_client_handle_pong(MainChannelClient *mcc, SpiceMsgPing *ping, uint32_t size)
{
- uint64_t roundtrip;
+ uint64_t roundtrip, rtt;
RedChannelClient* rcc = RED_CHANNEL_CLIENT(mcc);
roundtrip = g_get_monotonic_time() - ping->timestamp;
@@ -491,6 +517,10 @@ void main_channel_client_handle_pong(MainChannelClient *mcc, SpiceMsgPing *ping,
mcc->priv->latency = MIN(mcc->priv->latency, roundtrip);
break;
case NET_TEST_STAGE_RATE:
+ rtt = reds_stream_rtt(red_channel_client_get_stream(rcc));
+ if (rtt)
+ mcc->priv->latency = MIN(mcc->priv->latency, rtt);
+
mcc->priv->net_test_id = 0;
if (roundtrip <= mcc->priv->latency) {
// probably high load on client or server result with incorrect values
More information about the Spice-commits
mailing list