Skip to content

Commit ceb2adb

Browse files
authored
Merge branch 'nmos-aes67-daemon' into dependabot/npm_and_yarn/webui/vite-6.4.3
2 parents 45de400 + af20315 commit ceb2adb

14 files changed

Lines changed: 2740 additions & 763 deletions

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ The daemon should work on all Ubuntu starting from 18.04 onward, it's possible t
106106
## Devices and interoperability tests ##
107107
See [Devices and interoperability tests with the AES67 daemon](DEVICES.md)
108108

109+
## Support for NMOS ##
110+
Starting from daemon version 4.x the support for NMOS (IS-04 and IS-05) was added.
111+
109112
## Support for ST-2022-7 ##
110113
Starting from the daemon version 3.0 and driver version 2.0 support for ST-2022-7 was added.
111114
This feature is automatically enabled when 2 interfaces are configured via the daemon _interface_name_ parameter.

build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ cmake \
4242
-DFAKE_DRIVER=OFF \
4343
-DWITH_SYSTEMD=ON \
4444
-DWITH_STREAMER=ON \
45+
-DWITH_NMOS=ON \
4546
.
4647
make
4748
cd ..

daemon/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ set(CMAKE_CXX_STANDARD 17)
1313

1414
option(WITH_SYSTEMD "Include systemd notify and watchdog support" OFF)
1515
option(WITH_STREAMER "Enable streamer support" ON)
16+
option(WITH_NMOS "Include NMOS IS-04 Node API and Registration support" OFF)
1617

1718
# ravena lkm _should_ be provided by the CLI. Nonetheless, we should be able
1819
# to find it in system dirs too...
@@ -43,6 +44,12 @@ if(WITH_STREAMER)
4344
list(APPEND SOURCES streamer.cpp)
4445
endif()
4546

47+
if(WITH_NMOS)
48+
MESSAGE(STATUS "WITH_NMOS")
49+
add_definitions(-D_USE_NMOS_)
50+
list(APPEND SOURCES nmos_manager.cpp)
51+
endif()
52+
4653
if(FAKE_DRIVER)
4754
MESSAGE(STATUS "FAKE_DRIVER")
4855
add_definitions(-D_USE_FAKE_DRIVER_)

daemon/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,10 @@ Example
222222
"streamer_files_num": 6,
223223
"streamer_file_duration": 1,
224224
"streamer_player_buffer_files_num": 1
225+
"nmos_registry_address": "127.0.0.1",
226+
"nmos_registry_port": 8010,
227+
"nmos_node_port": 3212,
228+
"nmos_label": "AES67 Daemon"
225229
}
226230

227231
where:
@@ -343,6 +347,19 @@ where:
343347
> **streamer\_player\_buffer\_files\_num**
344348
> JSON number specifying the player buffer in number of files.
345349
350+
> **nmos\_registry\_address**
351+
> JSON string specifying the address of the NMOS registry to connect to.
352+
353+
> **nmos\_registry\_port**
354+
> JSON number specifying the port of the NMOS registry to connect to.
355+
356+
> **nmos\_node\_port**
357+
> JSON number specifying the port of the local NMOS node.
358+
> The NMOS node binds to any network interface on this port.
359+
360+
> **nmos\_label**
361+
> JSON string specifying the NMOS label.
362+
346363

347364
### JSON PTP Config<a name="ptp-config"></a> ###
348365

