[Spice-devel] [spice v1 2/2] display-channel: Make video-codecs readwrite
Frediano Ziglio
fziglio at redhat.com
Fri Dec 2 17:17:00 UTC 2016
>
> From: Victor Toso <me at victortoso.com>
>
> By making video-codecs readeable, we can avoid other objects to access
> the internals of DisplayChannel.
>
> The GArray video-codecs is copied as static, no need to unref it
> afterwards.
>
> Signed-off-by: Victor Toso <victortoso at redhat.com>
> ---
> server/display-channel.c | 5 ++++-
> server/stream.c | 6 ++++--
> 2 files changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/server/display-channel.c b/server/display-channel.c
> index 2d475d1..8bad693 100644
> --- a/server/display-channel.c
> +++ b/server/display-channel.c
> @@ -43,6 +43,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);
> }
> @@ -2246,7 +2249,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/stream.c b/server/stream.c
> index 3f3c286..bb2ca99 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);
> + g_object_get(display, "video-codecs", &video_codecs, NULL);
> + 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) {
I prefer accessors.
Also streaming code should have access to this information, in all
other DisplayChannel code video_codecs are useless.
That is the problem is that stream data are in DisplayChannel,
I think the right direction is encapsulate correctly stream code,
data related to stream should be in a "stream" structure.
Frediano
More information about the Spice-devel
mailing list