[Spice-commits] 2 commits - server/dcc.c server/dcc.h server/dcc-private.h server/dcc-send.c server/display-channel.c server/display-channel.h server/display-channel-private.h server/Makefile.am server/red-worker.c server/stream.c server/stream-channel.c server/stream-device.c server/stream.h server/video-stream.c server/video-stream.h

Jonathon Jongsma jjongsma at kemper.freedesktop.org
Thu Nov 30 17:51:25 UTC 2017


 server/Makefile.am               |    4 
 server/dcc-private.h             |    4 
 server/dcc-send.c                |   29 +++--
 server/dcc.c                     |   14 +-
 server/dcc.h                     |   12 +-
 server/display-channel-private.h |    8 -
 server/display-channel.c         |   47 ++++-----
 server/display-channel.h         |    4 
 server/red-worker.c              |    6 -
 server/stream-channel.c          |    2 
 server/stream-device.c           |    1 
 server/video-stream.c            |  197 ++++++++++++++++++++-------------------
 server/video-stream.h            |   65 +++++-------
 13 files changed, 201 insertions(+), 192 deletions(-)

New commits:
commit 5ea0f68263d34a6d62cf9976274c518e20284112
Author: Jonathon Jongsma <jjongsma at redhat.com>
Date:   Fri Oct 20 15:50:09 2017 -0500

    Rename StreamAgent to VideoStreamAgent
    
    Just to avoid confusion between different uses of the word Stream (e.g.
    RedStream) clarify that it's related to video streams
    
    Signed-off-by: Jonathon Jongsma <jjongsma at redhat.com>
    Acked-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/server/dcc-private.h b/server/dcc-private.h
index 76e194fe..848d4270 100644
--- a/server/dcc-private.h
+++ b/server/dcc-private.h
@@ -61,7 +61,7 @@ struct DisplayChannelClientPrivate
     uint8_t surface_client_created[NUM_SURFACES];
     QRegion surface_client_lossy_region[NUM_SURFACES];
 
-    StreamAgent stream_agents[NUM_STREAMS];
+    VideoStreamAgent stream_agents[NUM_STREAMS];
     uint32_t streams_max_latency;
     uint64_t streams_max_bit_rate;
     bool gl_draw_ongoing;
diff --git a/server/dcc-send.c b/server/dcc-send.c
index 642c6edd..d94615a9 100644
--- a/server/dcc-send.c
+++ b/server/dcc-send.c
@@ -1709,7 +1709,7 @@ static bool red_marshall_stream_data(RedChannelClient *rcc,
     }
 
     int stream_id = display_channel_get_video_stream_id(display, stream);
-    StreamAgent *agent = &dcc->priv->stream_agents[stream_id];
+    VideoStreamAgent *agent = &dcc->priv->stream_agents[stream_id];
     VideoBuffer *outbuf;
     /* workaround for vga streams */
     frame_mm_time =  drawable->red_drawable->mm_time ?
@@ -2151,7 +2151,8 @@ static void marshall_qxl_drawable(RedChannelClient *rcc,
 }
 
 static void marshall_stream_start(RedChannelClient *rcc,
-                                  SpiceMarshaller *base_marshaller, StreamAgent *agent)
+                                  SpiceMarshaller *base_marshaller,
+                                  VideoStreamAgent *agent)
 {
     DisplayChannelClient *dcc = DISPLAY_CHANNEL_CLIENT(rcc);
     VideoStream *stream = agent->stream;
@@ -2195,7 +2196,7 @@ static void marshall_stream_clip(RedChannelClient *rcc,
                                  RedStreamClipItem *item)
 {
     DisplayChannelClient *dcc = DISPLAY_CHANNEL_CLIENT(rcc);
-    StreamAgent *agent = item->stream_agent;
+    VideoStreamAgent *agent = item->stream_agent;
 
     spice_return_if_fail(agent->stream);
 
@@ -2210,14 +2211,15 @@ static void marshall_stream_clip(RedChannelClient *rcc,
 }
 
 static void marshall_stream_end(RedChannelClient *rcc,
-                                SpiceMarshaller *base_marshaller, StreamAgent* agent)
+                                SpiceMarshaller *base_marshaller,
+                                VideoStreamAgent* agent)
 {
     DisplayChannelClient *dcc = DISPLAY_CHANNEL_CLIENT(rcc);
     SpiceMsgDisplayStreamDestroy destroy;
 
     red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_STREAM_DESTROY);
     destroy.id = display_channel_get_video_stream_id(DCC_TO_DC(dcc), agent->stream);
-    stream_agent_stop(agent);
+    video_stream_agent_stop(agent);
     spice_marshall_msg_display_stream_destroy(base_marshaller, &destroy);
 }
 
@@ -2308,7 +2310,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];
+    VideoStreamAgent *agent = &dcc->priv->stream_agents[stream_id];
     SpiceMsgDisplayStreamActivateReport msg;
 
     red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_STREAM_ACTIVATE_REPORT);
diff --git a/server/dcc.c b/server/dcc.c
index 951d1e9f..628b33ed 100644
--- a/server/dcc.c
+++ b/server/dcc.c
@@ -487,7 +487,7 @@ 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];
+        VideoStreamAgent *agent = &dcc->priv->stream_agents[i];
         agent->stream = display_channel_get_nth_video_stream(display, i);
         region_init(&agent->vis_region);
         region_init(&agent->clip);
@@ -601,7 +601,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];
+        VideoStreamAgent *agent = &dcc->priv->stream_agents[i];
         region_destroy(&agent->vis_region);
         region_destroy(&agent->clip);
         if (agent->video_encoder) {
@@ -627,7 +627,7 @@ static void dcc_stop(DisplayChannelClient *dcc)
     }
 }
 
