rtppacketizer.hpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * libdatachannel streamer example
  3. * Copyright (c) 2020 Filip Klembara (in2core)
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation; either version 2
  8. * of the License, or (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; If not, see <http://www.gnu.org/licenses/>.
  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. public:
  28. // RTP configuration
  29. const std::shared_ptr<RtpPacketizationConfig> rtpConfig;
  30. /// Constructs packetizer with given RTP configuration.
  31. /// @note RTP configuration is used in packetization process which may change some configuration
  32. /// properties such as sequence number.
  33. /// @param rtpConfig RTP configuration
  34. RtpPacketizer(std::shared_ptr<RtpPacketizationConfig> rtpConfig);
  35. /// Creates RTP packet for given payload based on `rtpConfig`.
  36. /// @note This function increase sequence number after packetization.
  37. /// @param payload RTP payload
  38. /// @param setMark Set marker flag in RTP packet if true
  39. virtual std::shared_ptr<binary> packetize(std::shared_ptr<binary> payload, bool setMark);
  40. };
  41. } // namespace rtc
  42. #endif /* RTC_ENABLE_MEDIA */
  43. #endif /* RTC_RTP_PACKETIZER_H */