h265rtpdepacketizer.hpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /**
  2. * Copyright (c) 2020 Staz Modrzynski
  3. * Copyright (c) 2020-2024 Paul-Louis Ageneau
  4. * Copyright (c) 2024 Robert Edmonds
  5. *
  6. * This Source Code Form is subject to the terms of the Mozilla Public
  7. * License, v. 2.0. If a copy of the MPL was not distributed with this
  8. * file, You can obtain one at https://mozilla.org/MPL/2.0/.
  9. */
  10. #ifndef RTC_H265_RTP_DEPACKETIZER_H
  11. #define RTC_H265_RTP_DEPACKETIZER_H
  12. #if RTC_ENABLE_MEDIA
  13. #include "common.hpp"
  14. #include "h265nalunit.hpp"
  15. #include "mediahandler.hpp"
  16. #include "message.hpp"
  17. #include "rtp.hpp"
  18. #include <iterator>
  19. namespace rtc {
  20. /// RTP depacketization for H265
  21. class RTC_CPP_EXPORT H265RtpDepacketizer : public MediaHandler {
  22. public:
  23. using Separator = NalUnit::Separator;
  24. inline static const uint32_t ClockRate = 90 * 1000;
  25. H265RtpDepacketizer(Separator separator = Separator::LongStartSequence);
  26. virtual ~H265RtpDepacketizer() = default;
  27. void incoming(message_vector &messages, const message_callback &send) override;
  28. private:
  29. std::vector<message_ptr> mRtpBuffer;
  30. const NalUnit::Separator separator;
  31. void addSeparator(binary& accessUnit);
  32. message_vector buildFrames(message_vector::iterator firstPkt, message_vector::iterator lastPkt,
  33. uint8_t payloadType, uint32_t timestamp);
  34. };
  35. } // namespace rtc
  36. #endif // RTC_ENABLE_MEDIA
  37. #endif // RTC_H265_RTP_DEPACKETIZER_H