h264rtpdepacketizer.hpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**
  2. * Copyright (c) 2020 Staz Modrzynski
  3. * Copyright (c) 2020 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_DEPACKETIZER_H
  10. #define RTC_H264_RTP_DEPACKETIZER_H
  11. #if RTC_ENABLE_MEDIA
  12. #include "common.hpp"
  13. #include "mediahandler.hpp"
  14. #include "message.hpp"
  15. #include "nalunit.hpp"
  16. #include "rtp.hpp"
  17. #include <iterator>
  18. namespace rtc {
  19. /// RTP depacketization for H264
  20. class RTC_CPP_EXPORT H264RtpDepacketizer : public MediaHandler {
  21. public:
  22. using Separator = NalUnit::Separator;
  23. H264RtpDepacketizer(Separator separator = Separator::LongStartSequence);
  24. virtual ~H264RtpDepacketizer() = default;
  25. void incoming(message_vector &messages, const message_callback &send) override;
  26. private:
  27. std::vector<message_ptr> mRtpBuffer;
  28. const NalUnit::Separator mSeparator;
  29. void addSeparator(binary &accessUnit);
  30. message_vector buildFrames(message_vector::iterator firstPkt, message_vector::iterator lastPkt,
  31. uint8_t payloadType, uint32_t timestamp);
  32. };
  33. } // namespace rtc
  34. #endif // RTC_ENABLE_MEDIA
  35. #endif /* RTC_H264_RTP_DEPACKETIZER_H */