blob: 758e4d3238df8399407e84c8e10ab6d5519f4611 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
pwestin@webrtc.orgf6bb77a2012-01-24 17:16:59 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
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 WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_H_
12#define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_H_
pbos@webrtc.org12dc1a32013-08-05 16:22:53 +000013
pwestin@webrtc.org00741872012-01-19 15:56:10 +000014#include <map>
kwiberg84be5112016-04-27 01:19:58 -070015#include <memory>
danilchapb8b6fbb2015-12-10 05:05:27 -080016#include <utility>
17#include <vector>
pwestin@webrtc.org00741872012-01-19 15:56:10 +000018
kwiberg4485ffb2016-04-26 08:14:39 -070019#include "webrtc/base/constructormagic.h"
tommiae695e92016-02-02 08:31:45 -080020#include "webrtc/base/criticalsection.h"
danilchap7bfe3a22016-09-19 05:37:56 -070021#include "webrtc/base/deprecation.h"
brandtr9dfff292016-11-14 05:14:50 -080022#include "webrtc/base/optional.h"
danilchap47a740b2015-12-15 00:30:07 -080023#include "webrtc/base/random.h"
sprangcd349d92016-07-13 09:11:28 -070024#include "webrtc/base/rate_statistics.h"
pbos@webrtc.org38344ed2014-09-24 06:05:00 +000025#include "webrtc/base/thread_annotations.h"
pwestin@webrtc.org571a1c02012-11-13 21:12:39 +000026#include "webrtc/common_types.h"
brandtrdbdb3f12016-11-10 05:04:48 -080027#include "webrtc/modules/rtp_rtcp/include/flexfec_sender.h"
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010028#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
isheriff6b4b5f32016-06-08 00:24:21 -070029#include "webrtc/modules/rtp_rtcp/source/playout_delay_oracle.h"
pwestin@webrtc.org571a1c02012-11-13 21:12:39 +000030#include "webrtc/modules/rtp_rtcp/source/rtp_header_extension.h"
stefan@webrtc.org7e9315b2013-12-04 10:24:26 +000031#include "webrtc/modules/rtp_rtcp/source/rtp_packet_history.h"
pwestin@webrtc.org571a1c02012-11-13 21:12:39 +000032#include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_config.h"
mflodmanfcf54bd2015-04-14 21:28:08 +020033#include "webrtc/modules/rtp_rtcp/source/rtp_utility.h"
pwestin@webrtc.org571a1c02012-11-13 21:12:39 +000034#include "webrtc/modules/rtp_rtcp/source/ssrc_database.h"
pbos2d566682015-09-28 09:59:31 -070035#include "webrtc/transport.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000036
niklase@google.com470e71d2011-07-07 08:21:25 +000037namespace webrtc {
phoglund@webrtc.org43da54a2013-01-25 10:53:38 +000038
michaelt4da30442016-11-17 01:38:43 -080039class OverheadObserver;
sprangcd349d92016-07-13 09:11:28 -070040class RateLimiter;
Danil Chapovalov31e4e802016-08-03 18:27:40 +020041class RtcEventLog;
42class RtpPacketToSend;
niklase@google.com470e71d2011-07-07 08:21:25 +000043class RTPSenderAudio;
44class RTPSenderVideo;
45
danilchap5fb291a2016-08-09 07:43:25 -070046class RTPSender {
pwestin@webrtc.orgc66e8b32012-11-07 17:01:04 +000047 public:
Peter Boströmac547a62015-09-17 23:03:57 +020048 RTPSender(bool audio,
pbos@webrtc.orgd16e8392014-12-19 13:49:55 +000049 Clock* clock,
50 Transport* transport,
sprangebbf8a82015-09-21 15:11:14 -070051 RtpPacketSender* paced_sender,
brandtrdbdb3f12016-11-10 05:04:48 -080052 // TODO(brandtr): Remove |flexfec_sender| when that is hooked up
53 // to PacedSender instead.
54 FlexfecSender* flexfec_sender,
sprangebbf8a82015-09-21 15:11:14 -070055 TransportSequenceNumberAllocator* sequence_number_allocator,
sprang5e023eb2015-09-14 06:42:43 -070056 TransportFeedbackObserver* transport_feedback_callback,
andresp@webrtc.org8f151212014-07-10 09:39:23 +000057 BitrateStatisticsObserver* bitrate_callback,
stefan@webrtc.org168f23f2014-07-11 13:44:02 +000058 FrameCountObserver* frame_count_observer,
terelius429c3452016-01-21 05:42:04 -080059 SendSideDelayObserver* send_side_delay_observer,
asapersson35151f32016-05-02 23:44:01 -070060 RtcEventLog* event_log,
sprangcd349d92016-07-13 09:11:28 -070061 SendPacketObserver* send_packet_observer,
michaelt4da30442016-11-17 01:38:43 -080062 RateLimiter* nack_rate_limiter,
63 OverheadObserver* overhead_observer);
asapersson35151f32016-05-02 23:44:01 -070064
danilchap5fb291a2016-08-09 07:43:25 -070065 ~RTPSender();
niklase@google.com470e71d2011-07-07 08:21:25 +000066
pwestin@webrtc.orgc66e8b32012-11-07 17:01:04 +000067 void ProcessBitrate();
niklase@google.com470e71d2011-07-07 08:21:25 +000068
danilchap5fb291a2016-08-09 07:43:25 -070069 uint16_t ActualSendBitrateKbit() const;
niklase@google.com470e71d2011-07-07 08:21:25 +000070
pbos@webrtc.org2f446732013-04-08 11:08:41 +000071 uint32_t VideoBitrateSent() const;
72 uint32_t FecOverheadRate() const;
73 uint32_t NackOverheadRate() const;
stefan@webrtc.orgd0bdab02011-10-14 14:24:54 +000074
pkasting@chromium.org4591fbd2014-11-20 22:28:14 +000075 // Includes size of RTP and FEC headers.
danilchap5fb291a2016-08-09 07:43:25 -070076 size_t MaxDataPayloadLength() const;
niklase@google.com470e71d2011-07-07 08:21:25 +000077
Peter Boström8b79b072016-02-26 16:31:37 +010078 int32_t RegisterPayload(const char* payload_name,
79 const int8_t payload_type,
80 const uint32_t frequency,
81 const size_t channels,
82 const uint32_t rate);
niklase@google.com470e71d2011-07-07 08:21:25 +000083
pbos@webrtc.org2f446732013-04-08 11:08:41 +000084 int32_t DeRegisterSendPayload(const int8_t payload_type);
niklase@google.com470e71d2011-07-07 08:21:25 +000085
andresp@webrtc.orgc3c29112014-08-27 09:39:43 +000086 void SetSendPayloadType(int8_t payload_type);
87
pbos@webrtc.org2f446732013-04-08 11:08:41 +000088 int8_t SendPayloadType() const;
niklase@google.com470e71d2011-07-07 08:21:25 +000089
pbos@webrtc.org59f20bb2013-09-09 16:02:19 +000090 void SetSendingStatus(bool enabled);
niklase@google.com470e71d2011-07-07 08:21:25 +000091
pbos@webrtc.orgd16e8392014-12-19 13:49:55 +000092 void SetSendingMediaStatus(bool enabled);
pwestin@webrtc.orgc66e8b32012-11-07 17:01:04 +000093 bool SendingMedia() const;
niklase@google.com470e71d2011-07-07 08:21:25 +000094
pbos@webrtc.org2f4b14e2014-07-15 15:25:39 +000095 void GetDataCounters(StreamDataCounters* rtp_stats,
96 StreamDataCounters* rtx_stats) const;
niklase@google.com470e71d2011-07-07 08:21:25 +000097
danilchap71fead22016-08-18 02:01:49 -070098 uint32_t TimestampOffset() const;
99 void SetTimestampOffset(uint32_t timestamp);
niklase@google.com470e71d2011-07-07 08:21:25 +0000100
pbos@webrtc.org2f446732013-04-08 11:08:41 +0000101 uint32_t GenerateNewSSRC();
pbos@webrtc.orgd16e8392014-12-19 13:49:55 +0000102 void SetSSRC(uint32_t ssrc);
niklase@google.com470e71d2011-07-07 08:21:25 +0000103
danilchap5fb291a2016-08-09 07:43:25 -0700104 uint16_t SequenceNumber() const;
pbos@webrtc.org2f446732013-04-08 11:08:41 +0000105 void SetSequenceNumber(uint16_t seq);
niklase@google.com470e71d2011-07-07 08:21:25 +0000106
pbos@webrtc.org9334ac22014-11-24 08:25:50 +0000107 void SetCsrcs(const std::vector<uint32_t>& csrcs);
niklase@google.com470e71d2011-07-07 08:21:25 +0000108
danilchap41befce2016-03-30 11:11:51 -0700109 void SetMaxPayloadLength(size_t max_payload_length);
niklase@google.com470e71d2011-07-07 08:21:25 +0000110
Sergey Ulanov525df3f2016-08-02 17:46:41 -0700111 bool SendOutgoingData(FrameType frame_type,
112 int8_t payload_type,
113 uint32_t timestamp,
114 int64_t capture_time_ms,
115 const uint8_t* payload_data,
116 size_t payload_size,
117 const RTPFragmentationHeader* fragmentation,
118 const RTPVideoHeader* rtp_header,
119 uint32_t* transport_frame_id_out);
niklase@google.com470e71d2011-07-07 08:21:25 +0000120
phoglund@webrtc.org43da54a2013-01-25 10:53:38 +0000121 // RTP header extension
pbos@webrtc.orgd16e8392014-12-19 13:49:55 +0000122 int32_t RegisterRtpHeaderExtension(RTPExtensionType type, uint8_t id);
danilchap5fb291a2016-08-09 07:43:25 -0700123 bool IsRtpHeaderExtensionRegistered(RTPExtensionType type);
pbos@webrtc.orgd16e8392014-12-19 13:49:55 +0000124 int32_t DeregisterRtpHeaderExtension(RTPExtensionType type);
asapersson@webrtc.org5249cc82011-12-16 14:31:37 +0000125
isheriff6b4b5f32016-06-08 00:24:21 -0700126 size_t RtpHeaderExtensionLength() const;
asapersson@webrtc.org5249cc82011-12-16 14:31:37 +0000127
brandtr9dfff292016-11-14 05:14:50 -0800128 bool TimeToSendPacket(uint32_t ssrc,
129 uint16_t sequence_number,
philipela1ed0b32016-06-01 06:31:17 -0700130 int64_t capture_time_ms,
131 bool retransmission,
132 int probe_cluster_id);
133 size_t TimeToSendPadding(size_t bytes, int probe_cluster_id);
asapersson@webrtc.org0b3c35a2012-01-16 11:06:31 +0000134
phoglund@webrtc.org43da54a2013-01-25 10:53:38 +0000135 // NACK.
pwestin@webrtc.org571a1c02012-11-13 21:12:39 +0000136 int SelectiveRetransmissions() const;
137 int SetSelectiveRetransmissions(uint8_t settings);
Danil Chapovalov2800d742016-08-26 18:48:46 +0200138 void OnReceivedNack(const std::vector<uint16_t>& nack_sequence_numbers,
pkasting@chromium.org16825b12015-01-12 21:51:21 +0000139 int64_t avg_rtt);
asapersson@webrtc.org0b3c35a2012-01-16 11:06:31 +0000140
pbos@webrtc.orgd16e8392014-12-19 13:49:55 +0000141 void SetStorePacketsStatus(bool enable, uint16_t number_to_store);
niklase@google.com470e71d2011-07-07 08:21:25 +0000142
pwestin@webrtc.org571a1c02012-11-13 21:12:39 +0000143 bool StorePackets() const;
niklase@google.com470e71d2011-07-07 08:21:25 +0000144
pkasting@chromium.org16825b12015-01-12 21:51:21 +0000145 int32_t ReSendPacket(uint16_t packet_id, int64_t min_resend_time = 0);
niklase@google.com470e71d2011-07-07 08:21:25 +0000146
isheriff6b4b5f32016-06-08 00:24:21 -0700147 // Feedback to decide when to stop sending playout delay.
148 void OnReceivedRtcpReportBlocks(const ReportBlockList& report_blocks);
149
phoglund@webrtc.org43da54a2013-01-25 10:53:38 +0000150 // RTX.
pbos@webrtc.org0b0c2412015-01-13 14:15:15 +0000151 void SetRtxStatus(int mode);
152 int RtxStatus() const;
mflodman@webrtc.org9f5ebb52013-04-12 14:55:46 +0000153
pbos@webrtc.org2bb1bda2014-07-07 13:06:48 +0000154 uint32_t RtxSsrc() const;
stefan@webrtc.orgef927552014-06-05 08:25:29 +0000155 void SetRtxSsrc(uint32_t ssrc);
156
Shao Changbine62202f2015-04-21 20:24:50 +0800157 void SetRtxPayloadType(int payload_type, int associated_payload_type);
pwestin@webrtc.org8281e7d2012-01-10 14:09:18 +0000158
Danil Chapovalov5e57b172016-09-02 19:15:59 +0200159 // Create empty packet, fills ssrc, csrcs and reserve place for header
160 // extensions RtpSender updates before sending.
161 std::unique_ptr<RtpPacketToSend> AllocatePacket() const;
162 // Allocate sequence number for provided packet.
163 // Save packet's fields to generate padding that doesn't break media stream.
164 // Return false if sending was turned off.
165 bool AssignSequenceNumber(RtpPacketToSend* packet);
166
danilchap5fb291a2016-08-09 07:43:25 -0700167 size_t RtpHeaderLength() const;
168 uint16_t AllocateSequenceNumber(uint16_t packets_to_send);
169 size_t MaxPayloadLength() const;
niklase@google.com470e71d2011-07-07 08:21:25 +0000170
danilchap5fb291a2016-08-09 07:43:25 -0700171 uint32_t SSRC() const;
niklase@google.com470e71d2011-07-07 08:21:25 +0000172
brandtr9dfff292016-11-14 05:14:50 -0800173 rtc::Optional<uint32_t> FlexfecSsrc() const;
174
Danil Chapovalov31e4e802016-08-03 18:27:40 +0200175 bool SendToNetwork(std::unique_ptr<RtpPacketToSend> packet,
176 StorageType storage,
177 RtpPacketSender::Priority priority);
phoglund@webrtc.org43da54a2013-01-25 10:53:38 +0000178
179 // Audio.
180
181 // Send a DTMF tone using RFC 2833 (4733).
pbos@webrtc.orgd16e8392014-12-19 13:49:55 +0000182 int32_t SendTelephoneEvent(uint8_t key, uint16_t time_ms, uint8_t level);
niklase@google.com470e71d2011-07-07 08:21:25 +0000183
pwestin@webrtc.org571a1c02012-11-13 21:12:39 +0000184 // Set audio packet size, used to determine when it's time to send a DTMF
phoglund@webrtc.org43da54a2013-01-25 10:53:38 +0000185 // packet in silence (CNG).
pbos@webrtc.orgd16e8392014-12-19 13:49:55 +0000186 int32_t SetAudioPacketSize(uint16_t packet_size_samples);
niklase@google.com470e71d2011-07-07 08:21:25 +0000187
phoglund@webrtc.org43da54a2013-01-25 10:53:38 +0000188 // Store the audio level in d_bov for
pwestin@webrtc.org571a1c02012-11-13 21:12:39 +0000189 // header-extension-for-audio-level-indication.
pbos@webrtc.orgd16e8392014-12-19 13:49:55 +0000190 int32_t SetAudioLevel(uint8_t level_d_bov);
niklase@google.com470e71d2011-07-07 08:21:25 +0000191
pwestin@webrtc.org571a1c02012-11-13 21:12:39 +0000192 RtpVideoCodecTypes VideoCodecType() const;
niklase@google.com470e71d2011-07-07 08:21:25 +0000193
pbos@webrtc.org2f446732013-04-08 11:08:41 +0000194 uint32_t MaxConfiguredBitrateVideo() const;
niklase@google.com470e71d2011-07-07 08:21:25 +0000195
brandtrf1bb4762016-11-07 03:05:06 -0800196 // ULPFEC.
197 void SetUlpfecConfig(int red_payload_type, int ulpfec_payload_type);
niklase@google.com470e71d2011-07-07 08:21:25 +0000198
brandtr1743a192016-11-07 03:36:05 -0800199 bool SetFecParameters(const FecProtectionParams& delta_params,
200 const FecProtectionParams& key_params);
niklase@google.com470e71d2011-07-07 08:21:25 +0000201
danilchap7bfe3a22016-09-19 05:37:56 -0700202 RTC_DEPRECATED
Stefan Holmer586b19b2015-09-18 11:14:31 +0200203 size_t SendPadData(size_t bytes,
204 bool timestamp_provided,
205 uint32_t timestamp,
philipel46948c12016-06-01 04:04:40 -0700206 int64_t capture_time_ms);
philipela1ed0b32016-06-01 06:31:17 -0700207
sprang@webrtc.orgebad7652013-12-05 14:29:02 +0000208 // Called on update of RTP statistics.
209 void RegisterRtpStatisticsCallback(StreamDataCountersCallback* callback);
210 StreamDataCountersCallback* GetRtpStatisticsCallback() const;
211
sprang@webrtc.org6811b6e2013-12-13 09:46:59 +0000212 uint32_t BitrateSent() const;
213
pbos@webrtc.org2bb1bda2014-07-07 13:06:48 +0000214 void SetRtpState(const RtpState& rtp_state);
215 RtpState GetRtpState() const;
216 void SetRtxRtpState(const RtpState& rtp_state);
217 RtpState GetRtxRtpState() const;
218
michaelt4da30442016-11-17 01:38:43 -0800219 void SetTransportOverhead(int transport_overhead);
220
pwestin@webrtc.orgc66e8b32012-11-07 17:01:04 +0000221 protected:
pbos@webrtc.orgd16e8392014-12-19 13:49:55 +0000222 int32_t CheckPayloadType(int8_t payload_type, RtpVideoCodecTypes* video_type);
niklase@google.com470e71d2011-07-07 08:21:25 +0000223
pwestin@webrtc.orgc66e8b32012-11-07 17:01:04 +0000224 private:
stefan@webrtc.org0a3c1472013-12-05 14:05:07 +0000225 // Maps capture time in milliseconds to send-side delay in milliseconds.
226 // Send-side delay is the difference between transmission time and capture
227 // time.
228 typedef std::map<int64_t, int> SendDelayMap;
229
danilchap7bfe3a22016-09-19 05:37:56 -0700230 size_t SendPadData(size_t bytes, int probe_cluster_id);
231
232 size_t DeprecatedSendPadData(size_t bytes,
233 bool timestamp_provided,
234 uint32_t timestamp,
235 int64_t capture_time_ms,
236 int probe_cluster_id);
237
Danil Chapovalov31e4e802016-08-03 18:27:40 +0200238 bool PrepareAndSendPacket(std::unique_ptr<RtpPacketToSend> packet,
stefan@webrtc.org7c6ff2d2014-03-19 18:14:52 +0000239 bool send_over_rtx,
philipela1ed0b32016-06-01 06:31:17 -0700240 bool is_retransmit,
241 int probe_cluster_id);
stefan@webrtc.org7e9315b2013-12-04 10:24:26 +0000242
pkasting@chromium.org4591fbd2014-11-20 22:28:14 +0000243 // Return the number of bytes sent. Note that both of these functions may
244 // return a larger value that their argument.
philipela1ed0b32016-06-01 06:31:17 -0700245 size_t TrySendRedundantPayloads(size_t bytes, int probe_cluster_id);
stefan@webrtc.org7e9315b2013-12-04 10:24:26 +0000246
Danil Chapovalov31e4e802016-08-03 18:27:40 +0200247 std::unique_ptr<RtpPacketToSend> BuildRtxPacket(
248 const RtpPacketToSend& packet);
phoglund@webrtc.orgbaaf2432012-05-31 10:47:35 +0000249
Danil Chapovalov31e4e802016-08-03 18:27:40 +0200250 bool SendPacketToNetwork(const RtpPacketToSend& packet,
stefan1d8a5062015-10-02 03:39:33 -0700251 const PacketOptions& options);
pwestin@webrtc.orgb0061f92013-04-27 00:41:08 +0000252
stefan@webrtc.org0a3c1472013-12-05 14:05:07 +0000253 void UpdateDelayStatistics(int64_t capture_time_ms, int64_t now_ms);
asapersson35151f32016-05-02 23:44:01 -0700254 void UpdateOnSendPacket(int packet_id,
255 int64_t capture_time_ms,
256 uint32_t ssrc);
stefan@webrtc.org0a3c1472013-12-05 14:05:07 +0000257
Danil Chapovalov31e4e802016-08-03 18:27:40 +0200258 bool UpdateTransportSequenceNumber(RtpPacketToSend* packet,
259 int* packet_id) const;
asapersson35151f32016-05-02 23:44:01 -0700260
Danil Chapovalov31e4e802016-08-03 18:27:40 +0200261 void UpdateRtpStats(const RtpPacketToSend& packet,
sprang@webrtc.orgebad7652013-12-05 14:29:02 +0000262 bool is_rtx,
263 bool is_retransmit);
Danil Chapovalov31e4e802016-08-03 18:27:40 +0200264 bool IsFecPacket(const RtpPacketToSend& packet) const;
sprang@webrtc.orgebad7652013-12-05 14:29:02 +0000265
michaelt4da30442016-11-17 01:38:43 -0800266 void AddPacketToTransportFeedback(uint16_t packet_id,
267 const RtpPacketToSend& packet,
268 int probe_cluster_id);
269
270 void UpdateRtpOverhead(const RtpPacketToSend& packet);
271
tommiae695e92016-02-02 08:31:45 -0800272 Clock* const clock_;
273 const int64_t clock_delta_ms_;
danilchap47a740b2015-12-15 00:30:07 -0800274 Random random_ GUARDED_BY(send_critsect_);
stefan@webrtc.org0bae1fa2014-11-05 14:05:29 +0000275
phoglund@webrtc.org43da54a2013-01-25 10:53:38 +0000276 const bool audio_configured_;
kwiberg84be5112016-04-27 01:19:58 -0700277 const std::unique_ptr<RTPSenderAudio> audio_;
278 const std::unique_ptr<RTPSenderVideo> video_;
phoglund@webrtc.orgbaaf2432012-05-31 10:47:35 +0000279
sprangebbf8a82015-09-21 15:11:14 -0700280 RtpPacketSender* const paced_sender_;
281 TransportSequenceNumberAllocator* const transport_sequence_number_allocator_;
sprang5e023eb2015-09-14 06:42:43 -0700282 TransportFeedbackObserver* const transport_feedback_observer_;
sprang@webrtc.orgdcebf2d2014-11-04 16:27:16 +0000283 int64_t last_capture_time_ms_sent_;
tommiae695e92016-02-02 08:31:45 -0800284 rtc::CriticalSection send_critsect_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000285
brandtrd8048952016-11-07 02:08:51 -0800286 Transport* transport_;
sprang@webrtc.org5a320fb2014-03-13 15:12:37 +0000287 bool sending_media_ GUARDED_BY(send_critsect_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000288
pkasting@chromium.org4591fbd2014-11-20 22:28:14 +0000289 size_t max_payload_length_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000290
sprang@webrtc.orgefcad392014-03-25 16:51:35 +0000291 int8_t payload_type_ GUARDED_BY(send_critsect_);
pbos@webrtc.org62bafae2014-07-08 12:10:51 +0000292 std::map<int8_t, RtpUtility::Payload*> payload_type_map_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000293
stefana23fc622016-07-28 07:56:38 -0700294 RtpHeaderExtensionMap rtp_header_extension_map_ GUARDED_BY(send_critsect_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000295
isheriff6b4b5f32016-06-08 00:24:21 -0700296 // Tracks the current request for playout delay limits from application
297 // and decides whether the current RTP frame should include the playout
298 // delay extension on header.
299 PlayoutDelayOracle playout_delay_oracle_;
isheriff6b4b5f32016-06-08 00:24:21 -0700300
Danil Chapovalov31e4e802016-08-03 18:27:40 +0200301 RtpPacketHistory packet_history_;
brandtr9dfff292016-11-14 05:14:50 -0800302 // TODO(brandtr): Remove |flexfec_packet_history_| when the FlexfecSender
303 // is hooked up to the PacedSender.
304 RtpPacketHistory flexfec_packet_history_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000305
pwestin@webrtc.org571a1c02012-11-13 21:12:39 +0000306 // Statistics
danilchap7c9426c2016-04-14 03:05:31 -0700307 rtc::CriticalSection statistics_crit_;
pbos@webrtc.org2bb1bda2014-07-07 13:06:48 +0000308 SendDelayMap send_delays_ GUARDED_BY(statistics_crit_);
pbos@webrtc.orgce4e9a32014-12-18 13:50:16 +0000309 FrameCounts frame_counts_ GUARDED_BY(statistics_crit_);
pbos@webrtc.org2bb1bda2014-07-07 13:06:48 +0000310 StreamDataCounters rtp_stats_ GUARDED_BY(statistics_crit_);
311 StreamDataCounters rtx_rtp_stats_ GUARDED_BY(statistics_crit_);
312 StreamDataCountersCallback* rtp_stats_callback_ GUARDED_BY(statistics_crit_);
sprangcd349d92016-07-13 09:11:28 -0700313 RateStatistics total_bitrate_sent_ GUARDED_BY(statistics_crit_);
314 RateStatistics nack_bitrate_sent_ GUARDED_BY(statistics_crit_);
andresp@webrtc.org8f151212014-07-10 09:39:23 +0000315 FrameCountObserver* const frame_count_observer_;
stefan@webrtc.org168f23f2014-07-11 13:44:02 +0000316 SendSideDelayObserver* const send_side_delay_observer_;
terelius429c3452016-01-21 05:42:04 -0800317 RtcEventLog* const event_log_;
asapersson35151f32016-05-02 23:44:01 -0700318 SendPacketObserver* const send_packet_observer_;
sprangcd349d92016-07-13 09:11:28 -0700319 BitrateStatisticsObserver* const bitrate_callback_;
asapersson@webrtc.org0b3c35a2012-01-16 11:06:31 +0000320
pwestin@webrtc.org571a1c02012-11-13 21:12:39 +0000321 // RTP variables
danilchap71fead22016-08-18 02:01:49 -0700322 uint32_t timestamp_offset_ GUARDED_BY(send_critsect_);
tommiae695e92016-02-02 08:31:45 -0800323 SSRCDatabase* const ssrc_db_;
pbos@webrtc.org2bb1bda2014-07-07 13:06:48 +0000324 uint32_t remote_ssrc_ GUARDED_BY(send_critsect_);
325 bool sequence_number_forced_ GUARDED_BY(send_critsect_);
326 uint16_t sequence_number_ GUARDED_BY(send_critsect_);
327 uint16_t sequence_number_rtx_ GUARDED_BY(send_critsect_);
328 bool ssrc_forced_ GUARDED_BY(send_critsect_);
329 uint32_t ssrc_ GUARDED_BY(send_critsect_);
danilchape5b41412016-08-22 03:39:23 -0700330 uint32_t last_rtp_timestamp_ GUARDED_BY(send_critsect_);
pbos@webrtc.org2bb1bda2014-07-07 13:06:48 +0000331 int64_t capture_time_ms_ GUARDED_BY(send_critsect_);
332 int64_t last_timestamp_time_ms_ GUARDED_BY(send_critsect_);
stefan@webrtc.org8b94e3d2014-07-17 16:10:14 +0000333 bool media_has_been_sent_ GUARDED_BY(send_critsect_);
pbos@webrtc.org2bb1bda2014-07-07 13:06:48 +0000334 bool last_packet_marker_bit_ GUARDED_BY(send_critsect_);
pbos@webrtc.org9334ac22014-11-24 08:25:50 +0000335 std::vector<uint32_t> csrcs_ GUARDED_BY(send_critsect_);
pbos@webrtc.org2bb1bda2014-07-07 13:06:48 +0000336 int rtx_ GUARDED_BY(send_critsect_);
337 uint32_t ssrc_rtx_ GUARDED_BY(send_critsect_);
Shao Changbine62202f2015-04-21 20:24:50 +0800338 // Mapping rtx_payload_type_map_[associated] = rtx.
339 std::map<int8_t, int8_t> rtx_payload_type_map_ GUARDED_BY(send_critsect_);
michaelt4da30442016-11-17 01:38:43 -0800340 size_t transport_overhead_bytes_per_packet_ GUARDED_BY(send_critsect_);
341 size_t rtp_overhead_bytes_per_packet_ GUARDED_BY(send_critsect_);
andresp@webrtc.orgd09d0742014-03-26 14:27:34 +0000342
sprangcd349d92016-07-13 09:11:28 -0700343 RateLimiter* const retransmission_rate_limiter_;
michaelt4da30442016-11-17 01:38:43 -0800344 OverheadObserver* overhead_observer_;
terelius429c3452016-01-21 05:42:04 -0800345
346 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(RTPSender);
niklase@google.com470e71d2011-07-07 08:21:25 +0000347};
niklase@google.com470e71d2011-07-07 08:21:25 +0000348
phoglund@webrtc.org43da54a2013-01-25 10:53:38 +0000349} // namespace webrtc
350
351#endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_H_