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 "mediahandlerrootelement.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, public MediaHandlerRootElement {
  17. shared_ptr<NalUnits> splitMessage(binary_ptr message);
  18. const uint16_t maximumFragmentSize;
  19. public:
  20. /// Default clock rate for AV1 in RTP
  21. inline static const uint32_t defaultClockRate = 90 * 1000;
  22. // Define how OBUs are seperated in a AV1 Sample
  23. enum class Packetization {
  24. Obu = RTC_OBU_PACKETIZED_OBU,
  25. TemporalUnit = RTC_OBU_PACKETIZED_TEMPORAL_UNIT,
  26. };
  27. /// Constructs AV1 payload packetizer with given RTP configuration.
  28. /// @note RTP configuration is used in packetization process which may change some configuration
  29. /// properties such as sequence number.
  30. /// @param rtpConfig RTP configuration
  31. AV1RtpPacketizer(Packetization packetization, shared_ptr<RtpPacketizationConfig> rtpConfig,
  32. uint16_t maximumFragmentSize = NalUnits::defaultMaximumFragmentSize);
  33. ChainedOutgoingProduct processOutgoingBinaryMessage(ChainedMessagesProduct messages,
  34. message_ptr control) override;
  35. private:
  36. const Packetization packetization;
  37. std::shared_ptr<binary> sequenceHeader;
  38. std::vector<shared_ptr<binary>> packetizeObu(binary_ptr message, uint16_t maximumFragmentSize);
  39. };
  40. } // namespace rtc
  41. #endif /* RTC_ENABLE_MEDIA */
  42. #endif /* RTC_AV1_RTP_PACKETIZER_H */