[Spice-devel] [PATCH 03/16] worker: move stream definitions to a new stream.h file

Frediano Ziglio fziglio at redhat.com
Tue Nov 10 06:16:16 PST 2015


From: Marc-André Lureau <marcandre.lureau at gmail.com>

Signed-off-by: Marc-André Lureau <marcandre.lureau at gmail.com>
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 server/Makefile.am       |   1 +
 server/display-channel.h |  60 +--------------------
 server/red_worker.c      |  45 +---------------
 server/stream.h          | 132 +++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 135 insertions(+), 103 deletions(-)
 create mode 100644 server/stream.h

diff --git a/server/Makefile.am b/server/Makefile.am
index 7216ab0..8ccf614 100644
--- a/server/Makefile.am
+++ b/server/Makefile.am
@@ -136,6 +136,7 @@ libspice_server_la_SOURCES =			\
 	spice-bitmap-utils.h			\
 	spice-bitmap-utils.c			\
 	utils.h					\
+	stream.h					\
 	$(NULL)
 
 if HAVE_GL
diff --git a/server/display-channel.h b/server/display-channel.h
index 055c2a7..7173c6e 100644
--- a/server/display-channel.h
+++ b/server/display-channel.h
@@ -54,6 +54,7 @@
 #include "spice_image_cache.h"
 #include "utils.h"
 #include "tree.h"
+#include "stream.h"
 
 typedef struct DisplayChannel DisplayChannel;
 typedef struct DisplayChannelClient DisplayChannelClient;
@@ -128,23 +129,6 @@ typedef struct {
     EncoderData data;
 } GlzData;
 
