opusrtppacketizer.hpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /**
  2. * Copyright (c) 2020 Filip Klembara (in2core)
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2.1 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with this library; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #ifndef RTC_OPUS_RTP_PACKETIZER_H
  19. #define RTC_OPUS_RTP_PACKETIZER_H
  20. #if RTC_ENABLE_MEDIA
  21. #include "mediahandlerrootelement.hpp"
  22. #include "rtppacketizer.hpp"
  23. namespace rtc {
  24. /// RTP packetizer for opus
  25. class RTC_CPP_EXPORT OpusRtpPacketizer final : public RtpPacketizer,
  26. public MediaHandlerRootElement {
  27. public:
  28. /// default clock rate used in opus RTP communication
  29. inline static const uint32_t defaultClockRate = 48 * 1000;
  30. /// Constructs opus packetizer with given RTP configuration.
  31. /// @note RTP configuration is used in packetization process which may change some configuration
  32. /// properties such as sequence number.
  33. /// @param rtpConfig RTP configuration
  34. OpusRtpPacketizer(shared_ptr<RtpPacketizationConfig> rtpConfig);
  35. /// Creates RTP packet for given payload based on `rtpConfig`.
  36. /// @note This function increase sequence number after packetization.
  37. /// @param payload RTP payload
  38. /// @param setMark This needs to be `false` for all RTP packets with opus payload
  39. binary_ptr packetize(binary_ptr payload, bool setMark) override;
  40. /// Creates RTP packet for given samples (all samples share same RTP timesamp)
  41. /// @param messages opus samples
  42. /// @param control RTCP
  43. /// @returns RTP packets and unchanged `control`
  44. ChainedOutgoingProduct processOutgoingBinaryMessage(ChainedMessagesProduct messages,
  45. message_ptr control) override;
  46. };
  47. } // namespace rtc
  48. #endif /* RTC_ENABLE_MEDIA */
  49. #endif /* RTC_OPUS_RTP_PACKETIZER_H */