blob: f1c46cc07855ddef7e412c6680d19c5b68c29de4 [file] [log] [blame]
nisseb8f9a322017-03-27 12:36:151/*
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 04:47:3111#ifndef CALL_RTP_TRANSPORT_CONTROLLER_SEND_H_
12#define CALL_RTP_TRANSPORT_CONTROLLER_SEND_H_
nisseb8f9a322017-03-27 12:36:1513
Sebastian Jansson91bb6672018-02-21 12:02:5114#include <map>
Sebastian Janssonc33c0fc2018-02-22 10:10:1815#include <memory>
Sebastian Jansson97f61ea2018-02-21 12:01:5516#include <string>
Stefan Holmerdbdb3a02018-07-17 14:03:4617#include <vector>
Sebastian Jansson97f61ea2018-02-21 12:01:5518
Sebastian Janssondfce03a2018-05-18 16:05:1019#include "api/transport/network_control.h"
Sebastian Jansson97f61ea2018-02-21 12:01:5520#include "call/rtp_bitrate_configurator.h"
Mirko Bonadei92ea95e2017-09-15 04:47:3121#include "call/rtp_transport_controller_send_interface.h"
Stefan Holmer9416ef82018-07-19 08:34:3822#include "call/rtp_video_sender.h"
Sebastian Jansson10211e92018-02-28 15:48:2623#include "modules/congestion_controller/include/send_side_congestion_controller_interface.h"
Niels Möllerfd6c0912017-10-31 09:19:1024#include "modules/pacing/packet_router.h"
Sebastian Janssonc33c0fc2018-02-22 10:10:1825#include "modules/utility/include/process_thread.h"
Mirko Bonadei92ea95e2017-09-15 04:47:3126#include "rtc_base/constructormagic.h"
Sebastian Jansson91bb6672018-02-21 12:02:5127#include "rtc_base/networkroute.h"
Sebastian Janssone6256052018-05-04 12:08:1528#include "rtc_base/task_queue.h"
nissecae45d02017-04-24 12:53:2029
nisseb8f9a322017-03-27 12:36:1530namespace webrtc {
Benjamin Wright192eeec2018-10-18 00:27:2531
nissecae45d02017-04-24 12:53:2032class Clock;
Benjamin Wright192eeec2018-10-18 00:27:2533class FrameEncryptorInterface;
nissecae45d02017-04-24 12:53:2034class RtcEventLog;
nisseb8f9a322017-03-27 12:36:1535
nissecae45d02017-04-24 12:53:2036// TODO(nisse): When we get the underlying transports here, we should
37// have one object implementing RtpTransportControllerSendInterface
38// per transport, sharing the same congestion controller.
Sebastian Jansson317a5222018-03-16 14:36:3739class RtpTransportControllerSend final
40 : public RtpTransportControllerSendInterface,
41 public NetworkChangedObserver {
nisseb8f9a322017-03-27 12:36:1542 public:
Sebastian Janssondfce03a2018-05-18 16:05:1043 RtpTransportControllerSend(
44 Clock* clock,
45 RtcEventLog* event_log,
46 NetworkControllerFactoryInterface* controller_factory,
47 const BitrateConstraints& bitrate_config);
Sebastian Jansson97f61ea2018-02-21 12:01:5548 ~RtpTransportControllerSend() override;
Sebastian Jansson19704ec2018-03-12 14:59:1249
Stefan Holmer9416ef82018-07-19 08:34:3850 RtpVideoSenderInterface* CreateRtpVideoSender(
Stefan Holmerdbdb3a02018-07-17 14:03:4651 const std::vector<uint32_t>& ssrcs,
52 std::map<uint32_t, RtpState> suspended_ssrcs,
53 const std::map<uint32_t, RtpPayloadState>&
54 states, // move states into RtpTransportControllerSend
55 const RtpConfig& rtp_config,
Jiawei Ou55718122018-11-09 21:17:3956 int rtcp_report_interval_ms,
Stefan Holmerdbdb3a02018-07-17 14:03:4657 Transport* send_transport,
58 const RtpSenderObservers& observers,
Stefan Holmer64be7fa2018-10-04 13:21:5559 RtcEventLog* event_log,
Benjamin Wright192eeec2018-10-18 00:27:2560 std::unique_ptr<FecController> fec_controller,
61 const RtpSenderFrameEncryptionConfig& frame_encryption_config) override;
Stefan Holmer9416ef82018-07-19 08:34:3862 void DestroyRtpVideoSender(
63 RtpVideoSenderInterface* rtp_video_sender) override;
Stefan Holmerdbdb3a02018-07-17 14:03:4664
Sebastian Jansson19704ec2018-03-12 14:59:1265 // Implements NetworkChangedObserver interface.
66 void OnNetworkChanged(uint32_t bitrate_bps,
67 uint8_t fraction_loss,
68 int64_t rtt_ms,
69 int64_t probing_interval_ms) override;
70
nissecae45d02017-04-24 12:53:2071 // Implements RtpTransportControllerSendInterface
Sebastian Janssone6256052018-05-04 12:08:1572 rtc::TaskQueue* GetWorkerQueue() override;
nisse76e62b02017-05-31 09:24:5273 PacketRouter* packet_router() override;
Sebastian Jansson4c1ffb82018-02-15 15:51:5874
nisse76e62b02017-05-31 09:24:5275 TransportFeedbackObserver* transport_feedback_observer() override;
76 RtpPacketSender* packet_sender() override;
sprangdb2a9fc2017-08-09 13:42:3277 const RtpKeepAliveConfig& keepalive_config() const override;
78
Stefan Holmer5c8942a2017-08-22 14:16:4479 void SetAllocatedSendBitrateLimits(int min_send_bitrate_bps,
philipel832b1c82018-02-28 16:04:1880 int max_padding_bitrate_bps,
philipeldb4fa4b2018-03-06 17:29:2281 int max_total_bitrate_bps) override;
Stefan Holmer5c8942a2017-08-22 14:16:4482
sprangdb2a9fc2017-08-09 13:42:3283 void SetKeepAliveConfig(const RtpKeepAliveConfig& config);
Sebastian Jansson4c1ffb82018-02-15 15:51:5884 void SetPacingFactor(float pacing_factor) override;
85 void SetQueueTimeLimit(int limit_ms) override;
Sebastian Janssone4be6da2018-02-15 15:51:4186 CallStatsObserver* GetCallStatsObserver() override;
87 void RegisterPacketFeedbackObserver(
88 PacketFeedbackObserver* observer) override;
89 void DeRegisterPacketFeedbackObserver(
90 PacketFeedbackObserver* observer) override;
Sebastian Jansson19704ec2018-03-12 14:59:1291 void RegisterTargetTransferRateObserver(
92 TargetTransferRateObserver* observer) override;
Sebastian Jansson97f61ea2018-02-21 12:01:5593 void OnNetworkRouteChanged(const std::string& transport_name,
94 const rtc::NetworkRoute& network_route) override;
Sebastian Janssone4be6da2018-02-15 15:51:4195 void OnNetworkAvailability(bool network_available) override;
Sebastian Janssone4be6da2018-02-15 15:51:4196 RtcpBandwidthObserver* GetBandwidthObserver() override;
Sebastian Janssone4be6da2018-02-15 15:51:4197 int64_t GetPacerQueuingDelayMs() const override;
98 int64_t GetFirstPacketTimeMs() const override;
Sebastian Jansson12130bb2018-03-21 11:48:4399 void SetPerPacketFeedbackAvailable(bool available) override;
Sebastian Janssone4be6da2018-02-15 15:51:41100 void EnablePeriodicAlrProbing(bool enable) override;
101 void OnSentPacket(const rtc::SentPacket& sent_packet) override;
nissecae45d02017-04-24 12:53:20102
Sebastian Jansson97f61ea2018-02-21 12:01:55103 void SetSdpBitrateParameters(const BitrateConstraints& constraints) override;
Yves Gerey665174f2018-06-19 13:03:05104 void SetClientBitratePreferences(const BitrateSettings& preferences) override;
Sebastian Jansson97f61ea2018-02-21 12:01:55105
Alex Narestbcf91802018-06-25 14:08:36106 void SetAllocatedBitrateWithoutFeedback(uint32_t bitrate_bps) override;
107
Stefan Holmer64be7fa2018-10-04 13:21:55108 void OnTransportOverheadChanged(
109 size_t transport_overhead_per_packet) override;
110
nissecae45d02017-04-24 12:53:20111 private:
Sebastian Jansson19704ec2018-03-12 14:59:12112 const Clock* const clock_;
nissecae45d02017-04-24 12:53:20113 PacketRouter packet_router_;
Stefan Holmer9416ef82018-07-19 08:34:38114 std::vector<std::unique_ptr<RtpVideoSenderInterface>> video_rtp_senders_;
Stefan Holmer5c8942a2017-08-22 14:16:44115 PacedSender pacer_;
sprangdb2a9fc2017-08-09 13:42:32116 RtpKeepAliveConfig keepalive_;
Sebastian Jansson97f61ea2018-02-21 12:01:55117 RtpBitrateConfigurator bitrate_configurator_;
Sebastian Jansson91bb6672018-02-21 12:02:51118 std::map<std::string, rtc::NetworkRoute> network_routes_;
Sebastian Janssonc33c0fc2018-02-22 10:10:18119 const std::unique_ptr<ProcessThread> process_thread_;
Sebastian Jansson19704ec2018-03-12 14:59:12120 rtc::CriticalSection observer_crit_;
121 TargetTransferRateObserver* observer_ RTC_GUARDED_BY(observer_crit_);
Sebastian Janssonbd9fe092018-05-07 14:33:50122 std::unique_ptr<SendSideCongestionControllerInterface> send_side_cc_;
Stefan Holmerdbdb3a02018-07-17 14:03:46123 RateLimiter retransmission_rate_limiter_;
124
Sebastian Janssone6256052018-05-04 12:08:15125 // TODO(perkj): |task_queue_| is supposed to replace |process_thread_|.
126 // |task_queue_| is defined last to ensure all pending tasks are cancelled
127 // and deleted before any other members.
128 rtc::TaskQueue task_queue_;
nissecae45d02017-04-24 12:53:20129 RTC_DISALLOW_COPY_AND_ASSIGN(RtpTransportControllerSend);
nisseb8f9a322017-03-27 12:36:15130};
131
132} // namespace webrtc
133
Mirko Bonadei92ea95e2017-09-15 04:47:31134#endif // CALL_RTP_TRANSPORT_CONTROLLER_SEND_H_