[Spice-devel] [PATCH spice-gtk] streaming: make draw-area visible on MJPEG encoder creation

Frediano Ziglio fziglio at redhat.com
Thu Aug 29 09:54:16 UTC 2019


>  
> This patch allows the MJPEG encoder to inform the spice-widget that
> its video drawing area (draw-area) should be made visible on screen.
> 
> This is required to switch from GST video decoding to native MJPEG
> decoding, otherwise the gst-area remained on top and the MJPEG video
> stream was never shown.
> 
> Signed-off-by: Kevin Pouget <kpouget at redhat.com>
> ---
> 
> I have simplified the patch to reuse the existing
> SPICE_DISPLAY_OVERLAY signal (with pipeline_ptr == NULL), instead of
> creating a new one dedicated to the native MJPEG decoder.
> 
> ---
>  src/channel-display-mjpeg.c |  2 ++
>  src/channel-display-priv.h  |  2 +-
>  src/channel-display.c       | 12 ++++++++++++
>  src/spice-widget.c          |  9 ++++++++-
>  4 files changed, 23 insertions(+), 2 deletions(-)
> 
> diff --git a/src/channel-display-mjpeg.c b/src/channel-display-mjpeg.c
> index 647d31b..6f1a4d7 100644
> --- a/src/channel-display-mjpeg.c
> +++ b/src/channel-display-mjpeg.c
> @@ -300,5 +300,7 @@ VideoDecoder* create_mjpeg_decoder(int codec_type,
> display_stream *stream)
> 
>      /* All the other fields are initialized to zero by g_new0(). */
> 
> +    show_mjpeg_widget(stream);
> +

Why not just calling hand_pipeline_to_widget passing NULL as pipeline?

>      return (VideoDecoder*)decoder;
>  }
> diff --git a/src/channel-display-priv.h b/src/channel-display-priv.h
> index b5d6728..90e08ac 100644
> --- a/src/channel-display-priv.h
> +++ b/src/channel-display-priv.h
> @@ -198,7 +198,7 @@ void stream_dropped_frame_on_playback(display_stream
> *st);
>  void stream_display_frame(display_stream *st, SpiceFrame *frame, uint32_t
>  width, uint32_t height, int stride, uint8_t* data);
>  guintptr get_window_handle(display_stream *st);
>  gboolean hand_pipeline_to_widget(display_stream *st,  GstPipeline
>  *pipeline);
> -
> +gboolean show_mjpeg_widget(display_stream *st);
>  void spice_frame_free(SpiceFrame *frame);
> 
>  G_END_DECLS
> diff --git a/src/channel-display.c b/src/channel-display.c
> index 59c809d..b8a27e3 100644
> --- a/src/channel-display.c
> +++ b/src/channel-display.c
> @@ -1484,6 +1484,18 @@ gboolean hand_pipeline_to_widget(display_stream *st,
> GstPipeline *pipeline)
>      return res;
>  }
> 
> +G_GNUC_INTERNAL
> +gboolean show_mjpeg_widget(display_stream *st)
> +{
> +    gboolean res = false;
> +
> +    if (st->surface->streaming_mode) {
> +        g_signal_emit(st->channel, signals[SPICE_DISPLAY_OVERLAY], 0, NULL,
> &res);
> +    }
> +
> +    return res;
> +}
> +
>  /* after a sequence of 3 drops, push a report to the server, even
>   * if the report window is bigger */
>  #define STREAM_REPORT_DROP_SEQ_LEN_LIMIT 3
> diff --git a/src/spice-widget.c b/src/spice-widget.c
> index a9ba1f1..7c257ff 100644
> --- a/src/spice-widget.c
> +++ b/src/spice-widget.c
> @@ -2780,13 +2780,20 @@ static void gst_size_allocate(GtkWidget *widget,
> GdkRectangle *a, gpointer data)
>  }
> 
>  /* This callback should pass to the widget a pointer of the pipeline
> - * so that we can set pipeline and overlay related calls from here.
> + * so that we can the set GST pipeline and overlay related calls from
> + * here.  If the pipeline pointer is NULL, the drawing area of the
> + * native renderer is set visible.
>   */
>  static gboolean set_overlay(SpiceChannel *channel, void* pipeline_ptr,
>  SpiceDisplay *display)
>  {
>  #if defined(GDK_WINDOWING_X11)
>      SpiceDisplayPrivate *d = display->priv;
> 
> +    if (pipeline_ptr == NULL) {
> +        gtk_stack_set_visible_child_name(d->stack, "draw-area");
> +        return true;
> +    }
> +
>      /* GstVideoOverlay is currently used only under x */
>      if (!g_getenv("DISABLE_GSTVIDEOOVERLAY") &&
>          GDK_IS_X11_DISPLAY(gdk_display_get_default())) {

Frediano


More information about the Spice-devel mailing list