Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Loading...
Searching...
No Matches
protocol_map.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 Roc Streaming authors
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 */
8
9//! @file roc_address/protocol_map.h
10//! @brief Protocol attributes map.
11
12#ifndef ROC_ADDRESS_PROTOCOL_MAP_H_
13#define ROC_ADDRESS_PROTOCOL_MAP_H_
14
17#include "roc_core/array.h"
19#include "roc_core/singleton.h"
20#include "roc_core/stddefs.h"
22#include "roc_packet/fec.h"
23
24namespace roc {
25namespace address {
26
27//! Protocol attributes.
29 //! Protocol ID.
31
32 //! Endpoint type.
34
35 //! Scheme name in URI.
36 const char* scheme_name;
37
38 //! Whether path is supported in URI.
40
41 //! Default port number of -1 if not specified.
43
44 //! FEC scheme associated wit the protocol, if any.
46
50 , scheme_name(NULL)
51 , path_supported(false)
52 , default_port(-1)
53 , fec_scheme(packet::FEC_None) {
54 }
55};
56
57//! Protocol attributes map.
59public:
60 //! Get instance.
64
65 //! Get protocol attributes by ID.
66 const ProtocolAttrs* find_by_id(Protocol proto) const;
67
68 //! Get protocol attributes by scheme name.
69 const ProtocolAttrs* find_by_scheme(const char* scheme) const;
70
71 //! Get list of interfaces with at least one protocol.
73
74 //! Get all supported protocols.
76
77private:
78 friend class core::Singleton<ProtocolMap>;
79
80 enum { MaxProtos = 8 };
81
83
84 void add_proto_(const ProtocolAttrs&);
85
86 ProtocolAttrs protos_[MaxProtos];
87};
88
89} // namespace address
90} // namespace roc
91
92#endif // ROC_ADDRESS_PROTOCOL_MAP_H_
Dynamic array.
#define ROC_ATTR_NODISCARD
Emit warning if function result is not checked.
Definition attributes.h:31
Protocol attributes map.
const ProtocolAttrs * find_by_id(Protocol proto) const
Get protocol attributes by ID.
static ProtocolMap & instance()
Get instance.
const ProtocolAttrs * find_by_scheme(const char *scheme) const
Get protocol attributes by scheme name.
bool get_supported_interfaces(core::Array< Interface > &)
Get list of interfaces with at least one protocol.
bool get_supported_protocols(Interface, core::StringList &)
Get all supported protocols.
Dynamic array.
Definition array.h:40
Base class for non-copyable objects.
Definition noncopyable.h:23
static T & instance()
Get singleton instance.
Definition singleton.h:29
Dynamic list of strings.
Definition string_list.h:36
FEC packet.
Interface ID.
Interface
Interface ID.
Definition interface.h:19
@ Iface_Invalid
Invalid interface.
Definition interface.h:21
Protocol
Protocol ID.
Definition protocol.h:19
@ Proto_None
Protocol is not set.
Definition protocol.h:21
FecScheme
FECFRAME scheme.
Definition fec.h:23
Root namespace.
Non-copyable object.
Protocol ID.
Singleton.
Commonly used types and functions.
Dynamic list of strings.
Protocol attributes.
Protocol protocol
Protocol ID.
Interface iface
Endpoint type.
const char * scheme_name
Scheme name in URI.
packet::FecScheme fec_scheme
FEC scheme associated wit the protocol, if any.
bool path_supported
Whether path is supported in URI.
int default_port
Default port number of -1 if not specified.