opusrtppacketizer.hpp 2.2 KB

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