blob: 6aaf29d6bc37b83323c78aa3e45301261f023416 [file] [log] [blame]
nisseb8f9a322017-03-27 05:36:15 -07001/*
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 Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef CALL_RTP_TRANSPORT_CONTROLLER_SEND_H_
12#define CALL_RTP_TRANSPORT_CONTROLLER_SEND_H_
nisseb8f9a322017-03-27 05:36:15 -070013
Sebastian Jansson91bb6672018-02-21 13:02:51 +010014#include <map>
Sebastian Janssonc33c0fc2018-02-22 11:10:18 +010015#include <memory>
Sebastian Jansson97f61ea2018-02-21 13:01:55 +010016#include <string>
Stefan Holmerdbdb3a02018-07-17 16:03:46 +020017#include <vector>
Sebastian Jansson97f61ea2018-02-21 13:01:55 +010018
Sebastian Janssondfce03a2018-05-18 18:05:10 +020019#include "api/transport/network_control.h"
Sebastian Jansson97f61ea2018-02-21 13:01:55 +010020#include "call/rtp_bitrate_configurator.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020021#include "call/rtp_transport_controller_send_interface.h"
Stefan Holmer9416ef82018-07-19 10:34:38 +020022#include "call/rtp_video_sender.h"
Mirko Bonadei71207422017-09-15 13:58:09 +020023#include "common_types.h" // NOLINT(build/include)
Sebastian Jansson10211e92018-02-28 16:48:26 +010024#include "modules/congestion_controller/include/send_side_congestion_controller_interface.h"
Niels Möllerfd6c0912017-10-31 10:19:10 +010025#include "modules/pacing/packet_router.h"
Sebastian Janssonc33c0fc2018-02-22 11:10:18 +010026#include "modules/utility/include/process_thread.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020027#include "rtc_base/constructormagic.h"
Sebastian Jansson91bb6672018-02-21 13:02:51 +010028#include "rtc_base/networkroute.h"
Sebastian Janssone6256052018-05-04 14:08:15 +020029#include "rtc_base/task_queue.h"
nissecae45d02017-04-24 05:53:20 -070030
nisseb8f9a322017-03-27 05:36:15 -070031namespace webrtc {
nissecae45d02017-04-24 05:53:20 -070032class Clock;
33class RtcEventLog;
nisseb8f9a322017-03-27 05:36:15 -070034
nissecae45d02017-04-24 05:53:20 -070035// 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 Jansson317a5222018-03-16 15:36:37 +010038class RtpTransportControllerSend final
39 : public RtpTransportControllerSendInterface,
40 public NetworkChangedObserver {
nisseb8f9a322017-03-27 05:36:15 -070041 public:
Sebastian Janssondfce03a2018-05-18 18:05:10 +020042 RtpTransportControllerSend(
43 Clock* clock,
44 RtcEventLog* event_log,
45 NetworkControllerFactoryInterface* controller_factory,
46 const BitrateConstraints& bitrate_config);
Sebastian Jansson97f61ea2018-02-21 13:01:55 +010047 ~RtpTransportControllerSend() override;
Sebastian Jansson19704ec2018-03-12 15:59:12 +010048
Stefan Holmer9416ef82018-07-19 10:34:38 +020049 RtpVideoSenderInterface* CreateRtpVideoSender(
Stefan Holmerdbdb3a02018-07-17 16:03:46 +020050 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,
Stefan Holmer64be7fa2018-10-04 15:21:55 +020058 RtcEventLog* event_log,
59 std::unique_ptr<FecController> fec_controller) override;
Stefan Holmer9416ef82018-07-19 10:34:38 +020060 void DestroyRtpVideoSender(
61 RtpVideoSenderInterface* rtp_video_sender) override;
Stefan Holmerdbdb3a02018-07-17 16:03:46 +020062
Sebastian Jansson19704ec2018-03-12 15:59:12 +010063 // Implements NetworkChangedObserver interface.
64 void OnNetworkChanged(uint32_t bitrate_bps,
65 uint8_t fraction_loss,
66 int64_t rtt_ms,
67 int64_t probing_interval_ms) override;
68
nissecae45d02017-04-24 05:53:20 -070069 // Implements RtpTransportControllerSendInterface
Sebastian Janssone6256052018-05-04 14:08:15 +020070 rtc::TaskQueue* GetWorkerQueue() override;
nisse76e62b02017-05-31 02:24:52 -070071 PacketRouter* packet_router() override;
Sebastian Jansson4c1ffb82018-02-15 16:51:58 +010072
nisse76e62b02017-05-31 02:24:52 -070073 TransportFeedbackObserver* transport_feedback_observer() override;
74 RtpPacketSender* packet_sender() override;
sprangdb2a9fc2017-08-09 06:42:32 -070075 const RtpKeepAliveConfig& keepalive_config() const override;
76
Stefan Holmer5c8942a2017-08-22 16:16:44 +020077 void SetAllocatedSendBitrateLimits(int min_send_bitrate_bps,
philipel832b1c82018-02-28 17:04:18 +010078 int max_padding_bitrate_bps,
philipeldb4fa4b2018-03-06 18:29:22 +010079 int max_total_bitrate_bps) override;
Stefan Holmer5c8942a2017-08-22 16:16:44 +020080
sprangdb2a9fc2017-08-09 06:42:32 -070081 void SetKeepAliveConfig(const RtpKeepAliveConfig& config);
Sebastian Jansson4c1ffb82018-02-15 16:51:58 +010082 void SetPacingFactor(float pacing_factor) override;
83 void SetQueueTimeLimit(int limit_ms) override;
Sebastian Janssone4be6da2018-02-15 16:51:41 +010084 CallStatsObserver* GetCallStatsObserver() override;
85 void RegisterPacketFeedbackObserver(
86 PacketFeedbackObserver* observer) override;
87 void DeRegisterPacketFeedbackObserver(
88 PacketFeedbackObserver* observer) override;
Sebastian Jansson19704ec2018-03-12 15:59:12 +010089 void RegisterTargetTransferRateObserver(
90 TargetTransferRateObserver* observer) override;
Sebastian Jansson97f61ea2018-02-21 13:01:55 +010091 void OnNetworkRouteChanged(const std::string& transport_name,
92 const rtc::NetworkRoute& network_route) override;
Sebastian Janssone4be6da2018-02-15 16:51:41 +010093 void OnNetworkAvailability(bool network_available) override;
Sebastian Janssone4be6da2018-02-15 16:51:41 +010094 RtcpBandwidthObserver* GetBandwidthObserver() override;
Sebastian Janssone4be6da2018-02-15 16:51:41 +010095 int64_t GetPacerQueuingDelayMs() const override;
96 int64_t GetFirstPacketTimeMs() const override;
Sebastian Jansson12130bb2018-03-21 12:48:43 +010097 void SetPerPacketFeedbackAvailable(bool available) override;
Sebastian Janssone4be6da2018-02-15 16:51:41 +010098 void EnablePeriodicAlrProbing(bool enable) override;
99 void OnSentPacket(const rtc::SentPacket& sent_packet) override;
nissecae45d02017-04-24 05:53:20 -0700100
Sebastian Jansson97f61ea2018-02-21 13:01:55 +0100101 void SetSdpBitrateParameters(const BitrateConstraints& constraints) override;
Yves Gerey665174f2018-06-19 15:03:05 +0200102 void SetClientBitratePreferences(const BitrateSettings& preferences) override;
Sebastian Jansson97f61ea2018-02-21 13:01:55 +0100103
Alex Narestbcf91802018-06-25 16:08:36 +0200104 void SetAllocatedBitrateWithoutFeedback(uint32_t bitrate_bps) override;
105
Stefan Holmer64be7fa2018-10-04 15:21:55 +0200106 void OnTransportOverheadChanged(
107 size_t transport_overhead_per_packet) override;
108
nissecae45d02017-04-24 05:53:20 -0700109 private:
Sebastian Jansson19704ec2018-03-12 15:59:12 +0100110 const Clock* const clock_;
nissecae45d02017-04-24 05:53:20 -0700111 PacketRouter packet_router_;
Stefan Holmer9416ef82018-07-19 10:34:38 +0200112 std::vector<std::unique_ptr<RtpVideoSenderInterface>> video_rtp_senders_;
Stefan Holmer5c8942a2017-08-22 16:16:44 +0200113 PacedSender pacer_;
sprangdb2a9fc2017-08-09 06:42:32 -0700114 RtpKeepAliveConfig keepalive_;
Sebastian Jansson97f61ea2018-02-21 13:01:55 +0100115 RtpBitrateConfigurator bitrate_configurator_;
Sebastian Jansson91bb6672018-02-21 13:02:51 +0100116 std::map<std::string, rtc::NetworkRoute> network_routes_;
Sebastian Janssonc33c0fc2018-02-22 11:10:18 +0100117 const std::unique_ptr<ProcessThread> process_thread_;
Sebastian Jansson19704ec2018-03-12 15:59:12 +0100118 rtc::CriticalSection observer_crit_;
119 TargetTransferRateObserver* observer_ RTC_GUARDED_BY(observer_crit_);
Sebastian Janssonbd9fe092018-05-07 16:33:50 +0200120 std::unique_ptr<SendSideCongestionControllerInterface> send_side_cc_;
Stefan Holmerdbdb3a02018-07-17 16:03:46 +0200121 RateLimiter retransmission_rate_limiter_;
122
Sebastian Janssone6256052018-05-04 14:08:15 +0200123 // TODO(perkj): |task_queue_| is supposed to replace |process_thread_|.
124 // |task_queue_| is defined last to ensure all pending tasks are cancelled
125 // and deleted before any other members.
126 rtc::TaskQueue task_queue_;
nissecae45d02017-04-24 05:53:20 -0700127 RTC_DISALLOW_COPY_AND_ASSIGN(RtpTransportControllerSend);
nisseb8f9a322017-03-27 05:36:15 -0700128};
129
130} // namespace webrtc
131
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200132#endif // CALL_RTP_TRANSPORT_CONTROLLER_SEND_H_