blob: 32862d8dd4560b1b70d9b8600a7bea4b1210d34f [file] [log] [blame]
nissecae45d02017-04-24 05:53:20 -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_INTERFACE_H_
12#define CALL_RTP_TRANSPORT_CONTROLLER_SEND_INTERFACE_H_
Sebastian Janssone4be6da2018-02-15 16:51:41 +010013#include <stddef.h>
14#include <stdint.h>
nissecae45d02017-04-24 05:53:20 -070015
Stefan Holmerdbdb3a02018-07-17 16:03:46 +020016#include <map>
Stefan Holmer64be7fa2018-10-04 15:21:55 +020017#include <memory>
Sebastian Jansson97f61ea2018-02-21 13:01:55 +010018#include <string>
Stefan Holmerdbdb3a02018-07-17 16:03:46 +020019#include <vector>
Sebastian Jansson97f61ea2018-02-21 13:01:55 +010020
Danil Chapovalovb9b146c2018-06-15 12:28:07 +020021#include "absl/types/optional.h"
Patrik Höglundb6b29e02018-06-21 16:58:01 +020022#include "api/bitrate_constraints.h"
Steve Anton10542f22019-01-11 09:11:00 -080023#include "api/crypto/crypto_options.h"
Stefan Holmer64be7fa2018-10-04 15:21:55 +020024#include "api/fec_controller.h"
Niels Möller0c4f7be2018-05-07 14:01:37 +020025#include "api/transport/bitrate_settings.h"
Stefan Holmerdbdb3a02018-07-17 16:03:46 +020026#include "call/rtp_config.h"
27#include "logging/rtc_event_log/rtc_event_log.h"
Niels Möller53382cb2018-11-27 14:05:08 +010028#include "modules/rtp_rtcp/include/rtcp_statistics.h"
Stefan Holmerdbdb3a02018-07-17 16:03:46 +020029#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
Sebastian Jansson97f61ea2018-02-21 13:01:55 +010030
Sebastian Janssone4be6da2018-02-15 16:51:41 +010031namespace rtc {
32struct SentPacket;
33struct NetworkRoute;
Sebastian Janssone6256052018-05-04 14:08:15 +020034class TaskQueue;
Sebastian Janssone4be6da2018-02-15 16:51:41 +010035} // namespace rtc
nissecae45d02017-04-24 05:53:20 -070036namespace webrtc {
37
Sebastian Janssone4be6da2018-02-15 16:51:41 +010038class CallStatsObserver;
Benjamin Wright192eeec2018-10-17 17:27:25 -070039class FrameEncryptorInterface;
Sebastian Jansson19704ec2018-03-12 15:59:12 +010040class TargetTransferRateObserver;
Stefan Holmerdbdb3a02018-07-17 16:03:46 +020041class Transport;
Sebastian Janssone4be6da2018-02-15 16:51:41 +010042class Module;
Stefan Holmer5c8942a2017-08-22 16:16:44 +020043class PacedSender;
Sebastian Janssone4be6da2018-02-15 16:51:41 +010044class PacketFeedbackObserver;
nissecae45d02017-04-24 05:53:20 -070045class PacketRouter;
Stefan Holmer9416ef82018-07-19 10:34:38 +020046class RtpVideoSenderInterface;
Sebastian Janssone4be6da2018-02-15 16:51:41 +010047class RateLimiter;
48class RtcpBandwidthObserver;
nissecae45d02017-04-24 05:53:20 -070049class RtpPacketSender;
Stefan Holmerdbdb3a02018-07-17 16:03:46 +020050class SendDelayStats;
51class SendStatisticsProxy;
nissecae45d02017-04-24 05:53:20 -070052class TransportFeedbackObserver;
53
Stefan Holmerdbdb3a02018-07-17 16:03:46 +020054struct RtpSenderObservers {
55 RtcpRttStats* rtcp_rtt_stats;
56 RtcpIntraFrameObserver* intra_frame_callback;
57 RtcpStatisticsCallback* rtcp_stats;
58 StreamDataCountersCallback* rtp_stats;
59 BitrateStatisticsObserver* bitrate_observer;
60 FrameCountObserver* frame_count_observer;
61 RtcpPacketTypeCounterObserver* rtcp_type_observer;
62 SendSideDelayObserver* send_delay_observer;
63 SendPacketObserver* send_packet_observer;
Stefan Holmerdbdb3a02018-07-17 16:03:46 +020064};
65
Benjamin Wright192eeec2018-10-17 17:27:25 -070066struct RtpSenderFrameEncryptionConfig {
67 FrameEncryptorInterface* frame_encryptor = nullptr;
68 CryptoOptions crypto_options;
69};
70
nissecae45d02017-04-24 05:53:20 -070071// An RtpTransportController should own everything related to the RTP
72// transport to/from a remote endpoint. We should have separate
73// interfaces for send and receive side, even if they are implemented
74// by the same class. This is an ongoing refactoring project. At some
75// point, this class should be promoted to a public api under
76// webrtc/api/rtp/.
77//
78// For a start, this object is just a collection of the objects needed
79// by the VideoSendStream constructor. The plan is to move ownership
80// of all RTP-related objects here, and add methods to create per-ssrc
81// objects which would then be passed to VideoSendStream. Eventually,
82// direct accessors like packet_router() should be removed.
83//
84// This should also have a reference to the underlying
85// webrtc::Transport(s). Currently, webrtc::Transport is implemented by
eladalonf1841382017-06-12 01:16:46 -070086// WebRtcVideoChannel and WebRtcVoiceMediaChannel, and owned by
nissecae45d02017-04-24 05:53:20 -070087// WebrtcSession. Video and audio always uses different transport
88// objects, even in the common case where they are bundled over the
89// same underlying transport.
90//
91// Extracting the logic of the webrtc::Transport from BaseChannel and
92// subclasses into a separate class seems to be a prerequesite for
93// moving the transport here.
94class RtpTransportControllerSendInterface {
95 public:
96 virtual ~RtpTransportControllerSendInterface() {}
Sebastian Janssone6256052018-05-04 14:08:15 +020097 virtual rtc::TaskQueue* GetWorkerQueue() = 0;
nissecae45d02017-04-24 05:53:20 -070098 virtual PacketRouter* packet_router() = 0;
Stefan Holmerdbdb3a02018-07-17 16:03:46 +020099
Stefan Holmer9416ef82018-07-19 10:34:38 +0200100 virtual RtpVideoSenderInterface* CreateRtpVideoSender(
Stefan Holmerdbdb3a02018-07-17 16:03:46 +0200101 std::map<uint32_t, RtpState> suspended_ssrcs,
102 // TODO(holmer): Move states into RtpTransportControllerSend.
103 const std::map<uint32_t, RtpPayloadState>& states,
104 const RtpConfig& rtp_config,
Jiawei Ou55718122018-11-09 13:17:39 -0800105 int rtcp_report_interval_ms,
Stefan Holmerdbdb3a02018-07-17 16:03:46 +0200106 Transport* send_transport,
Ilya Nikolaevskiyab65d8a2019-03-28 14:53:04 +0100107 bool is_svc,
Stefan Holmerdbdb3a02018-07-17 16:03:46 +0200108 const RtpSenderObservers& observers,
Stefan Holmer64be7fa2018-10-04 15:21:55 +0200109 RtcEventLog* event_log,
Benjamin Wright192eeec2018-10-17 17:27:25 -0700110 std::unique_ptr<FecController> fec_controller,
111 const RtpSenderFrameEncryptionConfig& frame_encryption_config) = 0;
Stefan Holmer9416ef82018-07-19 10:34:38 +0200112 virtual void DestroyRtpVideoSender(
113 RtpVideoSenderInterface* rtp_video_sender) = 0;
Stefan Holmerdbdb3a02018-07-17 16:03:46 +0200114
nissecae45d02017-04-24 05:53:20 -0700115 virtual TransportFeedbackObserver* transport_feedback_observer() = 0;
116
117 virtual RtpPacketSender* packet_sender() = 0;
Stefan Holmer5c8942a2017-08-22 16:16:44 +0200118
119 // SetAllocatedSendBitrateLimits sets bitrates limits imposed by send codec
120 // settings.
121 // |min_send_bitrate_bps| is the total minimum send bitrate required by all
122 // sending streams. This is the minimum bitrate the PacedSender will use.
123 // Note that SendSideCongestionController::OnNetworkChanged can still be
124 // called with a lower bitrate estimate. |max_padding_bitrate_bps| is the max
125 // bitrate the send streams request for padding. This can be higher than the
126 // current network estimate and tells the PacedSender how much it should max
127 // pad unless there is real packets to send.
128 virtual void SetAllocatedSendBitrateLimits(int min_send_bitrate_bps,
philipel832b1c82018-02-28 17:04:18 +0100129 int max_padding_bitrate_bps,
130 int total_bitrate_bps) = 0;
Sebastian Janssone4be6da2018-02-15 16:51:41 +0100131
Sebastian Jansson4c1ffb82018-02-15 16:51:58 +0100132 virtual void SetPacingFactor(float pacing_factor) = 0;
133 virtual void SetQueueTimeLimit(int limit_ms) = 0;
134
Sebastian Janssone4be6da2018-02-15 16:51:41 +0100135 virtual void RegisterPacketFeedbackObserver(
136 PacketFeedbackObserver* observer) = 0;
137 virtual void DeRegisterPacketFeedbackObserver(
138 PacketFeedbackObserver* observer) = 0;
Sebastian Jansson19704ec2018-03-12 15:59:12 +0100139 virtual void RegisterTargetTransferRateObserver(
140 TargetTransferRateObserver* observer) = 0;
Sebastian Jansson97f61ea2018-02-21 13:01:55 +0100141 virtual void OnNetworkRouteChanged(
142 const std::string& transport_name,
143 const rtc::NetworkRoute& network_route) = 0;
Sebastian Janssone4be6da2018-02-15 16:51:41 +0100144 virtual void OnNetworkAvailability(bool network_available) = 0;
Sebastian Janssone4be6da2018-02-15 16:51:41 +0100145 virtual RtcpBandwidthObserver* GetBandwidthObserver() = 0;
Sebastian Janssone4be6da2018-02-15 16:51:41 +0100146 virtual int64_t GetPacerQueuingDelayMs() const = 0;
147 virtual int64_t GetFirstPacketTimeMs() const = 0;
Sebastian Janssone4be6da2018-02-15 16:51:41 +0100148 virtual void EnablePeriodicAlrProbing(bool enable) = 0;
149 virtual void OnSentPacket(const rtc::SentPacket& sent_packet) = 0;
Sebastian Jansson97f61ea2018-02-21 13:01:55 +0100150
151 virtual void SetSdpBitrateParameters(
152 const BitrateConstraints& constraints) = 0;
153 virtual void SetClientBitratePreferences(
Niels Möller0c4f7be2018-05-07 14:01:37 +0200154 const BitrateSettings& preferences) = 0;
Alex Narestbcf91802018-06-25 16:08:36 +0200155
Stefan Holmer64be7fa2018-10-04 15:21:55 +0200156 virtual void OnTransportOverheadChanged(
157 size_t transport_overhead_per_packet) = 0;
nissecae45d02017-04-24 05:53:20 -0700158};
159
160} // namespace webrtc
161
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200162#endif // CALL_RTP_TRANSPORT_CONTROLLER_SEND_INTERFACE_H_