av1rtppacketizer.hpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /**
  2. * Copyright (c) 2023 Paul-Louis Ageneau
  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_AV1_RTP_PACKETIZER_H
  9. #define RTC_AV1_RTP_PACKETIZER_H
  10. #if RTC_ENABLE_MEDIA
  11. #include "mediahandler.hpp"
  12. #include "nalunit.hpp"
  13. #include "rtppacketizer.hpp"
  14. namespace rtc {
  15. // RTP packetization of AV1 payload
  16. class RTC_CPP_EXPORT AV1RtpPacketizer final : public RtpPacketizer {
  17. public:
  18. inline static const uint32_t ClockRate = VideoClockRate;
  19. [[deprecated("Use ClockRate")]] inline static const uint32_t defaultClockRate = ClockRate;
  20. // Define how OBUs are seperated in a AV1 Sample
  21. enum class Packetization {
  22. Obu = RTC_OBU_PACKETIZED_OBU,
  23. TemporalUnit = RTC_OBU_PACKETIZED_TEMPORAL_UNIT,
  24. };
  25. // Constructs AV1 payload packetizer with given RTP configuration.
  26. // @note RTP configuration is used in packetization process which may change some configuration
  27. // properties such as sequence number.
  28. AV1RtpPacketizer(Packetization packetization, shared_ptr<RtpPacketizationConfig> rtpConfig,
  29. size_t maxFragmentSize = DefaultMaxFragmentSize);
  30. private:
  31. static std::vector<binary> extractTemporalUnitObus(const binary &data);
  32. std::vector<binary> fragment(binary data) override;
  33. std::vector<binary> fragmentObu(const binary &data);
  34. const Packetization mPacketization;
  35. const size_t mMaxFragmentSize;
  36. std::unique_ptr<binary> mSequenceHeader;
  37. };
  38. // For backward compatibility, do not use
  39. using AV1PacketizationHandler [[deprecated("Add AV1RtpPacketizer directly")]] = PacketizationHandler;
  40. } // namespace rtc
  41. #endif /* RTC_ENABLE_MEDIA */
  42. #endif /* RTC_AV1_RTP_PACKETIZER_H */