daemon/config.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,12 @@ bool Config::save(const Config& config) {
182182
get_streamer_files_num() != config.get_streamer_files_num() ||
183183
get_streamer_player_buffer_files_num() !=
184184
config.get_streamer_player_buffer_files_num() ||
185-
get_streamer_enabled() != config.get_streamer_enabled();
185+
get_streamer_enabled() != config.get_streamer_enabled() ||
186+
get_nmos_enabled() != config.get_nmos_enabled() ||
187+
get_nmos_registry_address() != config.get_nmos_registry_address() ||
188+
get_nmos_registry_port() != config.get_nmos_registry_port() ||
189+
get_nmos_node_port() != config.get_nmos_node_port() ||
190+
get_nmos_label() != config.get_nmos_label();
186191

187192
if (!daemon_restart_)
188193
*this = config;

daemon/config.hpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ class Config {
7474
std::string get_node_id() const;
7575
bool get_auto_sinks_update() const { return auto_sinks_update_; };
7676

77+
bool get_nmos_enabled() const { return nmos_enabled_; }
78+
const std::string& get_nmos_registry_address() const { return nmos_registry_address_; }
79+
uint16_t get_nmos_registry_port() const { return nmos_registry_port_; }
80+
uint16_t get_nmos_node_port() const { return nmos_node_port_; }
81+
const std::string& get_nmos_label() const { return nmos_label_; }
82+
7783
/* attributes set during init */
7884
const std::array<uint8_t, 6>& get_mac_addr() const { return mac_addr_; };
7985
const std::string& get_mac_addr_str() const { return mac_str_; };
@@ -171,6 +177,12 @@ class Config {
171177
};
172178
void set_driver_restart(bool restart) { driver_restart_ = restart; }
173179

180+
void set_nmos_enabled(bool v) { nmos_enabled_ = v; }
181+
void set_nmos_registry_address(std::string_view v) { nmos_registry_address_ = v; }
182+
void set_nmos_registry_port(uint16_t v) { nmos_registry_port_ = v; }
183+
void set_nmos_node_port(uint16_t v) { nmos_node_port_ = v; }
184+
void set_nmos_label(std::string_view v) { nmos_label_ = v; }
185+
174186
friend bool operator!=(const Config& lhs, const Config& rhs) {
175187
return lhs.get_http_addr_str() != rhs.get_http_addr_str() ||
176188
lhs.get_http_port() != rhs.get_http_port() ||
@@ -202,7 +214,12 @@ class Config {
202214
lhs.get_interface_name() != rhs.get_interface_name() ||
203215
lhs.get_mdns_enabled() != rhs.get_mdns_enabled() ||
204216
lhs.get_auto_sinks_update() != rhs.get_auto_sinks_update() ||
205-
lhs.get_custom_node_id() != rhs.get_custom_node_id();
217+
lhs.get_custom_node_id() != rhs.get_custom_node_id() ||
218+
lhs.get_nmos_enabled() != rhs.get_nmos_enabled() ||
219+
lhs.get_nmos_registry_address() != rhs.get_nmos_registry_address() ||
220+
lhs.get_nmos_registry_port() != rhs.get_nmos_registry_port() ||
221+
lhs.get_nmos_node_port() != rhs.get_nmos_node_port() ||
222+
lhs.get_nmos_label() != rhs.get_nmos_label();
206223
};
207224
friend bool operator==(const Config& lhs, const Config& rhs) {
208225
return !(lhs != rhs);
@@ -243,6 +260,12 @@ class Config {
243260
std::string node_id_;
244261
bool auto_sinks_update_{true};
245262

263+
bool nmos_enabled_{false};
264+
std::string nmos_registry_address_;
265+
uint16_t nmos_registry_port_{8010};
266+
uint16_t nmos_node_port_{3212};
267+
std::string nmos_label_{"AES67 Daemon"};
268+
246269
/* set during init */
247270
std::array<uint8_t, 6> mac_addr_{0, 0, 0, 0, 0, 0};
248271
std::string mac_str_;

daemon/daemon.conf

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"rtp_mcast_base_sec": "239.1.0.1",
1212
"rtp_port": 5004,
1313
"rtp_port_sec": 5004,
14-
"ptp_domain": 0,
14+
"ptp_domain": 127,
1515
"ptp_dscp": 48,
1616
"sap_mcast_addr": "239.255.255.255",
1717
"sap_interval": 30,
@@ -27,5 +27,10 @@
2727
"streamer_file_duration": 1,
2828
"streamer_player_buffer_files_num": 1,
2929
"streamer_enabled": false,
30-
"auto_sinks_update": true
30+
"auto_sinks_update": true,
31+
"nmos_enabled": true,
32+
"nmos_registry_address": "127.0.0.1",
33+
"nmos_registry_port": 8010,
34+
"nmos_node_port": 3212,
35+
"nmos_label": "AES67 Daemon"
3136
}

daemon/http_server.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ bool HttpServer::init() {
259259
set_error(ret, "failed to add source " + std::to_string(source.id),
260260
res);
261261
} else {
262+
session_manager_->save_status();
262263
set_headers(res);
263264
}
264265
} catch (const std::runtime_error& e) {
@@ -280,6 +281,7 @@ bool HttpServer::init() {
280281
if (ret) {
281282
set_error(ret, "failed to remove source " + std::to_string(id), res);
282283
} else {
284+
session_manager_->save_status();
283285
set_headers(res);
284286
}
285287
});
@@ -292,6 +294,7 @@ bool HttpServer::init() {
292294
if (ret) {
293295
set_error(ret, "failed to add sink " + std::to_string(sink.id), res);
294296
} else {
297+
session_manager_->save_status();
295298
set_headers(res);
296299
}
297300
} catch (const std::runtime_error& e) {
@@ -312,6 +315,7 @@ bool HttpServer::init() {
312315
if (ret) {
313316
set_error(ret, "failed to remove sink " + std::to_string(id), res);
314317
} else {
318+
session_manager_->save_status();
315319
set_headers(res);
316320
}
317321
});

daemon/json.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,14 @@ std::string config_to_json(const Config& config) {
123123
<< ",\n \"streamer_enabled\": " << std::boolalpha
124124
<< config.get_streamer_enabled()
125125
<< ",\n \"auto_sinks_update\": " << std::boolalpha
126-
<< config.get_auto_sinks_update() << "\n}\n";
126+
<< config.get_auto_sinks_update()
127+
<< ",\n \"nmos_enabled\": " << std::boolalpha << config.get_nmos_enabled()
128+
<< ",\n \"nmos_registry_address\": \""
129+
<< escape_json(config.get_nmos_registry_address()) << "\""
130+
<< ",\n \"nmos_registry_port\": " << config.get_nmos_registry_port()
131+
<< ",\n \"nmos_node_port\": " << config.get_nmos_node_port()
132+
<< ",\n \"nmos_label\": \"" << escape_json(config.get_nmos_label()) << "\""
133+
<< "\n}\n";
127134
return ss.str();
128135
}
129136

@@ -379,6 +386,18 @@ Config json_to_config_(std::istream& js, Config& config) {
379386
remove_undesired_chars(val.get_value<std::string>()));
380387
} else if (key == "auto_sinks_update") {
381388
config.set_auto_sinks_update(val.get_value<bool>());
389+
} else if (key == "nmos_enabled") {
390+
config.set_nmos_enabled(val.get_value<bool>());
391+
} else if (key == "nmos_registry_address") {
392+
config.set_nmos_registry_address(
393+
remove_undesired_chars(val.get_value<std::string>()));
394+
} else if (key == "nmos_registry_port") {
395+
config.set_nmos_registry_port(val.get_value<uint16_t>());
396+
} else if (key == "nmos_node_port") {
397+
config.set_nmos_node_port(val.get_value<uint16_t>());
398+
} else if (key == "nmos_label") {
399+
config.set_nmos_label(
400+
remove_undesired_chars(val.get_value<std::string>()));
382401
} else if (key == "ip_addr") {
383402
config.set_ip_addr_str(val.get_value<std::string>());
384403
} else if (key == "mac_addr" || key == "node_id") {

daemon/main.cpp

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
#include "streamer.hpp"
3636
#endif
3737

38+
#ifdef _USE_NMOS_
39+
#include "nmos_manager.hpp"
40+
#endif
41+
3842
#ifdef _USE_SYSTEMD_
3943
#include <systemd/sd-daemon.h>
4044
#endif
@@ -43,7 +47,7 @@ namespace po = boost::program_options;
4347
namespace postyle = boost::program_options::command_line_style;
4448
namespace logging = boost::log;
4549

46-
static const std::string version("bondagit-3.1.0");
50+
static const std::string version("bondagit-4.0.0");
4751
static std::atomic<bool> terminate = false;
4852

4953
void termination_handler(int signum) {
@@ -203,6 +207,17 @@ int main(int argc, char* argv[]) {
203207
/* load session status from file */
204208
session_manager->load_status();
205209

210+
#ifdef _USE_NMOS_
211+
/* start NMOS manager */
212+
std::shared_ptr<NmosManager> nmos_manager;
213+
if (config->get_nmos_enabled()) {
214+
nmos_manager = NmosManager::create(session_manager, config);
215+
if (nmos_manager == nullptr || !nmos_manager->init()) {
216+
throw std::runtime_error(std::string("NmosManager:: init failed"));
217+
}
218+
}
219+
#endif
220+
206221
BOOST_LOG_TRIVIAL(debug) << "main:: init done, entering loop...";
207222

208223
#ifdef _USE_SYSTEMD_
@@ -249,6 +264,15 @@ int main(int argc, char* argv[]) {
249264
/* save session status to file */
250265
session_manager->save_status();
251266

267+
#ifdef _USE_NMOS_
268+
/* stop NMOS manager */
269+
if (config->get_nmos_enabled() && nmos_manager) {
270+
if (!nmos_manager->terminate()) {
271+
throw std::runtime_error(std::string("NmosManager:: terminate failed"));
272+
}
273+
}
274+
#endif
275+
252276
/* stop http server */
253277
if (!http_server.terminate()) {
254278
throw std::runtime_error(std::string("HttpServer:: terminate failed"));

0 commit comments

Comments
 (0)