h265rtppacketizer.hpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /**
  2. * Copyright (c) 2020 Filip Klembara (in2core)
  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 https://mozilla.org/MPL/2.0/.
  7. */
  8. #ifndef RTC_H265_RTP_PACKETIZER_H
  9. #define RTC_H265_RTP_PACKETIZER_H
  10. #if RTC_ENABLE_MEDIA
  11. #include "mediahandlerrootelement.hpp"
  12. #include "h265nalunit.hpp"
  13. #include "rtppacketizer.hpp"
  14. namespace rtc {
  15. /// RTP packetization of h265 payload
  16. class RTC_CPP_EXPORT H265RtpPacketizer final : public RtpPacketizer,
  17. public MediaHandlerRootElement {
  18. shared_ptr<H265NalUnits> splitMessage(binary_ptr message);
  19. const uint16_t maximumFragmentSize;
  20. public:
  21. /// Default clock rate for H265 in RTP
  22. inline static const uint32_t defaultClockRate = 90 * 1000;
  23. /// NAL unit separator
  24. enum class Separator {
  25. Length = RTC_NAL_SEPARATOR_LENGTH, // first 4 bytes are NAL unit length
  26. LongStartSequence = RTC_NAL_SEPARATOR_LONG_START_SEQUENCE, // 0x00, 0x00, 0x00, 0x01
  27. ShortStartSequence = RTC_NAL_SEPARATOR_SHORT_START_SEQUENCE, // 0x00, 0x00, 0x01
  28. StartSequence = RTC_NAL_SEPARATOR_START_SEQUENCE, // LongStartSequence or ShortStartSequence
  29. };
  30. H265RtpPacketizer(H265RtpPacketizer::Separator separator,
  31. shared_ptr<RtpPacketizationConfig> rtpConfig,
  32. uint16_t maximumFragmentSize = H265NalUnits::defaultMaximumFragmentSize);
  33. /// Constructs h265 payload packetizer with given RTP configuration.
  34. /// @note RTP configuration is used in packetization process which may change some configuration
  35. /// properties such as sequence number.
  36. /// @param rtpConfig RTP configuration
  37. /// @param maximumFragmentSize maximum size of one NALU fragment
  38. H265RtpPacketizer(shared_ptr<RtpPacketizationConfig> rtpConfig,
  39. uint16_t maximumFragmentSize = H265NalUnits::defaultMaximumFragmentSize);
  40. ChainedOutgoingProduct processOutgoingBinaryMessage(ChainedMessagesProduct messages,
  41. message_ptr control) override;
  42. private:
  43. const Separator separator;
  44. };
  45. } // namespace rtc
  46. #endif /* RTC_ENABLE_MEDIA */
  47. #endif /* RTC_H265_RTP_PACKETIZER_H */