h264rtppacketizer.hpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. inline static const uint32_t ClockRate = VideoClockRate;
  20. [[deprecated("Use ClockRate")]] inline static const uint32_t defaultClockRate = ClockRate;
  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 maxFragmentSize maximum size of one NALU fragment
  27. H264RtpPacketizer(Separator separator, shared_ptr<RtpPacketizationConfig> rtpConfig,
  28. size_t maxFragmentSize = DefaultMaxFragmentSize);
  29. // For backward compatibility, do not use
  30. [[deprecated]] H264RtpPacketizer(
  31. shared_ptr<RtpPacketizationConfig> rtpConfig,
  32. size_t maxFragmentSize = DefaultMaxFragmentSize);
  33. private:
  34. std::vector<binary> fragment(binary data) override;
  35. std::vector<NalUnit> splitFrame(const binary &frame);
  36. const Separator mSeparator;
  37. const size_t mMaxFragmentSize;
  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 */