opusrtppacketizer.hpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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_OPUS_RTP_PACKETIZER_H
  9. #define RTC_OPUS_RTP_PACKETIZER_H
  10. #if RTC_ENABLE_MEDIA
  11. #include "mediahandlerrootelement.hpp"
  12. #include "rtppacketizer.hpp"
  13. namespace rtc {
  14. /// RTP packetizer for opus
  15. class RTC_CPP_EXPORT OpusRtpPacketizer final : public RtpPacketizer,
  16. public MediaHandlerRootElement {
  17. public:
  18. /// default clock rate used in opus RTP communication
  19. inline static const uint32_t defaultClockRate = 48 * 1000;
  20. /// Constructs opus 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. OpusRtpPacketizer(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 opus 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 opus samples
  32. /// @param control RTCP
  33. /// @returns RTP packets and unchanged `control`
  34. ChainedOutgoingProduct processOutgoingBinaryMessage(ChainedMessagesProduct messages,
  35. message_ptr control) override;
  36. };
  37. } // namespace rtc
  38. #endif /* RTC_ENABLE_MEDIA */
  39. #endif /* RTC_OPUS_RTP_PACKETIZER_H */