opusrtppacketizer.hpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * libdatachannel streamer example
  3. * Copyright (c) 2020 Filip Klembara (in2core)
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation; either version 2
  8. * of the License, or (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; If not, see <http://www.gnu.org/licenses/>.
  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 "messagehandlerrootelement.hpp"
  23. namespace rtc {
  24. /// RTP packetizer for opus
  25. class RTC_CPP_EXPORT OpusRtpPacketizer : public RtpPacketizer, public MessageHandlerRootElement {
  26. public:
  27. /// default clock rate used in opus RTP communication
  28. 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(std::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 modifyOutgoingBinary(ChainedMessagesProduct messages, std::optional<message_ptr> control) override;
  44. };
  45. } // namespace rtc
  46. #endif /* RTC_ENABLE_MEDIA */
  47. #endif /* RTC_OPUS_RTP_PACKETIZER_H */