blob: b40aabdc2c6a0d3750f1c6956b8d22c12924e187 [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"
Steve Anton10542f22019-01-11 09:11:00 -080022#include "api/crypto/crypto_options.h"
Stefan Holmer64be7fa2018-10-04 15:21:55 +020023#include "api/fec_controller.h"
Danil Chapovalov83bbe912019-08-07 12:24:53 +020024#include "api/rtc_event_log/rtc_event_log.h"
Niels Möller0c4f7be2018-05-07 14:01:37 +020025#include "api/transport/bitrate_settings.h"
Erik Språng425d6aa2019-07-29 16:38:27 +020026#include "api/units/timestamp.h"
Stefan Holmerdbdb3a02018-07-17 16:03:46 +020027#include "call/rtp_config.h"
Henrik Boström87e3f9d2019-05-27 10:44:24 +020028#include "modules/rtp_rtcp/include/report_block_data.h"
Niels Möller53382cb2018-11-27 14:05:08 +010029#include "modules/rtp_rtcp/include/rtcp_statistics.h"
Erik Språngaa59eca2019-07-24 14:52:55 +020030#include "modules/rtp_rtcp/include/rtp_packet_sender.h"
Stefan Holmerdbdb3a02018-07-17 16:03:46 +020031#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
Ying Wang8b279102019-05-27 17:19:08 +020032#include "modules/rtp_rtcp/source/rtp_packet_received.h"
Sebastian Jansson97f61ea2018-02-21 13:01:55 +010033
Sebastian Janssone4be6da2018-02-15 16:51:41 +010034namespace rtc {
35struct SentPacket;
36struct NetworkRoute;
Sebastian Janssone6256052018-05-04 14:08:15 +020037class TaskQueue;
Sebastian Janssone4be6da2018-02-15 16:51:41 +010038} // namespace rtc
nissecae45d02017-04-24 05:53:20 -070039namespace webrtc {
40
Sebastian Janssone4be6da2018-02-15 16:51:41 +010041class CallStatsObserver;
Benjamin Wright192eeec2018-10-17 17:27:25 -070042class FrameEncryptorInterface;
Sebastian Jansson19704ec2018-03-12 15:59:12 +010043class TargetTransferRateObserver;
Stefan Holmerdbdb3a02018-07-17 16:03:46 +020044class Transport;
Sebastian Janssone4be6da2018-02-15 16:51:41 +010045class Module;
Stefan Holmer5c8942a2017-08-22 16:16:44 +020046class PacedSender;
nissecae45d02017-04-24 05:53:20 -070047class PacketRouter;
Stefan Holmer9416ef82018-07-19 10:34:38 +020048class RtpVideoSenderInterface;
Sebastian Janssone4be6da2018-02-15 16:51:41 +010049class RateLimiter;
50class RtcpBandwidthObserver;
nissecae45d02017-04-24 05:53:20 -070051class RtpPacketSender;
Stefan Holmerdbdb3a02018-07-17 16:03:46 +020052class SendDelayStats;
53class SendStatisticsProxy;
nissecae45d02017-04-24 05:53:20 -070054
Stefan Holmerdbdb3a02018-07-17 16:03:46 +020055struct RtpSenderObservers {
56 RtcpRttStats* rtcp_rtt_stats;
57 RtcpIntraFrameObserver* intra_frame_callback;
Elad Alon0a8562e2019-04-09 11:55:13 +020058 RtcpLossNotificationObserver* rtcp_loss_notification_observer;
Stefan Holmerdbdb3a02018-07-17 16:03:46 +020059 RtcpStatisticsCallback* rtcp_stats;
Henrik Boström87e3f9d2019-05-27 10:44:24 +020060 ReportBlockDataObserver* report_block_data_observer;
Stefan Holmerdbdb3a02018-07-17 16:03:46 +020061 StreamDataCountersCallback* rtp_stats;
62 BitrateStatisticsObserver* bitrate_observer;
63 FrameCountObserver* frame_count_observer;
64 RtcpPacketTypeCounterObserver* rtcp_type_observer;
65 SendSideDelayObserver* send_delay_observer;
66 SendPacketObserver* send_packet_observer;
Stefan Holmerdbdb3a02018-07-17 16:03:46 +020067};
68
Benjamin Wright192eeec2018-10-17 17:27:25 -070069struct RtpSenderFrameEncryptionConfig {
70 FrameEncryptorInterface* frame_encryptor = nullptr;
71 CryptoOptions crypto_options;
72};
73
nissecae45d02017-04-24 05:53:20 -070074// An RtpTransportController should own everything related to the RTP
75// transport to/from a remote endpoint. We should have separate
76// interfaces for send and receive side, even if they are implemented
77// by the same class. This is an ongoing refactoring project. At some
78// point, this class should be promoted to a public api under
79// webrtc/api/rtp/.
80//
81// For a start, this object is just a collection of the objects needed
82// by the VideoSendStream constructor. The plan is to move ownership
83// of all RTP-related objects here, and add methods to create per-ssrc
84// objects which would then be passed to VideoSendStream. Eventually,
85// direct accessors like packet_router() should be removed.
86//
87// This should also have a reference to the underlying
88// webrtc::Transport(s). Currently, webrtc::Transport is implemented by
eladalonf1841382017-06-12 01:16:46 -070089// WebRtcVideoChannel and WebRtcVoiceMediaChannel, and owned by
nissecae45d02017-04-24 05:53:20 -070090// WebrtcSession. Video and audio always uses different transport
91// objects, even in the common case where they are bundled over the
92// same underlying transport.
93//
94// Extracting the logic of the webrtc::Transport from BaseChannel and
95// subclasses into a separate class seems to be a prerequesite for
96// moving the transport here.
97class RtpTransportControllerSendInterface {
98 public:
99 virtual ~RtpTransportControllerSendInterface() {}
Sebastian Janssone6256052018-05-04 14:08:15 +0200100 virtual rtc::TaskQueue* GetWorkerQueue() = 0;
nissecae45d02017-04-24 05:53:20 -0700101 virtual PacketRouter* packet_router() = 0;
Stefan Holmerdbdb3a02018-07-17 16:03:46 +0200102
Stefan Holmer9416ef82018-07-19 10:34:38 +0200103 virtual RtpVideoSenderInterface* CreateRtpVideoSender(
Stefan Holmerdbdb3a02018-07-17 16:03:46 +0200104 std::map<uint32_t, RtpState> suspended_ssrcs,
105 // TODO(holmer): Move states into RtpTransportControllerSend.
106 const std::map<uint32_t, RtpPayloadState>& states,
107 const RtpConfig& rtp_config,
Jiawei Ou55718122018-11-09 13:17:39 -0800108 int rtcp_report_interval_ms,
Stefan Holmerdbdb3a02018-07-17 16:03:46 +0200109 Transport* send_transport,
110 const RtpSenderObservers& observers,
Stefan Holmer64be7fa2018-10-04 15:21:55 +0200111 RtcEventLog* event_log,
Benjamin Wright192eeec2018-10-17 17:27:25 -0700112 std::unique_ptr<FecController> fec_controller,
113 const RtpSenderFrameEncryptionConfig& frame_encryption_config) = 0;
Stefan Holmer9416ef82018-07-19 10:34:38 +0200114 virtual void DestroyRtpVideoSender(
115 RtpVideoSenderInterface* rtp_video_sender) = 0;
Stefan Holmerdbdb3a02018-07-17 16:03:46 +0200116
Sebastian Janssone1795f42019-07-24 11:38:03 +0200117 virtual NetworkStateEstimateObserver* network_state_estimate_observer() = 0;
nissecae45d02017-04-24 05:53:20 -0700118 virtual TransportFeedbackObserver* transport_feedback_observer() = 0;
119
Erik Språngaa59eca2019-07-24 14:52:55 +0200120 virtual RtpPacketSender* packet_sender() = 0;
Stefan Holmer5c8942a2017-08-22 16:16:44 +0200121
122 // SetAllocatedSendBitrateLimits sets bitrates limits imposed by send codec
123 // settings.
Sebastian Jansson93b1ea22019-09-18 18:31:52 +0200124 virtual void SetAllocatedSendBitrateLimits(
125 BitrateAllocationLimits limits) = 0;
Sebastian Janssone4be6da2018-02-15 16:51:41 +0100126
Sebastian Jansson4c1ffb82018-02-15 16:51:58 +0100127 virtual void SetPacingFactor(float pacing_factor) = 0;
128 virtual void SetQueueTimeLimit(int limit_ms) = 0;
129
Sebastian Janssonf2988552019-10-29 17:18:51 +0100130 virtual StreamFeedbackProvider* GetStreamFeedbackProvider() = 0;
Sebastian Jansson19704ec2018-03-12 15:59:12 +0100131 virtual void RegisterTargetTransferRateObserver(
132 TargetTransferRateObserver* observer) = 0;
Sebastian Jansson97f61ea2018-02-21 13:01:55 +0100133 virtual void OnNetworkRouteChanged(
134 const std::string& transport_name,
135 const rtc::NetworkRoute& network_route) = 0;
Sebastian Janssone4be6da2018-02-15 16:51:41 +0100136 virtual void OnNetworkAvailability(bool network_available) = 0;
Sebastian Janssone4be6da2018-02-15 16:51:41 +0100137 virtual RtcpBandwidthObserver* GetBandwidthObserver() = 0;
Sebastian Janssone4be6da2018-02-15 16:51:41 +0100138 virtual int64_t GetPacerQueuingDelayMs() const = 0;
Erik Språng425d6aa2019-07-29 16:38:27 +0200139 virtual absl::optional<Timestamp> GetFirstPacketTime() const = 0;
Sebastian Janssone4be6da2018-02-15 16:51:41 +0100140 virtual void EnablePeriodicAlrProbing(bool enable) = 0;
141 virtual void OnSentPacket(const rtc::SentPacket& sent_packet) = 0;
Sebastian Jansson607a6f12019-06-13 17:48:53 +0200142 virtual void OnReceivedPacket(const ReceivedPacket& received_packet) = 0;
Sebastian Jansson97f61ea2018-02-21 13:01:55 +0100143
144 virtual void SetSdpBitrateParameters(
145 const BitrateConstraints& constraints) = 0;
146 virtual void SetClientBitratePreferences(
Niels Möller0c4f7be2018-05-07 14:01:37 +0200147 const BitrateSettings& preferences) = 0;
Alex Narestbcf91802018-06-25 16:08:36 +0200148
Stefan Holmer64be7fa2018-10-04 15:21:55 +0200149 virtual void OnTransportOverheadChanged(
150 size_t transport_overhead_per_packet) = 0;
Erik Språngaa59eca2019-07-24 14:52:55 +0200151
152 virtual void AccountForAudioPacketsInPacedSender(bool account_for_audio) = 0;
Sebastian Janssonc3eb9fd2020-01-29 17:42:52 +0100153 virtual void IncludeOverheadInPacedSender() = 0;
nissecae45d02017-04-24 05:53:20 -0700154};
155
156} // namespace webrtc
157
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200158#endif // CALL_RTP_TRANSPORT_CONTROLLER_SEND_INTERFACE_H_