[Spice-devel] [PATCH spice-server v2 1/2] Rename Stream to VideoStream
Jonathon Jongsma
jjongsma at redhat.com
Wed Nov 29 20:12:31 UTC 2017
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>
---
Changes in v2:
- broke long lines, changed function declaration indentation
server/Makefile.am | 4 +-
server/dcc-private.h | 2 +-
server/dcc-send.c | 17 ++--
server/dcc.c | 4 +-
server/dcc.h | 4 +-
server/display-channel-private.h | 8 +-
server/display-channel.c | 43 +++++-----
server/display-channel.h | 4 +-
server/red-worker.c | 6 +-
server/stream-channel.c | 2 +-
server/stream-device.c | 6 ++
server/{stream.c => video-stream.c} | 156 +++++++++++++++++++-----------------
server/{stream.h => video-stream.h} | 55 ++++++-------
13 files changed, 160 insertions(+), 151 deletions(-)
rename server/{stream.c => video-stream.c} (85%)
rename server/{stream.h => video-stream.h} (65%)
diff --git a/server/Makefile.am b/server/Makefile.am
index 20f0f1925..8ea258db3 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 c4662202d..76e194fe3 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 84c109680..642c6edd3 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 c2fdd8c21..951d1e9f5 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 4de494571..8ee0bd78a 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 82a3e8c69..24fa42b1f 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 ad346c938..a5bcb1ff2 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 5e3d9eb7f..4f7def216 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 fa57235d9..eb41cef7e 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 c7ca02062..bfacc3754 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 0953a6d03..c2d6dcf25 100644
--- a/server/stream-device.c
+++ b/server/stream-device.c
@@ -131,6 +131,8 @@ handle_msg_invalid(StreamDevice *dev, SpiceCharDeviceInstance *sin, const char *
{
static const char default_error_msg[] = "Protocol error";
+ spice_assert(dev->hdr_pos >= sizeof(StreamDevHeader));
+
if (!error_msg) {
error_msg = default_error_msg;
}
@@ -189,6 +191,10 @@ handle_msg_data(StreamDevice *dev, SpiceCharDeviceInstance *sin)
{
SpiceCharDeviceInterface *sif = spice_char_device_get_interface(sin);
int n;
+
+ spice_assert(dev->hdr_pos >= sizeof(StreamDevHeader));
+ spice_assert(dev->hdr.type == STREAM_TYPE_DATA);
+
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 846c921a7..2d51885de 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 6f194618d..0928fc02d 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_ */
--
2.13.6
More information about the Spice-devel
mailing list