nisse | cae45d0 | 2017-04-24 05:53:20 -0700 | [diff] [blame] | 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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef CALL_RTP_TRANSPORT_CONTROLLER_SEND_INTERFACE_H_ |
| 12 | #define CALL_RTP_TRANSPORT_CONTROLLER_SEND_INTERFACE_H_ |
Sebastian Jansson | e4be6da | 2018-02-15 16:51:41 +0100 | [diff] [blame] | 13 | #include <stddef.h> |
| 14 | #include <stdint.h> |
nisse | cae45d0 | 2017-04-24 05:53:20 -0700 | [diff] [blame] | 15 | |
Stefan Holmer | dbdb3a0 | 2018-07-17 16:03:46 +0200 | [diff] [blame] | 16 | #include <map> |
Stefan Holmer | 64be7fa | 2018-10-04 15:21:55 +0200 | [diff] [blame] | 17 | #include <memory> |
Sebastian Jansson | 97f61ea | 2018-02-21 13:01:55 +0100 | [diff] [blame] | 18 | #include <string> |
Stefan Holmer | dbdb3a0 | 2018-07-17 16:03:46 +0200 | [diff] [blame] | 19 | #include <vector> |
Sebastian Jansson | 97f61ea | 2018-02-21 13:01:55 +0100 | [diff] [blame] | 20 | |
Danil Chapovalov | b9b146c | 2018-06-15 12:28:07 +0200 | [diff] [blame] | 21 | #include "absl/types/optional.h" |
Patrik Höglund | b6b29e0 | 2018-06-21 16:58:01 +0200 | [diff] [blame] | 22 | #include "api/bitrate_constraints.h" |
Benjamin Wright | 192eeec | 2018-10-17 17:27:25 -0700 | [diff] [blame^] | 23 | #include "api/crypto/cryptooptions.h" |
Stefan Holmer | 64be7fa | 2018-10-04 15:21:55 +0200 | [diff] [blame] | 24 | #include "api/fec_controller.h" |
Niels Möller | 0c4f7be | 2018-05-07 14:01:37 +0200 | [diff] [blame] | 25 | #include "api/transport/bitrate_settings.h" |
Stefan Holmer | dbdb3a0 | 2018-07-17 16:03:46 +0200 | [diff] [blame] | 26 | #include "call/rtp_config.h" |
| 27 | #include "logging/rtc_event_log/rtc_event_log.h" |
| 28 | #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
Sebastian Jansson | 97f61ea | 2018-02-21 13:01:55 +0100 | [diff] [blame] | 29 | |
Sebastian Jansson | e4be6da | 2018-02-15 16:51:41 +0100 | [diff] [blame] | 30 | namespace rtc { |
| 31 | struct SentPacket; |
| 32 | struct NetworkRoute; |
Sebastian Jansson | e625605 | 2018-05-04 14:08:15 +0200 | [diff] [blame] | 33 | class TaskQueue; |
Sebastian Jansson | e4be6da | 2018-02-15 16:51:41 +0100 | [diff] [blame] | 34 | } // namespace rtc |
nisse | cae45d0 | 2017-04-24 05:53:20 -0700 | [diff] [blame] | 35 | namespace webrtc { |
| 36 | |
Stefan Holmer | dbdb3a0 | 2018-07-17 16:03:46 +0200 | [diff] [blame] | 37 | class CallStats; |
Sebastian Jansson | e4be6da | 2018-02-15 16:51:41 +0100 | [diff] [blame] | 38 | class CallStatsObserver; |
Benjamin Wright | 192eeec | 2018-10-17 17:27:25 -0700 | [diff] [blame^] | 39 | class FrameEncryptorInterface; |
Sebastian Jansson | 19704ec | 2018-03-12 15:59:12 +0100 | [diff] [blame] | 40 | class TargetTransferRateObserver; |
Stefan Holmer | dbdb3a0 | 2018-07-17 16:03:46 +0200 | [diff] [blame] | 41 | class Transport; |
Sebastian Jansson | e4be6da | 2018-02-15 16:51:41 +0100 | [diff] [blame] | 42 | class Module; |
Stefan Holmer | 5c8942a | 2017-08-22 16:16:44 +0200 | [diff] [blame] | 43 | class PacedSender; |
Sebastian Jansson | e4be6da | 2018-02-15 16:51:41 +0100 | [diff] [blame] | 44 | class PacketFeedbackObserver; |
nisse | cae45d0 | 2017-04-24 05:53:20 -0700 | [diff] [blame] | 45 | class PacketRouter; |
Stefan Holmer | 9416ef8 | 2018-07-19 10:34:38 +0200 | [diff] [blame] | 46 | class RtpVideoSenderInterface; |
Sebastian Jansson | e4be6da | 2018-02-15 16:51:41 +0100 | [diff] [blame] | 47 | class RateLimiter; |
| 48 | class RtcpBandwidthObserver; |
nisse | cae45d0 | 2017-04-24 05:53:20 -0700 | [diff] [blame] | 49 | class RtpPacketSender; |
sprang | db2a9fc | 2017-08-09 06:42:32 -0700 | [diff] [blame] | 50 | struct RtpKeepAliveConfig; |
Stefan Holmer | dbdb3a0 | 2018-07-17 16:03:46 +0200 | [diff] [blame] | 51 | class SendDelayStats; |
| 52 | class SendStatisticsProxy; |
nisse | cae45d0 | 2017-04-24 05:53:20 -0700 | [diff] [blame] | 53 | class TransportFeedbackObserver; |
| 54 | |
Stefan Holmer | dbdb3a0 | 2018-07-17 16:03:46 +0200 | [diff] [blame] | 55 | struct RtpSenderObservers { |
| 56 | RtcpRttStats* rtcp_rtt_stats; |
| 57 | RtcpIntraFrameObserver* intra_frame_callback; |
| 58 | RtcpStatisticsCallback* rtcp_stats; |
| 59 | StreamDataCountersCallback* rtp_stats; |
| 60 | BitrateStatisticsObserver* bitrate_observer; |
| 61 | FrameCountObserver* frame_count_observer; |
| 62 | RtcpPacketTypeCounterObserver* rtcp_type_observer; |
| 63 | SendSideDelayObserver* send_delay_observer; |
| 64 | SendPacketObserver* send_packet_observer; |
Stefan Holmer | dbdb3a0 | 2018-07-17 16:03:46 +0200 | [diff] [blame] | 65 | }; |
| 66 | |
Benjamin Wright | 192eeec | 2018-10-17 17:27:25 -0700 | [diff] [blame^] | 67 | struct RtpSenderFrameEncryptionConfig { |
| 68 | FrameEncryptorInterface* frame_encryptor = nullptr; |
| 69 | CryptoOptions crypto_options; |
| 70 | }; |
| 71 | |
nisse | cae45d0 | 2017-04-24 05:53:20 -0700 | [diff] [blame] | 72 | // An RtpTransportController should own everything related to the RTP |
| 73 | // transport to/from a remote endpoint. We should have separate |
| 74 | // interfaces for send and receive side, even if they are implemented |
| 75 | // by the same class. This is an ongoing refactoring project. At some |
| 76 | // point, this class should be promoted to a public api under |
| 77 | // webrtc/api/rtp/. |
| 78 | // |
| 79 | // For a start, this object is just a collection of the objects needed |
| 80 | // by the VideoSendStream constructor. The plan is to move ownership |
| 81 | // of all RTP-related objects here, and add methods to create per-ssrc |
| 82 | // objects which would then be passed to VideoSendStream. Eventually, |
| 83 | // direct accessors like packet_router() should be removed. |
| 84 | // |
| 85 | // This should also have a reference to the underlying |
| 86 | // webrtc::Transport(s). Currently, webrtc::Transport is implemented by |
eladalon | f184138 | 2017-06-12 01:16:46 -0700 | [diff] [blame] | 87 | // WebRtcVideoChannel and WebRtcVoiceMediaChannel, and owned by |
nisse | cae45d0 | 2017-04-24 05:53:20 -0700 | [diff] [blame] | 88 | // WebrtcSession. Video and audio always uses different transport |
| 89 | // objects, even in the common case where they are bundled over the |
| 90 | // same underlying transport. |
| 91 | // |
| 92 | // Extracting the logic of the webrtc::Transport from BaseChannel and |
| 93 | // subclasses into a separate class seems to be a prerequesite for |
| 94 | // moving the transport here. |
| 95 | class RtpTransportControllerSendInterface { |
| 96 | public: |
| 97 | virtual ~RtpTransportControllerSendInterface() {} |
Sebastian Jansson | e625605 | 2018-05-04 14:08:15 +0200 | [diff] [blame] | 98 | virtual rtc::TaskQueue* GetWorkerQueue() = 0; |
nisse | cae45d0 | 2017-04-24 05:53:20 -0700 | [diff] [blame] | 99 | virtual PacketRouter* packet_router() = 0; |
Stefan Holmer | dbdb3a0 | 2018-07-17 16:03:46 +0200 | [diff] [blame] | 100 | |
Stefan Holmer | 9416ef8 | 2018-07-19 10:34:38 +0200 | [diff] [blame] | 101 | virtual RtpVideoSenderInterface* CreateRtpVideoSender( |
Stefan Holmer | dbdb3a0 | 2018-07-17 16:03:46 +0200 | [diff] [blame] | 102 | const std::vector<uint32_t>& ssrcs, |
| 103 | std::map<uint32_t, RtpState> suspended_ssrcs, |
| 104 | // TODO(holmer): Move states into RtpTransportControllerSend. |
| 105 | const std::map<uint32_t, RtpPayloadState>& states, |
| 106 | const RtpConfig& rtp_config, |
| 107 | const RtcpConfig& rtcp_config, |
| 108 | Transport* send_transport, |
| 109 | const RtpSenderObservers& observers, |
Stefan Holmer | 64be7fa | 2018-10-04 15:21:55 +0200 | [diff] [blame] | 110 | RtcEventLog* event_log, |
Benjamin Wright | 192eeec | 2018-10-17 17:27:25 -0700 | [diff] [blame^] | 111 | std::unique_ptr<FecController> fec_controller, |
| 112 | const RtpSenderFrameEncryptionConfig& frame_encryption_config) = 0; |
Stefan Holmer | 9416ef8 | 2018-07-19 10:34:38 +0200 | [diff] [blame] | 113 | virtual void DestroyRtpVideoSender( |
| 114 | RtpVideoSenderInterface* rtp_video_sender) = 0; |
Stefan Holmer | dbdb3a0 | 2018-07-17 16:03:46 +0200 | [diff] [blame] | 115 | |
nisse | cae45d0 | 2017-04-24 05:53:20 -0700 | [diff] [blame] | 116 | virtual TransportFeedbackObserver* transport_feedback_observer() = 0; |
| 117 | |
| 118 | virtual RtpPacketSender* packet_sender() = 0; |
sprang | db2a9fc | 2017-08-09 06:42:32 -0700 | [diff] [blame] | 119 | virtual const RtpKeepAliveConfig& keepalive_config() const = 0; |
Stefan Holmer | 5c8942a | 2017-08-22 16:16:44 +0200 | [diff] [blame] | 120 | |
| 121 | // SetAllocatedSendBitrateLimits sets bitrates limits imposed by send codec |
| 122 | // settings. |
| 123 | // |min_send_bitrate_bps| is the total minimum send bitrate required by all |
| 124 | // sending streams. This is the minimum bitrate the PacedSender will use. |
| 125 | // Note that SendSideCongestionController::OnNetworkChanged can still be |
| 126 | // called with a lower bitrate estimate. |max_padding_bitrate_bps| is the max |
| 127 | // bitrate the send streams request for padding. This can be higher than the |
| 128 | // current network estimate and tells the PacedSender how much it should max |
| 129 | // pad unless there is real packets to send. |
| 130 | virtual void SetAllocatedSendBitrateLimits(int min_send_bitrate_bps, |
philipel | 832b1c8 | 2018-02-28 17:04:18 +0100 | [diff] [blame] | 131 | int max_padding_bitrate_bps, |
| 132 | int total_bitrate_bps) = 0; |
Sebastian Jansson | e4be6da | 2018-02-15 16:51:41 +0100 | [diff] [blame] | 133 | |
Sebastian Jansson | 4c1ffb8 | 2018-02-15 16:51:58 +0100 | [diff] [blame] | 134 | virtual void SetPacingFactor(float pacing_factor) = 0; |
| 135 | virtual void SetQueueTimeLimit(int limit_ms) = 0; |
| 136 | |
Sebastian Jansson | e4be6da | 2018-02-15 16:51:41 +0100 | [diff] [blame] | 137 | virtual CallStatsObserver* GetCallStatsObserver() = 0; |
| 138 | |
| 139 | virtual void RegisterPacketFeedbackObserver( |
| 140 | PacketFeedbackObserver* observer) = 0; |
| 141 | virtual void DeRegisterPacketFeedbackObserver( |
| 142 | PacketFeedbackObserver* observer) = 0; |
Sebastian Jansson | 19704ec | 2018-03-12 15:59:12 +0100 | [diff] [blame] | 143 | virtual void RegisterTargetTransferRateObserver( |
| 144 | TargetTransferRateObserver* observer) = 0; |
Sebastian Jansson | 97f61ea | 2018-02-21 13:01:55 +0100 | [diff] [blame] | 145 | virtual void OnNetworkRouteChanged( |
| 146 | const std::string& transport_name, |
| 147 | const rtc::NetworkRoute& network_route) = 0; |
Sebastian Jansson | e4be6da | 2018-02-15 16:51:41 +0100 | [diff] [blame] | 148 | virtual void OnNetworkAvailability(bool network_available) = 0; |
Sebastian Jansson | e4be6da | 2018-02-15 16:51:41 +0100 | [diff] [blame] | 149 | virtual RtcpBandwidthObserver* GetBandwidthObserver() = 0; |
Sebastian Jansson | e4be6da | 2018-02-15 16:51:41 +0100 | [diff] [blame] | 150 | virtual int64_t GetPacerQueuingDelayMs() const = 0; |
| 151 | virtual int64_t GetFirstPacketTimeMs() const = 0; |
Sebastian Jansson | e4be6da | 2018-02-15 16:51:41 +0100 | [diff] [blame] | 152 | virtual void EnablePeriodicAlrProbing(bool enable) = 0; |
| 153 | virtual void OnSentPacket(const rtc::SentPacket& sent_packet) = 0; |
Sebastian Jansson | 12130bb | 2018-03-21 12:48:43 +0100 | [diff] [blame] | 154 | virtual void SetPerPacketFeedbackAvailable(bool available) = 0; |
Sebastian Jansson | 97f61ea | 2018-02-21 13:01:55 +0100 | [diff] [blame] | 155 | |
| 156 | virtual void SetSdpBitrateParameters( |
| 157 | const BitrateConstraints& constraints) = 0; |
| 158 | virtual void SetClientBitratePreferences( |
Niels Möller | 0c4f7be | 2018-05-07 14:01:37 +0200 | [diff] [blame] | 159 | const BitrateSettings& preferences) = 0; |
Alex Narest | bcf9180 | 2018-06-25 16:08:36 +0200 | [diff] [blame] | 160 | |
| 161 | virtual void SetAllocatedBitrateWithoutFeedback(uint32_t bitrate_bps) = 0; |
Stefan Holmer | 64be7fa | 2018-10-04 15:21:55 +0200 | [diff] [blame] | 162 | |
| 163 | virtual void OnTransportOverheadChanged( |
| 164 | size_t transport_overhead_per_packet) = 0; |
nisse | cae45d0 | 2017-04-24 05:53:20 -0700 | [diff] [blame] | 165 | }; |
| 166 | |
| 167 | } // namespace webrtc |
| 168 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 169 | #endif // CALL_RTP_TRANSPORT_CONTROLLER_SEND_INTERFACE_H_ |