[Spice-devel] [RFC PATCH spice-streaming-agent v2 07/20] Send a StreamInfo message when starting to stream

Jonathon Jongsma jjongsma at redhat.com
Tue Aug 21 20:03:11 UTC 2018


On Thu, 2018-08-16 at 18:26 +0200, Lukáš Hrázký wrote:
> The StreamInfo message contanis information about the new stream,
> e.g.
> the guest (xrandr) output ID of the monitor that is being streamed.
> 
> Signed-off-by: Lukáš Hrázký <lhrazky at redhat.com>
> ---
>  configure.ac                  |  2 +-
>  src/spice-streaming-agent.cpp | 22 ++++++++++++++++++++++
>  2 files changed, 23 insertions(+), 1 deletion(-)
> 
> diff --git a/configure.ac b/configure.ac
> index b59c447..9eb9f9c 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -30,7 +30,7 @@ PKG_PROG_PKG_CONFIG
>  dnl
> =====================================================================
> ====
>  dnl Check deps
>  
> -SPICE_PROTOCOL_MIN_VER=0.12.14
> +SPICE_PROTOCOL_MIN_VER=0.12.15
>  PKG_CHECK_MODULES([SPICE_PROTOCOL], [spice-protocol >=
> $SPICE_PROTOCOL_MIN_VER])
>  AC_SUBST([SPICE_PROTOCOL_MIN_VER])
>  
> diff --git a/src/spice-streaming-agent.cpp b/src/spice-streaming-
> agent.cpp
> index a9baf4d..403a473 100644
> --- a/src/spice-streaming-agent.cpp
> +++ b/src/spice-streaming-agent.cpp
> @@ -53,6 +53,12 @@ struct SpiceStreamDataMessage
>      StreamMsgData msg;
>  };
>  
> +struct SpiceStreamInfoMessage
> +{
> +    StreamDevHeader hdr;
> +    StreamMsgInfo msg;
> +};
> +
>  static bool streaming_requested = false;
>  static bool quit_requested = false;
>  static std::set<SpiceVideoCodecType> client_codecs;
> @@ -200,6 +206,20 @@ static void spice_stream_send_format(StreamPort
> &stream_port, unsigned w, unsign
>      stream_port.write(&msg, msgsize);
>  }
>  
> +static void spice_stream_send_info(StreamPort &stream_port, uint32_t
> guest_output_id)
> +{
> +    SpiceStreamInfoMessage msg;
> +    const size_t msgsize = sizeof(msg);
> +    const size_t hdrsize  = sizeof(msg.hdr);
> +    memset(&msg, 0, msgsize);
> +    msg.hdr.protocol_version = STREAM_DEVICE_PROTOCOL;
> +    msg.hdr.type = STREAM_TYPE_INFO;
> +    msg.hdr.size = msgsize - hdrsize;
> +    msg.msg.guest_output_id = guest_output_id;
> +    syslog(LOG_DEBUG, "writing stream info\n");
> +    stream_port.write(&msg, msgsize);
> +}
> +
>  static void spice_stream_send_frame(StreamPort &stream_port, const
> void *buf, const unsigned size)
>  {
>      SpiceStreamDataMessage msg;
> @@ -302,6 +322,8 @@ do_capture(StreamPort &stream_port, FrameLog
> &frame_log)
>                  syslog(LOG_DEBUG, "wXh %uX%u  codec=%u", width,
> height, codec);
>                  frame_log.log_stat("Started new stream wXh %uX%u
> codec=%u", width, height, codec);
>  
> +                // TODO use xrandr to get the output id, hard-coded
> 0 is ok until multimonitor support
> +                spice_stream_send_info(stream_port, 0);

>                  spice_stream_send_format(stream_port, width, height,
> codec);
>              }
>              frame_log.log_stat("Frame of %zu bytes",
> frame.buffer_size);

So, if we use the Stream Device protocol messages I proposed in patch
03/20 (or something based on it, at least), then instead of sending the
 INFO message followed by the FORMAT message, we'd just send a single
OUTPUT_CONFIG message here

Reviewed-by: Jonathon Jongsma <jjongsma at redhat.com>


More information about the Spice-devel mailing list