• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
11 #ifndef CALL_RTP_TRANSPORT_CONTROLLER_SEND_INTERFACE_H_
12 #define CALL_RTP_TRANSPORT_CONTROLLER_SEND_INTERFACE_H_
13 #include <stddef.h>
14 #include <stdint.h>
15 
16 #include <map>
17 #include <memory>
18 #include <string>
19 #include <vector>
20 
21 #include "absl/types/optional.h"
22 #include "api/crypto/crypto_options.h"
23 #include "api/fec_controller.h"
24 #include "api/frame_transformer_interface.h"
25 #include "api/rtc_event_log/rtc_event_log.h"
26 #include "api/transport/bitrate_settings.h"
27 #include "api/units/timestamp.h"
28 #include "call/rtp_config.h"
29 #include "modules/rtp_rtcp/include/report_block_data.h"
30 #include "modules/rtp_rtcp/include/rtcp_statistics.h"
31 #include "modules/rtp_rtcp/include/rtp_packet_sender.h"
32 #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
33 #include "modules/rtp_rtcp/source/rtp_packet_received.h"
34 
35 namespace rtc {
36 struct SentPacket;
37 struct NetworkRoute;
38 class TaskQueue;
39 }  // namespace rtc
40 namespace webrtc {
41 
42 class CallStatsObserver;
43 class FrameEncryptorInterface;
44 class TargetTransferRateObserver;
45 class Transport;
46 class Module;
47 class PacedSender;
48 class PacketRouter;
49 class RtpVideoSenderInterface;
50 class RateLimiter;
51 class RtcpBandwidthObserver;
52 class RtpPacketSender;
53 class SendDelayStats;
54 class SendStatisticsProxy;
55 
56 struct RtpSenderObservers {
57   RtcpRttStats* rtcp_rtt_stats;
58   RtcpIntraFrameObserver* intra_frame_callback;
59   RtcpLossNotificationObserver* rtcp_loss_notification_observer;
60   RtcpStatisticsCallback* rtcp_stats;
61   ReportBlockDataObserver* report_block_data_observer;
62   StreamDataCountersCallback* rtp_stats;
63   BitrateStatisticsObserver* bitrate_observer;
64   FrameCountObserver* frame_count_observer;
65   RtcpPacketTypeCounterObserver* rtcp_type_observer;
66   SendSideDelayObserver* send_delay_observer;
67   SendPacketObserver* send_packet_observer;
68 };
69 
70 struct RtpSenderFrameEncryptionConfig {
71   FrameEncryptorInterface* frame_encryptor = nullptr;
72   CryptoOptions crypto_options;
73 };
74 
75 // An RtpTransportController should own everything related to the RTP
76 // transport to/from a remote endpoint. We should have separate
77 // interfaces for send and receive side, even if they are implemented
78 // by the same class. This is an ongoing refactoring project. At some
79 // point, this class should be promoted to a public api under
80 // webrtc/api/rtp/.
81 //
82 // For a start, this object is just a collection of the objects needed
83 // by the VideoSendStream constructor. The plan is to move ownership
84 // of all RTP-related objects here, and add methods to create per-ssrc
85 // objects which would then be passed to VideoSendStream. Eventually,
86 // direct accessors like packet_router() should be removed.
87 //
88 // This should also have a reference to the underlying
89 // webrtc::Transport(s). Currently, webrtc::Transport is implemented by
90 // WebRtcVideoChannel and WebRtcVoiceMediaChannel, and owned by
91 // WebrtcSession. Video and audio always uses different transport
92 // objects, even in the common case where they are bundled over the
93 // same underlying transport.
94 //
95 // Extracting the logic of the webrtc::Transport from BaseChannel and
96 // subclasses into a separate class seems to be a prerequesite for
97 // moving the transport here.
98 class RtpTransportControllerSendInterface {
99  public:
~RtpTransportControllerSendInterface()100   virtual ~RtpTransportControllerSendInterface() {}
101   virtual rtc::TaskQueue* GetWorkerQueue() = 0;
102   virtual PacketRouter* packet_router() = 0;
103 
104   virtual RtpVideoSenderInterface* CreateRtpVideoSender(
105       std::map<uint32_t, RtpState> suspended_ssrcs,
106       // TODO(holmer): Move states into RtpTransportControllerSend.
107       const std::map<uint32_t, RtpPayloadState>& states,
108       const RtpConfig& rtp_config,
109       int rtcp_report_interval_ms,
110       Transport* send_transport,
111       const RtpSenderObservers& observers,
112       RtcEventLog* event_log,
113       std::unique_ptr<FecController> fec_controller,
114       const RtpSenderFrameEncryptionConfig& frame_encryption_config,
115       rtc::scoped_refptr<FrameTransformerInterface> frame_transformer) = 0;
116   virtual void DestroyRtpVideoSender(
117       RtpVideoSenderInterface* rtp_video_sender) = 0;
118 
119   virtual NetworkStateEstimateObserver* network_state_estimate_observer() = 0;
120   virtual TransportFeedbackObserver* transport_feedback_observer() = 0;
121 
122   virtual RtpPacketSender* packet_sender() = 0;
123 
124   // SetAllocatedSendBitrateLimits sets bitrates limits imposed by send codec
125   // settings.
126   virtual void SetAllocatedSendBitrateLimits(
127       BitrateAllocationLimits limits) = 0;
128 
129   virtual void SetPacingFactor(float pacing_factor) = 0;
130   virtual void SetQueueTimeLimit(int limit_ms) = 0;
131 
132   virtual StreamFeedbackProvider* GetStreamFeedbackProvider() = 0;
133   virtual void RegisterTargetTransferRateObserver(
134       TargetTransferRateObserver* observer) = 0;
135   virtual void OnNetworkRouteChanged(
136       const std::string& transport_name,
137       const rtc::NetworkRoute& network_route) = 0;
138   virtual void OnNetworkAvailability(bool network_available) = 0;
139   virtual RtcpBandwidthObserver* GetBandwidthObserver() = 0;
140   virtual int64_t GetPacerQueuingDelayMs() const = 0;
141   virtual absl::optional<Timestamp> GetFirstPacketTime() const = 0;
142   virtual void EnablePeriodicAlrProbing(bool enable) = 0;
143   virtual void OnSentPacket(const rtc::SentPacket& sent_packet) = 0;
144   virtual void OnReceivedPacket(const ReceivedPacket& received_packet) = 0;
145 
146   virtual void SetSdpBitrateParameters(
147       const BitrateConstraints& constraints) = 0;
148   virtual void SetClientBitratePreferences(
149       const BitrateSettings& preferences) = 0;
150 
151   virtual void OnTransportOverheadChanged(
152       size_t transport_overhead_per_packet) = 0;
153 
154   virtual void AccountForAudioPacketsInPacedSender(bool account_for_audio) = 0;
155   virtual void IncludeOverheadInPacedSender() = 0;
156 };
157 
158 }  // namespace webrtc
159 
160 #endif  // CALL_RTP_TRANSPORT_CONTROLLER_SEND_INTERFACE_H_
161