rtppacketizer.hpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 RTPPacketizer_hpp
  19. #define RTPPacketizer_hpp
  20. #if RTC_ENABLE_MEDIA
  21. #include "rtppacketizationconfig.hpp"
  22. #include "message.hpp"
  23. namespace rtc {
  24. /// Class responsizble for rtp packetization
  25. class 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 properties such as sequence number.
  32. /// @param rtpConfig RTP configuration
  33. RTPPacketizer(std::shared_ptr<RTPPacketizationConfig> rtpConfig);
  34. /// Creates RTP packet for given payload based on `rtpConfig`.
  35. /// @note This function increase sequence number after packetization.
  36. /// @param payload RTP payload
  37. /// @param setMark Set marker flag in RTP packet if true
  38. virtual message_ptr packetize(binary payload, bool setMark);
  39. };
  40. } // namespace
  41. #endif /* RTC_ENABLE_MEDIA */
  42. #endif /* RTPPacketizer_hpp */