[Spice-devel,v2] display-channel: Make video-codecs property read-write

Submitted by Victor Toso on Dec. 5, 2016, 1:59 p.m.

Details

Message ID 20161205135933.31161-1-victortoso@redhat.com
State Accepted
Commit f007c0a9915342b13fd7beae45faf8cbec8df372
Headers show
Series "display-channel: Make video-codecs property read-write" ( rev: 1 ) in Spice

Not browsing as part of any series.

Commit Message

Victor Toso Dec. 5, 2016, 1:59 p.m.
From: Victor Toso <me@victortoso.com>

This patch creates display_channel_get_video_codecs() helper to let
stream.c get the video-codecs without accessing the internal structure
of DisplayChannel.

As video-codecs is a property of DisplayChannel, this change means
making this property readable as well.

Signed-off-by: Victor Toso <victortoso@redhat.com>
---
 server/display-channel.c | 12 +++++++++++-
 server/display-channel.h |  1 +
 server/stream.c          |  6 ++++--
 3 files changed, 16 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/server/display-channel.c b/server/display-channel.c
index 061a99d..1a29859 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -44,6 +44,9 @@  display_channel_get_property(GObject *object,
         case PROP_N_SURFACES:
             g_value_set_uint(value, self->priv->n_surfaces);
             break;
+        case PROP_VIDEO_CODECS:
+            g_value_set_static_boxed(value, self->priv->video_codecs);
+            break;
         default:
             G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
     }
@@ -213,6 +216,13 @@  void display_channel_set_video_codecs(DisplayChannel *display, GArray *video_cod
     display->priv->video_codecs = g_array_ref(video_codecs);
 }
 
+GArray *display_channel_get_video_codecs(DisplayChannel *display)
+{
+    spice_return_val_if_fail(display, NULL);
+
+    return display->priv->video_codecs;
+}
+
 int display_channel_get_stream_video(DisplayChannel *display)
 {
     return display->priv->stream_video;
@@ -2247,7 +2257,7 @@  display_channel_class_init(DisplayChannelClass *klass)
                                                        "Video Codecs",
                                                        G_TYPE_ARRAY,
                                                        G_PARAM_CONSTRUCT_ONLY |
-                                                       G_PARAM_WRITABLE |
+                                                       G_PARAM_READWRITE |
                                                        G_PARAM_STATIC_STRINGS));
 }
 
diff --git a/server/display-channel.h b/server/display-channel.h
index d782969..715ad1a 100644
--- a/server/display-channel.h
+++ b/server/display-channel.h
@@ -229,6 +229,7 @@  void                       display_channel_set_stream_video          (DisplayCha
                                                                       int stream_video);
 void                       display_channel_set_video_codecs          (DisplayChannel *display,
                                                                       GArray *video_codecs);
+GArray*                    display_channel_get_video_codecs          (DisplayChannel *display);
 int                        display_channel_get_stream_video          (DisplayChannel *display);
 int                        display_channel_get_streams_timeout       (DisplayChannel *display);
 void                       display_channel_compress_stats_print      (DisplayChannel *display);
