rtp_transport_controller_send_interface.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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 CALL_RTP_TRANSPORT_CONTROLLER_SEND_INTERFACE_H_
  11. #define CALL_RTP_TRANSPORT_CONTROLLER_SEND_INTERFACE_H_
  12. #include <stddef.h>
  13. #include <stdint.h>
  14. #include <map>
  15. #include <memory>
  16. #include <string>
  17. #include <vector>
  18. #include "absl/types/optional.h"
  19. #include "api/crypto/crypto_options.h"
  20. #include "api/fec_controller.h"
  21. #include "api/frame_transformer_interface.h"
  22. #include "api/rtc_event_log/rtc_event_log.h"
  23. #include "api/transport/bitrate_settings.h"
  24. #include "api/units/timestamp.h"
  25. #include "call/rtp_config.h"
  26. #include "common_video/frame_counts.h"
  27. #include "modules/rtp_rtcp/include/report_block_data.h"
  28. #include "modules/rtp_rtcp/include/rtcp_statistics.h"
  29. #include "modules/rtp_rtcp/include/rtp_packet_sender.h"
  30. #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
  31. #include "modules/rtp_rtcp/source/rtp_packet_received.h"
  32. namespace rtc {
  33. struct SentPacket;
  34. struct NetworkRoute;
  35. class TaskQueue;
  36. } // namespace rtc
  37. namespace webrtc {
  38. class CallStatsObserver;
  39. class FrameEncryptorInterface;
  40. class TargetTransferRateObserver;
  41. class Transport;
  42. class Module;
  43. class PacedSender;
  44. class PacketRouter;
  45. class RtpVideoSenderInterface;
  46. class RateLimiter;
  47. class RtcpBandwidthObserver;
  48. class RtpPacketSender;
  49. class SendDelayStats;
  50. class SendStatisticsProxy;
  51. struct RtpSenderObservers {
  52. RtcpRttStats* rtcp_rtt_stats;
  53. RtcpIntraFrameObserver* intra_frame_callback;
  54. RtcpLossNotificationObserver* rtcp_loss_notification_observer;
  55. RtcpStatisticsCallback* rtcp_stats;
  56. ReportBlockDataObserver* report_block_data_observer;
  57. StreamDataCountersCallback* rtp_stats;
  58. BitrateStatisticsObserver* bitrate_observer;
  59. FrameCountObserver* frame_count_observer;
  60. RtcpPacketTypeCounterObserver* rtcp_type_observer;
  61. SendSideDelayObserver* send_delay_observer;
  62. SendPacketObserver* send_packet_observer;
  63. };
  64. struct RtpSenderFrameEncryptionConfig {
  65. FrameEncryptorInterface* frame_encryptor = nullptr;
  66. CryptoOptions crypto_options;
  67. };
  68. // An RtpTransportController should own everything related to the RTP
  69. // transport to/from a remote endpoint. We should have separate
  70. // interfaces for send and receive side, even if they are implemented
  71. // by the same class. This is an ongoing refactoring project. At some
  72. // point, this class should be promoted to a public api under
  73. // webrtc/api/rtp/.
  74. //
  75. // For a start, this object is just a collection of the objects needed
  76. // by the VideoSendStream constructor. The plan is to move ownership
  77. // of all RTP-related objects here, and add methods to create per-ssrc
  78. // objects which would then be passed to VideoSendStream. Eventually,
  79. // direct accessors like packet_router() should be removed.
  80. //
  81. // This should also have a reference to the underlying
  82. // webrtc::Transport(s). Currently, webrtc::Transport is implemented by
  83. // WebRtcVideoChannel and WebRtcVoiceMediaChannel, and owned by
  84. // WebrtcSession. Video and audio always uses different transport
  85. // objects, even in the common case where they are bundled over the
  86. // same underlying transport.
  87. //
  88. // Extracting the logic of the webrtc::Transport from BaseChannel and
  89. // subclasses into a separate class seems to be a prerequesite for
  90. // moving the transport here.
  91. class RtpTransportControllerSendInterface {
  92. public:
  93. virtual ~RtpTransportControllerSendInterface() {}
  94. virtual rtc::TaskQueue* GetWorkerQueue() = 0;
  95. virtual PacketRouter* packet_router() = 0;
  96. virtual RtpVideoSenderInterface* CreateRtpVideoSender(
  97. std::map<uint32_t, RtpState> suspended_ssrcs,
  98. // TODO(holmer): Move states into RtpTransportControllerSend.
  99. const std::map<uint32_t, RtpPayloadState>& states,
  100. const RtpConfig& rtp_config,
  101. int rtcp_report_interval_ms,
  102. Transport* send_transport,
  103. const RtpSenderObservers& observers,
  104. RtcEventLog* event_log,
  105. std::unique_ptr<FecController> fec_controller,
  106. const RtpSenderFrameEncryptionConfig& frame_encryption_config,
  107. rtc::scoped_refptr<FrameTransformerInterface> frame_transformer) = 0;
  108. virtual void DestroyRtpVideoSender(
  109. RtpVideoSenderInterface* rtp_video_sender) = 0;
  110. virtual NetworkStateEstimateObserver* network_state_estimate_observer() = 0;
  111. virtual TransportFeedbackObserver* transport_feedback_observer() = 0;
  112. virtual RtpPacketSender* packet_sender() = 0;
  113. // SetAllocatedSendBitrateLimits sets bitrates limits imposed by send codec
  114. // settings.
  115. virtual void SetAllocatedSendBitrateLimits(
  116. BitrateAllocationLimits limits) = 0;
  117. virtual void SetPacingFactor(float pacing_factor) = 0;
  118. virtual void SetQueueTimeLimit(int limit_ms) = 0;
  119. virtual StreamFeedbackProvider* GetStreamFeedbackProvider() = 0;
  120. virtual void RegisterTargetTransferRateObserver(
  121. TargetTransferRateObserver* observer) = 0;
  122. virtual void OnNetworkRouteChanged(
  123. const std::string& transport_name,
  124. const rtc::NetworkRoute& network_route) = 0;
  125. virtual void OnNetworkAvailability(bool network_available) = 0;
  126. virtual RtcpBandwidthObserver* GetBandwidthObserver() = 0;
  127. virtual int64_t GetPacerQueuingDelayMs() const = 0;
  128. virtual absl::optional<Timestamp> GetFirstPacketTime() const = 0;
  129. virtual void EnablePeriodicAlrProbing(bool enable) = 0;
  130. virtual void OnSentPacket(const rtc::SentPacket& sent_packet) = 0;
  131. virtual void OnReceivedPacket(const ReceivedPacket& received_packet) = 0;
  132. virtual void SetSdpBitrateParameters(
  133. const BitrateConstraints& constraints) = 0;
  134. virtual void SetClientBitratePreferences(
  135. const BitrateSettings& preferences) = 0;
  136. virtual void OnTransportOverheadChanged(
  137. size_t transport_overhead_per_packet) = 0;
  138. virtual void AccountForAudioPacketsInPacedSender(bool account_for_audio) = 0;
  139. virtual void IncludeOverheadInPacedSender() = 0;
  140. virtual void EnsureStarted() = 0;
  141. };
  142. } // namespace webrtc
  143. #endif // CALL_RTP_TRANSPORT_CONTROLLER_SEND_INTERFACE_H_