Blue Brain BioExplorer
utils.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-2024, EPFL/Blue Brain Project
3  * All rights reserved. Do not distribute without permission.
4  * Responsible Author: Daniel Nachbaur <daniel.nachbaur@epfl.ch>
5  *
6  * This file is part of https://github.com/BlueBrain/Core
7  *
8  * This library is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU Lesser General Public License version 3.0 as published
10  * by the Free Software Foundation.
11  *
12  * This library is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
15  * details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this library; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21 
22 #pragma once
23 
24 #include "DeflectParameters.h"
26 #include <deflect/deflect.h>
27 
28 #define deflectPixelOp deflectPixelOp
29 #define TEXTIFY(A) #A
30 
31 namespace core
32 {
33 template <>
34 inline std::vector<std::pair<std::string, deflect::ChromaSubsampling>> enumMap()
35 {
36  return {{"yuv444", deflect::ChromaSubsampling::YUV444},
37  {"yuv422", deflect::ChromaSubsampling::YUV422},
38  {"yuv420", deflect::ChromaSubsampling::YUV420}};
39 }
40 namespace utils
41 {
46 inline deflect::View getView(const std::string& name)
47 {
48  if (name.length() == 2)
49  {
50  if (name.at(1) == 'L')
51  return deflect::View::left_eye;
52  if (name.at(1) == 'R')
53  return deflect::View::right_eye;
54  return deflect::View::mono;
55  }
56  return deflect::View::mono;
57 }
58 
63 inline uint8_t getChannel(const std::string& name)
64 {
65  if (name.length() == 2)
66  return std::stoi(&name.at(0));
67  return 0;
68 }
69 
70 inline bool needsReset(const deflect::Observer& stream, const DeflectParameters& params)
71 {
72  const bool changed = stream.getId() != params.getId() || stream.getPort() != params.getPort() ||
73  stream.getHost() != params.getHostname();
74 
75  return changed || !stream.isConnected() || !params.getEnabled();
76 }
77 } // namespace utils
78 } // namespace core
std::string getHostname() const
std::string getId() const
unsigned getPort() const
deflect::View getView(const std::string &name)
Definition: utils.h:46
uint8_t getChannel(const std::string &name)
Definition: utils.h:63
bool needsReset(const deflect::Observer &stream, const DeflectParameters &params)
Definition: utils.h:70
std::vector< std::pair< std::string, GeometryQuality > > enumMap()
Definition: Types.h:405
@ mono
Definition: CommonTypes.h:30