av1rtppacketizer.hpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. // Default clock rate for AV1 in RTP
  19. inline static const uint32_t defaultClockRate = 90 * 1000;
  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. uint16_t maximumFragmentSize = NalUnits::defaultMaximumFragmentSize);
  30. void outgoing(message_vector &messages, const message_callback &send) override;
  31. private:
  32. shared_ptr<NalUnits> splitMessage(binary_ptr message);
  33. std::vector<shared_ptr<binary>> packetizeObu(binary_ptr message, uint16_t maximumFragmentSize);
  34. const uint16_t maximumFragmentSize;
  35. const Packetization packetization;
  36. std::shared_ptr<binary> sequenceHeader;
  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 */