h264rtpdepacketizer.hpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. inline static const uint32_t ClockRate = 90 * 1000;
  24. H264RtpDepacketizer(Separator separator = Separator::LongStartSequence);
  25. virtual ~H264RtpDepacketizer() = default;
  26. void incoming(message_vector &messages, const message_callback &send) override;
  27. private:
  28. std::vector<message_ptr> mRtpBuffer;
  29. const NalUnit::Separator mSeparator;
  30. void addSeparator(binary &accessUnit);
  31. message_vector buildFrames(message_vector::iterator firstPkt, message_vector::iterator lastPkt,
  32. uint8_t payloadType, uint32_t timestamp);
  33. };
  34. } // namespace rtc
  35. #endif // RTC_ENABLE_MEDIA
  36. #endif /* RTC_H264_RTP_DEPACKETIZER_H */