nisse | b8f9a32 | 2017-03-27 05:36:15 -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_H_ |
| 12 | #define CALL_RTP_TRANSPORT_CONTROLLER_SEND_H_ |
nisse | b8f9a32 | 2017-03-27 05:36:15 -0700 | [diff] [blame] | 13 | |
Sebastian Jansson | 91bb667 | 2018-02-21 13:02:51 +0100 | [diff] [blame] | 14 | #include <map> |
Sebastian Jansson | c33c0fc | 2018-02-22 11:10:18 +0100 | [diff] [blame] | 15 | #include <memory> |
Sebastian Jansson | 97f61ea | 2018-02-21 13:01:55 +0100 | [diff] [blame] | 16 | #include <string> |
Stefan Holmer | dbdb3a0 | 2018-07-17 16:03:46 +0200 | [diff] [blame] | 17 | #include <vector> |
Sebastian Jansson | 97f61ea | 2018-02-21 13:01:55 +0100 | [diff] [blame] | 18 | |
Sebastian Jansson | dfce03a | 2018-05-18 18:05:10 +0200 | [diff] [blame] | 19 | #include "api/transport/network_control.h" |
Sebastian Jansson | 97f61ea | 2018-02-21 13:01:55 +0100 | [diff] [blame] | 20 | #include "call/rtp_bitrate_configurator.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 21 | #include "call/rtp_transport_controller_send_interface.h" |
Stefan Holmer | 9416ef8 | 2018-07-19 10:34:38 +0200 | [diff] [blame] | 22 | #include "call/rtp_video_sender.h" |
Mirko Bonadei | 7120742 | 2017-09-15 13:58:09 +0200 | [diff] [blame] | 23 | #include "common_types.h" // NOLINT(build/include) |
Sebastian Jansson | 10211e9 | 2018-02-28 16:48:26 +0100 | [diff] [blame] | 24 | #include "modules/congestion_controller/include/send_side_congestion_controller_interface.h" |
Niels Möller | fd6c091 | 2017-10-31 10:19:10 +0100 | [diff] [blame] | 25 | #include "modules/pacing/packet_router.h" |
Sebastian Jansson | c33c0fc | 2018-02-22 11:10:18 +0100 | [diff] [blame] | 26 | #include "modules/utility/include/process_thread.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 27 | #include "rtc_base/constructormagic.h" |
Sebastian Jansson | 91bb667 | 2018-02-21 13:02:51 +0100 | [diff] [blame] | 28 | #include "rtc_base/networkroute.h" |
Sebastian Jansson | e625605 | 2018-05-04 14:08:15 +0200 | [diff] [blame] | 29 | #include "rtc_base/task_queue.h" |
nisse | cae45d0 | 2017-04-24 05:53:20 -0700 | [diff] [blame] | 30 | |
nisse | b8f9a32 | 2017-03-27 05:36:15 -0700 | [diff] [blame] | 31 | namespace webrtc { |
nisse | cae45d0 | 2017-04-24 05:53:20 -0700 | [diff] [blame] | 32 | class Clock; |
| 33 | class RtcEventLog; |
nisse | b8f9a32 | 2017-03-27 05:36:15 -0700 | [diff] [blame] | 34 | |
nisse | cae45d0 | 2017-04-24 05:53:20 -0700 | [diff] [blame] | 35 | // TODO(nisse): When we get the underlying transports here, we should |
| 36 | // have one object implementing RtpTransportControllerSendInterface |
| 37 | // per transport, sharing the same congestion controller. |
Sebastian Jansson | 317a522 | 2018-03-16 15:36:37 +0100 | [diff] [blame] | 38 | class RtpTransportControllerSend final |
| 39 | : public RtpTransportControllerSendInterface, |
| 40 | public NetworkChangedObserver { |
nisse | b8f9a32 | 2017-03-27 05:36:15 -0700 | [diff] [blame] | 41 | public: |
Sebastian Jansson | dfce03a | 2018-05-18 18:05:10 +0200 | [diff] [blame] | 42 | RtpTransportControllerSend( |
| 43 | Clock* clock, |
| 44 | RtcEventLog* event_log, |
| 45 | NetworkControllerFactoryInterface* controller_factory, |
| 46 | const BitrateConstraints& bitrate_config); |
Sebastian Jansson | 97f61ea | 2018-02-21 13:01:55 +0100 | [diff] [blame] | 47 | ~RtpTransportControllerSend() override; |
Sebastian Jansson | 19704ec | 2018-03-12 15:59:12 +0100 | [diff] [blame] | 48 | |
Stefan Holmer | 9416ef8 | 2018-07-19 10:34:38 +0200 | [diff] [blame] | 49 | RtpVideoSenderInterface* CreateRtpVideoSender( |
Stefan Holmer | dbdb3a0 | 2018-07-17 16:03:46 +0200 | [diff] [blame] | 50 | const std::vector<uint32_t>& ssrcs, |
| 51 | std::map<uint32_t, RtpState> suspended_ssrcs, |
| 52 | const std::map<uint32_t, RtpPayloadState>& |
| 53 | states, // move states into RtpTransportControllerSend |
| 54 | const RtpConfig& rtp_config, |
| 55 | const RtcpConfig& rtcp_config, |
| 56 | Transport* send_transport, |
| 57 | const RtpSenderObservers& observers, |
| 58 | RtcEventLog* event_log) override; |
Stefan Holmer | 9416ef8 | 2018-07-19 10:34:38 +0200 | [diff] [blame] | 59 | void DestroyRtpVideoSender( |
| 60 | RtpVideoSenderInterface* rtp_video_sender) override; |
Stefan Holmer | dbdb3a0 | 2018-07-17 16:03:46 +0200 | [diff] [blame] | 61 | |
Sebastian Jansson | 19704ec | 2018-03-12 15:59:12 +0100 | [diff] [blame] | 62 | // Implements NetworkChangedObserver interface. |
| 63 | void OnNetworkChanged(uint32_t bitrate_bps, |
| 64 | uint8_t fraction_loss, |
| 65 | int64_t rtt_ms, |
| 66 | int64_t probing_interval_ms) override; |
| 67 | |
nisse | cae45d0 | 2017-04-24 05:53:20 -0700 | [diff] [blame] | 68 | // Implements RtpTransportControllerSendInterface |
Sebastian Jansson | e625605 | 2018-05-04 14:08:15 +0200 | [diff] [blame] | 69 | rtc::TaskQueue* GetWorkerQueue() override; |
nisse | 76e62b0 | 2017-05-31 02:24:52 -0700 | [diff] [blame] | 70 | PacketRouter* packet_router() override; |
Sebastian Jansson | 4c1ffb8 | 2018-02-15 16:51:58 +0100 | [diff] [blame] | 71 | |
nisse | 76e62b0 | 2017-05-31 02:24:52 -0700 | [diff] [blame] | 72 | TransportFeedbackObserver* transport_feedback_observer() override; |
| 73 | RtpPacketSender* packet_sender() override; |
sprang | db2a9fc | 2017-08-09 06:42:32 -0700 | [diff] [blame] | 74 | const RtpKeepAliveConfig& keepalive_config() const override; |
| 75 | |
Stefan Holmer | 5c8942a | 2017-08-22 16:16:44 +0200 | [diff] [blame] | 76 | void SetAllocatedSendBitrateLimits(int min_send_bitrate_bps, |
philipel | 832b1c8 | 2018-02-28 17:04:18 +0100 | [diff] [blame] | 77 | int max_padding_bitrate_bps, |
philipel | db4fa4b | 2018-03-06 18:29:22 +0100 | [diff] [blame] | 78 | int max_total_bitrate_bps) override; |
Stefan Holmer | 5c8942a | 2017-08-22 16:16:44 +0200 | [diff] [blame] | 79 | |
sprang | db2a9fc | 2017-08-09 06:42:32 -0700 | [diff] [blame] | 80 | void SetKeepAliveConfig(const RtpKeepAliveConfig& config); |
Sebastian Jansson | 4c1ffb8 | 2018-02-15 16:51:58 +0100 | [diff] [blame] | 81 | void SetPacingFactor(float pacing_factor) override; |
| 82 | void SetQueueTimeLimit(int limit_ms) override; |
Sebastian Jansson | e4be6da | 2018-02-15 16:51:41 +0100 | [diff] [blame] | 83 | CallStatsObserver* GetCallStatsObserver() override; |
| 84 | void RegisterPacketFeedbackObserver( |
| 85 | PacketFeedbackObserver* observer) override; |
| 86 | void DeRegisterPacketFeedbackObserver( |
| 87 | PacketFeedbackObserver* observer) override; |
Sebastian Jansson | 19704ec | 2018-03-12 15:59:12 +0100 | [diff] [blame] | 88 | void RegisterTargetTransferRateObserver( |
| 89 | TargetTransferRateObserver* observer) override; |
Sebastian Jansson | 97f61ea | 2018-02-21 13:01:55 +0100 | [diff] [blame] | 90 | void OnNetworkRouteChanged(const std::string& transport_name, |
| 91 | const rtc::NetworkRoute& network_route) override; |
Sebastian Jansson | e4be6da | 2018-02-15 16:51:41 +0100 | [diff] [blame] | 92 | void OnNetworkAvailability(bool network_available) override; |
Sebastian Jansson | e4be6da | 2018-02-15 16:51:41 +0100 | [diff] [blame] | 93 | RtcpBandwidthObserver* GetBandwidthObserver() override; |
Sebastian Jansson | e4be6da | 2018-02-15 16:51:41 +0100 | [diff] [blame] | 94 | int64_t GetPacerQueuingDelayMs() const override; |
| 95 | int64_t GetFirstPacketTimeMs() const override; |
Sebastian Jansson | 12130bb | 2018-03-21 12:48:43 +0100 | [diff] [blame] | 96 | void SetPerPacketFeedbackAvailable(bool available) override; |
Sebastian Jansson | e4be6da | 2018-02-15 16:51:41 +0100 | [diff] [blame] | 97 | void EnablePeriodicAlrProbing(bool enable) override; |
| 98 | void OnSentPacket(const rtc::SentPacket& sent_packet) override; |
nisse | cae45d0 | 2017-04-24 05:53:20 -0700 | [diff] [blame] | 99 | |
Sebastian Jansson | 97f61ea | 2018-02-21 13:01:55 +0100 | [diff] [blame] | 100 | void SetSdpBitrateParameters(const BitrateConstraints& constraints) override; |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 101 | void SetClientBitratePreferences(const BitrateSettings& preferences) override; |
Sebastian Jansson | 97f61ea | 2018-02-21 13:01:55 +0100 | [diff] [blame] | 102 | |
Alex Narest | bcf9180 | 2018-06-25 16:08:36 +0200 | [diff] [blame] | 103 | void SetAllocatedBitrateWithoutFeedback(uint32_t bitrate_bps) override; |
| 104 | |
nisse | cae45d0 | 2017-04-24 05:53:20 -0700 | [diff] [blame] | 105 | private: |
Sebastian Jansson | 19704ec | 2018-03-12 15:59:12 +0100 | [diff] [blame] | 106 | const Clock* const clock_; |
nisse | cae45d0 | 2017-04-24 05:53:20 -0700 | [diff] [blame] | 107 | PacketRouter packet_router_; |
Stefan Holmer | 9416ef8 | 2018-07-19 10:34:38 +0200 | [diff] [blame] | 108 | std::vector<std::unique_ptr<RtpVideoSenderInterface>> video_rtp_senders_; |
Stefan Holmer | 5c8942a | 2017-08-22 16:16:44 +0200 | [diff] [blame] | 109 | PacedSender pacer_; |
sprang | db2a9fc | 2017-08-09 06:42:32 -0700 | [diff] [blame] | 110 | RtpKeepAliveConfig keepalive_; |
Sebastian Jansson | 97f61ea | 2018-02-21 13:01:55 +0100 | [diff] [blame] | 111 | RtpBitrateConfigurator bitrate_configurator_; |
Sebastian Jansson | 91bb667 | 2018-02-21 13:02:51 +0100 | [diff] [blame] | 112 | std::map<std::string, rtc::NetworkRoute> network_routes_; |
Sebastian Jansson | c33c0fc | 2018-02-22 11:10:18 +0100 | [diff] [blame] | 113 | const std::unique_ptr<ProcessThread> process_thread_; |
Sebastian Jansson | 19704ec | 2018-03-12 15:59:12 +0100 | [diff] [blame] | 114 | rtc::CriticalSection observer_crit_; |
| 115 | TargetTransferRateObserver* observer_ RTC_GUARDED_BY(observer_crit_); |
Sebastian Jansson | bd9fe09 | 2018-05-07 16:33:50 +0200 | [diff] [blame] | 116 | std::unique_ptr<SendSideCongestionControllerInterface> send_side_cc_; |
Stefan Holmer | dbdb3a0 | 2018-07-17 16:03:46 +0200 | [diff] [blame] | 117 | RateLimiter retransmission_rate_limiter_; |
| 118 | |
Sebastian Jansson | e625605 | 2018-05-04 14:08:15 +0200 | [diff] [blame] | 119 | // TODO(perkj): |task_queue_| is supposed to replace |process_thread_|. |
| 120 | // |task_queue_| is defined last to ensure all pending tasks are cancelled |
| 121 | // and deleted before any other members. |
| 122 | rtc::TaskQueue task_queue_; |
nisse | cae45d0 | 2017-04-24 05:53:20 -0700 | [diff] [blame] | 123 | RTC_DISALLOW_COPY_AND_ASSIGN(RtpTransportControllerSend); |
nisse | b8f9a32 | 2017-03-27 05:36:15 -0700 | [diff] [blame] | 124 | }; |
| 125 | |
| 126 | } // namespace webrtc |
| 127 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 128 | #endif // CALL_RTP_TRANSPORT_CONTROLLER_SEND_H_ |