rtcp.hpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /**
  2. * Copyright (c) 2020 Staz Modrzynski
  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 <utility>
  22. #include "include.hpp"
  23. #include "log.hpp"
  24. #include "message.hpp"
  25. #include "rtp.hpp"
  26. namespace rtc {
  27. class RtcpHandler {
  28. public:
  29. /**
  30. * If there is traffic coming from the remote side
  31. * @param ptr
  32. * @return
  33. */
  34. virtual rtc::message_ptr incoming(rtc::message_ptr ptr) = 0;
  35. /**
  36. * If there is traffic being sent to the remote side
  37. * @param ptr
  38. * @return
  39. */
  40. virtual rtc::message_ptr outgoing(rtc::message_ptr ptr) = 0;
  41. };
  42. class Track;
  43. // An RtcpSession can be plugged into a Track to handle the whole RTCP session
  44. class RtcpReceivingSession : public RtcpHandler {
  45. protected:
  46. std::shared_ptr<Track> track;
  47. public:
  48. RtcpReceivingSession(std::shared_ptr<Track> track): track(std::move(track)) {}
  49. rtc::message_ptr incoming(rtc::message_ptr ptr) override;
  50. rtc::message_ptr outgoing(rtc::message_ptr ptr) override;
  51. bool send(rtc::message_ptr ptr);
  52. void requestBitrate(unsigned int newBitrate);
  53. protected:
  54. void pushREMB(unsigned int bitrate);
  55. void pushRR(unsigned int lastSR_delay);
  56. unsigned int mRequestedBitrate = 0;
  57. SSRC mSsrc = 0;
  58. uint32_t mGreatestSeqNo = 0;
  59. uint64_t mSyncRTPTS, mSyncNTPTS;
  60. };
  61. } // namespace rtc
  62. #endif // RTC_RTCP_H