-
Notifications
You must be signed in to change notification settings - Fork 6
/
Config.h
147 lines (122 loc) · 3.48 KB
/
Config.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#pragma once
#include <cstdint>
#include <deque>
#include <map>
#include <optional>
#include <chrono>
#include <filesystem>
#include <spdlog/common.h>
#include "Client/Config.h"
#include "Signalling/Config.h"
#include "RtStreaming/WebRTCConfig.h"
struct SignallingServer : public client::Config
{
SignallingServer(
const std::string& server,
const std::string& uri,
const std::string& token,
bool useTls) :
client::Config {
server,
useTls ? signalling::DEFAULT_WSS_PORT : signalling::DEFAULT_WS_PORT,
useTls },
uri(uri),
token(token)
{
}
std::string uri;
std::string token;
};
struct CameraConfig
{
struct Resolution {
unsigned width;
unsigned height;
};
std::optional<Resolution> resolution;
std::optional<unsigned> framerate;
};
struct RecordConfig
{
enum: uint64_t {
MIN_MAX_DIR_SIZE = 100 * (1ull << 20), // 100 Mb
MIN_MAX_FILE_SIZE = 10 * (1ull << 20), // 10 Mb
};
RecordConfig(const std::filesystem::path& dir, uint64_t maxDirSize, uint64_t maxFileSize) :
dir(dir),
maxDirSize(std::max<uint64_t>(maxDirSize, MIN_MAX_DIR_SIZE)),
maxFileSize(std::max<uint64_t>(maxFileSize, MIN_MAX_FILE_SIZE))
{}
const std::filesystem::path dir;
const uint64_t maxDirSize;
const uint64_t maxFileSize;
};
struct StreamerConfig
{
enum class Type {
Test,
ReStreamer,
#if ONVIF_SUPPORT
ONVIFReStreamer,
#endif
Record,
FilePlayer,
Proxy,
Pipeline,
Camera,
V4L2,
};
enum class Visibility {
Auto, // Protected if authentication is required, Public if not.
Public,
Protected, // Accessible only for authenticated users
};
Type type;
bool restream = true;
Visibility visibility = Visibility::Protected;
std::string uri;
std::string pipeline;
std::optional<std::string> username;
std::optional<std::string> password;
std::string remoteAgentToken;
std::string description;
std::string forceH264ProfileLevelId;
std::optional<RecordConfig> recordConfig;
std::optional<std::string> edidFilePath;
std::optional<CameraConfig> cameraConfig;
bool useHwEncoder = true;
};
#if !defined(BUILD_AS_CAMERA_STREAMER) && !defined(BUILD_AS_V4L2_STREAMER)
struct AgentsConfig
{
WebRTCConfig::IceServers iceServers;
#ifdef SNAPCRAFT_BUILD
bool useCoturn = true;
#else
bool useCoturn = false;
#endif
};
#endif
struct CoturnConfig
{
uint16_t port = 3478;
std::optional<std::string> staticAuthSecret;
std::chrono::seconds passwordTTL = std::chrono::hours(1);
};
struct Config : public signalling::Config
{
spdlog::level::level_enum logLevel = spdlog::level::info;
spdlog::level::level_enum lwsLogLevel = spdlog::level::warn;
std::optional<SignallingServer> signallingServer;
bool forceServerMode = false;
std::map<std::string, StreamerConfig> streamers; // escaped streamer name -> StreamerConfig
bool authRequired = true;
std::shared_ptr<WebRTCConfig> webRTCConfig = std::make_shared<WebRTCConfig>();
std::optional<std::string> publicIp;
#if !defined(BUILD_AS_CAMERA_STREAMER) && !defined(BUILD_AS_V4L2_STREAMER)
AgentsConfig agentsConfig;
#endif
CoturnConfig coturnConfig;
bool useAgentMode() const { return signallingServer.has_value(); }
bool useServerMode() const { return !signallingServer.has_value() || forceServerMode; }
};