rtcpreceivingsession.hpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /**
  2. * Copyright (c) 2020 Staz Modrzynski
  3. * Copyright (c) 2020 Paul-Louis Ageneau
  4. *
  5. * This Source Code Form is subject to the terms of the Mozilla Public
  6. * License, v. 2.0. If a copy of the MPL was not distributed with this
  7. * file, You can obtain one at https://mozilla.org/MPL/2.0/.
  8. */
  9. #ifndef RTC_RTCP_RECEIVING_SESSION_H
  10. #define RTC_RTCP_RECEIVING_SESSION_H
  11. #if RTC_ENABLE_MEDIA
  12. #include "common.hpp"
  13. #include "mediahandler.hpp"
  14. #include "message.hpp"
  15. #include "rtp.hpp"
  16. #include <atomic>
  17. #define RTP_SEQ_MOD (1<<16)
  18. namespace rtc {
  19. // An RtcpSession can be plugged into a Track to handle the whole RTCP session
  20. class RTC_CPP_EXPORT RtcpReceivingSession : public MediaHandler {
  21. public:
  22. RtcpReceivingSession() = default;
  23. virtual ~RtcpReceivingSession() = default;
  24. void incoming(message_vector &messages, const message_callback &send) override;
  25. bool requestKeyframe(const message_callback &send) override;
  26. bool requestBitrate(unsigned int bitrate, const message_callback &send) override;
  27. // For backward compatibility
  28. [[deprecated("Use Track::requestKeyframe()")]] inline bool requestKeyframe() { return false; };
  29. [[deprecated("Use Track::requestBitrate()")]] inline void requestBitrate(unsigned int) {};
  30. protected:
  31. void pushREMB(const message_callback &send, unsigned int bitrate);
  32. void pushRR(const message_callback &send,unsigned int lastSrDelay);
  33. void pushPLI(const message_callback &send);
  34. void initSeq(uint16_t seq);
  35. bool updateSeq(uint16_t seq);
  36. SSRC mSsrc = 0;
  37. uint32_t mGreatestSeqNo = 0;
  38. uint16_t mMaxSeq = 0; // highest seq. number seen
  39. uint32_t mCycles = 0; // shifted count of seq. number cycles
  40. uint32_t mBaseSeq = 0; // base seq number
  41. uint32_t mBadSeq = 0; // last 'bad' seq number + 1
  42. uint32_t mProbation = 0; // sequ. packets till source is valid
  43. uint32_t mReceived = 0; // packets received
  44. uint32_t mExpectedPrior = 0; // packet expected at last interval
  45. uint32_t mReceivedPrior = 0; // packet received at last interval
  46. uint32_t mTransit = 0; // relative trans time for prev pkt
  47. uint32_t mJitter = 0;
  48. uint64_t mSyncRTPTS, mSyncNTPTS;
  49. std::atomic<unsigned int> mRequestedBitrate = 0;
  50. };
  51. } // namespace rtc
  52. #endif // RTC_ENABLE_MEDIA
  53. #endif // RTC_RTCP_RECEIVING_SESSION_H