diff options
author | Frediano Ziglio <fziglio@redhat.com> | 2017-12-07 19:22:00 +0000 |
---|---|---|
committer | Frediano Ziglio <freddy77@gmail.com> | 2023-11-22 07:39:17 +0000 |
commit | 66ab2289eddd81d6f5d8e33daeda2d29ee774d1c (patch) | |
tree | 9b44b85ddfc08113e9d92d7cb47e9ea535dc354b | |
parent | a1e6d3859840866a30e79c5c155d0456e0161dd0 (diff) |
get VideoStreams from VideoStream
avoid to use some private DisplayChannel fields
-rw-r--r-- | server/video-stream.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/server/video-stream.cpp b/server/video-stream.cpp index 34bec32e..27e28db6 100644 --- a/server/video-stream.cpp +++ b/server/video-stream.cpp @@ -38,6 +38,14 @@ VideoStreamAgents *video_stream_agent_get_agents(VideoStreamAgent *agent) return SPICE_CONTAINEROF(start, VideoStreamAgents, agents); } +static inline +VideoStreams *video_stream_get_streams(VideoStream *stream) +{ + // XXX pretty ugly hack + auto start = reinterpret_cast<std::array<VideoStream, NUM_STREAMS>*>(stream-stream->id); + return SPICE_CONTAINEROF(start, VideoStreams, streams_buf); +} + static void video_stream_agent_stats_print(VideoStreamAgent *agent) { #ifdef STREAM_STATS @@ -76,9 +84,8 @@ static void video_stream_agent_stats_print(VideoStreamAgent *agent) StreamCreateDestroyItem::~StreamCreateDestroyItem() { - // TODO use streams - DisplayChannel *display = DCC_TO_DC(agent->dcc); - video_stream_agent_unref(&display->priv->streams_, agent); + VideoStreams *streams = video_stream_get_streams(agent->stream); + video_stream_agent_unref(streams, agent); } StreamCreateDestroyItem::StreamCreateDestroyItem(VideoStreamAgent *init_agent, int init_type): @@ -100,7 +107,7 @@ static RedPipeItemPtr video_stream_destroy_item_new(VideoStreamAgent *agent) static void video_stream_stop(DisplayChannel *display, VideoStream *stream) { - VideoStreams *streams = &display->priv->streams_; + VideoStreams *streams = video_stream_get_streams(stream); DisplayChannelClient *dcc; int stream_id = streams_get_stream_id(streams, stream); @@ -177,9 +184,8 @@ static void video_stream_agent_unref(VideoStreams *streams, VideoStreamAgent *ag VideoStreamClipItem::~VideoStreamClipItem() { - DisplayChannel *display = DCC_TO_DC(stream_agent->dcc); - - video_stream_agent_unref(&display->priv->streams_, stream_agent); + VideoStreams *streams = video_stream_get_streams(stream_agent->stream); + video_stream_agent_unref(streams, stream_agent); } VideoStreamClipItem::VideoStreamClipItem(VideoStreamAgent *agent): |