rtcp.hpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /**
  2. * Copyright (c) 2020 Staz M
  3. * Copyright (c) 2020 Paul-Louis Ageneau
  4. *
  5. * This library is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2.1 of the License, or (at your option) any later version.
  9. *
  10. * This library 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 GNU
  13. * Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public
  16. * License along with this library; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  18. */
  19. #ifndef RTC_RTCP_H
  20. #define RTC_RTCP_H
  21. #include "include.hpp"
  22. #include "log.hpp"
  23. #include "message.hpp"
  24. namespace rtc {
  25. typedef uint32_t SSRC;
  26. class RtcpHandler {
  27. public:
  28. virtual void onOutgoing(std::function<void(rtc::message_ptr)> cb) = 0;
  29. virtual std::optional<rtc::message_ptr> incoming(rtc::message_ptr ptr) = 0;
  30. };
  31. // An RtcpSession can be plugged into a Track to handle the whole RTCP session
  32. class RtcpSession : public RtcpHandler {
  33. public:
  34. void onOutgoing(std::function<void(rtc::message_ptr)> cb) override;
  35. std::optional<rtc::message_ptr> incoming(rtc::message_ptr ptr) override;
  36. void requestBitrate(unsigned int newBitrate);
  37. private:
  38. void pushREMB(unsigned int bitrate);
  39. void pushRR(unsigned int lastSR_delay);
  40. void tx(message_ptr msg);
  41. unsigned int mRequestedBitrate = 0;
  42. synchronized_callback<rtc::message_ptr> mTxCallback;
  43. SSRC mSsrc = 0;
  44. uint32_t mGreatestSeqNo = 0;
  45. uint64_t mSyncRTPTS, mSyncNTPTS;
  46. };
  47. } // namespace rtc
  48. #endif // RTC_RTCP_H