Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
iparser.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/iparser.h
10 //! @brief Packet parser interface.
11 
12 #ifndef ROC_PACKET_IPARSER_H_
13 #define ROC_PACKET_IPARSER_H_
14 
15 #include "roc_core/slice.h"
16 #include "roc_packet/packet.h"
17 
18 namespace roc {
19 namespace packet {
20 
21 //! Packet parser interface.
22 class IParser {
23 public:
24  virtual ~IParser();
25 
26  //! Parse packet from buffer.
27  //! @remarks
28  //! Parses input @p buffer and fills @p packet. If the packet payload contains
29  //! an inner packet, calls the inner parser as well.
30  //! @returns
31  //! true if the packet was successfully parsed or false if the packet is invalid.
32  virtual bool parse(Packet& packet, const core::Slice<uint8_t>& buffer) = 0;
33 };
34 
35 } // namespace packet
36 } // namespace roc
37 
38 #endif // ROC_PACKET_IPARSER_H_
Packet parser interface.
Definition: iparser.h:22
virtual bool parse(Packet &packet, const core::Slice< uint8_t > &buffer)=0
Parse packet from buffer.
Root namespace.
Packet.
Slice.