[Spice-devel] [PATCH 04/16] worker: move stream functions to a new stream.c file
Jonathon Jongsma
jjongsma at redhat.com
Tue Nov 10 07:50:03 PST 2015
ACK
On Tue, 2015-11-10 at 14:16 +0000, Frediano Ziglio wrote:
> 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/red_worker.c | 52 ++---------------------------------------
> server/stream.c | 66
> +++++++++++++++++++++++++++++++++++++++++++++++++++++
> server/stream.h | 5 ++++
> 4 files changed, 74 insertions(+), 50 deletions(-)
> create mode 100644 server/stream.c
>
> diff --git a/server/Makefile.am b/server/Makefile.am
> index 8ccf614..52703c9 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.c \
> stream.h \
> $(NULL)
>
> diff --git a/server/red_worker.c b/server/red_worker.c
> index d68a009..f855765 100644
> --- a/server/red_worker.c
> +++ b/server/red_worker.c
> @@ -1530,21 +1530,9 @@ static inline void red_detach_stream(RedWorker
> *worker, Stream *stream, int deta
> stream->current = NULL;
> }
>
> -static StreamClipItem *__new_stream_clip(DisplayChannelClient* dcc,
> StreamAgent *agent)
> -{
> - StreamClipItem *item = spice_new(StreamClipItem, 1);
> - red_channel_pipe_item_init(RED_CHANNEL_CLIENT(dcc)->channel,
> - (PipeItem *)item, PIPE_ITEM_TYPE_STREAM_CLIP);
> -
> - item->stream_agent = agent;
> - agent->stream->refs++;
> - item->refs = 1;
> - return item;
> -}
> -
> static void push_stream_clip(DisplayChannelClient* dcc, StreamAgent
> *agent)
> {
> - StreamClipItem *item = __new_stream_clip(dcc, agent);
> + StreamClipItem *item = stream_clip_item_new(dcc, agent);
> int n_rects;
>
> if (!item) {
> @@ -1618,42 +1606,6 @@ static void red_attach_stream(RedWorker
> *worker, Drawable *drawable, Stream *str
> }
> }
>
> -static void red_print_stream_stats(DisplayChannelClient *dcc,
> StreamAgent *agent)
> -{
> -#ifdef STREAM_STATS
> - StreamStats *stats = &agent->stats;
> - double passed_mm_time = (stats->end - stats->start) / 1000.0;
> - MJpegEncoderStats encoder_stats = {0};
> -
> - if (agent->mjpeg_encoder) {
> - mjpeg_encoder_get_stats(agent->mjpeg_encoder,
> &encoder_stats);
> - }
> -
> - spice_debug("stream=%"PRIdPTR" dim=(%dx%d) #in-frames=%"PRIu64"
> #in-avg-fps=%.2f #out-frames=%"PRIu64" "
> - "out/in=%.2f #drops=%"PRIu64" (#pipe=%"PRIu64"
> #fps=%"PRIu64") out-avg-fps=%.2f "
> - "passed-mm-time(sec)=%.2f size-total(MB)=%.2f size
> -per-sec(Mbps)=%.2f "
> - "size-per-frame(KBpf)=%.2f avg-quality=%.2f "
> - "start-bit-rate(Mbps)=%.2f end-bit-rate(Mbps)=%.2f",
> - agent - dcc->stream_agents, agent->stream->width,
> agent->stream->height,
> - stats->num_input_frames,
> - stats->num_input_frames / passed_mm_time,
> - stats->num_frames_sent,
> - (stats->num_frames_sent + 0.0) / stats
> ->num_input_frames,
> - stats->num_drops_pipe +
> - stats->num_drops_fps,
> - stats->num_drops_pipe,
> - stats->num_drops_fps,
> - stats->num_frames_sent / passed_mm_time,
> - passed_mm_time,
> - stats->size_sent / 1024.0 / 1024.0,
> - ((stats->size_sent * 8.0) / (1024.0 * 1024)) /
> passed_mm_time,
> - stats->size_sent / 1000.0 / stats->num_frames_sent,
> - encoder_stats.avg_quality,
> - encoder_stats.starting_bit_rate / (1024.0 * 1024),
> - encoder_stats.cur_bit_rate / (1024.0 * 1024));
> -#endif
> -}
> -
> static void red_stop_stream(RedWorker *worker, Stream *stream)
> {
> DisplayChannelClient *dcc;
> @@ -1681,7 +1633,7 @@ static void red_stop_stream(RedWorker *worker,
> Stream *stream)
> }
> stream->refs++;
> red_channel_client_pipe_add(RED_CHANNEL_CLIENT(dcc),
> &stream_agent->destroy_item);
> - red_print_stream_stats(dcc, stream_agent);
> + stream_agent_stats_print(stream_agent);
> }
> worker->streams_size_total -= stream->width * stream->height;
> ring_remove(&stream->link);
> diff --git a/server/stream.c b/server/stream.c
> new file mode 100644
> index 0000000..53d05f3
> --- /dev/null
> +++ b/server/stream.c
> @@ -0,0 +1,66 @@
> +/*
> + 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/>.
> +*/
> +#include "stream.h"
> +#include "display-channel.h"
> +
> +void stream_agent_stats_print(StreamAgent *agent)
> +{
> +#ifdef STREAM_STATS
> + StreamStats *stats = &agent->stats;
> + double passed_mm_time = (stats->end - stats->start) / 1000.0;
> + MJpegEncoderStats encoder_stats = {0};
> +
> + if (agent->mjpeg_encoder) {
> + mjpeg_encoder_get_stats(agent->mjpeg_encoder,
> &encoder_stats);
> + }
> +
> + spice_debug("stream=%p dim=(%dx%d) #in-frames=%"PRIu64" #in-avg
> -fps=%.2f #out-frames=%"PRIu64" "
> + "out/in=%.2f #drops=%"PRIu64" (#pipe=%"PRIu64"
> #fps=%"PRIu64") out-avg-fps=%.2f "
> + "passed-mm-time(sec)=%.2f size-total(MB)=%.2f size
> -per-sec(Mbps)=%.2f "
> + "size-per-frame(KBpf)=%.2f avg-quality=%.2f "
> + "start-bit-rate(Mbps)=%.2f end-bit-rate(Mbps)=%.2f",
> + agent, agent->stream->width, agent->stream->height,
> + stats->num_input_frames,
> + stats->num_input_frames / passed_mm_time,
> + stats->num_frames_sent,
> + (stats->num_frames_sent + 0.0) / stats
> ->num_input_frames,
> + stats->num_drops_pipe +
> + stats->num_drops_fps,
> + stats->num_drops_pipe,
> + stats->num_drops_fps,
> + stats->num_frames_sent / passed_mm_time,
> + passed_mm_time,
> + stats->size_sent / 1024.0 / 1024.0,
> + ((stats->size_sent * 8.0) / (1024.0 * 1024)) /
> passed_mm_time,
> + stats->size_sent / 1000.0 / stats->num_frames_sent,
> + encoder_stats.avg_quality,
> + encoder_stats.starting_bit_rate / (1024.0 * 1024),
> + encoder_stats.cur_bit_rate / (1024.0 * 1024));
> +#endif
> +}
> +
> +StreamClipItem *stream_clip_item_new(DisplayChannelClient* dcc,
> StreamAgent *agent)
> +{
> + StreamClipItem *item = spice_new(StreamClipItem, 1);
> + red_channel_pipe_item_init(RED_CHANNEL_CLIENT(dcc)->channel,
> + (PipeItem *)item,
> PIPE_ITEM_TYPE_STREAM_CLIP);
> +
> + item->stream_agent = agent;
> + agent->stream->refs++;
> + item->refs = 1;
> + return item;
> +}
> diff --git a/server/stream.h b/server/stream.h
> index 210abd7..f77fa96 100644
> --- a/server/stream.h
> +++ b/server/stream.h
> @@ -103,6 +103,9 @@ typedef struct StreamClipItem {
> SpiceClipRects *rects;
> } StreamClipItem;
>
> +StreamClipItem *stream_clip_item_new(DisplayChannelClient* dcc,
> + StreamAgent *agent);
> +
> typedef struct ItemTrace {
> red_time_t time;
> int frames_count;
> @@ -129,4 +132,6 @@ struct Stream {
> uint32_t input_fps;
> };
>
> +void stream_agent_stats_print(StreamAgent *agent);
> +
> #endif /* STREAM_H */
More information about the Spice-devel
mailing list