Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Loading...
Searching...
No Matches
router.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017 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_packet/router.h
10//! @brief Route packets to writers.
11
12#ifndef ROC_PACKET_ROUTER_H_
13#define ROC_PACKET_ROUTER_H_
14
15#include "roc_core/array.h"
16#include "roc_core/attributes.h"
17#include "roc_core/iarena.h"
19#include "roc_core/stddefs.h"
20#include "roc_packet/iwriter.h"
21#include "roc_packet/packet.h"
22
23namespace roc {
24namespace packet {
25
26//! Route packets to writers.
27class Router : public IWriter, public core::NonCopyable<> {
28public:
29 //! Initialize.
31
32 //! Add route.
33 //! @remarks
34 //! Packets that has given @p flags set will be routed to @p writer.
35 ROC_ATTR_NODISCARD bool add_route(IWriter& writer, unsigned flags);
36
37 //! Write next packet.
38 //! @remarks
39 //! Route @p packet to a writer or drop it if no routes found.
41
42private:
43 struct Route {
44 IWriter* writer;
45 unsigned flags;
46 stream_source_t source;
47 bool has_source;
48 };
49
51};
52
53} // namespace packet
54} // namespace roc
55
56#endif // ROC_PACKET_ROUTER_H_
Dynamic array.
Compiler attributes.
#define ROC_ATTR_NODISCARD
Emit warning if function result is not checked.
Definition attributes.h:31
Memory arena interface.
Definition iarena.h:23
Base class for non-copyable objects.
Definition noncopyable.h:23
Packet writer interface.
Definition iwriter.h:23
Route packets to writers.
Definition router.h:27
Router(core::IArena &arena)
Initialize.
virtual ROC_ATTR_NODISCARD status::StatusCode write(const PacketPtr &packet)
Write next packet.
ROC_ATTR_NODISCARD bool add_route(IWriter &writer, unsigned flags)
Add route.
Memory arena interface.
Packet writer interface.
uint32_t stream_source_t
Packet stream identifier.
Definition units.h:27
Root namespace.
Non-copyable object.
Packet.
StatusCode
Status code.
Definition status_code.h:19
Commonly used types and functions.