\fresh{}

\section{Desktop and mobile interactions}

\subsection{Desktop interaction}

Regardind desktop interaction, we keep the interaction we described in Section~\ref{bi:our-nve}, namely:
\begin{itemize}
    \item W, A, S and D keys to translate the camera;
    \item mouse motions to rotate the camera.
\end{itemize}
A screenshot of this interface is displayed in Figure~\ref{sb:desktop}.

\subsection{Mobile interaction}

\copied{}
Mobile interactions are more complex because the user does not have neither keyboard nor mouse to interact with.
However, there are some other sensors on most mobile devices that can help interaction.
The most useful sensor for 3D interaction on mobile devices is definitely the gyroscope.
We use the gyroscope to enable a user to rotate his device to rotate the virtual camera.
We also add the possibility to rotate the camera by drag and dropping the scene.
This way, the user is not forced to perform a real-world half-turn to be able to look behind or to keep its device pointing to the sky (which can quickly become tiring) to look up.
These interactions, however, do not allow the user to move the camera: he can rotate it but not translate it.
For this reason, we display a small joystick on the bottom left corner of the screen that mimics the first person video games interactions and  allow the user translating the camera:
\begin{itemize}
    \item moving the joystick up makes the camera move forward;
    \item moving the joystick down makes the camera move backwards;
    \item moving the joystick sideways makes the camera move sidewars.
\end{itemize}
A screenshot of this interface is displayed in Figure~\ref{sb:mobile}.

\section{Adding bookmarks into DASH NVE framework\label{sb:bookmarks}}

\copied{}
In this section, we explain how to include a new interaction in the system described in the previous chapter.
\fresh{}

\subsection{Interaction --- Visual}

In Chapter~\ref{bi} Section~\ref{bi:3d-bookmarks}, we described two 3D widgets that we used to display bookmarks to users.
One of the conclusions of the user-study, described in Section~\ref{bi:user-study}, was that the impact of the way we display bookmark was not significant.
In this work, we chose a slightly different way of representing bookmarks due to some concerns with our original representations:
\begin{itemize}
    \item viewport bookmarks are simple, but people who are not in the field of vision are not familiar with this representation;
    \item arrow bookmarks are complex, and need to be refreshed when the camera moves, which can harm the framerate of the rendering.
\end{itemize}
For these reasons, we changed the display to a vertical bar with a 2D sprite of a pictural representation of an eye.
This 2D sprite is always facing the camera to prevent it from being invisible when the camera would be on the side of it.
Screenshots of user interfaces with bookmarks are available in Figures~\ref{sb:desktop} and~\ref{sb:mobile}.

The size of the sprite changes when time goes by following a sine to help the user differenciate what is part of the scene and what is extra widgets.
Since our scene is static, a user knows when seeing a bookmark that it is not part of the scene.

The other parameters of the bookmarks remain unchanged since Chapter~\ref{bi}: in order to avoid users to lose context, clicking on a bookmark triggers an automatic, smooth, camera displacement that ends up at the bookmark.
We also display a thumbnail of the bookmark's viewpoint when the mouse hovers over a bookmark.
Such thumbnail is displayed in Figure~\ref{sb:desktop}.
Note that since on mobile, there is no mouse and thus no pointer, thumbnails are never downloaded nor displayed.

\begin{figure}[ht]
    \centering
    \includegraphics[width=\textwidth]{assets/system-bookmarks/screenshots/desktop.png}
    \caption{Screenshot of the desktop version, with a bookmark and its thumbnail on the bottom left corner\label{sb:desktop}}
\end{figure}

\begin{figure}[ht]
    \centering
    \includegraphics[width=\textwidth]{assets/system-bookmarks/screenshots/mobile.png}
    \caption{Screenshot of the mobile version, with its joystick on the bottom left corner\label{sb:mobile}}
\end{figure}

\subsection{Segments utility at bookmarked viewpoint\label{sb:utility}}
\copied{}
Introducing bookmarks is a way to make users navigation more predictable.
Indeed, since they are emphasized and, in a way, recommended viewpoints, bookmarks are more likely to be visited by a significant portion of users than any other viewpoint on the scene.
As such, bookmarks can be used as a way to optimize streaming by downloading segments in an optimal, pre-computed order.

More specifically, segment utility as introduced in Section~\ref{d3:utility} is only an approximation of the segment's true contribution to the current viewpoint rendering.
When bookmarks are defined, it is possible to obtain a perfect measure of segment utility by performing an offline rendering at each bookmark's viewpoint.
% Then, by simply counting the number of pixels that are rendered using each segment, we can rank the segments by order of importance in the rendering.

We define $\mathcal{U}^{*} (s,B_i)$ as being the true utility of a segment $s$ in a viewpoint defined at bookmark $B_i$.

