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/iallocator.h"
18#include "roc_core/stddefs.h"
19#include "roc_packet/iwriter.h"
20#include "roc_packet/packet.h"
21
22namespace roc {
23namespace packet {
24
25//! Route packets to writers.
26class Router : public IWriter, public core::NonCopyable<> {
27public:
28 //! Initialize.
30
31 //! Add route.
32 //! @remarks
33 //! Packets that has given @p flags set will be routed to @p writer.
34 bool add_route(IWriter& writer, unsigned flags);
35
36 //! Write next packet.
37 //! @remarks
38 //! Route @p packet to a writer or drop it if no routes found.
39 virtual void write(const PacketPtr& packet);
40
41private:
42 struct Route {
43 IWriter* writer;
44 unsigned flags;
45 source_t source;
46 bool has_source;
47 };
48
50};
51
52} // namespace packet
53} // namespace roc
54
55#endif // ROC_PACKET_ROUTER_H_
Dynamic array.
Dynamic array.
Definition array.h:38
Memory allocator interface.
Definition iallocator.h:23
Base class for non-copyable objects.
Definition noncopyable.h:23
Packet writer interface.
Definition iwriter.h:21
Route packets to writers.
Definition router.h:26
bool add_route(IWriter &writer, unsigned flags)
Add route.
Router(core::IAllocator &allocator)
Initialize.
virtual void write(const PacketPtr &packet)
Write next packet.
Memory allocator interface.
Packet writer interface.
uint32_t source_t
Packet source ID identifying packet stream.
Definition units.h:22
Root namespace.
Non-copyable object.
Packet.
Commonly used types and functions.