tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

rtp_transport_controller_send_interface.h (7092B)


      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 
     11 #ifndef CALL_RTP_TRANSPORT_CONTROLLER_SEND_INTERFACE_H_
     12 #define CALL_RTP_TRANSPORT_CONTROLLER_SEND_INTERFACE_H_
     13 #include <stddef.h>
     14 #include <stdint.h>
     15 
     16 #include <map>
     17 #include <memory>
     18 #include <optional>
     19 
     20 #include "absl/strings/string_view.h"
     21 #include "api/crypto/crypto_options.h"
     22 #include "api/fec_controller.h"
     23 #include "api/frame_transformer_interface.h"
     24 #include "api/rtp_packet_sender.h"
     25 #include "api/scoped_refptr.h"
     26 #include "api/transport/bandwidth_estimation_settings.h"
     27 #include "api/transport/bitrate_settings.h"
     28 #include "api/transport/network_control.h"
     29 #include "api/transport/network_types.h"
     30 #include "api/units/timestamp.h"
     31 #include "call/rtp_config.h"
     32 #include "common_video/frame_counts.h"
     33 #include "modules/rtp_rtcp/include/report_block_data.h"
     34 #include "modules/rtp_rtcp/include/rtcp_statistics.h"
     35 #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
     36 #include "rtc_base/network_route.h"
     37 
     38 namespace webrtc {
     39 
     40 struct SentPacketInfo;
     41 class FrameEncryptorInterface;
     42 class TargetTransferRateObserver;
     43 class Transport;
     44 class PacketRouter;
     45 class RtpVideoSenderInterface;
     46 class RtpPacketSender;
     47 class RtpRtcpInterface;
     48 
     49 struct RtpSenderObservers {
     50  RtcpRttStats* rtcp_rtt_stats;
     51  RtcpIntraFrameObserver* intra_frame_callback;
     52  RtcpLossNotificationObserver* rtcp_loss_notification_observer;
     53  ReportBlockDataObserver* report_block_data_observer;
     54  StreamDataCountersCallback* rtp_stats;
     55  BitrateStatisticsObserver* bitrate_observer;
     56  FrameCountObserver* frame_count_observer;
     57  RtcpPacketTypeCounterObserver* rtcp_type_observer;
     58  SendPacketObserver* send_packet_observer;
     59 };
     60 
     61 struct RtpSenderFrameEncryptionConfig {
     62  FrameEncryptorInterface* frame_encryptor = nullptr;
     63  CryptoOptions crypto_options;
     64 };
     65 
     66 // An RtpTransportController should own everything related to the RTP
     67 // transport to/from a remote endpoint. We should have separate
     68 // interfaces for send and receive side, even if they are implemented
     69 // by the same class. This is an ongoing refactoring project. At some
     70 // point, this class should be promoted to a public api under
     71 // webrtc/api/rtp/.
     72 //
     73 // For a start, this object is just a collection of the objects needed
     74 // by the VideoSendStream constructor. The plan is to move ownership
     75 // of all RTP-related objects here, and add methods to create per-ssrc
     76 // objects which would then be passed to VideoSendStream. Eventually,
     77 // direct accessors like packet_router() should be removed.
     78 //
     79 // This should also have a reference to the underlying
     80 // webrtc::Transport(s). Currently, webrtc::Transport is implemented by
     81 // WebRtcVideoChannel and WebRtcVoiceMediaChannel, and owned by
     82 // WebrtcSession. Video and audio always uses different transport
     83 // objects, even in the common case where they are bundled over the
     84 // same underlying transport.
     85 //
     86 // Extracting the logic of the webrtc::Transport from BaseChannel and
     87 // subclasses into a separate class seems to be a prerequesite for
     88 // moving the transport here.
     89 class RtpTransportControllerSendInterface {
     90 public:
     91  virtual ~RtpTransportControllerSendInterface() {}
     92  virtual PacketRouter* packet_router() = 0;
     93 
     94  virtual RtpVideoSenderInterface* CreateRtpVideoSender(
     95      const std::map<uint32_t, RtpState>& suspended_ssrcs,
     96      // TODO(holmer): Move states into RtpTransportControllerSend.
     97      const std::map<uint32_t, RtpPayloadState>& states,
     98      const RtpConfig& rtp_config,
     99      int rtcp_report_interval_ms,
    100      Transport* send_transport,
    101      const RtpSenderObservers& observers,
    102      std::unique_ptr<FecController> fec_controller,
    103      const RtpSenderFrameEncryptionConfig& frame_encryption_config,
    104      scoped_refptr<FrameTransformerInterface> frame_transformer) = 0;
    105  virtual void DestroyRtpVideoSender(
    106      RtpVideoSenderInterface* rtp_video_sender) = 0;
    107 
    108  // Register a specific RTP stream as sending. This means that the pacer and
    109  // packet router can send packets using this RTP stream.
    110  virtual void RegisterSendingRtpStream(RtpRtcpInterface& rtp_module) = 0;
    111  // Pacer and PacketRouter stop using this RTP stream.
    112  virtual void DeRegisterSendingRtpStream(RtpRtcpInterface& rtp_module) = 0;
    113 
    114  virtual NetworkStateEstimateObserver* network_state_estimate_observer() = 0;
    115 
    116  virtual RtpPacketSender* packet_sender() = 0;
    117 
    118  // SetAllocatedSendBitrateLimits sets bitrates limits imposed by send codec
    119  // settings.
    120  virtual void SetAllocatedSendBitrateLimits(
    121      BitrateAllocationLimits limits) = 0;
    122 
    123  virtual void ReconfigureBandwidthEstimation(
    124      const BandwidthEstimationSettings& settings) = 0;
    125 
    126  virtual void SetPacingFactor(float pacing_factor) = 0;
    127  virtual void SetQueueTimeLimit(int limit_ms) = 0;
    128 
    129  virtual StreamFeedbackProvider* GetStreamFeedbackProvider() = 0;
    130  virtual void RegisterTargetTransferRateObserver(
    131      TargetTransferRateObserver* observer) = 0;
    132  virtual void OnNetworkRouteChanged(absl::string_view transport_name,
    133                                     const NetworkRoute& network_route) = 0;
    134  virtual void OnNetworkAvailability(bool network_available) = 0;
    135  virtual NetworkLinkRtcpObserver* GetRtcpObserver() = 0;
    136  virtual int64_t GetPacerQueuingDelayMs() const = 0;
    137  virtual std::optional<Timestamp> GetFirstPacketTime() const = 0;
    138  virtual void EnablePeriodicAlrProbing(bool enable) = 0;
    139 
    140  // Called when a packet has been sent.
    141  // The call should arrive on the network thread, but may not in all cases
    142  // (some tests don't adhere to this). Implementations today should not block
    143  // the calling thread or make assumptions about the thread context.
    144  virtual void OnSentPacket(const SentPacketInfo& sent_packet) = 0;
    145 
    146  virtual void OnReceivedPacket(const ReceivedPacket& received_packet) = 0;
    147 
    148  virtual void SetSdpBitrateParameters(
    149      const BitrateConstraints& constraints) = 0;
    150  virtual void SetClientBitratePreferences(
    151      const BitrateSettings& preferences) = 0;
    152 
    153  virtual void OnTransportOverheadChanged(
    154      size_t transport_overhead_per_packet) = 0;
    155 
    156  virtual void AccountForAudioPacketsInPacedSender(bool account_for_audio) = 0;
    157  virtual void IncludeOverheadInPacedSender() = 0;
    158 
    159  virtual void EnsureStarted() = 0;
    160  virtual NetworkControllerInterface* GetNetworkController() = 0;
    161 
    162  // Called once it's known that the remote end supports RFC 8888.
    163  virtual void EnableCongestionControlFeedbackAccordingToRfc8888() = 0;
    164  // Count of RFC8888 feedback reports received
    165  virtual std::optional<int> ReceivedCongestionControlFeedbackCount() const = 0;
    166  // Count of transport-cc feedback reports received
    167  virtual std::optional<int> ReceivedTransportCcFeedbackCount() const = 0;
    168 };
    169 
    170 }  // namespace webrtc
    171 
    172 #endif  // CALL_RTP_TRANSPORT_CONTROLLER_SEND_INTERFACE_H_