1 /**
2  * Copyright (c) 2020 Filip Klembara (in2core)
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #ifndef RTC_RTP_PACKETIZER_H
20 #define RTC_RTP_PACKETIZER_H
21 
22 #if RTC_ENABLE_MEDIA
23 
24 #include "message.hpp"
25 #include "rtppacketizationconfig.hpp"
26 
27 namespace rtc {
28 
29 /// Class responsible for RTP packetization
30 class RTC_CPP_EXPORT RtpPacketizer {
31 	static const auto rtpHeaderSize = 12;
32 	static const auto rtpExtHeaderCvoSize = 8;
33 
34 public:
35 	// RTP configuration
36 	const shared_ptr<RtpPacketizationConfig> rtpConfig;
37 
38 	/// Constructs packetizer with given RTP configuration.
39 	/// @note RTP configuration is used in packetization process which may change some configuration
40 	/// properties such as sequence number.
41 	/// @param rtpConfig  RTP configuration
42 	RtpPacketizer(shared_ptr<RtpPacketizationConfig> rtpConfig);
43 
44 	/// Creates RTP packet for given payload based on `rtpConfig`.
45 	/// @note This function increase sequence number after packetization.
46 	/// @param payload RTP payload
47 	/// @param setMark Set marker flag in RTP packet if true
48 	virtual shared_ptr<binary> packetize(shared_ptr<binary> payload, bool setMark);
49 };
50 
51 } // namespace rtc
52 
53 #endif /* RTC_ENABLE_MEDIA */
54 
55 #endif /* RTC_RTP_PACKETIZER_H */
56