\fresh{}
Algorithm~\ref{sb:algo-optimal-order} computes the best order of segments from a viewpoint.
It starts with an empty model, and it tries all the segments from a set of candidates, and computes the PSNR between the corresponding render and the ground truth render.
With all those PSNRs, it is able to determine which segment is the one that brings the best $\Delta\text{PSNR} / s$, $s$ being the size of the segment in bytes.
Once it found the best segment, it registers it, and starts again.
That way, it is able to generate an order of segments sorted by $\Delta\text{PSNR} / s$.
This order is then saved as a JSON file and a client will be able to download it to know which segments are more appropriate from a certain viewpoint.

\begin{algorithm}[th]
    \SetKwInOut{Input}{input}
    \SetKwInOut{Output}{output}

    \SetKwData{BookmarkViewpoint}{bookmark\_viewpoint}
    \SetKwData{OptimalOrder}{optimal\_order}
    \SetKwData{TotalModel}{total\_model}
    \SetKwData{EmptyModel}{empty\_model}
    \SetKwData{I}{i}
    \SetKwData{BestSegment}{best\_segment}
    \SetKwData{BestPsnr}{best\_delta\_psnr}
    \SetKwData{PreviousPsnr}{previous\_psnr}
    \SetKwData{None}{none}
    \SetKwData{CurrentModel}{current\_model}
    \SetKwData{EmptyRender}{empty\_render}
    \SetKwData{CurrentRender}{current\_render}
    \SetKwData{GroundTruthRender}{ground\_truth\_render}
    \SetKwData{CurrentPsnr}{current\_psnr}
    \SetKwData{CurrentDeltaPsnr}{current\_delta\_psnr}
    \SetKwData{Segment}{segment}
    \SetKwData{Candidates}{candidates}
    \SetKwFunction{Render}{render}
    \SetKwFunction{Psnr}{psnr}

    \Input{The bookmark viewpoint, the ground truth render at this viewpoint, the candidate segments}
    \Output{The optimal order of the segments}

    \OptimalOrder\leftarrow{} []\;
    \EmptyRender\leftarrow\Render{\EmptyModel,\BookmarkViewpoint}\;
    \PreviousPsnr\leftarrow\Psnr(\EmptyRender,\GroundTruthRender)\;

    \TotalModel\leftarrow\EmptyModel\;

    \For{\I\in0\ldots200}{%

        \BestSegment\leftarrow\None\;
        \BestPsnr\leftarrow0\;

        \For{\Segment\in\Candidates}{%

            \CurrentModel\leftarrow\TotalModel\cup\Segment\;
            \CurrentRender\leftarrow\Render{\CurrentModel,\BookmarkViewpoint}\;
            \CurrentPsnr\leftarrow\Psnr{\CurrentRender,\GroundTruthRender}\;
            \CurrentDeltaPsnr\leftarrow\CurrentPsnr$-$\PreviousPsnr\;

            \If{\CurrentDeltaPsnr$>$\BestPsnr}{%
                \BestSegment\leftarrow\Segment\;
                \BestPsnr\leftarrow\CurrentDeltaPsnr\;
            }
        }
        \OptimalOrder\leftarrow\OptimalOrder+\BestSegment\;
        \TotalModel\leftarrow\TotalModel\cup\BestSegment\;
    }
    \caption{Computation of the optimal order of segments from a bookmark\label{sb:algo-optimal-order}}
\end{algorithm}

% This utility is simply the ratio between the number of pixels displaying that segment on screen, and the total screen area (in pixels).
% This utility definition is the same for geometry and texture segments, which allows all segments to be ranked by order of importance, i.e.\ of decreasing utility.

\copied{}

\begin{figure}[th]
    \centering
    \begin{tikzpicture}
        \begin{axis}[
                xlabel=Data downloaded (in B),
                ylabel=PSNR,
                no markers,
                cycle list name=mystyle,
                width=\tikzwidth,
                height=\tikzheight,
                legend pos=south east,
                xmin=0,
            ]

            \addplot table [x=x, y=y]{assets/system-bookmarks/precomputation/greedy.dat};
            \addlegendentry{\scriptsize Default order $\mathcal{U}$}
            \addplot table [x=x, y=y]{assets/system-bookmarks/precomputation/precomputed.dat};
            \addlegendentry{\scriptsize Proposed order $\mathcal{U}^*$}

        \end{axis}
    \end{tikzpicture}
    \caption{Impact of using the precomputed information of bookmarks to select segments to download\label{sb:precomputation}}
\end{figure}

\begin{figure}[th]
    \includegraphics[width=0.49\columnwidth]{assets/system-bookmarks/bookmark/ground-truth.png}
    \includegraphics[width=0.49\columnwidth]{assets/system-bookmarks/bookmark/geometry.png}
    \caption{A bookmarked viewpoint (left), and a pixel to geometry segment map (right)\label{sb:bookmarks-utility}}
\end{figure}

Figure~\ref{sb:bookmarks-utility} depicts a ``pixel to geometry segment'' map: all pixels of the same color in the right image display an element of the same geometry segment.
We render such maps offline, for each bookmark, and use it to compute the true utility $\mathcal{U}^*(s)$ of segment $s$.

