blob: 25b11276750bddec01ed70629642adcb0fdf54ef [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>
17
Sebastian Janssondfce03a2018-05-18 18:05:10 +020018#include "api/transport/network_control.h"
Sebastian Jansson97f61ea2018-02-21 13:01:55 +010019#include "call/rtp_bitrate_configurator.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020020#include "call/rtp_transport_controller_send_interface.h"
Mirko Bonadei71207422017-09-15 13:58:09 +020021#include "common_types.h" // NOLINT(build/include)
Sebastian Jansson10211e92018-02-28 16:48:26 +010022#include "modules/congestion_controller/include/send_side_congestion_controller_interface.h"
Niels Möllerfd6c0912017-10-31 10:19:10 +010023#include "modules/pacing/packet_router.h"
Sebastian Janssonc33c0fc2018-02-22 11:10:18 +010024#include "modules/utility/include/process_thread.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020025#include "rtc_base/constructormagic.h"
Sebastian Jansson91bb6672018-02-21 13:02:51 +010026#include "rtc_base/networkroute.h"
Sebastian Janssone6256052018-05-04 14:08:15 +020027#include "rtc_base/task_queue.h"
nissecae45d02017-04-24 05:53:20 -070028
nisseb8f9a322017-03-27 05:36:15 -070029namespace webrtc {
nissecae45d02017-04-24 05:53:20 -070030class Clock;
31class RtcEventLog;
nisseb8f9a322017-03-27 05:36:15 -070032
nissecae45d02017-04-24 05:53:20 -070033// TODO(nisse): When we get the underlying transports here, we should
34// have one object implementing RtpTransportControllerSendInterface
35// per transport, sharing the same congestion controller.
Sebastian Jansson317a5222018-03-16 15:36:37 +010036class RtpTransportControllerSend final
37 : public RtpTransportControllerSendInterface,
38 public NetworkChangedObserver {
nisseb8f9a322017-03-27 05:36:15 -070039 public:
Sebastian Janssondfce03a2018-05-18 18:05:10 +020040 RtpTransportControllerSend(
41 Clock* clock,
42 RtcEventLog* event_log,
43 NetworkControllerFactoryInterface* controller_factory,
44 const BitrateConstraints& bitrate_config);
Sebastian Jansson97f61ea2018-02-21 13:01:55 +010045 ~RtpTransportControllerSend() override;
Sebastian Jansson19704ec2018-03-12 15:59:12 +010046
47 // Implements NetworkChangedObserver interface.
48 void OnNetworkChanged(uint32_t bitrate_bps,
49 uint8_t fraction_loss,
50 int64_t rtt_ms,
51 int64_t probing_interval_ms) override;
52
nissecae45d02017-04-24 05:53:20 -070053 // Implements RtpTransportControllerSendInterface
Sebastian Janssone6256052018-05-04 14:08:15 +020054 rtc::TaskQueue* GetWorkerQueue() override;
nisse76e62b02017-05-31 02:24:52 -070055 PacketRouter* packet_router() override;
Sebastian Jansson4c1ffb82018-02-15 16:51:58 +010056
nisse76e62b02017-05-31 02:24:52 -070057 TransportFeedbackObserver* transport_feedback_observer() override;
58 RtpPacketSender* packet_sender() override;
sprangdb2a9fc2017-08-09 06:42:32 -070059 const RtpKeepAliveConfig& keepalive_config() const override;
60
Stefan Holmer5c8942a2017-08-22 16:16:44 +020061 void SetAllocatedSendBitrateLimits(int min_send_bitrate_bps,
philipel832b1c82018-02-28 17:04:18 +010062 int max_padding_bitrate_bps,
philipeldb4fa4b2018-03-06 18:29:22 +010063 int max_total_bitrate_bps) override;
Stefan Holmer5c8942a2017-08-22 16:16:44 +020064
sprangdb2a9fc2017-08-09 06:42:32 -070065 void SetKeepAliveConfig(const RtpKeepAliveConfig& config);
Sebastian Jansson4c1ffb82018-02-15 16:51:58 +010066 void SetPacingFactor(float pacing_factor) override;
67 void SetQueueTimeLimit(int limit_ms) override;
Sebastian Janssone4be6da2018-02-15 16:51:41 +010068 CallStatsObserver* GetCallStatsObserver() override;
69 void RegisterPacketFeedbackObserver(
70 PacketFeedbackObserver* observer) override;
71 void DeRegisterPacketFeedbackObserver(
72 PacketFeedbackObserver* observer) override;
Sebastian Jansson19704ec2018-03-12 15:59:12 +010073 void RegisterTargetTransferRateObserver(
74 TargetTransferRateObserver* observer) override;
Sebastian Jansson97f61ea2018-02-21 13:01:55 +010075 void OnNetworkRouteChanged(const std::string& transport_name,
76 const rtc::NetworkRoute& network_route) override;
Sebastian Janssone4be6da2018-02-15 16:51:41 +010077 void OnNetworkAvailability(bool network_available) override;
Sebastian Janssone4be6da2018-02-15 16:51:41 +010078 RtcpBandwidthObserver* GetBandwidthObserver() override;
Sebastian Janssone4be6da2018-02-15 16:51:41 +010079 int64_t GetPacerQueuingDelayMs() const override;
80 int64_t GetFirstPacketTimeMs() const override;
Sebastian Jansson12130bb2018-03-21 12:48:43 +010081 void SetPerPacketFeedbackAvailable(bool available) override;
Sebastian Janssone4be6da2018-02-15 16:51:41 +010082 void EnablePeriodicAlrProbing(bool enable) override;
83 void OnSentPacket(const rtc::SentPacket& sent_packet) override;
nissecae45d02017-04-24 05:53:20 -070084
Sebastian Jansson97f61ea2018-02-21 13:01:55 +010085 void SetSdpBitrateParameters(const BitrateConstraints& constraints) override;
86 void SetClientBitratePreferences(
Niels Möller0c4f7be2018-05-07 14:01:37 +020087 const BitrateSettings& preferences) override;
Sebastian Jansson97f61ea2018-02-21 13:01:55 +010088
nissecae45d02017-04-24 05:53:20 -070089 private:
Sebastian Jansson19704ec2018-03-12 15:59:12 +010090 const Clock* const clock_;
nissecae45d02017-04-24 05:53:20 -070091 PacketRouter packet_router_;
Stefan Holmer5c8942a2017-08-22 16:16:44 +020092 PacedSender pacer_;
sprangdb2a9fc2017-08-09 06:42:32 -070093 RtpKeepAliveConfig keepalive_;
Sebastian Jansson97f61ea2018-02-21 13:01:55 +010094 RtpBitrateConfigurator bitrate_configurator_;
Sebastian Jansson91bb6672018-02-21 13:02:51 +010095 std::map<std::string, rtc::NetworkRoute> network_routes_;
Sebastian Janssonc33c0fc2018-02-22 11:10:18 +010096 const std::unique_ptr<ProcessThread> process_thread_;
Sebastian Jansson19704ec2018-03-12 15:59:12 +010097 rtc::CriticalSection observer_crit_;
98 TargetTransferRateObserver* observer_ RTC_GUARDED_BY(observer_crit_);
Sebastian Janssonbd9fe092018-05-07 16:33:50 +020099 std::unique_ptr<SendSideCongestionControllerInterface> send_side_cc_;
Sebastian Janssone6256052018-05-04 14:08:15 +0200100 // TODO(perkj): |task_queue_| is supposed to replace |process_thread_|.
101 // |task_queue_| is defined last to ensure all pending tasks are cancelled
102 // and deleted before any other members.
103 rtc::TaskQueue task_queue_;
nissecae45d02017-04-24 05:53:20 -0700104 RTC_DISALLOW_COPY_AND_ASSIGN(RtpTransportControllerSend);
nisseb8f9a322017-03-27 05:36:15 -0700105};
106
107} // namespace webrtc
108
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200109#endif // CALL_RTP_TRANSPORT_CONTROLLER_SEND_H_