blob: f68c4bf3dd6bc2ae7cd0d33897633879dba2b049 [file] [log] [blame]
nissecae45d02017-04-24 12:53:201/*
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_INTERFACE_H_
12#define CALL_RTP_TRANSPORT_CONTROLLER_SEND_INTERFACE_H_
Sebastian Janssone4be6da2018-02-15 15:51:4113#include <stddef.h>
14#include <stdint.h>
nissecae45d02017-04-24 12:53:2015
Stefan Holmerdbdb3a02018-07-17 14:03:4616#include <map>
Stefan Holmer64be7fa2018-10-04 13:21:5517#include <memory>
Sebastian Jansson97f61ea2018-02-21 12:01:5518#include <string>
Stefan Holmerdbdb3a02018-07-17 14:03:4619#include <vector>
Sebastian Jansson97f61ea2018-02-21 12:01:5520
Danil Chapovalovb9b146c2018-06-15 10:28:0721#include "absl/types/optional.h"
Steve Anton10542f22019-01-11 17:11:0022#include "api/crypto/crypto_options.h"
Stefan Holmer64be7fa2018-10-04 13:21:5523#include "api/fec_controller.h"
Marina Cioceae77912b2020-02-27 15:16:5524#include "api/frame_transformer_interface.h"
Danil Chapovalov83bbe912019-08-07 10:24:5325#include "api/rtc_event_log/rtc_event_log.h"
Niels Möller0c4f7be2018-05-07 12:01:3726#include "api/transport/bitrate_settings.h"
Erik Språng425d6aa2019-07-29 14:38:2727#include "api/units/timestamp.h"
Stefan Holmerdbdb3a02018-07-17 14:03:4628#include "call/rtp_config.h"
Niels Möllera8327d42020-08-25 08:28:5029#include "common_video/frame_counts.h"
Henrik Boström87e3f9d2019-05-27 08:44:2430#include "modules/rtp_rtcp/include/report_block_data.h"
Niels Möller53382cb2018-11-27 13:05:0831#include "modules/rtp_rtcp/include/rtcp_statistics.h"
Erik Språngaa59eca2019-07-24 12:52:5532#include "modules/rtp_rtcp/include/rtp_packet_sender.h"
Stefan Holmerdbdb3a02018-07-17 14:03:4633#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
Ying Wang8b279102019-05-27 15:19:0834#include "modules/rtp_rtcp/source/rtp_packet_received.h"
Sebastian Jansson97f61ea2018-02-21 12:01:5535
Sebastian Janssone4be6da2018-02-15 15:51:4136namespace rtc {
37struct SentPacket;
38struct NetworkRoute;
Sebastian Janssone6256052018-05-04 12:08:1539class TaskQueue;
Sebastian Janssone4be6da2018-02-15 15:51:4140} // namespace rtc
nissecae45d02017-04-24 12:53:2041namespace webrtc {
42
Benjamin Wright192eeec2018-10-18 00:27:2543class FrameEncryptorInterface;
Sebastian Jansson19704ec2018-03-12 14:59:1244class TargetTransferRateObserver;
Stefan Holmerdbdb3a02018-07-17 14:03:4645class Transport;
nissecae45d02017-04-24 12:53:2046class PacketRouter;
Stefan Holmer9416ef82018-07-19 08:34:3847class RtpVideoSenderInterface;
Sebastian Janssone4be6da2018-02-15 15:51:4148class RtcpBandwidthObserver;
nissecae45d02017-04-24 12:53:2049class RtpPacketSender;
nissecae45d02017-04-24 12:53:2050
Stefan Holmerdbdb3a02018-07-17 14:03:4651struct RtpSenderObservers {
52 RtcpRttStats* rtcp_rtt_stats;
53 RtcpIntraFrameObserver* intra_frame_callback;
Elad Alon0a8562e2019-04-09 09:55:1354 RtcpLossNotificationObserver* rtcp_loss_notification_observer;
Henrik Boström87e3f9d2019-05-27 08:44:2455 ReportBlockDataObserver* report_block_data_observer;
Stefan Holmerdbdb3a02018-07-17 14:03:4656 StreamDataCountersCallback* rtp_stats;
57 BitrateStatisticsObserver* bitrate_observer;
58 FrameCountObserver* frame_count_observer;
59 RtcpPacketTypeCounterObserver* rtcp_type_observer;
60 SendSideDelayObserver* send_delay_observer;
61 SendPacketObserver* send_packet_observer;
Stefan Holmerdbdb3a02018-07-17 14:03:4662};
63
Benjamin Wright192eeec2018-10-18 00:27:2564struct RtpSenderFrameEncryptionConfig {
65 FrameEncryptorInterface* frame_encryptor = nullptr;
66 CryptoOptions crypto_options;
67};
68
nissecae45d02017-04-24 12:53:2069// An RtpTransportController should own everything related to the RTP
70// transport to/from a remote endpoint. We should have separate
71// interfaces for send and receive side, even if they are implemented
72// by the same class. This is an ongoing refactoring project. At some
73// point, this class should be promoted to a public api under
74// webrtc/api/rtp/.
75//
76// For a start, this object is just a collection of the objects needed
77// by the VideoSendStream constructor. The plan is to move ownership
78// of all RTP-related objects here, and add methods to create per-ssrc
79// objects which would then be passed to VideoSendStream. Eventually,
80// direct accessors like packet_router() should be removed.
81//
82// This should also have a reference to the underlying
83// webrtc::Transport(s). Currently, webrtc::Transport is implemented by
eladalonf1841382017-06-12 08:16:4684// WebRtcVideoChannel and WebRtcVoiceMediaChannel, and owned by
nissecae45d02017-04-24 12:53:2085// WebrtcSession. Video and audio always uses different transport
86// objects, even in the common case where they are bundled over the
87// same underlying transport.
88//
89// Extracting the logic of the webrtc::Transport from BaseChannel and
90// subclasses into a separate class seems to be a prerequesite for
91// moving the transport here.
92class RtpTransportControllerSendInterface {
93 public:
94 virtual ~RtpTransportControllerSendInterface() {}
Sebastian Janssone6256052018-05-04 12:08:1595 virtual rtc::TaskQueue* GetWorkerQueue() = 0;
nissecae45d02017-04-24 12:53:2096 virtual PacketRouter* packet_router() = 0;
Stefan Holmerdbdb3a02018-07-17 14:03:4697
Stefan Holmer9416ef82018-07-19 08:34:3898 virtual RtpVideoSenderInterface* CreateRtpVideoSender(
Tommi86952822021-11-29 09:26:4099 const std::map<uint32_t, RtpState>& suspended_ssrcs,
Stefan Holmerdbdb3a02018-07-17 14:03:46100 // TODO(holmer): Move states into RtpTransportControllerSend.
101 const std::map<uint32_t, RtpPayloadState>& states,
102 const RtpConfig& rtp_config,
Jiawei Ou55718122018-11-09 21:17:39103 int rtcp_report_interval_ms,
Stefan Holmerdbdb3a02018-07-17 14:03:46104 Transport* send_transport,
105 const RtpSenderObservers& observers,
Stefan Holmer64be7fa2018-10-04 13:21:55106 RtcEventLog* event_log,
Benjamin Wright192eeec2018-10-18 00:27:25107 std::unique_ptr<FecController> fec_controller,
Marina Cioceae77912b2020-02-27 15:16:55108 const RtpSenderFrameEncryptionConfig& frame_encryption_config,
109 rtc::scoped_refptr<FrameTransformerInterface> frame_transformer) = 0;
Stefan Holmer9416ef82018-07-19 08:34:38110 virtual void DestroyRtpVideoSender(
111 RtpVideoSenderInterface* rtp_video_sender) = 0;
Stefan Holmerdbdb3a02018-07-17 14:03:46112
Sebastian Janssone1795f42019-07-24 09:38:03113 virtual NetworkStateEstimateObserver* network_state_estimate_observer() = 0;
nissecae45d02017-04-24 12:53:20114 virtual TransportFeedbackObserver* transport_feedback_observer() = 0;
115
Erik Språngaa59eca2019-07-24 12:52:55116 virtual RtpPacketSender* packet_sender() = 0;
Stefan Holmer5c8942a2017-08-22 14:16:44117
118 // SetAllocatedSendBitrateLimits sets bitrates limits imposed by send codec
119 // settings.
Sebastian Jansson93b1ea22019-09-18 16:31:52120 virtual void SetAllocatedSendBitrateLimits(
121 BitrateAllocationLimits limits) = 0;
Sebastian Janssone4be6da2018-02-15 15:51:41122
Sebastian Jansson4c1ffb82018-02-15 15:51:58123 virtual void SetPacingFactor(float pacing_factor) = 0;
124 virtual void SetQueueTimeLimit(int limit_ms) = 0;
125
Sebastian Janssonf2988552019-10-29 16:18:51126 virtual StreamFeedbackProvider* GetStreamFeedbackProvider() = 0;
Sebastian Jansson19704ec2018-03-12 14:59:12127 virtual void RegisterTargetTransferRateObserver(
128 TargetTransferRateObserver* observer) = 0;
Sebastian Jansson97f61ea2018-02-21 12:01:55129 virtual void OnNetworkRouteChanged(
130 const std::string& transport_name,
131 const rtc::NetworkRoute& network_route) = 0;
Sebastian Janssone4be6da2018-02-15 15:51:41132 virtual void OnNetworkAvailability(bool network_available) = 0;
Sebastian Janssone4be6da2018-02-15 15:51:41133 virtual RtcpBandwidthObserver* GetBandwidthObserver() = 0;
Sebastian Janssone4be6da2018-02-15 15:51:41134 virtual int64_t GetPacerQueuingDelayMs() const = 0;
Erik Språng425d6aa2019-07-29 14:38:27135 virtual absl::optional<Timestamp> GetFirstPacketTime() const = 0;
Sebastian Janssone4be6da2018-02-15 15:51:41136 virtual void EnablePeriodicAlrProbing(bool enable) = 0;
Tomas Gunnarssoneb9c3f22021-04-19 10:53:09137
138 // Called when a packet has been sent.
139 // The call should arrive on the network thread, but may not in all cases
140 // (some tests don't adhere to this). Implementations today should not block
141 // the calling thread or make assumptions about the thread context.
Sebastian Janssone4be6da2018-02-15 15:51:41142 virtual void OnSentPacket(const rtc::SentPacket& sent_packet) = 0;
Tomas Gunnarssoneb9c3f22021-04-19 10:53:09143
Sebastian Jansson607a6f12019-06-13 15:48:53144 virtual void OnReceivedPacket(const ReceivedPacket& received_packet) = 0;
Sebastian Jansson97f61ea2018-02-21 12:01:55145
146 virtual void SetSdpBitrateParameters(
147 const BitrateConstraints& constraints) = 0;
148 virtual void SetClientBitratePreferences(
Niels Möller0c4f7be2018-05-07 12:01:37149 const BitrateSettings& preferences) = 0;
Alex Narestbcf91802018-06-25 14:08:36150
Stefan Holmer64be7fa2018-10-04 13:21:55151 virtual void OnTransportOverheadChanged(
152 size_t transport_overhead_per_packet) = 0;
Erik Språngaa59eca2019-07-24 12:52:55153
154 virtual void AccountForAudioPacketsInPacedSender(bool account_for_audio) = 0;
Sebastian Janssonc3eb9fd2020-01-29 16:42:52155 virtual void IncludeOverheadInPacedSender() = 0;
Erik Språng7703f232020-09-14 09:03:13156
157 virtual void EnsureStarted() = 0;
nissecae45d02017-04-24 12:53:20158};
159
160} // namespace webrtc
161
Mirko Bonadei92ea95e2017-09-15 04:47:31162#endif // CALL_RTP_TRANSPORT_CONTROLLER_SEND_INTERFACE_H_