aacrtppacketizer.hpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /**
  2. * Copyright (c) 2020 Filip Klembara (in2core)
  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_AAC_RTP_PACKETIZER_H
  9. #define RTC_AAC_RTP_PACKETIZER_H
  10. #if RTC_ENABLE_MEDIA
  11. #include "mediachainablehandler.hpp"
  12. #include "mediahandlerrootelement.hpp"
  13. #include "rtppacketizer.hpp"
  14. namespace rtc {
  15. /// RTP packetizer for aac
  16. class RTC_CPP_EXPORT AACRtpPacketizer final : public RtpPacketizer, public MediaHandlerRootElement {
  17. public:
  18. /// default clock rate used in aac RTP communication
  19. inline static const uint32_t defaultClockRate = 48 * 1000;
  20. /// Constructs aac packetizer with given RTP configuration.
  21. /// @note RTP configuration is used in packetization process which may change some configuration
  22. /// properties such as sequence number.
  23. /// @param rtpConfig RTP configuration
  24. AACRtpPacketizer(shared_ptr<RtpPacketizationConfig> rtpConfig);
  25. /// Creates RTP packet for given payload based on `rtpConfig`.
  26. /// @note This function increase sequence number after packetization.
  27. /// @param payload RTP payload
  28. /// @param setMark This needs to be `false` for all RTP packets with aac payload
  29. binary_ptr packetize(binary_ptr payload, bool setMark) override;
  30. /// Creates RTP packet for given samples (all samples share same RTP timesamp)
  31. /// @param messages aac samples
  32. /// @param control RTCP
  33. /// @returns RTP packets and unchanged `control`
  34. ChainedOutgoingProduct processOutgoingBinaryMessage(ChainedMessagesProduct messages,
  35. message_ptr control) override;
  36. };
  37. /// Handler for aac packetization
  38. class RTC_CPP_EXPORT AACPacketizationHandler final : public MediaChainableHandler {
  39. public:
  40. /// Construct handler for aac packetization.
  41. /// @param packetizer RTP packetizer for aac
  42. AACPacketizationHandler(shared_ptr<AACRtpPacketizer> packetizer)
  43. : MediaChainableHandler(packetizer) {}
  44. };
  45. } // namespace rtc
  46. #endif /* RTC_ENABLE_MEDIA */
  47. #endif /* RTC_AAC_RTP_PACKETIZER_H */