RAVENNAKIT
Loading...
Searching...
No Matches
ravenna_node_example.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: AGPL-3.0-or-later
2/*
3 * Project: RAVENNAKIT (RAVENNA / AES67 / ST2110-30 SDK)
4 * Copyright (c) 2024-2025 Sound on Digital
5 *
6 * This file is part of RAVENNAKIT.
7 *
8 * RAVENNAKIT is dual-licensed:
9 * 1) Under the terms of the GNU Affero General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version (the "AGPL License"); and
12 * 2) Under a commercial license from Sound on Digital, for customers who
13 * cannot (or do not wish to) comply with the AGPL License terms.
14 *
15 * If you obtained this file under the AGPL License, you may redistribute it
16 * and/or modify it under the terms of the AGPL License. See the LICENSE
17 * file in the project root for details.
18 *
19 * For commercial licensing, support, and other inquiries, please visit:
20 *
21 * https://ravennakit.com
22 *
23 */
24
27
28namespace examples {
29
31 public:
33 RAV_LOG_INFO("Discovered node: {}", desc.to_string());
34 }
35
37 RAV_LOG_INFO("Removed node: {}", desc.to_string());
38 }
39
41 RAV_LOG_INFO("Discovered session: {}", desc.to_string());
42 }
43
45 RAV_LOG_INFO("Removed session: {}", desc.to_string());
46 }
47
49 RAV_LOG_INFO("Node configuration updated: {}", rav::to_string(configuration));
50 }
51
52 void ravenna_receiver_added([[maybe_unused]] const rav::RavennaReceiver& receiver) override {
53 // Called when a receiver was added to the node.
54 }
55
56 void ravenna_receiver_removed([[maybe_unused]] const rav::Id receiver_id) override {
57 // Called when a receiver was removed from the node.
58 }
59
60 void ravenna_sender_added([[maybe_unused]] const rav::RavennaSender& sender) override {
61 // Called when a sender was added to the node.
62 }
63
64 void ravenna_sender_removed([[maybe_unused]] const rav::Id sender_id) override {
65 // Called when a sender was removed fom the node.
66 }
67
68 void nmos_node_config_updated([[maybe_unused]] const rav::nmos::Node::Configuration& config) override {
69 // Called when the NMOS node configuration was updated.
70 }
71
73 [[maybe_unused]] const rav::nmos::Node::Status status, [[maybe_unused]] const rav::nmos::Node::StatusInfo& registry_info
74 ) override {
75 // Called when the NMOS status changed (connected to a registry for example).
76 }
77
78 void network_interface_config_updated([[maybe_unused]] const rav::NetworkInterfaceConfig& config) override {
79 // Called when the network interface config was updated.
80 }
81};
82
83} // namespace examples
84
89int main([[maybe_unused]] int const argc, [[maybe_unused]] char* argv[]) {
92
94 node_config.enable_dnssd_node_discovery = true;
95 node_config.enable_dnssd_session_advertisement = true;
96 node_config.enable_dnssd_session_discovery = true;
97
99 node.set_configuration(node_config);
100
102 node.subscribe(&subscriber).wait();
103
104 fmt::println("Press return key to stop...");
105 std::string line;
106 std::getline(std::cin, line);
107
108 node.unsubscribe(&subscriber).wait();
109
110 return 0;
111}
void ravenna_receiver_removed(const rav::Id receiver_id) override
Called when a receiver is removed from the node.
void network_interface_config_updated(const rav::NetworkInterfaceConfig &config) override
Called when the network interface configuration is updated.
void nmos_node_config_updated(const rav::nmos::Node::Configuration &config) override
Called when the NMOS configuration is updated.
void ravenna_sender_added(const rav::RavennaSender &sender) override
Called when a sender is added to the node, or when subscribing.
void ravenna_session_discovered(const rav::dnssd::ServiceDescription &desc) override
Called when a session is discovered.
void nmos_node_status_changed(const rav::nmos::Node::Status status, const rav::nmos::Node::StatusInfo &registry_info) override
Called when the NMOS node state changed.
void ravenna_node_discovered(const rav::dnssd::ServiceDescription &desc) override
Called when a node is discovered.
void ravenna_sender_removed(const rav::Id sender_id) override
Called when a sender is removed from the node.
void ravenna_session_removed(const rav::dnssd::ServiceDescription &desc) override
Called when a session is removed.
void ravenna_node_configuration_updated(const rav::RavennaNode::Configuration &configuration) override
Called when the configuration of the RavennaNode is updated.
void ravenna_receiver_added(const rav::RavennaReceiver &receiver) override
Called when a receiver is added to the node, or when subscribing.
void ravenna_node_removed(const rav::dnssd::ServiceDescription &desc) override
Called when a node is removed.
A class which represents a unique identifier.
Definition id.hpp:38
Base class for classes which want to receive updates from the ravenna node.
This class contains all the components to act like a RAVENNA node as specified in the RAVENNA protoco...
std::future< void > subscribe(Subscriber *subscriber)
Adds a subscriber to the node.
std::future< void > set_configuration(Configuration config)
Sets the configuration for this node, state will be updated accordingly.
std::future< void > unsubscribe(Subscriber *subscriber)
Removes a subscriber from the node.
int main()
#define RAV_LOG_INFO(...)
Definition log.hpp:120
void set_log_level_from_env(const char *env_var="RAV_LOG_LEVEL")
Tries to find given environment variable and set the log level accordingly.
Definition log.hpp:216
void do_system_checks()
Definition system.hpp:33
const char * to_string(const AudioEncoding encoding)
Holds the configuration of the node.
bool enable_dnssd_session_discovery
When true, the RAVENNA node will discover sessions (streams) using dns-sd.
bool enable_dnssd_node_discovery
When true, the RAVENNA node will discover other nodes using dns-sd.
bool enable_dnssd_session_advertisement
When true, the RAVENNA node will advertise senders using dns-sd.
A struct containing data which represents a service on the network.
std::string to_string() const noexcept
Returns a description of this struct, which might be handy for debugging or logging purposes.
The configuration of the NMOS node.
Definition nmos_node.hpp:66