h264rtppacketizer.hpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /**
  2. * Copyright (c) 2020 Filip Klembara (in2core)
  3. * Copyright (c) 2023 Paul-Louis Ageneau
  4. *
  5. * This Source Code Form is subject to the terms of the Mozilla Public
  6. * License, v. 2.0. If a copy of the MPL was not distributed with this
  7. * file, You can obtain one at https://mozilla.org/MPL/2.0/.
  8. */
  9. #ifndef RTC_H264_RTP_PACKETIZER_H
  10. #define RTC_H264_RTP_PACKETIZER_H
  11. #if RTC_ENABLE_MEDIA
  12. #include "nalunit.hpp"
  13. #include "rtppacketizer.hpp"
  14. namespace rtc {
  15. /// RTP packetization for H264
  16. class RTC_CPP_EXPORT H264RtpPacketizer final : public RtpPacketizer {
  17. public:
  18. using Separator = NalUnit::Separator;
  19. /// Default clock rate for H264 in RTP
  20. inline static const uint32_t defaultClockRate = 90 * 1000;
  21. /// Constructs h264 payload packetizer with given RTP configuration.
  22. /// @note RTP configuration is used in packetization process which may change some configuration
  23. /// properties such as sequence number.
  24. /// @param separator NAL unit separator
  25. /// @param rtpConfig RTP configuration
  26. /// @param maximumFragmentSize maximum size of one NALU fragment
  27. H264RtpPacketizer(Separator separator, shared_ptr<RtpPacketizationConfig> rtpConfig,
  28. uint16_t maximumFragmentSize = NalUnits::defaultMaximumFragmentSize);
  29. // For backward compatibility, do not use
  30. [[deprecated]] H264RtpPacketizer(
  31. shared_ptr<RtpPacketizationConfig> rtpConfig,
  32. uint16_t maximumFragmentSize = NalUnits::defaultMaximumFragmentSize);
  33. void outgoing(message_vector &messages, const message_callback &send) override;
  34. private:
  35. shared_ptr<NalUnits> splitMessage(binary_ptr message);
  36. const uint16_t maximumFragmentSize;
  37. const Separator separator;
  38. };
  39. // For backward compatibility, do not use
  40. using H264PacketizationHandler [[deprecated("Add H264RtpPacketizer directly")]] = PacketizationHandler;
  41. } // namespace rtc
  42. #endif /* RTC_ENABLE_MEDIA */
  43. #endif /* RTC_H264_RTP_PACKETIZER_H */