Repository navigation
Expand file tree
/
Copy pathConfig.h
More file actions
136 lines (110 loc) · 3.32 KB
/
Copy pathConfig.h
File metadata and controls
136 lines (110 loc) · 3.32 KB
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
#pragma once
#include <cstdint>
#include <deque>
#include <map>
#include <optional>
#include <chrono>
#include <filesystem>
#include <spdlog/common.h>
#include "Signalling/Config.h"
#include "RtStreaming/WebRTCConfig.h"
struct SignallingServer : public WsClientConfig, public WsClientCredentials
{
std::string uri;
};
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;
};
#if !defined(BUILD_AS_CAMERA_STREAMER) && !defined(BUILD_AS_V4L2_RESTREAMER)
struct StreamerConfig
{
enum class Type {
Test,
ReStreamer,
#if ONVIF_SUPPORT
ONVIFReStreamer,
#endif
Record,
FilePlayer,
Proxy,
Pipeline,
};
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;
};
#endif
#if !defined(BUILD_AS_CAMERA_STREAMER) && !defined(BUILD_AS_V4L2_RESTREAMER)
struct AgentsConfig
{
WebRTCConfig::IceServers iceServers;
bool useCoturn = false;
};
#endif
struct CoturnConfig
{
uint16_t port = 3478;
std::optional<std::string> staticAuthSecret;
std::chrono::seconds passwordTTL = std::chrono::hours(1);
};
struct Config : public WsServerConfig
{
spdlog::level::level_enum logLevel = spdlog::level::info;
spdlog::level::level_enum lwsLogLevel = spdlog::level::warn;
std::optional<SignallingServer> signallingServer;
bool forceServerMode = false;
#if defined(BUILD_AS_CAMERA_STREAMER)
CameraConfig cameraConfig;
bool useHwEncoder = true;
#elif defined(BUILD_AS_V4L2_RESTREAMER)
std::optional<std::string> edidFilePath;
bool useHwEncoder = true;
#else
std::map<std::string, StreamerConfig, std::less<>> streamers; // escaped streamer name -> StreamerConfig
#endif
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_RESTREAMER)
AgentsConfig agentsConfig;
#endif
CoturnConfig coturnConfig;
std::string clientId;
std::map<std::string, std::string> passwd; // for agent mode
bool useAgentMode() const { return signallingServer.has_value(); }
bool useServerMode() const { return !signallingServer.has_value() || forceServerMode; }
};