From c57359afb4f83f8e5f00d892dd8a1f4e3da493ba Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Anthony=20L=C3=A9onard?=
 <anthony.leonard@savoirfairelinux.com>
Date: Wed, 3 Jan 2018 14:19:21 -0500
Subject: [PATCH] add height and width in Video::Frame structure

By adding those member variables, this information is now conveyed from
daemon to client on a per-frame basis. This is necessary as ffmpeg may
output frames with a size different than what is returned by
Renderer::size().

This later value is set when a video stream reception is established
with height and width corresponding to format of frame sent by the
other end. After decoding, this first size may not be equal to the size
of the frame decoded by ffmpeg (seen at least on macOS with hardware
acceleration enabled).

Finally, doing so is more secure as we are protected by the Renderer
mutex. Previously, getting size and frame were 2 different operations
(method calls) with no guarantee of atomicity, and thus consistency.

Change-Id: I05699b71d2afd38deeea36374830ff00d7d66ad7
Reviewed-by: Olivier Soldano <olivier.soldano@savoirfairelinux.com>
---
 src/private/directrenderer.cpp | 3 +++
 src/video/renderer.h           | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/src/private/directrenderer.cpp b/src/private/directrenderer.cpp
index f394756b..da9c33f0 100644
--- a/src/private/directrenderer.cpp
+++ b/src/private/directrenderer.cpp
@@ -125,6 +125,9 @@ Video::Frame Video::DirectRenderer::currentFrame() const
     frame.storage = std::move(d_ptr->daemonFramePtr_->storage);
     frame.ptr = frame.storage.data();
     frame.size = frame.storage.size();
+    frame.height = d_ptr->daemonFramePtr_->height;
+    frame.width = d_ptr->daemonFramePtr_->width;
+
     return std::move(frame);
 }
 
diff --git a/src/video/renderer.h b/src/video/renderer.h
index a7392e5a..9247cf8b 100644
--- a/src/video/renderer.h
+++ b/src/video/renderer.h
@@ -52,6 +52,9 @@ struct Frame {
    uint8_t*             ptr     { nullptr };
    std::size_t          size    { 0       };
    std::vector<uint8_t> storage {         };
+   // Next variables are currently used with DirectRenderer only
+   unsigned int         height  { 0       };
+   unsigned int         width   { 0       };
 };
 
 /**
-- 
GitLab