[Spice-devel] [PATCH spice-server 15/15] Move display_channel_create_video_stream()
Jonathon Jongsma
jjongsma at redhat.com
Fri Oct 20 21:13:20 UTC 2017
Like the previous commit, this function deals with how the
DisplayChannel allocates and manages the video streams, so it belongs
with the implementation of DisplayChannel.
Signed-off-by: Jonathon Jongsma <jjongsma at redhat.com>
---
server/display-channel.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++
server/display-channel.h | 2 ++
server/video-stream.c | 61 ------------------------------------------------
3 files changed, 63 insertions(+), 61 deletions(-)
diff --git a/server/display-channel.c b/server/display-channel.c
index 8c3d72899..c5d80997d 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -2299,6 +2299,67 @@ static void display_channel_init_video_streams(DisplayChannel *display)
}
}
+static VideoStream *display_channel_video_stream_try_new(DisplayChannel *display)
+{
+ VideoStream *stream;
+ if (!display->priv->free_streams) {
+ return NULL;
+ }
+ stream = display->priv->free_streams;
+ display->priv->free_streams = display->priv->free_streams->next;
+ stream->display = display;
+ return stream;
+}
+
+void display_channel_create_video_stream(DisplayChannel *display, Drawable *drawable)
+{
+ DisplayChannelClient *dcc;
+ VideoStream *stream;
+ SpiceRect* src_rect;
+
+ spice_assert(!drawable->stream);
+
+ if (!(stream = display_channel_video_stream_try_new(display))) {
+ return;
+ }
+
+ spice_assert(drawable->red_drawable->type == QXL_DRAW_COPY);
+ src_rect = &drawable->red_drawable->u.copy.src_area;
+
+ ring_add(&display->priv->streams, &stream->link);
+ stream->current = drawable;
+ stream->last_time = drawable->creation_time;
+ stream->width = src_rect->right - src_rect->left;
+ stream->height = src_rect->bottom - src_rect->top;
+ stream->dest_area = drawable->red_drawable->bbox;
+ stream->refs = 1;
+ SpiceBitmap *bitmap = &drawable->red_drawable->u.copy.src_bitmap->u.bitmap;
+ stream->top_down = !!(bitmap->flags & SPICE_BITMAP_FLAGS_TOP_DOWN);
+ drawable->stream = stream;
+ /* Provide an fps estimate the video encoder can use when initializing
+ * based on the frames that lead to the creation of the stream. Round to
+ * the nearest integer, for instance 24 for 23.976.
+ */
+ uint64_t duration = drawable->creation_time - drawable->first_frame_time;
+ if (duration > NSEC_PER_SEC * drawable->frames_count / MAX_FPS) {
+ stream->input_fps = (NSEC_PER_SEC * drawable->frames_count + duration / 2) / duration;
+ } else {
+ stream->input_fps = MAX_FPS;
+ }
+ stream->num_input_frames = 0;
+ stream->input_fps_start_time = drawable->creation_time;
+ display->priv->streams_size_total += stream->width * stream->height;
+ display->priv->stream_count++;
+ FOREACH_DCC(display, dcc) {
+ 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,
+ stream->height, stream->dest_area.left, stream->dest_area.top,
+ stream->dest_area.right, stream->dest_area.bottom,
+ stream->input_fps);
+}
+
static void
display_channel_constructed(GObject *object)
{
diff --git a/server/display-channel.h b/server/display-channel.h
index 377fc7ea7..3a18c2cc7 100644
--- a/server/display-channel.h
+++ b/server/display-channel.h
@@ -157,6 +157,8 @@ void display_channel_gl_scanout (DisplayCha
void display_channel_gl_draw (DisplayChannel *display,
SpiceMsgDisplayGlDraw *draw);
void display_channel_gl_draw_done (DisplayChannel *display);
+void display_channel_create_video_stream (DisplayChannel *display,
+ Drawable *drawable);
void display_channel_free_video_stream (DisplayChannel *display,
VideoStream *stream);
diff --git a/server/video-stream.c b/server/video-stream.c
index a88d0ae5f..50e53b7b6 100644
--- a/server/video-stream.c
+++ b/server/video-stream.c
@@ -221,67 +221,6 @@ static void before_reattach_stream(DisplayChannel *display,
}
}
-static VideoStream *display_channel_video_stream_try_new(DisplayChannel *display)
-{
- VideoStream *stream;
- if (!display->priv->free_streams) {
- return NULL;
- }
- stream = display->priv->free_streams;
- display->priv->free_streams = display->priv->free_streams->next;
- stream->display = display;
- return stream;
-}
-
-static void display_channel_create_video_stream(DisplayChannel *display, Drawable *drawable)
-{
- DisplayChannelClient *dcc;
- VideoStream *stream;
- SpiceRect* src_rect;
-
- spice_assert(!drawable->stream);
-
- if (!(stream = display_channel_video_stream_try_new(display))) {
- return;
- }
-
- spice_assert(drawable->red_drawable->type == QXL_DRAW_COPY);
- src_rect = &drawable->red_drawable->u.copy.src_area;
-
- ring_add(&display->priv->streams, &stream->link);
- stream->current = drawable;
- stream->last_time = drawable->creation_time;
- stream->width = src_rect->right - src_rect->left;
- stream->height = src_rect->bottom - src_rect->top;
- stream->dest_area = drawable->red_drawable->bbox;
- stream->refs = 1;
- SpiceBitmap *bitmap = &drawable->red_drawable->u.copy.src_bitmap->u.bitmap;
- stream->top_down = !!(bitmap->flags & SPICE_BITMAP_FLAGS_TOP_DOWN);
- drawable->stream = stream;
- /* Provide an fps estimate the video encoder can use when initializing
- * based on the frames that lead to the creation of the stream. Round to
- * the nearest integer, for instance 24 for 23.976.
- */
- uint64_t duration = drawable->creation_time - drawable->first_frame_time;
- if (duration > NSEC_PER_SEC * drawable->frames_count / MAX_FPS) {
- stream->input_fps = (NSEC_PER_SEC * drawable->frames_count + duration / 2) / duration;
- } else {
- stream->input_fps = MAX_FPS;
- }
- stream->num_input_frames = 0;
- stream->input_fps_start_time = drawable->creation_time;
- display->priv->streams_size_total += stream->width * stream->height;
- display->priv->stream_count++;
- FOREACH_DCC(display, dcc) {
- 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,
- 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 video_stream_add_frame(DisplayChannel *display,
Drawable *frame_drawable,
--
2.13.6
More information about the Spice-devel
mailing list