rtcp_transceiver.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #ifndef MODULES_RTP_RTCP_SOURCE_RTCP_TRANSCEIVER_H_
  11. #define MODULES_RTP_RTCP_SOURCE_RTCP_TRANSCEIVER_H_
  12. #include <functional>
  13. #include <memory>
  14. #include <string>
  15. #include <vector>
  16. #include "api/task_queue/task_queue_base.h"
  17. #include "modules/rtp_rtcp/source/rtcp_transceiver_config.h"
  18. #include "modules/rtp_rtcp/source/rtcp_transceiver_impl.h"
  19. #include "rtc_base/copy_on_write_buffer.h"
  20. namespace webrtc {
  21. //
  22. // Manage incoming and outgoing rtcp messages for multiple BUNDLED streams.
  23. //
  24. // This class is thread-safe wrapper of RtcpTransceiverImpl
  25. class RtcpTransceiver : public RtcpFeedbackSenderInterface {
  26. public:
  27. explicit RtcpTransceiver(const RtcpTransceiverConfig& config);
  28. RtcpTransceiver(const RtcpTransceiver&) = delete;
  29. RtcpTransceiver& operator=(const RtcpTransceiver&) = delete;
  30. // Note that interfaces provided in constructor still might be used after the
  31. // destructor. However they can only be used on the confic.task_queue.
  32. // Use Stop function to get notified when they are no longer used or
  33. // ensure those objects outlive the task queue.
  34. ~RtcpTransceiver() override;
  35. // Start asynchronious destruction of the RtcpTransceiver.
  36. // It is safe to call destructor right after Stop exits.
  37. // No other methods can be called.
  38. // Note that interfaces provided in constructor or registered with AddObserver
  39. // still might be used by the transceiver on the task queue
  40. // until |on_destroyed| runs.
  41. void Stop(std::function<void()> on_destroyed);
  42. // Registers observer to be notified about incoming rtcp packets.
  43. // Calls to observer will be done on the |config.task_queue|.
  44. void AddMediaReceiverRtcpObserver(uint32_t remote_ssrc,
  45. MediaReceiverRtcpObserver* observer);
  46. // Deregisters the observer. Might return before observer is deregistered.
  47. // Runs |on_removed| when observer is deregistered.
  48. void RemoveMediaReceiverRtcpObserver(uint32_t remote_ssrc,
  49. MediaReceiverRtcpObserver* observer,
  50. std::function<void()> on_removed);
  51. // Enables/disables sending rtcp packets eventually.
  52. // Packets may be sent after the SetReadyToSend(false) returns, but no new
  53. // packets will be scheduled.
  54. void SetReadyToSend(bool ready);
  55. // Handles incoming rtcp packets.
  56. void ReceivePacket(rtc::CopyOnWriteBuffer packet);
  57. // Sends RTCP packets starting with a sender or receiver report.
  58. void SendCompoundPacket();
  59. // (REMB) Receiver Estimated Max Bitrate.
  60. // Includes REMB in following compound packets and sends a REMB message
  61. // immediately if 'RtcpTransceiverConfig::send_remb_on_change' is set.
  62. void SetRemb(int64_t bitrate_bps, std::vector<uint32_t> ssrcs) override;
  63. // Stops sending REMB in following compound packets.
  64. void UnsetRemb() override;
  65. // TODO(bugs.webrtc.org/8239): Remove SendCombinedRtcpPacket
  66. // and move generating of the TransportFeedback message inside
  67. // RtcpTransceiverImpl when there is one RtcpTransceiver per rtp transport.
  68. void SendCombinedRtcpPacket(
  69. std::vector<std::unique_ptr<rtcp::RtcpPacket>> rtcp_packets) override;
  70. // Reports missing packets, https://tools.ietf.org/html/rfc4585#section-6.2.1
  71. void SendNack(uint32_t ssrc, std::vector<uint16_t> sequence_numbers);
  72. // Requests new key frame.
  73. // using PLI, https://tools.ietf.org/html/rfc4585#section-6.3.1.1
  74. void SendPictureLossIndication(uint32_t ssrc);
  75. // using FIR, https://tools.ietf.org/html/rfc5104#section-4.3.1.2
  76. // Use the SendFullIntraRequest(ssrcs, true) instead.
  77. void SendFullIntraRequest(std::vector<uint32_t> ssrcs);
  78. // If new_request is true then requested sequence no. will increase for each
  79. // requested ssrc.
  80. void SendFullIntraRequest(std::vector<uint32_t> ssrcs, bool new_request);
  81. private:
  82. TaskQueueBase* const task_queue_;
  83. std::unique_ptr<RtcpTransceiverImpl> rtcp_transceiver_;
  84. };
  85. } // namespace webrtc
  86. #endif // MODULES_RTP_RTCP_SOURCE_RTCP_TRANSCEIVER_H_