RAVENNAKIT
Loading...
Searching...
No Matches
ravenna_browser.hpp
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
25#pragma once
26
30
31namespace rav {
32
37 public:
41 class Subscriber {
42 public:
43 virtual ~Subscriber() = default;
44
49 virtual void ravenna_node_discovered([[maybe_unused]] const dnssd::ServiceDescription& desc) {}
50
55 virtual void ravenna_node_removed([[maybe_unused]] const dnssd::ServiceDescription& desc) {}
56
61 virtual void ravenna_session_discovered([[maybe_unused]] const dnssd::ServiceDescription& desc) {}
62
67 virtual void ravenna_session_removed([[maybe_unused]] const dnssd::ServiceDescription& desc) {}
68 };
69
70 explicit RavennaBrowser(boost::asio::io_context& io_context);
71
77 [[nodiscard]] const dnssd::ServiceDescription* find_session(const std::string& session_name) const;
78
84 [[nodiscard]] const dnssd::ServiceDescription* find_node(const std::string& node_name) const;
85
91 [[nodiscard]] bool subscribe(Subscriber* subscriber_to_add);
92
98 [[nodiscard]] bool unsubscribe(const Subscriber* subscriber_to_remove);
99
104 tl::expected<void, const char*> set_node_browsing_enabled(bool enabled);
105
110 tl::expected<void, const char*> set_session_browsing_enabled(bool enabled);
111
112 private:
113 boost::asio::io_context& io_context_;
114 std::unique_ptr<dnssd::Browser> node_browser_;
115 std::unique_ptr<dnssd::Browser> session_browser_;
116
117 SubscriberList<Subscriber> subscribers_;
118};
119
120} // namespace rav
Baseclass for other classes which need updates on discovered nodes and sessions.
virtual void ravenna_node_removed(const dnssd::ServiceDescription &desc)
Called when a node is removed.
virtual void ravenna_node_discovered(const dnssd::ServiceDescription &desc)
Called when a node is discovered.
virtual void ravenna_session_discovered(const dnssd::ServiceDescription &desc)
Called when a session is discovered.
virtual void ravenna_session_removed(const dnssd::ServiceDescription &desc)
Called when a session is removed.
tl::expected< void, const char * > set_node_browsing_enabled(bool enabled)
Enables or disables browsing for nodes.
RavennaBrowser(boost::asio::io_context &io_context)
tl::expected< void, const char * > set_session_browsing_enabled(bool enabled)
Enables or disables browsing for nodes.
const dnssd::ServiceDescription * find_session(const std::string &session_name) const
Finds a node by its name.
bool subscribe(Subscriber *subscriber_to_add)
Adds a subscriber to the browser.
const dnssd::ServiceDescription * find_node(const std::string &node_name) const
Finds a node by its name.
bool unsubscribe(const Subscriber *subscriber_to_remove)
Removes a subscriber from the browser.
Super basic list of subscribers.
A struct containing data which represents a service on the network.