\subsection{MPD modification}

We now present how to introduce bookmarks information in the Media Presentation Description (MPD) file, to be used in a DASH framework.
Bookmarks are fully defined by a viewport description, and the additional content needed to properly render and use a bookmark in a system consists in three images: a thumbnail of the point of view at the bookmark, along with two ``pixel to segment'' maps (see Figure~\ref{sb:bookmarks-utility}, right image).
For this reason, we create a separate adaptation set in the MPD\@.
The bookmarked viewport information is stored as a supplemental property.
Bookmarks adaptation set only contain one representation, composed of three segments corresponding to the three images described earlier.

\begin{figure}[th]
    \lstinputlisting[%
        language=XML,
        caption={MPD description of a geometry adaptation set, and a texture adaptation set.},
        label=sb:bookmark-as,
        emph={%
            MPD,
            Period,
            AdaptationSet,
            Representation,
            BaseURL,
            SegmentBase,
            Initialization,
            Role,
            SupplementalProperty,
            SegmentList,
            SegmentURL,
            Viewpoint
        }
    ]{assets/system-bookmarks/bookmark-as.xml}
\end{figure}

An example of a bookmark adaptation set is depicted on Listing~\ref{sb:bookmark-as}.
The three first values in the supplemental property are the camera position coordinates, and the three last values are the target point coordinates.

\subsection{System-aware bookmarks}

The information we include in the MPD to optimize streaming at bookmarked viewpoints can also be used to give a sense of the system state to the user.
Indeed, displaying a thumbnail of what can be seen from a bookmark might fool users into thinking that all necessary segments visible from the bookmarked viewpoint have been downloaded.
In case this would be not true, users' Quality of Experience would be unsatisfactory.

In order to give users a sense of the amount of information readily available at a given bookmarked viewpoint, we use the pixel to segment maps described in Section~\ref{sb:utility} to create a mask of segment availability.
Since we know which segments have been downloaded at any given time, we know which pixels in the thumbnail accurately depict what the user will see when clicking on the bookmark.
We thus render the thumbnail with the mask of already downloaded segments superimposed over it.

\todo[inline]{Figure of altered thumbnail}


\subsection{Loader modifications}

We build on the loader introduced in Algorithm~\ref{d3:next-segment} to implement a client adaptation logic.
We include a bookmark adaptation logic such that (i) when a bookmark is hovered for the first time, the corresponding images (see Listing~\ref{sb:bookmark-as}) are downloaded, and (ii) when a bookmark is clicked, we switch from utility $\mathcal{U}$ to true utility $\mathcal{U}^*$ to determine which segments to download next.

\begin{algorithm}[th]
    \SetKwInOut{Input}{input}
    \SetKwInOut{Output}{output}
    \Input{Current index $i$, time $t_i$, viewpoint $v(t_i)$, buffer of already downloaded  \texttt{segments} $\mathcal{B}_i$, MPD}
    \Output{Next segment $s^{*}_i$ to request, updated buffer $\mathcal{B}_{i+1}$}
    \SetAlgoLined%
    {- Estimate the bandwidth $\widehat{BW_i}$ and RTT $\widehat{\tau_i}$ \;}

    {-  Among all \texttt{segments} that are not already downloaded $s \in \mathcal{S} \backslash \mathcal{B}_i$, % \;}
   % {-
    keep the ones inside the upcoming viewing frustums $\mathcal{FC}=\mathbb{FC}(\widehat{v}(t_i)), t\in [t_i, t_i+\chi]$  thanks to a viewpoint predictor $t_i \rightarrow \hat{v}(t_i)$, a temporal horizon $\chi$ and a frustum culling operator $\mathbb{FC}$ \;}


    {- Optimize a criterion  $\Omega$ based on $\mathcal{U}$ values and well chosen viewpoint $v(t_i)$ to select the next segment to query }
   {\begin{equation*}
   s^{*}_i= \argmax{s \in \mathcal{S} \backslash \mathcal{B}_i \cap \mathcal{FC}}  \Omega_{\theta_i} \Big(\mathcal{U}(s,v(t_i))\Big) \label{sb:eq1}
   \end{equation*} \\
   given parameters $\theta_i$ that gathers both online parameters $(i,t_i,v(t_i),\widehat{BW_i}, \widehat{\tau_i}, \mathcal{B}_i)$ and offline metadata;}

    {- Update the buffer $\mathcal{B}_{i+1}$  for the next decision: $s^{*}_i$ and lowest \texttt{representations} of $s^{*}_i$ are considered downloaded\;}
     {- \Return{segment  $s^{*}_i$, buffer $\mathcal{B}_{i+1}$}\;}

    {\caption{Algorithm to identify the next segment to query\label{sb:next-segment}}}
\end{algorithm}

\todo[inline]{to be modified to include bookmarks}