-void dcc_stream_agent_clip(DisplayChannelClient* dcc, StreamAgent *agent)
+void dcc_video_stream_agent_clip(DisplayChannelClient* dcc, VideoStreamAgent *agent)
 {
     RedStreamClipItem *item = red_stream_clip_item_new(agent);
     int n_rects;
@@ -1041,7 +1041,7 @@ static bool dcc_handle_init(DisplayChannelClient *dcc, SpiceMsgcDisplayInit *ini
 static bool dcc_handle_stream_report(DisplayChannelClient *dcc,
                                      SpiceMsgcDisplayStreamReport *report)
 {
-    StreamAgent *agent;
+    VideoStreamAgent *agent;
 
     if (report->stream_id >= NUM_STREAMS) {
         spice_warning("stream_report: invalid stream id %u",
@@ -1383,7 +1383,7 @@ bool dcc_handle_migrate_data(DisplayChannelClient *dcc, uint32_t size, void *mes
     return TRUE;
 }
 
-StreamAgent* dcc_get_stream_agent(DisplayChannelClient *dcc, int stream_id)
+VideoStreamAgent* dcc_get_video_stream_agent(DisplayChannelClient *dcc, int stream_id)
 {
     return &dcc->priv->stream_agents[stream_id];
 }
diff --git a/server/dcc.h b/server/dcc.h
index 8ee0bd78..a0399676 100644
--- a/server/dcc.h
+++ b/server/dcc.h
@@ -79,7 +79,7 @@ GType display_channel_client_get_type(void) G_GNUC_CONST;
 
 typedef struct DisplayChannel DisplayChannel;
 typedef struct VideoStream VideoStream;
-typedef struct StreamAgent StreamAgent;
+typedef struct VideoStreamAgent VideoStreamAgent;
 
 typedef struct WaitForChannels {
     SpiceMsgWaitForChannels header;
@@ -146,8 +146,8 @@ bool                       dcc_handle_migrate_data                   (DisplayCha
 void                       dcc_push_monitors_config                  (DisplayChannelClient *dcc);
 void                       dcc_destroy_surface                       (DisplayChannelClient *dcc,
                                                                       uint32_t surface_id);
-void                       dcc_stream_agent_clip                     (DisplayChannelClient* dcc,
-                                                                      StreamAgent *agent);
+void                       dcc_video_stream_agent_clip               (DisplayChannelClient* dcc,
+                                                                      VideoStreamAgent *agent);
 void                       dcc_create_stream                         (DisplayChannelClient *dcc,
                                                                       VideoStream *stream);
 void                       dcc_create_surface                        (DisplayChannelClient *dcc,
@@ -189,7 +189,7 @@ int                        dcc_compress_image                        (DisplayCha
                                                                       int can_lossy,
                                                                       compress_send_data_t* o_comp_data);
 
-StreamAgent *              dcc_get_stream_agent                      (DisplayChannelClient *dcc, int stream_id);
+VideoStreamAgent *dcc_get_video_stream_agent(DisplayChannelClient *dcc, int stream_id);
 ImageEncoders *dcc_get_encoders(DisplayChannelClient *dcc);
 spice_wan_compression_t    dcc_get_jpeg_state                        (DisplayChannelClient *dcc);
 spice_wan_compression_t    dcc_get_zlib_glz_state                    (DisplayChannelClient *dcc);
diff --git a/server/display-channel.c b/server/display-channel.c
index a5bcb1ff..2caaa643 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -341,7 +341,7 @@ static void streams_update_visible_region(DisplayChannel *display, Drawable *dra
 
     while (item) {
         VideoStream *stream = SPICE_CONTAINEROF(item, VideoStream, link);
-        StreamAgent *agent;
+        VideoStreamAgent *agent;
 
         item = ring_next(ring, item);
 
@@ -351,12 +351,12 @@ static void streams_update_visible_region(DisplayChannel *display, Drawable *dra
 
         FOREACH_DCC(display, dcc) {
             int stream_id = display_channel_get_video_stream_id(display, stream);
-            agent = dcc_get_stream_agent(dcc, stream_id);
+            agent = dcc_get_video_stream_agent(dcc, stream_id);
 
             if (region_intersects(&agent->vis_region, &drawable->tree_item.base.rgn)) {
                 region_exclude(&agent->vis_region, &drawable->tree_item.base.rgn);
                 region_exclude(&agent->clip, &drawable->tree_item.base.rgn);
-                dcc_stream_agent_clip(dcc, agent);
+                dcc_video_stream_agent_clip(dcc, agent);
             }
         }
     }
diff --git a/server/video-stream.c b/server/video-stream.c
index 2d51885d..2dc63cba 100644
--- a/server/video-stream.c
+++ b/server/video-stream.c
@@ -27,7 +27,7 @@
 #define FOREACH_STREAMS(display, item)                  \
     RING_FOREACH(item, &(display)->priv->streams)
 
-static void stream_agent_stats_print(StreamAgent *agent)
+static void video_stream_agent_stats_print(VideoStreamAgent *agent)
 {
 #ifdef STREAM_STATS
     StreamStats *stats = &agent->stats;
@@ -67,11 +67,12 @@ static void video_stream_create_destroy_item_release(RedPipeItem *base)
 {
     StreamCreateDestroyItem *item = SPICE_UPCAST(StreamCreateDestroyItem, base);
     DisplayChannel *display = DCC_TO_DC(item->agent->dcc);
-    stream_agent_unref(display, item->agent);
+    video_stream_agent_unref(display, item->agent);
     g_free(item);
 }
 
-static RedPipeItem *video_stream_create_destroy_item_new(StreamAgent *agent, gint type)
+static RedPipeItem *video_stream_create_destroy_item_new(VideoStreamAgent *agent,
+                                                         gint type)
 {
     StreamCreateDestroyItem *item = g_new0(StreamCreateDestroyItem, 1);
 
@@ -82,12 +83,12 @@ static RedPipeItem *video_stream_create_destroy_item_new(StreamAgent *agent, gin
     return &item->base;
 }
 
-static RedPipeItem *video_stream_create_item_new(StreamAgent *agent)
+static RedPipeItem *video_stream_create_item_new(VideoStreamAgent *agent)
 {
     return video_stream_create_destroy_item_new(agent, RED_PIPE_ITEM_TYPE_STREAM_CREATE);
 }
 
-static RedPipeItem *video_stream_destroy_item_new(StreamAgent *agent)
+static RedPipeItem *video_stream_destroy_item_new(VideoStreamAgent *agent)
 {
     return video_stream_create_destroy_item_new(agent, RED_PIPE_ITEM_TYPE_STREAM_DESTROY);
 }
@@ -103,9 +104,9 @@ void video_stream_stop(DisplayChannel *display, VideoStream *stream)
 
     spice_debug("stream %d", stream_id);
     FOREACH_DCC(display, dcc) {
-        StreamAgent *stream_agent;
+        VideoStreamAgent *stream_agent;
 
-        stream_agent = dcc_get_stream_agent(dcc, stream_id);
+        stream_agent = dcc_get_video_stream_agent(dcc, stream_id);
         region_clear(&stream_agent->vis_region);
         region_clear(&stream_agent->clip);
         if (stream_agent->video_encoder) {
@@ -120,7 +121,7 @@ void video_stream_stop(DisplayChannel *display, VideoStream *stream)
         }
         red_channel_client_pipe_add(RED_CHANNEL_CLIENT(dcc),
                                     video_stream_destroy_item_new(stream_agent));
-        stream_agent_stats_print(stream_agent);
+        video_stream_agent_stats_print(stream_agent);
     }
     display->priv->streams_size_total -= stream->width * stream->height;
     ring_remove(&stream->link);
@@ -157,7 +158,7 @@ void video_stream_unref(DisplayChannel *display, VideoStream *stream)
     display->priv->stream_count--;
 }
 
-void stream_agent_unref(DisplayChannel *display, StreamAgent *agent)
+void video_stream_agent_unref(DisplayChannel *display, VideoStreamAgent *agent)
 {
     video_stream_unref(display, agent->stream);
 }
@@ -170,12 +171,12 @@ static void red_stream_clip_item_free(RedPipeItem *base)
 
     g_return_if_fail(item->base.refcount == 0);
 
-    stream_agent_unref(display, item->stream_agent);
+    video_stream_agent_unref(display, item->stream_agent);
     g_free(item->rects);
     g_free(item);
 }
 
-RedStreamClipItem *red_stream_clip_item_new(StreamAgent *agent)
+RedStreamClipItem *red_stream_clip_item_new(VideoStreamAgent *agent)
 {
     RedStreamClipItem *item = g_new(RedStreamClipItem, 1);
     red_pipe_item_init_full(&item->base, RED_PIPE_ITEM_TYPE_STREAM_CLIP,
@@ -299,10 +300,11 @@ static void attach_stream(DisplayChannel *display, Drawable *drawable, VideoStre
     }
 
     FOREACH_DCC(display, dcc) {
-        StreamAgent *agent;
+        VideoStreamAgent *agent;
         QRegion clip_in_draw_dest;
+        int stream_id = display_channel_get_video_stream_id(display, stream);
 
-        agent = dcc_get_stream_agent(dcc, display_channel_get_video_stream_id(display, stream));
+        agent = dcc_get_video_stream_agent(dcc, stream_id);
         region_or(&agent->vis_region, &drawable->tree_item.base.rgn);
 
         region_init(&clip_in_draw_dest);
@@ -312,7 +314,7 @@ static void attach_stream(DisplayChannel *display, Drawable *drawable, VideoStre
         if (!region_is_equal(&clip_in_draw_dest, &drawable->tree_item.base.rgn)) {
             region_remove(&agent->clip, &drawable->red_drawable->bbox);
             region_or(&agent->clip, &drawable->tree_item.base.rgn);
-            dcc_stream_agent_clip(dcc, agent);
+            dcc_video_stream_agent_clip(dcc, agent);
         }
         region_destroy(&clip_in_draw_dest);
 #ifdef STREAM_STATS
@@ -334,7 +336,7 @@ static void before_reattach_stream(DisplayChannel *display,
 {
     DisplayChannelClient *dcc;
     int index;
-    StreamAgent *agent;
+    VideoStreamAgent *agent;
     GList *dpi_link, *dpi_next;
 
     spice_return_if_fail(stream->current);
@@ -353,7 +355,7 @@ static void before_reattach_stream(DisplayChannel *display,
         RedDrawablePipeItem *dpi = dpi_link->data;
         dpi_next = dpi_link->next;
         dcc = dpi->dcc;
-        agent = dcc_get_stream_agent(dcc, index);
+        agent = dcc_get_video_stream_agent(dcc, index);
 
         if (red_channel_client_pipe_item_is_linked(RED_CHANNEL_CLIENT(dcc),
                                                    &dpi->dpi_pipe_item)) {
@@ -548,7 +550,8 @@ void video_stream_maintenance(DisplayChannel *display,
     }
 }
 
-static void dcc_update_streams_max_latency(DisplayChannelClient *dcc, StreamAgent *remove_agent)
+static void dcc_update_streams_max_latency(DisplayChannelClient *dcc,
+                                           VideoStreamAgent *remove_agent)
 {
     uint32_t new_max_latency = 0;
     int i;
@@ -562,7 +565,7 @@ static void dcc_update_streams_max_latency(DisplayChannelClient *dcc, StreamAgen
         return;
     }
     for (i = 0; i < NUM_STREAMS; i++) {
-        StreamAgent *other_agent = dcc_get_stream_agent(dcc, i);
+        VideoStreamAgent *other_agent = dcc_get_video_stream_agent(dcc, i);
         if (other_agent == remove_agent || !other_agent->video_encoder) {
             continue;
         }
@@ -622,7 +625,7 @@ static uint64_t get_initial_bit_rate(DisplayChannelClient *dcc, VideoStream *str
 
 static uint32_t get_roundtrip_ms(void *opaque)
 {
-    StreamAgent *agent = opaque;
+    VideoStreamAgent *agent = opaque;
     int roundtrip;
     RedChannelClient *rcc = RED_CHANNEL_CLIENT(agent->dcc);
 
@@ -643,14 +646,14 @@ static uint32_t get_roundtrip_ms(void *opaque)
 
 static uint32_t get_source_fps(void *opaque)
 {
-    StreamAgent *agent = opaque;
+    VideoStreamAgent *agent = opaque;
 
     return agent->stream->input_fps;
 }
 
 static void update_client_playback_delay(void *opaque, uint32_t delay_ms)
 {
-    StreamAgent *agent = opaque;
+    VideoStreamAgent *agent = opaque;
     DisplayChannelClient *dcc = agent->dcc;
     RedChannel *channel = red_channel_client_get_channel(RED_CHANNEL_CLIENT(dcc));
     RedClient *client = red_channel_client_get_client(RED_CHANNEL_CLIENT(dcc));
@@ -722,7 +725,7 @@ static VideoEncoder* dcc_create_video_encoder(DisplayChannelClient *dcc,
 void dcc_create_stream(DisplayChannelClient *dcc, VideoStream *stream)
 {
     int stream_id = display_channel_get_video_stream_id(DCC_TO_DC(dcc), stream);
-    StreamAgent *agent = dcc_get_stream_agent(dcc, stream_id);
+    VideoStreamAgent *agent = dcc_get_video_stream_agent(dcc, stream_id);
 
     spice_return_if_fail(region_is_empty(&agent->vis_region));
 
@@ -760,7 +763,7 @@ void dcc_create_stream(DisplayChannelClient *dcc, VideoStream *stream)
 #endif
 }
 
-void stream_agent_stop(StreamAgent *agent)
+void video_stream_agent_stop(VideoStreamAgent *agent)
 {
     DisplayChannelClient *dcc = agent->dcc;
 
@@ -794,11 +797,11 @@ static void dcc_detach_stream_gracefully(DisplayChannelClient *dcc,
 {
     DisplayChannel *display = DCC_TO_DC(dcc);
     int stream_id = display_channel_get_video_stream_id(display, stream);
-    StreamAgent *agent = dcc_get_stream_agent(dcc, stream_id);
+    VideoStreamAgent *agent = dcc_get_video_stream_agent(dcc, stream_id);
 
     /* stopping the client from playing older frames at once*/
     region_clear(&agent->clip);
-    dcc_stream_agent_clip(dcc, agent);
+    dcc_video_stream_agent_clip(dcc, agent);
 
     if (region_is_empty(&agent->vis_region)) {
         spice_debug("stream %d: vis region empty", stream_id);
@@ -892,7 +895,7 @@ void video_stream_detach_behind(DisplayChannel *display,
         int stream_id = display_channel_get_video_stream_id(display, stream);
 
         FOREACH_DCC(display, dcc) {
-            StreamAgent *agent = dcc_get_stream_agent(dcc, stream_id);
+            VideoStreamAgent *agent = dcc_get_video_stream_agent(dcc, stream_id);
 
             if (region_intersects(&agent->vis_region, region)) {
                 dcc_detach_stream_gracefully(dcc, stream, drawable);
diff --git a/server/video-stream.h b/server/video-stream.h
index 0928fc02..33bbd6bd 100644
--- a/server/video-stream.h
+++ b/server/video-stream.h
@@ -63,7 +63,7 @@ typedef struct StreamStats {
 } StreamStats;
 #endif
 
-typedef struct StreamAgent {
+typedef struct VideoStreamAgent {
     QRegion vis_region; /* the part of the surface area that is currently occupied by video
                            fragments */
     QRegion clip;       /* the current video clipping. It can be different from vis_region:
@@ -84,20 +84,20 @@ typedef struct StreamAgent {
 #ifdef STREAM_STATS
     StreamStats stats;
 #endif
-} StreamAgent;
+} VideoStreamAgent;
 
 typedef struct RedStreamClipItem {
     RedPipeItem base;
-    StreamAgent *stream_agent;
+    VideoStreamAgent *stream_agent;
     int clip_type;
     SpiceClipRects *rects;
 } RedStreamClipItem;
 
-RedStreamClipItem *   red_stream_clip_item_new                      (StreamAgent *agent);
+RedStreamClipItem *red_stream_clip_item_new(VideoStreamAgent *agent);
 
 typedef struct StreamCreateDestroyItem {
     RedPipeItem base;
-    StreamAgent *agent;
+    VideoStreamAgent *agent;
 } StreamCreateDestroyItem;
 
 typedef struct ItemTrace {
@@ -139,8 +139,8 @@ void video_stream_trace_add_drawable(DisplayChannel *display, Drawable *item);
 void video_stream_detach_behind(DisplayChannel *display, QRegion *region,
                                 Drawable *drawable);
 
-void stream_agent_unref(DisplayChannel *display, StreamAgent *agent);
-void stream_agent_stop(StreamAgent *agent);
+void video_stream_agent_unref(DisplayChannel *display, VideoStreamAgent *agent);
+void video_stream_agent_stop(VideoStreamAgent *agent);
 
 void video_stream_detach_drawable(VideoStream *stream);
 
commit 2e08354ce1869a2919ea6955895c2295d78b7ab2
Author: Jonathon Jongsma <jjongsma at redhat.com>
Date:   Wed Nov 15 14:22:43 2017 -0600

    Rename Stream to VideoStream
    
    To prevent confusion between Stream (a video stream) and RedStream (a
    generic data stream between client and server), change the name to
    VideoStream to be more explicit about what it is.
    
    Signed-off-by: Jonathon Jongsma <jjongsma at redhat.com>
    Acked-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/server/Makefile.am b/server/Makefile.am
index 20f0f192..8ea258db 100644
--- a/server/Makefile.am
+++ b/server/Makefile.am
@@ -164,8 +164,6 @@ libserver_la_SOURCES =				\
 	stat-file.c				\
 	stat-file.h				\
 	stat.h					\
-	stream.c				\
-	stream.h				\
 	stream-channel.c			\
 	stream-channel.h			\
 	stream-device.c				\
@@ -175,6 +173,8 @@ libserver_la_SOURCES =				\
 	utils.c					\
 	utils.h					\
 	video-encoder.h				\
+	video-stream.c				\
+	video-stream.h				\
 	zlib-encoder.c				\
 	zlib-encoder.h				\
 	$(NULL)
diff --git a/server/dcc-private.h b/server/dcc-private.h
index c4662202..76e194fe 100644
--- a/server/dcc-private.h
+++ b/server/dcc-private.h
@@ -22,7 +22,7 @@
 #include "cache-item.h"
 #include "dcc.h"
 #include "image-encoders.h"
-#include "stream.h"
+#include "video-stream.h"
 #include "red-channel-client.h"
 
 typedef struct DisplayChannelClientPrivate DisplayChannelClientPrivate;
diff --git a/server/dcc-send.c b/server/dcc-send.c
index 84c10968..642c6edd 100644
--- a/server/dcc-send.c
+++ b/server/dcc-send.c
@@ -1686,7 +1686,7 @@ static bool red_marshall_stream_data(RedChannelClient *rcc,
 {
     DisplayChannelClient *dcc = DISPLAY_CHANNEL_CLIENT(rcc);
     DisplayChannel *display = DCC_TO_DC(dcc);
-    Stream *stream = drawable->stream;
+    VideoStream *stream = drawable->stream;
     SpiceCopy *copy;
     uint32_t frame_mm_time;
     int is_sized;
@@ -1708,7 +1708,8 @@ static bool red_marshall_stream_data(RedChannelClient *rcc,
         return FALSE;
     }
 
-    StreamAgent *agent = &dcc->priv->stream_agents[display_channel_get_stream_id(display, stream)];
+    int stream_id = display_channel_get_video_stream_id(display, stream);
+    StreamAgent *agent = &dcc->priv->stream_agents[stream_id];
     VideoBuffer *outbuf;
     /* workaround for vga streams */
     frame_mm_time =  drawable->red_drawable->mm_time ?
@@ -1741,7 +1742,7 @@ static bool red_marshall_stream_data(RedChannelClient *rcc,
 
         red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_STREAM_DATA);
 
-        stream_data.base.id = display_channel_get_stream_id(display, stream);
+        stream_data.base.id = display_channel_get_video_stream_id(display, stream);
         stream_data.base.multi_media_time = frame_mm_time;
         stream_data.data_size = outbuf->size;
 
@@ -1751,7 +1752,7 @@ static bool red_marshall_stream_data(RedChannelClient *rcc,
 
         red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_STREAM_DATA_SIZED);
 
-        stream_data.base.id = display_channel_get_stream_id(display, stream);
+        stream_data.base.id = display_channel_get_video_stream_id(display, stream);
         stream_data.base.multi_media_time = frame_mm_time;
         stream_data.data_size = outbuf->size;
         stream_data.width = copy->src_area.right - copy->src_area.left;
@@ -2153,7 +2154,7 @@ static void marshall_stream_start(RedChannelClient *rcc,
                                   SpiceMarshaller *base_marshaller, StreamAgent *agent)
 {
     DisplayChannelClient *dcc = DISPLAY_CHANNEL_CLIENT(rcc);
-    Stream *stream = agent->stream;
+    VideoStream *stream = agent->stream;
 
     spice_assert(stream);
     if (!agent->video_encoder) {
@@ -2165,7 +2166,7 @@ static void marshall_stream_start(RedChannelClient *rcc,
     SpiceClipRects clip_rects;
 
     stream_create.surface_id = 0;
-    stream_create.id = display_channel_get_stream_id(DCC_TO_DC(dcc), stream);
+    stream_create.id = display_channel_get_video_stream_id(DCC_TO_DC(dcc), stream);
     stream_create.flags = stream->top_down ? SPICE_STREAM_FLAGS_TOP_DOWN : 0;
     stream_create.codec_type = agent->video_encoder->codec_type;
 
@@ -2201,7 +2202,7 @@ static void marshall_stream_clip(RedChannelClient *rcc,
     red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_STREAM_CLIP);
     SpiceMsgDisplayStreamClip stream_clip;
 
-    stream_clip.id = display_channel_get_stream_id(DCC_TO_DC(dcc), agent->stream);
+    stream_clip.id = display_channel_get_video_stream_id(DCC_TO_DC(dcc), agent->stream);
     stream_clip.clip.type = item->clip_type;
     stream_clip.clip.rects = item->rects;
 
@@ -2215,7 +2216,7 @@ static void marshall_stream_end(RedChannelClient *rcc,
     SpiceMsgDisplayStreamDestroy destroy;
 
     red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_STREAM_DESTROY);
-    destroy.id = display_channel_get_stream_id(DCC_TO_DC(dcc), agent->stream);
+    destroy.id = display_channel_get_video_stream_id(DCC_TO_DC(dcc), agent->stream);
     stream_agent_stop(agent);
     spice_marshall_msg_display_stream_destroy(base_marshaller, &destroy);
 }
diff --git a/server/dcc.c b/server/dcc.c
index c2fdd8c2..951d1e9f 100644
--- a/server/dcc.c
+++ b/server/dcc.c
@@ -488,7 +488,7 @@ static void dcc_init_stream_agents(DisplayChannelClient *dcc)
 
     for (i = 0; i < NUM_STREAMS; i++) {
         StreamAgent *agent = &dcc->priv->stream_agents[i];
-        agent->stream = display_channel_get_nth_stream(display, i);
+        agent->stream = display_channel_get_nth_video_stream(display, i);
         region_init(&agent->vis_region);
         region_init(&agent->clip);
     }
@@ -531,7 +531,7 @@ static void dcc_create_all_streams(DisplayChannelClient *dcc)
     RingItem *item = ring;
 
     while ((item = ring_next(ring, item))) {
-        Stream *stream = SPICE_CONTAINEROF(item, Stream, link);
+        VideoStream *stream = SPICE_CONTAINEROF(item, VideoStream, link);
         dcc_create_stream(dcc, stream);
     }
 }
diff --git a/server/dcc.h b/server/dcc.h
index 4de49457..8ee0bd78 100644
--- a/server/dcc.h
+++ b/server/dcc.h
@@ -78,7 +78,7 @@ GType display_channel_client_get_type(void) G_GNUC_CONST;
 #define MAX_PIPE_SIZE 50
 
 typedef struct DisplayChannel DisplayChannel;
-typedef struct Stream Stream;
+typedef struct VideoStream VideoStream;
 typedef struct StreamAgent StreamAgent;
 
 typedef struct WaitForChannels {
@@ -149,7 +149,7 @@ void                       dcc_destroy_surface                       (DisplayCha
 void                       dcc_stream_agent_clip                     (DisplayChannelClient* dcc,
                                                                       StreamAgent *agent);
 void                       dcc_create_stream                         (DisplayChannelClient *dcc,
-                                                                      Stream *stream);
+                                                                      VideoStream *stream);
 void                       dcc_create_surface                        (DisplayChannelClient *dcc,
                                                                       int surface_id);
 void                       dcc_push_surface_image                    (DisplayChannelClient *dcc,
diff --git a/server/display-channel-private.h b/server/display-channel-private.h
index 82a3e8c6..24fa42b1 100644
--- a/server/display-channel-private.h
+++ b/server/display-channel-private.h
@@ -98,8 +98,8 @@ struct DisplayChannelPrivate
     int stream_video;
     GArray *video_codecs;
     uint32_t stream_count;
-    Stream streams_buf[NUM_STREAMS];
-    Stream *free_streams;
+    VideoStream streams_buf[NUM_STREAMS];
+    VideoStream *free_streams;
     Ring streams;
     ItemTrace items_trace[NUM_TRACE_ITEMS];
     uint32_t next_item_trace;
@@ -170,8 +170,8 @@ void display_channel_current_flush(DisplayChannel *display,
                                    int surface_id);
 uint32_t display_channel_generate_uid(DisplayChannel *display);
 
-int display_channel_get_stream_id(DisplayChannel *display, Stream *stream);
-Stream *display_channel_get_nth_stream(DisplayChannel *display, gint i);
+int display_channel_get_video_stream_id(DisplayChannel *display, VideoStream *stream);
+VideoStream *display_channel_get_nth_video_stream(DisplayChannel *display, gint i);
 
 typedef struct RedSurfaceDestroyItem {
     RedPipeItem pipe_item;
diff --git a/server/display-channel.c b/server/display-channel.c
index ad346c93..a5bcb1ff 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -91,7 +91,7 @@ display_channel_finalize(GObject *object)
     if (ENABLE_EXTRA_CHECKS) {
         unsigned int count;
         _Drawable *drawable;
-        Stream *stream;
+        VideoStream *stream;
 
         count = 0;
         for (drawable = self->priv->free_drawables; drawable; drawable = drawable->u.next) {
@@ -206,9 +206,9 @@ int display_channel_get_streams_timeout(DisplayChannel *display)
 
     red_time_t now = spice_get_monotonic_time_ns();
     while ((item = ring_next(ring, item))) {
-        Stream *stream;
+        VideoStream *stream;
 
-        stream = SPICE_CONTAINEROF(item, Stream, link);
+        stream = SPICE_CONTAINEROF(item, VideoStream, link);
         red_time_t delta = (stream->last_time + RED_STREAM_TIMEOUT) - now;
 
         if (delta < 1000 * 1000) {
@@ -269,10 +269,10 @@ static void stop_streams(DisplayChannel *display)
     RingItem *item = ring_get_head(ring);
 
     while (item) {
-        Stream *stream = SPICE_CONTAINEROF(item, Stream, link);
+        VideoStream *stream = SPICE_CONTAINEROF(item, VideoStream, link);
         item = ring_next(ring, item);
         if (!stream->current) {
-            stream_stop(display, stream);
+            video_stream_stop(display, stream);
         } else {
             spice_debug("attached stream");
         }
@@ -340,7 +340,7 @@ static void streams_update_visible_region(DisplayChannel *display, Drawable *dra
     item = ring_get_head(ring);
 
     while (item) {
-        Stream *stream = SPICE_CONTAINEROF(item, Stream, link);
+        VideoStream *stream = SPICE_CONTAINEROF(item, VideoStream, link);
         StreamAgent *agent;
 
         item = ring_next(ring, item);
@@ -350,7 +350,8 @@ static void streams_update_visible_region(DisplayChannel *display, Drawable *dra
         }
 
         FOREACH_DCC(display, dcc) {
-            agent = dcc_get_stream_agent(dcc, display_channel_get_stream_id(display, stream));
+            int stream_id = display_channel_get_video_stream_id(display, stream);
+            agent = dcc_get_stream_agent(dcc, stream_id);
 
             if (region_intersects(&agent->vis_region, &drawable->tree_item.base.rgn)) {
                 region_exclude(&agent->vis_region, &drawable->tree_item.base.rgn);
@@ -428,7 +429,7 @@ static void current_add_drawable(DisplayChannel *display,
 static void current_remove_drawable(DisplayChannel *display, Drawable *item)
 {
     /* todo: move all to unref? */
-    stream_trace_add_drawable(display, item);
+    video_stream_trace_add_drawable(display, item);
     draw_item_remove_shadow(&item->tree_item);
     ring_remove(&item->tree_item.base.siblings_link);
     ring_remove(&item->list_link);
@@ -553,7 +554,7 @@ static bool current_add_equal(DisplayChannel *display, DrawItem *item, TreeItem
          * end of the queue */
         int add_after = !!other_drawable->stream &&
                         is_drawable_independent_from_surfaces(drawable);
-        stream_maintenance(display, drawable, other_drawable);
+        video_stream_maintenance(display, drawable, other_drawable);
         current_add_drawable(display, drawable, &other->siblings_link);
         other_drawable->refs++;
         current_remove_drawable(display, other_drawable);
@@ -712,7 +713,7 @@ static void __exclude_region(DisplayChannel *display, Ring *ring, TreeItem *item
                 /* TODO: document the purpose of this code */
                 if (frame_candidate) {
                     Drawable *drawable = SPICE_CONTAINEROF(draw, Drawable, tree_item);
-                    stream_maintenance(display, frame_candidate, drawable);
+                    video_stream_maintenance(display, frame_candidate, drawable);
                 }
                 /* Remove the intersection from the DrawItem's region */
                 region_exclude(&draw->base.rgn, &and_rgn);
@@ -883,7 +884,7 @@ static bool current_add_with_shadow(DisplayChannel *display, Ring *ring, Drawabl
 
     // only primary surface streams are supported
     if (is_primary_surface(display, item->surface_id)) {
-        stream_detach_behind(display, &shadow->base.rgn, NULL);
+        video_stream_detach_behind(display, &shadow->base.rgn, NULL);
     }
 
     /* Prepend the shadow to the beginning of the current ring */
@@ -904,7 +905,7 @@ static bool current_add_with_shadow(DisplayChannel *display, Ring *ring, Drawabl
         streams_update_visible_region(display, item);
     } else {
         if (is_primary_surface(display, item->surface_id)) {
-            stream_detach_behind(display, &item->tree_item.base.rgn, item);
+            video_stream_detach_behind(display, &item->tree_item.base.rgn, item);
         }
     }
     stat_add(&display->priv->add_stat, start_time);
@@ -1083,7 +1084,7 @@ static bool current_add(DisplayChannel *display, Ring *ring, Drawable *drawable)
          * the tree.  Add the new item's region to that */
         region_or(&exclude_rgn, &item->base.rgn);
         exclude_region(display, ring, exclude_base, &exclude_rgn, NULL, drawable);
-        stream_trace_update(display, drawable);
+        video_stream_trace_update(display, drawable);
         streams_update_visible_region(display, drawable);
         /*
          * Performing the insertion after exclude_region for
@@ -1093,14 +1094,14 @@ static bool current_add(DisplayChannel *display, Ring *ring, Drawable *drawable)
         current_add_drawable(display, drawable, ring);
     } else {
         /*
-         * stream_detach_behind can affect the current tree since
+         * video_stream_detach_behind can affect the current tree since
          * it may trigger calls to display_channel_draw. Thus, the
          * drawable should be added to the tree before calling
-         * stream_detach_behind
+         * video_stream_detach_behind
          */
         current_add_drawable(display, drawable, ring);
         if (is_primary_surface(display, drawable->surface_id)) {
-            stream_detach_behind(display, &drawable->tree_item.base.rgn, drawable);
+            video_stream_detach_behind(display, &drawable->tree_item.base.rgn, drawable);
         }
     }
     region_destroy(&exclude_rgn);
@@ -1284,7 +1285,7 @@ static bool handle_surface_deps(DisplayChannel *display, Drawable *drawable)
                 QRegion depend_region;
                 region_init(&depend_region);
                 region_add(&depend_region, &drawable->red_drawable->surfaces_rects[x]);
-                stream_detach_behind(display, &depend_region, NULL);
+                video_stream_detach_behind(display, &depend_region, NULL);
             }
         }
     }
@@ -1695,7 +1696,7 @@ void drawable_unref(Drawable *drawable)
     spice_warn_if_fail(drawable->pipes == NULL);
 
     if (drawable->stream) {
-        stream_detach_drawable(drawable->stream);
+        video_stream_detach_drawable(drawable->stream);
     }
     region_destroy(&drawable->tree_item.base.rgn);
 
@@ -2303,7 +2304,7 @@ display_channel_constructed(GObject *object)
                       "non_cache", TRUE);
     image_cache_init(&self->priv->image_cache);
     self->priv->stream_video = SPICE_STREAM_VIDEO_OFF;
-    display_channel_init_streams(self);
+    display_channel_init_video_streams(self);
 
     red_channel_set_cap(channel, SPICE_DISPLAY_CAP_MONITORS_CONFIG);
     red_channel_set_cap(channel, SPICE_DISPLAY_CAP_PREF_COMPRESSION);
@@ -2410,12 +2411,12 @@ void display_channel_gl_draw_done(DisplayChannel *display)
     set_gl_draw_async_count(display, display->priv->gl_draw_async_count - 1);
 }
 
-int display_channel_get_stream_id(DisplayChannel *display, Stream *stream)
+int display_channel_get_video_stream_id(DisplayChannel *display, VideoStream *stream)
 {
     return (int)(stream - display->priv->streams_buf);
 }
 
-Stream *display_channel_get_nth_stream(DisplayChannel *display, gint i)
+VideoStream *display_channel_get_nth_video_stream(DisplayChannel *display, gint i)
 {
     return &display->priv->streams_buf[i];
 }
diff --git a/server/display-channel.h b/server/display-channel.h
index 5e3d9eb7..4f7def21 100644
--- a/server/display-channel.h
+++ b/server/display-channel.h
@@ -40,7 +40,7 @@
 #include "spice-bitmap-utils.h"
 #include "utils.h"
 #include "tree.h"
-#include "stream.h"
+#include "video-stream.h"
 #include "dcc.h"
 #include "image-encoders.h"
 #include "common-graphics-channel.h"
@@ -96,7 +96,7 @@ struct Drawable {
     int frames_count;
     int gradual_frames_count;
     int last_gradual_frame;
-    Stream *stream;
+    VideoStream *stream;
     int streamable;
     BitmapGradualType copy_bitmap_graduality;
     DependItem depend_items[3];
diff --git a/server/red-worker.c b/server/red-worker.c
index fa57235d..eb41cef7 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -40,7 +40,7 @@
 #include <common/ring.h>
 
 #include "display-channel.h"
-#include "stream.h"
+#include "video-stream.h"
 
 #include "spice.h"
 #include "red-worker.h"
@@ -298,7 +298,7 @@ static void red_migrate_display(DisplayChannel *display, RedChannelClient *rcc)
      * Notice that detach_and_stop_streams won't lead to any dev ram changes, since
      * handle_dev_stop already took care of releasing all the dev ram resources.
      */
-    stream_detach_and_stop(display);
+    video_stream_detach_and_stop(display);
     if (red_channel_client_is_connected(rcc)) {
         red_channel_client_default_migrate(rcc);
     }
@@ -1260,7 +1260,7 @@ static gboolean worker_source_dispatch(GSource *source, GSourceFunc callback,
     display_channel_free_glz_drawables_to_free(display);
 
     /* TODO: could use its own source */
-    stream_timeout(display);
+    video_stream_timeout(display);
 
     worker->event_timeout = INF_EVENT_WAIT;
     worker->was_blocked = FALSE;
diff --git a/server/stream-channel.c b/server/stream-channel.c
index c7ca0206..bfacc375 100644
--- a/server/stream-channel.c
+++ b/server/stream-channel.c
@@ -27,7 +27,7 @@
 #include "reds.h"
 #include "common-graphics-channel.h"
 #include "display-limits.h"
-#include "stream.h" // TODO remove, put common stuff
+#include "video-stream.h" // TODO remove, put common stuff
 
 #define TYPE_STREAM_CHANNEL_CLIENT stream_channel_client_get_type()
 
diff --git a/server/stream-device.c b/server/stream-device.c
index 0953a6d0..a004899f 100644
--- a/server/stream-device.c
+++ b/server/stream-device.c
@@ -189,6 +189,7 @@ handle_msg_data(StreamDevice *dev, SpiceCharDeviceInstance *sin)
 {
     SpiceCharDeviceInterface *sif = spice_char_device_get_interface(sin);
     int n;
+
     while (1) {
         uint8_t buf[16 * 1024];
         n = sif->read(sin, buf, sizeof(buf));
diff --git a/server/stream.c b/server/video-stream.c
similarity index 85%
rename from server/stream.c
rename to server/video-stream.c
index 846c921a..2d51885d 100644
--- a/server/stream.c
+++ b/server/video-stream.c
@@ -18,7 +18,7 @@
 #include <config.h>
 #endif
 
-#include "stream.h"
+#include "video-stream.h"
 #include "display-channel-private.h"
 #include "main-channel-client.h"
 #include "red-client.h"
@@ -63,7 +63,7 @@ static void stream_agent_stats_print(StreamAgent *agent)
 #endif
 }
 
-static void stream_create_destroy_item_release(RedPipeItem *base)
+static void video_stream_create_destroy_item_release(RedPipeItem *base)
 {
     StreamCreateDestroyItem *item = SPICE_UPCAST(StreamCreateDestroyItem, base);
     DisplayChannel *display = DCC_TO_DC(item->agent->dcc);
@@ -71,40 +71,41 @@ static void stream_create_destroy_item_release(RedPipeItem *base)
     g_free(item);
 }
 
-static RedPipeItem *stream_create_destroy_item_new(StreamAgent *agent, gint type)
+static RedPipeItem *video_stream_create_destroy_item_new(StreamAgent *agent, gint type)
 {
     StreamCreateDestroyItem *item = g_new0(StreamCreateDestroyItem, 1);
 
     red_pipe_item_init_full(&item->base, type,
-                            stream_create_destroy_item_release);
+                            video_stream_create_destroy_item_release);
     agent->stream->refs++;
     item->agent = agent;
     return &item->base;
 }
 
-static RedPipeItem *stream_create_item_new(StreamAgent *agent)
+static RedPipeItem *video_stream_create_item_new(StreamAgent *agent)
 {
-    return stream_create_destroy_item_new(agent, RED_PIPE_ITEM_TYPE_STREAM_CREATE);
+    return video_stream_create_destroy_item_new(agent, RED_PIPE_ITEM_TYPE_STREAM_CREATE);
 }
 
-static RedPipeItem *stream_destroy_item_new(StreamAgent *agent)
+static RedPipeItem *video_stream_destroy_item_new(StreamAgent *agent)
 {
-    return stream_create_destroy_item_new(agent, RED_PIPE_ITEM_TYPE_STREAM_DESTROY);
+    return video_stream_create_destroy_item_new(agent, RED_PIPE_ITEM_TYPE_STREAM_DESTROY);
 }
 
 
-void stream_stop(DisplayChannel *display, Stream *stream)
+void video_stream_stop(DisplayChannel *display, VideoStream *stream)
 {
     DisplayChannelClient *dcc;
+    int stream_id = display_channel_get_video_stream_id(display, stream);
 
     spice_return_if_fail(ring_item_is_linked(&stream->link));
     spice_return_if_fail(!stream->current);
 
-    spice_debug("stream %d", display_channel_get_stream_id(display, stream));
+    spice_debug("stream %d", stream_id);
     FOREACH_DCC(display, dcc) {
         StreamAgent *stream_agent;
 
-        stream_agent = dcc_get_stream_agent(dcc, display_channel_get_stream_id(display, stream));
+        stream_agent = dcc_get_stream_agent(dcc, stream_id);
         region_clear(&stream_agent->vis_region);
         region_clear(&stream_agent->clip);
         if (stream_agent->video_encoder) {
@@ -117,47 +118,48 @@ void stream_stop(DisplayChannel *display, Stream *stream)
                 dcc_set_max_stream_bit_rate(dcc, stream_bit_rate);
             }
         }
-        red_channel_client_pipe_add(RED_CHANNEL_CLIENT(dcc), stream_destroy_item_new(stream_agent));
+        red_channel_client_pipe_add(RED_CHANNEL_CLIENT(dcc),
+                                    video_stream_destroy_item_new(stream_agent));
         stream_agent_stats_print(stream_agent);
     }
     display->priv->streams_size_total -= stream->width * stream->height;
     ring_remove(&stream->link);
-    stream_unref(display, stream);
+    video_stream_unref(display, stream);
 }
 
-static void stream_free(DisplayChannel *display, Stream *stream)
+static void video_stream_free(DisplayChannel *display, VideoStream *stream)
 {
     stream->next = display->priv->free_streams;
     display->priv->free_streams = stream;
 }
 
-void display_channel_init_streams(DisplayChannel *display)
+void display_channel_init_video_streams(DisplayChannel *display)
 {
     int i;
 
     ring_init(&display->priv->streams);
     display->priv->free_streams = NULL;
     for (i = 0; i < NUM_STREAMS; i++) {
-        Stream *stream = display_channel_get_nth_stream(display, i);
+        VideoStream *stream = display_channel_get_nth_video_stream(display, i);
         ring_item_init(&stream->link);
-        stream_free(display, stream);
+        video_stream_free(display, stream);
     }
 }
 
-void stream_unref(DisplayChannel *display, Stream *stream)
+void video_stream_unref(DisplayChannel *display, VideoStream *stream)
 {
     if (--stream->refs != 0)
         return;
 
     spice_warn_if_fail(!ring_item_is_linked(&stream->link));
 
-    stream_free(display, stream);
+    video_stream_free(display, stream);
     display->priv->stream_count--;
 }
 
 void stream_agent_unref(DisplayChannel *display, StreamAgent *agent)
 {
-    stream_unref(display, agent->stream);
+    video_stream_unref(display, agent->stream);
 }
 
 static void red_stream_clip_item_free(RedPipeItem *base)
@@ -221,7 +223,7 @@ static bool is_next_stream_frame(DisplayChannel *display,
                                  const int other_src_height,
                                  const SpiceRect *other_dest,
                                  const red_time_t other_time,
-                                 const Stream *stream,
+                                 const VideoStream *stream,
                                  int container_candidate_allowed)
 {
     RedDrawable *red_drawable;
@@ -275,7 +277,7 @@ static bool is_next_stream_frame(DisplayChannel *display,
     return TRUE;
 }
 
-static void attach_stream(DisplayChannel *display, Drawable *drawable, Stream *stream)
+static void attach_stream(DisplayChannel *display, Drawable *drawable, VideoStream *stream)
 {
     DisplayChannelClient *dcc;
 
@@ -300,7 +302,7 @@ static void attach_stream(DisplayChannel *display, Drawable *drawable, Stream *s
         StreamAgent *agent;
         QRegion clip_in_draw_dest;
 
-        agent = dcc_get_stream_agent(dcc, display_channel_get_stream_id(display, stream));
+        agent = dcc_get_stream_agent(dcc, display_channel_get_video_stream_id(display, stream));
         region_or(&agent->vis_region, &drawable->tree_item.base.rgn);
 
         region_init(&clip_in_draw_dest);
@@ -319,7 +321,7 @@ static void attach_stream(DisplayChannel *display, Drawable *drawable, Stream *s
     }
 }
 
-void stream_detach_drawable(Stream *stream)
+void video_stream_detach_drawable(VideoStream *stream)
 {
     spice_assert(stream->current && stream->current->stream);
     spice_assert(stream->current->stream == stream);
@@ -328,7 +330,7 @@ void stream_detach_drawable(Stream *stream)
 }
 
 static void before_reattach_stream(DisplayChannel *display,
-                                   Stream *stream, Drawable *new_frame)
+                                   VideoStream *stream, Drawable *new_frame)
 {
     DisplayChannelClient *dcc;
     int index;
@@ -346,7 +348,7 @@ static void before_reattach_stream(DisplayChannel *display,
         return;
     }
 
-    index = display_channel_get_stream_id(display, stream);
+    index = display_channel_get_video_stream_id(display, stream);
     for (dpi_link = stream->current->pipes; dpi_link; dpi_link = dpi_next) {
         RedDrawablePipeItem *dpi = dpi_link->data;
         dpi_next = dpi_link->next;
@@ -363,9 +365,9 @@ static void before_reattach_stream(DisplayChannel *display,
     }
 }
 
-static Stream *display_channel_stream_try_new(DisplayChannel *display)
+static VideoStream *display_channel_stream_try_new(DisplayChannel *display)
 {
-    Stream *stream;
+    VideoStream *stream;
     if (!display->priv->free_streams) {
         return NULL;
     }
@@ -377,7 +379,7 @@ static Stream *display_channel_stream_try_new(DisplayChannel *display)
 static void display_channel_create_stream(DisplayChannel *display, Drawable *drawable)
 {
     DisplayChannelClient *dcc;
-    Stream *stream;
+    VideoStream *stream;
     SpiceRect* src_rect;
 
     spice_assert(!drawable->stream);
@@ -417,14 +419,14 @@ static void display_channel_create_stream(DisplayChannel *display, Drawable *dra
         dcc_create_stream(dcc, stream);
     }
     spice_debug("stream %d %dx%d (%d, %d) (%d, %d) %u fps",
-                display_channel_get_stream_id(display, stream), stream->width,
+                display_channel_get_video_stream_id(display, stream), stream->width,
                 stream->height, stream->dest_area.left, stream->dest_area.top,
                 stream->dest_area.right, stream->dest_area.bottom,
                 stream->input_fps);
 }
 
 // returns whether a stream was created
-static bool stream_add_frame(DisplayChannel *display,
+static bool video_stream_add_frame(DisplayChannel *display,
                              Drawable *frame_drawable,
                              red_time_t first_frame_time,
                              int frames_count,
@@ -458,7 +460,7 @@ static bool stream_add_frame(DisplayChannel *display,
 }
 
 /* TODO: document the difference between the 2 functions below */
-void stream_trace_update(DisplayChannel *display, Drawable *drawable)
+void video_stream_trace_update(DisplayChannel *display, Drawable *drawable)
 {
     ItemTrace *trace;
     ItemTrace *trace_end;
@@ -469,7 +471,7 @@ void stream_trace_update(DisplayChannel *display, Drawable *drawable)
     }
 
     FOREACH_STREAMS(display, item) {
-        Stream *stream = SPICE_CONTAINEROF(item, Stream, link);
+        VideoStream *stream = SPICE_CONTAINEROF(item, VideoStream, link);
         bool is_next_frame = is_next_stream_frame(display,
                                                   drawable,
                                                   stream->width,
@@ -482,7 +484,7 @@ void stream_trace_update(DisplayChannel *display, Drawable *drawable)
             if (stream->current) {
                 stream->current->streamable = FALSE; //prevent item trace
                 before_reattach_stream(display, stream, drawable);
-                stream_detach_drawable(stream);
+                video_stream_detach_drawable(stream);
             }
             attach_stream(display, drawable, stream);
             return;
@@ -494,19 +496,19 @@ void stream_trace_update(DisplayChannel *display, Drawable *drawable)
     for (; trace < trace_end; trace++) {
         if (is_next_stream_frame(display, drawable, trace->width, trace->height,
                                  &trace->dest_area, trace->time, NULL, FALSE)) {
-            if (stream_add_frame(display, drawable,
-                                 trace->first_frame_time,
-                                 trace->frames_count,
-                                 trace->gradual_frames_count,
-                                 trace->last_gradual_frame)) {
+            if (video_stream_add_frame(display, drawable,
+                                       trace->first_frame_time,
+                                       trace->frames_count,
+                                       trace->gradual_frames_count,
+                                       trace->last_gradual_frame)) {
                 return;
             }
         }
     }
 }
 
-void stream_maintenance(DisplayChannel *display,
-                        Drawable *candidate, Drawable *prev)
+void video_stream_maintenance(DisplayChannel *display,
+                              Drawable *candidate, Drawable *prev)
 {
     bool is_next_frame;
 
@@ -515,7 +517,7 @@ void stream_maintenance(DisplayChannel *display,
     }
 
     if (prev->stream) {
-        Stream *stream = prev->stream;
+        VideoStream *stream = prev->stream;
 
         is_next_frame = is_next_stream_frame(display, candidate,
                                              stream->width, stream->height,
@@ -523,7 +525,7 @@ void stream_maintenance(DisplayChannel *display,
                                              stream, TRUE);
         if (is_next_frame) {
             before_reattach_stream(display, stream, candidate);
-            stream_detach_drawable(stream);
+            video_stream_detach_drawable(stream);
             prev->streamable = FALSE; //prevent item trace
             attach_stream(display, candidate, stream);
         }
@@ -537,11 +539,11 @@ void stream_maintenance(DisplayChannel *display,
                                  prev->stream,
                                  FALSE);
         if (is_next_frame) {
-            stream_add_frame(display, candidate,
-                             prev->first_frame_time,
-                             prev->frames_count,
-                             prev->gradual_frames_count,
-                             prev->last_gradual_frame);
+            video_stream_add_frame(display, candidate,
+                                   prev->first_frame_time,
+                                   prev->frames_count,
+                                   prev->gradual_frames_count,
+                                   prev->last_gradual_frame);
         }
     }
 }
@@ -571,7 +573,7 @@ static void dcc_update_streams_max_latency(DisplayChannelClient *dcc, StreamAgen
     dcc_set_max_stream_latency(dcc, new_max_latency);
 }
 
-static uint64_t get_initial_bit_rate(DisplayChannelClient *dcc, Stream *stream)
+static uint64_t get_initial_bit_rate(DisplayChannelClient *dcc, VideoStream *stream)
 {
     char *env_bit_rate_str;
     uint64_t bit_rate = 0;
@@ -717,9 +719,10 @@ static VideoEncoder* dcc_create_video_encoder(DisplayChannelClient *dcc,
     return NULL;
 }
 
-void dcc_create_stream(DisplayChannelClient *dcc, Stream *stream)
+void dcc_create_stream(DisplayChannelClient *dcc, VideoStream *stream)
 {
-    StreamAgent *agent = dcc_get_stream_agent(dcc, display_channel_get_stream_id(DCC_TO_DC(dcc), stream));
+    int stream_id = display_channel_get_video_stream_id(DCC_TO_DC(dcc), stream);
+    StreamAgent *agent = dcc_get_stream_agent(dcc, stream_id);
 
     spice_return_if_fail(region_is_empty(&agent->vis_region));
 
@@ -738,7 +741,7 @@ void dcc_create_stream(DisplayChannelClient *dcc, Stream *stream)
 
     uint64_t initial_bit_rate = get_initial_bit_rate(dcc, stream);
     agent->video_encoder = dcc_create_video_encoder(dcc, initial_bit_rate, &video_cbs);
-    red_channel_client_pipe_add(RED_CHANNEL_CLIENT(dcc), stream_create_item_new(agent));
+    red_channel_client_pipe_add(RED_CHANNEL_CLIENT(dcc), video_stream_create_item_new(agent));
 
     if (red_channel_client_test_remote_cap(RED_CHANNEL_CLIENT(dcc), SPICE_DISPLAY_CAP_STREAM_REPORT)) {
         RedStreamActivateReportItem *report_pipe_item = g_new0(RedStreamActivateReportItem, 1);
@@ -746,7 +749,7 @@ void dcc_create_stream(DisplayChannelClient *dcc, Stream *stream)
         agent->report_id = rand();
         red_pipe_item_init(&report_pipe_item->pipe_item,
                            RED_PIPE_ITEM_TYPE_STREAM_ACTIVATE_REPORT);
-        report_pipe_item->stream_id = display_channel_get_stream_id(DCC_TO_DC(dcc), stream);
+        report_pipe_item->stream_id = stream_id;
         red_channel_client_pipe_add(RED_CHANNEL_CLIENT(dcc), &report_pipe_item->pipe_item);
     }
 #ifdef STREAM_STATS
@@ -783,14 +786,14 @@ static void red_upgrade_item_free(RedPipeItem *base)
 
 /*
  * after dcc_detach_stream_gracefully is called for all the display channel clients,
- * stream_detach_drawable should be called. See comment (1).
+ * video_stream_detach_drawable should be called. See comment (1).
  */
 static void dcc_detach_stream_gracefully(DisplayChannelClient *dcc,
-                                         Stream *stream,
+                                         VideoStream *stream,
                                          Drawable *update_area_limit)
 {
     DisplayChannel *display = DCC_TO_DC(dcc);
-    int stream_id = display_channel_get_stream_id(display, stream);
+    int stream_id = display_channel_get_video_stream_id(display, stream);
     StreamAgent *agent = dcc_get_stream_agent(dcc, stream_id);
 
     /* stopping the client from playing older frames at once*/
@@ -849,8 +852,9 @@ clear_vis_region:
     region_clear(&agent->vis_region);
 }
 
-static void detach_stream_gracefully(DisplayChannel *display, Stream *stream,
-                                     Drawable *update_area_limit)
+static void detach_video_stream_gracefully(DisplayChannel *display,
+                                           VideoStream *stream,
+                                           Drawable *update_area_limit)
 {
     DisplayChannelClient *dcc;
 
@@ -858,7 +862,7 @@ static void detach_stream_gracefully(DisplayChannel *display, Stream *stream,
         dcc_detach_stream_gracefully(dcc, stream, update_area_limit);
     }
     if (stream->current) {
-        stream_detach_drawable(stream);
+        video_stream_detach_drawable(stream);
     }
 }
 
@@ -872,7 +876,9 @@ static void detach_stream_gracefully(DisplayChannel *display, Stream *stream,
  *           involves sending an upgrade image to the client, this drawable won't be rendered
  *           (see dcc_detach_stream_gracefully).
  */
-void stream_detach_behind(DisplayChannel *display, QRegion *region, Drawable *drawable)
+void video_stream_detach_behind(DisplayChannel *display,
+                                QRegion *region,
+                                Drawable *drawable)
 {
     Ring *ring = &display->priv->streams;
     RingItem *item = ring_get_head(ring);
@@ -880,44 +886,45 @@ void stream_detach_behind(DisplayChannel *display, QRegion *region, Drawable *dr
     bool is_connected = red_channel_is_connected(RED_CHANNEL(display));
 
     while (item) {
-        Stream *stream = SPICE_CONTAINEROF(item, Stream, link);
+        VideoStream *stream = SPICE_CONTAINEROF(item, VideoStream, link);
         int detach = 0;
         item = ring_next(ring, item);
+        int stream_id = display_channel_get_video_stream_id(display, stream);
 
         FOREACH_DCC(display, dcc) {
-            StreamAgent *agent = dcc_get_stream_agent(dcc, display_channel_get_stream_id(display, stream));
+            StreamAgent *agent = dcc_get_stream_agent(dcc, stream_id);
 
             if (region_intersects(&agent->vis_region, region)) {
                 dcc_detach_stream_gracefully(dcc, stream, drawable);
                 detach = 1;
-                spice_debug("stream %d", display_channel_get_stream_id(display, stream));
+                spice_debug("stream %d", stream_id);
             }
         }
         if (detach && stream->current) {
-            stream_detach_drawable(stream);
+            video_stream_detach_drawable(stream);
         } else if (!is_connected) {
             if (stream->current &&
                 region_intersects(&stream->current->tree_item.base.rgn, region)) {
-                stream_detach_drawable(stream);
+                video_stream_detach_drawable(stream);
             }
         }
     }
 }
 
-void stream_detach_and_stop(DisplayChannel *display)
+void video_stream_detach_and_stop(DisplayChannel *display)
 {
     RingItem *stream_item;
 
     spice_debug("trace");
     while ((stream_item = ring_get_head(&display->priv->streams))) {
-        Stream *stream = SPICE_CONTAINEROF(stream_item, Stream, link);
+        VideoStream *stream = SPICE_CONTAINEROF(stream_item, VideoStream, link);
 
-        detach_stream_gracefully(display, stream, NULL);
-        stream_stop(display, stream);
+        detach_video_stream_gracefully(display, stream, NULL);
+        video_stream_stop(display, stream);
     }
 }
 
-void stream_timeout(DisplayChannel *display)
+void video_stream_timeout(DisplayChannel *display)
 {
     Ring *ring = &display->priv->streams;
     RingItem *item;
@@ -925,16 +932,17 @@ void stream_timeout(DisplayChannel *display)
     red_time_t now = spice_get_monotonic_time_ns();
     item = ring_get_head(ring);
     while (item) {
-        Stream *stream = SPICE_CONTAINEROF(item, Stream, link);
+        VideoStream *stream = SPICE_CONTAINEROF(item, VideoStream, link);
         item = ring_next(ring, item);
         if (now >= (stream->last_time + RED_STREAM_TIMEOUT)) {
-            detach_stream_gracefully(display, stream, NULL);
-            stream_stop(display, stream);
+            detach_video_stream_gracefully(display, stream, NULL);
+            video_stream_stop(display, stream);
         }
     }
 }
 
-void stream_trace_add_drawable(DisplayChannel *display, Drawable *item)
+void video_stream_trace_add_drawable(DisplayChannel *display,
+                                     Drawable *item)
 {
     ItemTrace *trace;
 
diff --git a/server/stream.h b/server/video-stream.h
similarity index 65%
rename from server/stream.h
rename to server/video-stream.h
index 6f194618..0928fc02 100644
--- a/server/stream.h
+++ b/server/video-stream.h
@@ -16,8 +16,8 @@
    License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */
 
-#ifndef STREAM_H_
-#define STREAM_H_
+#ifndef VIDEO_STREAM_H_
+#define VIDEO_STREAM_H_
 
 #include <glib.h>
 #include <common/region.h>
@@ -43,7 +43,7 @@
 #define RED_STREAM_DEFAULT_LOW_START_BIT_RATE (2.5 * 1024 * 1024) // 2.5Mbps
 #define MAX_FPS 30
 
-typedef struct Stream Stream;
+typedef struct VideoStream VideoStream;
 
 typedef struct RedStreamActivateReportItem {
     RedPipeItem pipe_item;
@@ -73,7 +73,7 @@ typedef struct StreamAgent {
                            vis_region will contain c2 and also the part of c1/c2 that still
                            displays fragments of the video */
 
-    Stream *stream;
+    VideoStream *stream;
     VideoEncoder *video_encoder;
     DisplayChannelClient *dcc;
 
@@ -111,7 +111,7 @@ typedef struct ItemTrace {
     SpiceRect dest_area;
 } ItemTrace;
 
-struct Stream {
+struct VideoStream {
     uint8_t refs;
     Drawable *current;
     red_time_t last_time;
@@ -119,7 +119,7 @@ struct Stream {
     int height;
     SpiceRect dest_area;
     int top_down;
-    Stream *next;
+    VideoStream *next;
     RingItem link;
 
     uint32_t num_input_frames;
@@ -127,28 +127,21 @@ struct Stream {
     uint32_t input_fps;
 };
 
-void                  display_channel_init_streams                  (DisplayChannel *display);
-void                  stream_stop                                   (DisplayChannel *display,
-                                                                     Stream *stream);
-void                  stream_unref                                  (DisplayChannel *display,
-                                                                     Stream *stream);
-void                  stream_trace_update                           (DisplayChannel *display,
-                                                                     Drawable *drawable);
-void                  stream_maintenance                            (DisplayChannel *display,
-                                                                     Drawable *candidate,
-                                                                     Drawable *prev);
-void                  stream_timeout                                (DisplayChannel *display);
-void                  stream_detach_and_stop                        (DisplayChannel *display);
-void                  stream_trace_add_drawable                     (DisplayChannel *display,
-                                                                     Drawable *item);
-void                  stream_detach_behind                          (DisplayChannel *display,
-                                                                     QRegion *region,
-                                                                     Drawable *drawable);
-
-void                  stream_agent_unref                            (DisplayChannel *display,
-                                                                     StreamAgent *agent);
-void                  stream_agent_stop                             (StreamAgent *agent);
-
-void stream_detach_drawable(Stream *stream);
-
-#endif /* STREAM_H_ */
+void display_channel_init_video_streams(DisplayChannel *display);
+void video_stream_stop(DisplayChannel *display, VideoStream *stream);
+void video_stream_unref(DisplayChannel *display, VideoStream *stream);
+void video_stream_trace_update(DisplayChannel *display, Drawable *drawable);
+void video_stream_maintenance(DisplayChannel *display, Drawable *candidate,
+                              Drawable *prev);
+void video_stream_timeout(DisplayChannel *display);
+void video_stream_detach_and_stop(DisplayChannel *display);
+void video_stream_trace_add_drawable(DisplayChannel *display, Drawable *item);
+void video_stream_detach_behind(DisplayChannel *display, QRegion *region,
+                                Drawable *drawable);
+
+void stream_agent_unref(DisplayChannel *display, StreamAgent *agent);
+void stream_agent_stop(StreamAgent *agent);
+
+void video_stream_detach_drawable(VideoStream *stream);
+
+#endif /* VIDEO_STREAM_H_ */


More information about the Spice-commits mailing list