-typedef struct Stream Stream;
-struct Stream {
-    uint8_t refs;
-    Drawable *current;
-    red_time_t last_time;
-    int width;
-    int height;
-    SpiceRect dest_area;
-    int top_down;
-    Stream *next;
-    RingItem link;
-
-    uint32_t num_input_frames;
-    uint64_t input_fps_start_time;
-    uint32_t input_fps;
-};
-
 typedef struct DependItem {
     Drawable *drawable;
     RingItem ring_item;
@@ -179,48 +163,6 @@ struct Drawable {
     uint32_t process_commands_generation;
 };
 
-#define STREAM_STATS
-#ifdef STREAM_STATS
-typedef struct StreamStats {
-   uint64_t num_drops_pipe;
-   uint64_t num_drops_fps;
-   uint64_t num_frames_sent;
-   uint64_t num_input_frames;
-   uint64_t size_sent;
-
-   uint64_t start;
-   uint64_t end;
-} StreamStats;
-#endif
-
-typedef struct StreamAgent {
-    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:
-                           for example, let c1 be the clip area at time t1, and c2
-                           be the clip area at time t2, where t1 < t2. If c1 contains c2, and
-                           at least part of c1/c2, hasn't been covered by a non-video images,
-                           vis_region will contain c2 and also the part of c1/c2 that still
-                           displays fragments of the video */
-
-    PipeItem create_item;
-    PipeItem destroy_item;
-    Stream *stream;
-    uint64_t last_send_time;
-    MJpegEncoder *mjpeg_encoder;
-    DisplayChannelClient *dcc;
-
-    int frames;
-    int drops;
-    int fps;
-
-    uint32_t report_id;
-    uint32_t client_required_latency;
-#ifdef STREAM_STATS
-    StreamStats stats;
-#endif
-} StreamAgent;
-
 struct DisplayChannelClient {
     CommonChannelClient common;
 
diff --git a/server/red_worker.c b/server/red_worker.c
index d73d616..d68a009 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -58,6 +58,7 @@
 #include "common/generated_server_marshallers.h"
 
 #include "display-channel.h"
+#include "stream.h"
 
 #include "spice.h"
 #include "red_worker.h"
@@ -80,21 +81,6 @@
 
 #define DISPLAY_FREE_LIST_DEFAULT_SIZE 128
 
-#define RED_STREAM_DETACTION_MAX_DELTA ((1000 * 1000 * 1000) / 5) // 1/5 sec
-#define RED_STREAM_CONTINUS_MAX_DELTA (1000 * 1000 * 1000)
-#define RED_STREAM_TIMEOUT (1000 * 1000 * 1000)
-#define RED_STREAM_FRAMES_START_CONDITION 20
-#define RED_STREAM_GRADUAL_FRAMES_START_CONDITION 0.2
-#define RED_STREAM_FRAMES_RESET_CONDITION 100
-#define RED_STREAM_MIN_SIZE (96 * 96)
-#define RED_STREAM_INPUT_FPS_TIMEOUT ((uint64_t)5 * 1000 * 1000 * 1000) // 5 sec
-#define RED_STREAM_CHANNEL_CAPACITY 0.8
-/* the client's stream report frequency is the minimum of the 2 values below */
-#define RED_STREAM_CLIENT_REPORT_WINDOW 5 // #frames
-#define RED_STREAM_CLIENT_REPORT_TIMEOUT 1000 // milliseconds
-#define RED_STREAM_DEFAULT_HIGH_START_BIT_RATE (10 * 1024 * 1024) // 10Mbps
-#define RED_STREAM_DEFAULT_LOW_START_BIT_RATE (2.5 * 1024 * 1024) // 2.5Mbps
-
 #define FPS_TEST_INTERVAL 1
 #define MAX_FPS 30
 
@@ -241,11 +227,6 @@ typedef struct SurfaceDestroyItem {
     PipeItem pipe_item;
 } SurfaceDestroyItem;
 
-typedef struct StreamActivateReportItem {
-    PipeItem pipe_item;
-    uint32_t stream_id;
-} StreamActivateReportItem;
-
 #define MAX_PIPE_SIZE 50
 
 #define WIDE_CLIENT_ACK_WINDOW 40
@@ -266,20 +247,6 @@ typedef struct ImageItem {
     uint8_t data[0];
 } ImageItem;
 
-enum {
-    STREAM_FRAME_NONE,
-    STREAM_FRAME_NATIVE,
-    STREAM_FRAME_CONTAINER,
-};
-
-typedef struct StreamClipItem {
-    PipeItem base;
-    int refs;
-    StreamAgent *stream_agent;
-    int clip_type;
-    SpiceClipRects *rects;
-} StreamClipItem;
-
 typedef struct {
     QuicUsrContext usr;
     EncoderData data;
@@ -382,16 +349,6 @@ typedef struct RedSurface {
     QXLReleaseInfoExt create, destroy;
 } RedSurface;
 
-typedef struct ItemTrace {
-    red_time_t time;
-    int frames_count;
-    int gradual_frames_count;
-    int last_gradual_frame;
-    int width;
-    int height;
-    SpiceRect dest_area;
-} ItemTrace;
-
 #define TRACE_ITEMS_SHIFT 3
 #define NUM_TRACE_ITEMS (1 << TRACE_ITEMS_SHIFT)
 #define ITEMS_TRACE_MASK (NUM_TRACE_ITEMS - 1)
diff --git a/server/stream.h b/server/stream.h
new file mode 100644
index 0000000..210abd7
--- /dev/null
+++ b/server/stream.h
@@ -0,0 +1,132 @@
+/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+/*
+   Copyright (C) 2009-2015 Red Hat, Inc.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, see <http://www.gnu.org/licenses/>.
+*/
+#ifndef STREAM_H_
+#define STREAM_H_
+
+#include <glib.h>
+#include "utils.h"
+#include "mjpeg_encoder.h"
+#include "common/region.h"
+#include "red_channel.h"
+#include "spice_image_cache.h"
+
+#define RED_STREAM_DETACTION_MAX_DELTA ((1000 * 1000 * 1000) / 5) // 1/5 sec
+#define RED_STREAM_CONTINUS_MAX_DELTA (1000 * 1000 * 1000)
+#define RED_STREAM_TIMEOUT (1000 * 1000 * 1000)
+#define RED_STREAM_FRAMES_START_CONDITION 20
+#define RED_STREAM_GRADUAL_FRAMES_START_CONDITION 0.2
+#define RED_STREAM_FRAMES_RESET_CONDITION 100
+#define RED_STREAM_MIN_SIZE (96 * 96)
+#define RED_STREAM_INPUT_FPS_TIMEOUT ((uint64_t)5 * 1000 * 1000 * 1000) // 5 sec
+#define RED_STREAM_CHANNEL_CAPACITY 0.8
+/* the client's stream report frequency is the minimum of the 2 values below */
+#define RED_STREAM_CLIENT_REPORT_WINDOW 5 // #frames
+#define RED_STREAM_CLIENT_REPORT_TIMEOUT 1000 // milliseconds
+#define RED_STREAM_DEFAULT_HIGH_START_BIT_RATE (10 * 1024 * 1024) // 10Mbps
+#define RED_STREAM_DEFAULT_LOW_START_BIT_RATE (2.5 * 1024 * 1024) // 2.5Mbps
+
+typedef struct Stream Stream;
+
+typedef struct StreamActivateReportItem {
+    PipeItem pipe_item;
+    uint32_t stream_id;
+} StreamActivateReportItem;
+
+enum {
+    STREAM_FRAME_NONE,
+    STREAM_FRAME_NATIVE,
+    STREAM_FRAME_CONTAINER,
+};
+
+#define STREAM_STATS
+#ifdef STREAM_STATS
+typedef struct StreamStats {
+    uint64_t num_drops_pipe;
+    uint64_t num_drops_fps;
+    uint64_t num_frames_sent;
+    uint64_t num_input_frames;
+    uint64_t size_sent;
+
+    uint64_t start;
+    uint64_t end;
+} StreamStats;
+#endif
+
+typedef struct StreamAgent {
+    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:
+                           for example, let c1 be the clip area at time t1, and c2
+                           be the clip area at time t2, where t1 < t2. If c1 contains c2, and
+                           at least part of c1/c2, hasn't been covered by a non-video images,
+                           vis_region will contain c2 and also the part of c1/c2 that still
+                           displays fragments of the video */
+
+    PipeItem create_item;
+    PipeItem destroy_item;
+    Stream *stream;
+    uint64_t last_send_time;
+    MJpegEncoder *mjpeg_encoder;
+    DisplayChannelClient *dcc;
+
+    int frames;
+    int drops;
+    int fps;
+
+    uint32_t report_id;
+    uint32_t client_required_latency;
+#ifdef STREAM_STATS
+    StreamStats stats;
+#endif
+} StreamAgent;
+
+typedef struct StreamClipItem {
+    PipeItem base;
+    int refs;
+    StreamAgent *stream_agent;
+    int clip_type;
+    SpiceClipRects *rects;
+} StreamClipItem;
+
+typedef struct ItemTrace {
+    red_time_t time;
+    int frames_count;
+    int gradual_frames_count;
+    int last_gradual_frame;
+    int width;
+    int height;
+    SpiceRect dest_area;
+} ItemTrace;
+
+struct Stream {
+    uint8_t refs;
+    Drawable *current;
+    red_time_t last_time;
+    int width;
+    int height;
+    SpiceRect dest_area;
+    int top_down;
+    Stream *next;
+    RingItem link;
+
+    uint32_t num_input_frames;
+    uint64_t input_fps_start_time;
+    uint32_t input_fps;
+};
+
+#endif /* STREAM_H */
-- 
2.4.3



More information about the Spice-devel mailing list