aacrtppacketizer.hpp 2.1 KB

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