Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
composer.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 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_rtp/composer.h
10 //! @brief RTP packet composer.
11 
12 #ifndef ROC_RTP_COMPOSER_H_
13 #define ROC_RTP_COMPOSER_H_
14 
15 #include "roc_core/noncopyable.h"
16 #include "roc_packet/icomposer.h"
17 
18 namespace roc {
19 namespace rtp {
20 
21 //! RTP packet composer.
22 class Composer : public packet::IComposer, public core::NonCopyable<> {
23 public:
24  //! Initialization.
25  //! @remarks
26  //! If @p inner_composer is not NULL, it is used to compose the packet payload.
27  Composer(packet::IComposer* inner_composer);
28 
29  //! Adjust buffer to align payload.
30  virtual bool
31  align(core::Slice<uint8_t>& buffer, size_t header_size, size_t payload_alignment);
32 
33  //! Prepare buffer for composing a packet.
34  virtual bool
35  prepare(packet::Packet& packet, core::Slice<uint8_t>& buffer, size_t payload_size);
36 
37  //! Pad packet.
38  virtual bool pad(packet::Packet& packet, size_t padding_size);
39 
40  //! Compose packet to buffer.
41  virtual bool compose(packet::Packet& packet);
42 
43 private:
44  packet::IComposer* inner_composer_;
45 };
46 
47 } // namespace rtp
48 } // namespace roc
49 
50 #endif // ROC_RTP_COMPOSER_H_
Base class for non-copyable objects.
Definition: noncopyable.h:23
Packet composer interface.
Definition: icomposer.h:22
RTP packet composer.
Definition: composer.h:22
virtual bool compose(packet::Packet &packet)
Compose packet to buffer.
virtual bool prepare(packet::Packet &packet, core::Slice< uint8_t > &buffer, size_t payload_size)
Prepare buffer for composing a packet.
virtual bool pad(packet::Packet &packet, size_t padding_size)
Pad packet.
virtual bool align(core::Slice< uint8_t > &buffer, size_t header_size, size_t payload_alignment)
Adjust buffer to align payload.
Composer(packet::IComposer *inner_composer)
Initialization.
Packet composer interface.
Root namespace.
Non-copyable object.