Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Toggle main menu visibility
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
15
#include "
roc_address/interface.h
"
16
#include "
roc_address/protocol.h
"
17
#include "
roc_core/array.h
"
18
#include "
roc_core/noncopyable.h
"
19
#include "
roc_core/singleton.h
"
20
#include "
roc_core/stddefs.h
"
21
#include "
roc_core/string_list.h
"
22
#include "
roc_packet/fec.h
"
23
24
namespace
roc
{
25
namespace
address
{
26
27
//! Protocol attributes.
28
struct
ProtocolAttrs {
29
//! Protocol ID.
30
Protocol
protocol
;
31
32
//! Endpoint type.
33
Interface
iface
;
34
35
//! Scheme name in URI.
36
const
char
*
scheme_name
;
37
38
//! Whether path is supported in URI.
39
bool
path_supported
;
40
41
//! Default port number of -1 if not specified.
42
int
default_port
;
43
44
//! FEC scheme associated wit the protocol, if any.
45
packet::FecScheme
fec_scheme
;
46
47
ProtocolAttrs()
48
:
protocol
(
Proto_None
)
49
,
iface
(
Iface_Invalid
)
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.
58
class
ProtocolMap :
public
core::NonCopyable
<> {
59
public
:
60
//! Get instance.
61
static
ProtocolMap&
instance
() {
62
return
core::Singleton<ProtocolMap>::instance
();
63
}
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.
72
ROC_ATTR_NODISCARD
bool
get_supported_interfaces
(
core::Array<Interface>
&);
73
74
//! Get all supported protocols.
75
ROC_ATTR_NODISCARD
bool
get_supported_protocols
(
Interface
,
core::StringList
&);
76
77
private
:
78
friend
class
core::Singleton
<ProtocolMap>;
79
80
enum
{ MaxProtos = 8 };
81
82
ProtocolMap
();
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_
array.h
Dynamic array.
ROC_ATTR_NODISCARD
#define ROC_ATTR_NODISCARD
Emit warning if function result is not checked.
Definition
attributes.h:31
roc::address::ProtocolMap
Protocol attributes map.
Definition
protocol_map.h:58
roc::address::ProtocolMap::find_by_id
const ProtocolAttrs * find_by_id(Protocol proto) const
Get protocol attributes by ID.
roc::address::ProtocolMap::instance
static ProtocolMap & instance()
Get instance.
Definition
protocol_map.h:61
roc::address::ProtocolMap::find_by_scheme
const ProtocolAttrs * find_by_scheme(const char *scheme) const
Get protocol attributes by scheme name.
roc::address::ProtocolMap::get_supported_interfaces
ROC_ATTR_NODISCARD bool get_supported_interfaces(core::Array< Interface > &)
Get list of interfaces with at least one protocol.
roc::address::ProtocolMap::get_supported_protocols
ROC_ATTR_NODISCARD bool get_supported_protocols(Interface, core::StringList &)
Get all supported protocols.
roc::core::Array
Dynamic array.
Definition
array.h:40
roc::core::NonCopyable
Base class for non-copyable objects.
Definition
noncopyable.h:23
roc::core::Singleton
Singleton.
Definition
singleton.h:26
roc::core::Singleton::instance
static T & instance()
Get singleton instance.
Definition
singleton.h:29
roc::core::StringList
Dynamic list of strings.
Definition
string_list.h:36
fec.h
FEC packet.
interface.h
Interface ID.
roc::address
URIs and addresses.
roc::address::Interface
Interface
Interface ID.
Definition
interface.h:19
roc::address::Iface_Invalid
@ Iface_Invalid
Invalid interface.
Definition
interface.h:21
roc::address::Protocol
Protocol
Protocol ID.
Definition
protocol.h:19
roc::address::Proto_None
@ Proto_None
Protocol is not set.
Definition
protocol.h:21
roc::packet
Network packets and packet processing.
roc::packet::FecScheme
FecScheme
FECFRAME scheme.
Definition
fec.h:23
roc
Root namespace.
noncopyable.h
Non-copyable object.
protocol.h
Protocol ID.
singleton.h
Singleton.
stddefs.h
Commonly used types and functions.
string_list.h
Dynamic list of strings.
roc::address::ProtocolAttrs
Protocol attributes.
Definition
protocol_map.h:28
roc::address::ProtocolAttrs::protocol
Protocol protocol
Protocol ID.
Definition
protocol_map.h:30
roc::address::ProtocolAttrs::iface
Interface iface
Endpoint type.
Definition
protocol_map.h:33
roc::address::ProtocolAttrs::scheme_name
const char * scheme_name
Scheme name in URI.
Definition
protocol_map.h:36
roc::address::ProtocolAttrs::fec_scheme
packet::FecScheme fec_scheme
FEC scheme associated wit the protocol, if any.
Definition
protocol_map.h:45
roc::address::ProtocolAttrs::path_supported
bool path_supported
Whether path is supported in URI.
Definition
protocol_map.h:39
roc::address::ProtocolAttrs::default_port
int default_port
Default port number of -1 if not specified.
Definition
protocol_map.h:42
roc_address
protocol_map.h
Generated by
1.17.0