rtppacketizer.hpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. #ifndef RTC_RTP_PACKETIZER_H
  19. #define RTC_RTP_PACKETIZER_H
  20. #if RTC_ENABLE_MEDIA
  21. #include "message.hpp"
  22. #include "rtppacketizationconfig.hpp"
  23. namespace rtc {
  24. /// Class responsible for RTP packetization
  25. class RTC_CPP_EXPORT RtpPacketizer {
  26. static const auto rtpHeaderSize = 12;
  27. static const auto rtpExtHeaderCvoSize = 8;
  28. public:
  29. // RTP configuration
  30. const shared_ptr<RtpPacketizationConfig> rtpConfig;
  31. /// Constructs packetizer with given RTP configuration.
  32. /// @note RTP configuration is used in packetization process which may change some configuration
  33. /// properties such as sequence number.
  34. /// @param rtpConfig RTP configuration
  35. RtpPacketizer(shared_ptr<RtpPacketizationConfig> rtpConfig);
  36. /// Creates RTP packet for given payload based on `rtpConfig`.
  37. /// @note This function increase sequence number after packetization.
  38. /// @param payload RTP payload
  39. /// @param setMark Set marker flag in RTP packet if true
  40. virtual shared_ptr<binary> packetize(shared_ptr<binary> payload, bool setMark);
  41. };
  42. } // namespace rtc
  43. #endif /* RTC_ENABLE_MEDIA */
  44. #endif /* RTC_RTP_PACKETIZER_H */