diff --git a/server/stream.c b/server/stream.c
index 3f3c286..e2cd66e 100644
--- a/server/stream.c
+++ b/server/stream.c
@@ -691,9 +691,11 @@  static VideoEncoder* dcc_create_video_encoder(DisplayChannelClient *dcc,
     RedChannelClient *rcc = RED_CHANNEL_CLIENT(dcc);
     int client_has_multi_codec = red_channel_client_test_remote_cap(rcc, SPICE_DISPLAY_CAP_MULTI_CODEC);
     int i;
+    GArray *video_codecs;
 
-    for (i = 0; i < display->priv->video_codecs->len; i++) {
-        RedVideoCodec* video_codec = &g_array_index (display->priv->video_codecs, RedVideoCodec, i);
+    video_codecs = display_channel_get_video_codecs(display);
+    for (i = 0; i < video_codecs->len; i++) {
+        RedVideoCodec* video_codec = &g_array_index (video_codecs, RedVideoCodec, i);
 
         if (!client_has_multi_codec &&
             video_codec->type != SPICE_VIDEO_CODEC_TYPE_MJPEG) {

Comments

Looks fine to me.

Acked-by: Jonathon Jongsma <jjongsma@redhat.com>

On Mon, 2016-12-05 at 14:59 +0100, Victor Toso wrote:
> From: Victor Toso <me@victortoso.com>
> 
> This patch creates display_channel_get_video_codecs() helper to let
> stream.c get the video-codecs without accessing the internal
> structure
> of DisplayChannel.
> 
> As video-codecs is a property of DisplayChannel, this change means
> making this property readable as well.
> 
> Signed-off-by: Victor Toso <victortoso@redhat.com>
> ---
>  server/display-channel.c | 12 +++++++++++-
>  server/display-channel.h |  1 +
>  server/stream.c          |  6 ++++--
>  3 files changed, 16 insertions(+), 3 deletions(-)
> 
> diff --git a/server/display-channel.c b/server/display-channel.c
> index 061a99d..1a29859 100644
> --- a/server/display-channel.c
> +++ b/server/display-channel.c
> @@ -44,6 +44,9 @@ display_channel_get_property(GObject *object,
>          case PROP_N_SURFACES:
>              g_value_set_uint(value, self->priv->n_surfaces);
>              break;
> +        case PROP_VIDEO_CODECS:
> +            g_value_set_static_boxed(value, self->priv-
> >video_codecs);
> +            break;
>          default:
>              G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id,
> pspec);
>      }
> @@ -213,6 +216,13 @@ void
> display_channel_set_video_codecs(DisplayChannel *display, GArray
> *video_cod
>      display->priv->video_codecs = g_array_ref(video_codecs);
>  }
>  
> +GArray *display_channel_get_video_codecs(DisplayChannel *display)
> +{
> +    spice_return_val_if_fail(display, NULL);
> +
> +    return display->priv->video_codecs;
> +}
> +
>  int display_channel_get_stream_video(DisplayChannel *display)
>  {
>      return display->priv->stream_video;
> @@ -2247,7 +2257,7 @@ display_channel_class_init(DisplayChannelClass
> *klass)
>                                                         "Video
> Codecs",
>                                                         G_TYPE_ARRAY,
>                                                         G_PARAM_CONST
> RUCT_ONLY |
> -                                                       G_PARAM_WRITA
> BLE |
> +                                                       G_PARAM_READW
> RITE |
>                                                         G_PARAM_STATI
> C_STRINGS));
>  }
>  
> diff --git a/server/display-channel.h b/server/display-channel.h
> index d782969..715ad1a 100644
> --- a/server/display-channel.h
> +++ b/server/display-channel.h
> @@ -229,6 +229,7 @@
> void                       display_channel_set_stream_video          
> (DisplayCha
>                                                                      
>   int stream_video);
>  void                       display_channel_set_video_codecs         
>  (DisplayChannel *display,
>                                                                      
>   GArray *video_codecs);
> +GArray*                    display_channel_get_video_codecs         
>  (DisplayChannel *display);
>  int                        display_channel_get_stream_video         
>  (DisplayChannel *display);
>  int                        display_channel_get_streams_timeout      
>  (DisplayChannel *display);
>  void                       display_channel_compress_stats_print     
>  (DisplayChannel *display);
> diff --git a/server/stream.c b/server/stream.c
> index 3f3c286..e2cd66e 100644
> --- a/server/stream.c
> +++ b/server/stream.c
> @@ -691,9 +691,11 @@ static VideoEncoder*
> dcc_create_video_encoder(DisplayChannelClient *dcc,
>      RedChannelClient *rcc = RED_CHANNEL_CLIENT(dcc);
>      int client_has_multi_codec =
> red_channel_client_test_remote_cap(rcc,
> SPICE_DISPLAY_CAP_MULTI_CODEC);
>      int i;
> +    GArray *video_codecs;
>  
> -    for (i = 0; i < display->priv->video_codecs->len; i++) {
> -        RedVideoCodec* video_codec = &g_array_index (display->priv-
> >video_codecs, RedVideoCodec, i);
> +    video_codecs = display_channel_get_video_codecs(display);
> +    for (i = 0; i < video_codecs->len; i++) {
> +        RedVideoCodec* video_codec = &g_array_index (video_codecs,
> RedVideoCodec, i);
>  
>          if (!client_has_multi_codec &&
>              video_codec->type != SPICE_VIDEO_CODEC_TYPE_MJPEG) {
Hi,

On Mon, Dec 05, 2016 at 03:10:43PM -0600, Jonathon Jongsma wrote:
> Looks fine to me.
> 
> Acked-by: Jonathon Jongsma <jjongsma@redhat.com>

Thanks, pushed as f007c0a9915342b

> 
> On Mon, 2016-12-05 at 14:59 +0100, Victor Toso wrote:
> > From: Victor Toso <me@victortoso.com>
> > 
> > This patch creates display_channel_get_video_codecs() helper to let
> > stream.c get the video-codecs without accessing the internal
> > structure
> > of DisplayChannel.
> > 
> > As video-codecs is a property of DisplayChannel, this change means
> > making this property readable as well.
> > 
> > Signed-off-by: Victor Toso <victortoso@redhat.com>
> > ---
> >  server/display-channel.c | 12 +++++++++++-
> >  server/display-channel.h |  1 +
> >  server/stream.c          |  6 ++++--
> >  3 files changed, 16 insertions(+), 3 deletions(-)
> > 
> > diff --git a/server/display-channel.c b/server/display-channel.c
> > index 061a99d..1a29859 100644
> > --- a/server/display-channel.c
> > +++ b/server/display-channel.c
> > @@ -44,6 +44,9 @@ display_channel_get_property(GObject *object,
> >          case PROP_N_SURFACES:
> >              g_value_set_uint(value, self->priv->n_surfaces);
> >              break;
> > +        case PROP_VIDEO_CODECS:
> > +            g_value_set_static_boxed(value, self->priv-
> > >video_codecs);
> > +            break;
> >          default:
> >              G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id,
> > pspec);
> >      }
> > @@ -213,6 +216,13 @@ void
> > display_channel_set_video_codecs(DisplayChannel *display, GArray
> > *video_cod
> >      display->priv->video_codecs = g_array_ref(video_codecs);
> >  }
> >  
> > +GArray *display_channel_get_video_codecs(DisplayChannel *display)
> > +{
> > +    spice_return_val_if_fail(display, NULL);
> > +
> > +    return display->priv->video_codecs;
> > +}
> > +
> >  int display_channel_get_stream_video(DisplayChannel *display)
> >  {
> >      return display->priv->stream_video;
> > @@ -2247,7 +2257,7 @@ display_channel_class_init(DisplayChannelClass
> > *klass)
> >                                                         "Video
> > Codecs",
> >                                                         G_TYPE_ARRAY,
> >                                                         G_PARAM_CONST
> > RUCT_ONLY |
> > -                                                       G_PARAM_WRITA
> > BLE |
> > +                                                       G_PARAM_READW
> > RITE |
> >                                                         G_PARAM_STATI
> > C_STRINGS));
> >  }
> >  
> > diff --git a/server/display-channel.h b/server/display-channel.h
> > index d782969..715ad1a 100644
> > --- a/server/display-channel.h
> > +++ b/server/display-channel.h
> > @@ -229,6 +229,7 @@
> > void                       display_channel_set_stream_video          
> > (DisplayCha
> >                                                                      
> >   int stream_video);
> >  void                       display_channel_set_video_codecs         
> >  (DisplayChannel *display,
> >                                                                      
> >   GArray *video_codecs);
> > +GArray*                    display_channel_get_video_codecs         
> >  (DisplayChannel *display);
> >  int                        display_channel_get_stream_video         
> >  (DisplayChannel *display);
> >  int                        display_channel_get_streams_timeout      
> >  (DisplayChannel *display);
> >  void                       display_channel_compress_stats_print     
> >  (DisplayChannel *display);
> > diff --git a/server/stream.c b/server/stream.c
> > index 3f3c286..e2cd66e 100644
> > --- a/server/stream.c
> > +++ b/server/stream.c
> > @@ -691,9 +691,11 @@ static VideoEncoder*
> > dcc_create_video_encoder(DisplayChannelClient *dcc,
> >      RedChannelClient *rcc = RED_CHANNEL_CLIENT(dcc);
> >      int client_has_multi_codec =
> > red_channel_client_test_remote_cap(rcc,
> > SPICE_DISPLAY_CAP_MULTI_CODEC);
> >      int i;
> > +    GArray *video_codecs;
> >  
> > -    for (i = 0; i < display->priv->video_codecs->len; i++) {
> > -        RedVideoCodec* video_codec = &g_array_index (display->priv-
> > >video_codecs, RedVideoCodec, i);
> > +    video_codecs = display_channel_get_video_codecs(display);
> > +    for (i = 0; i < video_codecs->len; i++) {
> > +        RedVideoCodec* video_codec = &g_array_index (video_codecs,
> > RedVideoCodec, i);
> >  
> >          if (!client_has_multi_codec &&
> >              video_codec->type != SPICE_VIDEO_CODEC_TYPE_MJPEG) {