niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
pwestin@webrtc.org | f6bb77a | 2012-01-24 17:16:59 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 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 WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_H_ |
| 12 | #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_H_ |
| 13 | |
pwestin@webrtc.org | 0074187 | 2012-01-19 15:56:10 +0000 | [diff] [blame] | 14 | #include <cassert> |
| 15 | #include <cmath> |
| 16 | #include <map> |
| 17 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 18 | #include "webrtc/common_types.h" |
stefan@webrtc.org | 508a84b | 2013-06-17 12:53:37 +0000 | [diff] [blame] | 19 | #include "webrtc/modules/pacing/include/paced_sender.h" |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 20 | #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h" |
phoglund@webrtc.org | c38eef8 | 2013-01-07 10:18:30 +0000 | [diff] [blame] | 21 | #include "webrtc/modules/rtp_rtcp/source/bitrate.h" |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 22 | #include "webrtc/modules/rtp_rtcp/source/rtp_header_extension.h" |
| 23 | #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_config.h" |
| 24 | #include "webrtc/modules/rtp_rtcp/source/ssrc_database.h" |
| 25 | #include "webrtc/modules/rtp_rtcp/source/video_codec_information.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 26 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 27 | #define MAX_INIT_RTP_SEQ_NUMBER 32767 // 2^15 -1. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 28 | |
| 29 | namespace webrtc { |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 30 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 31 | class CriticalSectionWrapper; |
asapersson@webrtc.org | 0b3c35a | 2012-01-16 11:06:31 +0000 | [diff] [blame] | 32 | class RTPPacketHistory; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 33 | class RTPSenderAudio; |
| 34 | class RTPSenderVideo; |
| 35 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 36 | class RTPSenderInterface { |
| 37 | public: |
| 38 | RTPSenderInterface() {} |
| 39 | virtual ~RTPSenderInterface() {} |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 40 | |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 41 | virtual uint32_t SSRC() const = 0; |
| 42 | virtual uint32_t Timestamp() const = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 43 | |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 44 | virtual int32_t BuildRTPheader( |
| 45 | uint8_t *data_buffer, const int8_t payload_type, |
| 46 | const bool marker_bit, const uint32_t capture_time_stamp, |
stefan@webrtc.org | 8ccb9f9 | 2013-06-19 14:13:42 +0000 | [diff] [blame] | 47 | int64_t capture_time_ms, |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 48 | const bool time_stamp_provided = true, |
| 49 | const bool inc_sequence_number = true) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 50 | |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 51 | virtual uint16_t RTPHeaderLength() const = 0; |
| 52 | virtual uint16_t IncrementSequenceNumber() = 0; |
| 53 | virtual uint16_t SequenceNumber() const = 0; |
| 54 | virtual uint16_t MaxPayloadLength() const = 0; |
| 55 | virtual uint16_t MaxDataPayloadLength() const = 0; |
| 56 | virtual uint16_t PacketOverHead() const = 0; |
| 57 | virtual uint16_t ActualSendBitrateKbit() const = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 58 | |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 59 | virtual int32_t SendToNetwork( |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 60 | uint8_t *data_buffer, int payload_length, int rtp_header_length, |
stefan@webrtc.org | 508a84b | 2013-06-17 12:53:37 +0000 | [diff] [blame] | 61 | int64_t capture_time_ms, StorageType storage, |
| 62 | PacedSender::Priority priority) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 63 | }; |
| 64 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 65 | class RTPSender : public Bitrate, public RTPSenderInterface { |
| 66 | public: |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 67 | RTPSender(const int32_t id, const bool audio, Clock *clock, |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 68 | Transport *transport, RtpAudioFeedback *audio_feedback, |
| 69 | PacedSender *paced_sender); |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 70 | virtual ~RTPSender(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 71 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 72 | void ProcessBitrate(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 73 | |
pbos@webrtc.org | f3e4cee | 2013-07-31 15:17:19 +0000 | [diff] [blame^] | 74 | virtual uint16_t ActualSendBitrateKbit() const OVERRIDE; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 75 | |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 76 | uint32_t VideoBitrateSent() const; |
| 77 | uint32_t FecOverheadRate() const; |
| 78 | uint32_t NackOverheadRate() const; |
stefan@webrtc.org | d0bdab0 | 2011-10-14 14:24:54 +0000 | [diff] [blame] | 79 | |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 80 | void SetTargetSendBitrate(const uint32_t bits); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 81 | |
pbos@webrtc.org | f3e4cee | 2013-07-31 15:17:19 +0000 | [diff] [blame^] | 82 | virtual uint16_t MaxDataPayloadLength() const |
| 83 | OVERRIDE; // with RTP and FEC headers. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 84 | |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 85 | int32_t RegisterPayload( |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 86 | const char payload_name[RTP_PAYLOAD_NAME_SIZE], |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 87 | const int8_t payload_type, const uint32_t frequency, |
| 88 | const uint8_t channels, const uint32_t rate); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 89 | |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 90 | int32_t DeRegisterSendPayload(const int8_t payload_type); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 91 | |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 92 | int8_t SendPayloadType() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 93 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 94 | int SendPayloadFrequency() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 95 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 96 | void SetSendingStatus(const bool enabled); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 97 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 98 | void SetSendingMediaStatus(const bool enabled); |
| 99 | bool SendingMedia() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 100 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 101 | // Number of sent RTP packets. |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 102 | uint32_t Packets() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 103 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 104 | // Number of sent RTP bytes. |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 105 | uint32_t Bytes() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 106 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 107 | void ResetDataCounters(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 108 | |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 109 | uint32_t StartTimestamp() const; |
| 110 | void SetStartTimestamp(uint32_t timestamp, bool force); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 111 | |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 112 | uint32_t GenerateNewSSRC(); |
| 113 | void SetSSRC(const uint32_t ssrc); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 114 | |
pbos@webrtc.org | f3e4cee | 2013-07-31 15:17:19 +0000 | [diff] [blame^] | 115 | virtual uint16_t SequenceNumber() const OVERRIDE; |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 116 | void SetSequenceNumber(uint16_t seq); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 117 | |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 118 | int32_t CSRCs(uint32_t arr_of_csrc[kRtpCsrcSize]) const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 119 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 120 | void SetCSRCStatus(const bool include); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 121 | |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 122 | void SetCSRCs(const uint32_t arr_of_csrc[kRtpCsrcSize], |
| 123 | const uint8_t arr_length); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 124 | |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 125 | int32_t SetMaxPayloadLength(const uint16_t length, |
| 126 | const uint16_t packet_over_head); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 127 | |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 128 | int32_t SendOutgoingData( |
| 129 | const FrameType frame_type, const int8_t payload_type, |
| 130 | const uint32_t time_stamp, int64_t capture_time_ms, |
| 131 | const uint8_t *payload_data, const uint32_t payload_size, |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 132 | const RTPFragmentationHeader *fragmentation, |
| 133 | VideoCodecInformation *codec_info = NULL, |
| 134 | const RTPVideoTypeHeader * rtp_type_hdr = NULL); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 135 | |
stefan@webrtc.org | a817962 | 2013-06-04 13:47:36 +0000 | [diff] [blame] | 136 | int BuildPaddingPacket(uint8_t* packet, int header_length, int32_t bytes); |
stefan@webrtc.org | 8ccb9f9 | 2013-06-19 14:13:42 +0000 | [diff] [blame] | 137 | int SendPadData(int payload_type, uint32_t timestamp, int64_t capture_time_ms, |
| 138 | int32_t bytes, StorageType store, |
| 139 | bool force_full_size_packets); |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 140 | // RTP header extension |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 141 | int32_t SetTransmissionTimeOffset( |
| 142 | const int32_t transmission_time_offset); |
solenberg@webrtc.org | 7ebbea1 | 2013-05-16 11:10:31 +0000 | [diff] [blame] | 143 | int32_t SetAbsoluteSendTime( |
| 144 | const uint32_t absolute_send_time); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 145 | |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 146 | int32_t RegisterRtpHeaderExtension(const RTPExtensionType type, |
| 147 | const uint8_t id); |
asapersson@webrtc.org | 5249cc8 | 2011-12-16 14:31:37 +0000 | [diff] [blame] | 148 | |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 149 | int32_t DeregisterRtpHeaderExtension(const RTPExtensionType type); |
asapersson@webrtc.org | 5249cc8 | 2011-12-16 14:31:37 +0000 | [diff] [blame] | 150 | |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 151 | uint16_t RtpHeaderExtensionTotalLength() const; |
asapersson@webrtc.org | 5249cc8 | 2011-12-16 14:31:37 +0000 | [diff] [blame] | 152 | |
stefan@webrtc.org | a817962 | 2013-06-04 13:47:36 +0000 | [diff] [blame] | 153 | uint16_t BuildRTPHeaderExtension(uint8_t* data_buffer) const; |
asapersson@webrtc.org | 5249cc8 | 2011-12-16 14:31:37 +0000 | [diff] [blame] | 154 | |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 155 | uint8_t BuildTransmissionTimeOffsetExtension( |
| 156 | uint8_t *data_buffer) const; |
solenberg@webrtc.org | 7ebbea1 | 2013-05-16 11:10:31 +0000 | [diff] [blame] | 157 | uint8_t BuildAbsoluteSendTimeExtension( |
| 158 | uint8_t* data_buffer) const; |
asapersson@webrtc.org | 5249cc8 | 2011-12-16 14:31:37 +0000 | [diff] [blame] | 159 | |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 160 | bool UpdateTransmissionTimeOffset(uint8_t *rtp_packet, |
| 161 | const uint16_t rtp_packet_length, |
stefan@webrtc.org | a5cb98c | 2013-05-29 12:12:51 +0000 | [diff] [blame] | 162 | const RTPHeader &rtp_header, |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 163 | const int64_t time_diff_ms) const; |
solenberg@webrtc.org | 7ebbea1 | 2013-05-16 11:10:31 +0000 | [diff] [blame] | 164 | bool UpdateAbsoluteSendTime(uint8_t *rtp_packet, |
| 165 | const uint16_t rtp_packet_length, |
stefan@webrtc.org | a5cb98c | 2013-05-29 12:12:51 +0000 | [diff] [blame] | 166 | const RTPHeader &rtp_header, |
solenberg@webrtc.org | 7ebbea1 | 2013-05-16 11:10:31 +0000 | [diff] [blame] | 167 | const int64_t now_ms) const; |
asapersson@webrtc.org | 5249cc8 | 2011-12-16 14:31:37 +0000 | [diff] [blame] | 168 | |
hclam@chromium.org | 2e402ce | 2013-06-20 20:18:31 +0000 | [diff] [blame] | 169 | bool TimeToSendPacket(uint16_t sequence_number, int64_t capture_time_ms); |
stefan@webrtc.org | 508a84b | 2013-06-17 12:53:37 +0000 | [diff] [blame] | 170 | int TimeToSendPadding(int bytes); |
asapersson@webrtc.org | 0b3c35a | 2012-01-16 11:06:31 +0000 | [diff] [blame] | 171 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 172 | // NACK. |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 173 | int SelectiveRetransmissions() const; |
| 174 | int SetSelectiveRetransmissions(uint8_t settings); |
stefan@webrtc.org | becf9c8 | 2013-02-01 15:09:57 +0000 | [diff] [blame] | 175 | void OnReceivedNACK(const std::list<uint16_t>& nack_sequence_numbers, |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 176 | const uint16_t avg_rtt); |
asapersson@webrtc.org | 0b3c35a | 2012-01-16 11:06:31 +0000 | [diff] [blame] | 177 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 178 | void SetStorePacketsStatus(const bool enable, |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 179 | const uint16_t number_to_store); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 180 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 181 | bool StorePackets() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 182 | |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 183 | int32_t ReSendPacket(uint16_t packet_id, uint32_t min_resend_time = 0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 184 | |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 185 | bool ProcessNACKBitRate(const uint32_t now); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 186 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 187 | // RTX. |
mflodman@webrtc.org | 9f5ebb5 | 2013-04-12 14:55:46 +0000 | [diff] [blame] | 188 | void SetRTXStatus(RtxMode mode, bool set_ssrc, uint32_t ssrc); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 189 | |
mflodman@webrtc.org | 9f5ebb5 | 2013-04-12 14:55:46 +0000 | [diff] [blame] | 190 | void RTXStatus(RtxMode* mode, uint32_t* ssrc, int* payload_type) const; |
| 191 | |
| 192 | void SetRtxPayloadType(int payloadType); |
pwestin@webrtc.org | 8281e7d | 2012-01-10 14:09:18 +0000 | [diff] [blame] | 193 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 194 | // Functions wrapping RTPSenderInterface. |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 195 | virtual int32_t BuildRTPheader( |
| 196 | uint8_t *data_buffer, const int8_t payload_type, |
| 197 | const bool marker_bit, const uint32_t capture_time_stamp, |
stefan@webrtc.org | 8ccb9f9 | 2013-06-19 14:13:42 +0000 | [diff] [blame] | 198 | int64_t capture_time_ms, |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 199 | const bool time_stamp_provided = true, |
pbos@webrtc.org | f3e4cee | 2013-07-31 15:17:19 +0000 | [diff] [blame^] | 200 | const bool inc_sequence_number = true) OVERRIDE; |
pwestin@webrtc.org | 8281e7d | 2012-01-10 14:09:18 +0000 | [diff] [blame] | 201 | |
pbos@webrtc.org | f3e4cee | 2013-07-31 15:17:19 +0000 | [diff] [blame^] | 202 | virtual uint16_t RTPHeaderLength() const OVERRIDE; |
| 203 | virtual uint16_t IncrementSequenceNumber() OVERRIDE; |
| 204 | virtual uint16_t MaxPayloadLength() const OVERRIDE; |
| 205 | virtual uint16_t PacketOverHead() const OVERRIDE; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 206 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 207 | // Current timestamp. |
pbos@webrtc.org | f3e4cee | 2013-07-31 15:17:19 +0000 | [diff] [blame^] | 208 | virtual uint32_t Timestamp() const OVERRIDE; |
| 209 | virtual uint32_t SSRC() const OVERRIDE; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 210 | |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 211 | virtual int32_t SendToNetwork( |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 212 | uint8_t *data_buffer, int payload_length, int rtp_header_length, |
stefan@webrtc.org | 508a84b | 2013-06-17 12:53:37 +0000 | [diff] [blame] | 213 | int64_t capture_time_ms, StorageType storage, |
pbos@webrtc.org | f3e4cee | 2013-07-31 15:17:19 +0000 | [diff] [blame^] | 214 | PacedSender::Priority priority) OVERRIDE; |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 215 | |
| 216 | // Audio. |
| 217 | |
| 218 | // Send a DTMF tone using RFC 2833 (4733). |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 219 | int32_t SendTelephoneEvent(const uint8_t key, |
| 220 | const uint16_t time_ms, |
| 221 | const uint8_t level); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 222 | |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 223 | bool SendTelephoneEventActive(int8_t *telephone_event) const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 224 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 225 | // Set audio packet size, used to determine when it's time to send a DTMF |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 226 | // packet in silence (CNG). |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 227 | int32_t SetAudioPacketSize(const uint16_t packet_size_samples); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 228 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 229 | // Set status and ID for header-extension-for-audio-level-indication. |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 230 | int32_t SetAudioLevelIndicationStatus(const bool enable, const uint8_t ID); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 231 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 232 | // Get status and ID for header-extension-for-audio-level-indication. |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 233 | int32_t AudioLevelIndicationStatus(bool *enable, uint8_t *id) const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 234 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 235 | // Store the audio level in d_bov for |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 236 | // header-extension-for-audio-level-indication. |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 237 | int32_t SetAudioLevel(const uint8_t level_d_bov); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 238 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 239 | // Set payload type for Redundant Audio Data RFC 2198. |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 240 | int32_t SetRED(const int8_t payload_type); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 241 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 242 | // Get payload type for Redundant Audio Data RFC 2198. |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 243 | int32_t RED(int8_t *payload_type) const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 244 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 245 | // Video. |
| 246 | VideoCodecInformation *CodecInformationVideo(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 247 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 248 | RtpVideoCodecTypes VideoCodecType() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 249 | |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 250 | uint32_t MaxConfiguredBitrateVideo() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 251 | |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 252 | int32_t SendRTPIntraRequest(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 253 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 254 | // FEC. |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 255 | int32_t SetGenericFECStatus(const bool enable, |
| 256 | const uint8_t payload_type_red, |
| 257 | const uint8_t payload_type_fec); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 258 | |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 259 | int32_t GenericFECStatus(bool *enable, uint8_t *payload_type_red, |
| 260 | uint8_t *payload_type_fec) const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 261 | |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 262 | int32_t SetFecParameters(const FecProtectionParams *delta_params, |
| 263 | const FecProtectionParams *key_params); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 264 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 265 | protected: |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 266 | int32_t CheckPayloadType(const int8_t payload_type, |
| 267 | RtpVideoCodecTypes *video_type); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 268 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 269 | private: |
stefan@webrtc.org | a817962 | 2013-06-04 13:47:36 +0000 | [diff] [blame] | 270 | int CreateRTPHeader(uint8_t* header, int8_t payload_type, |
| 271 | uint32_t ssrc, bool marker_bit, |
| 272 | uint32_t timestamp, uint16_t sequence_number, |
| 273 | const uint32_t* csrcs, uint8_t csrcs_length) const; |
| 274 | |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 275 | void UpdateNACKBitRate(const uint32_t bytes, const uint32_t now); |
pwestin@webrtc.org | 8281e7d | 2012-01-10 14:09:18 +0000 | [diff] [blame] | 276 | |
stefan@webrtc.org | a817962 | 2013-06-04 13:47:36 +0000 | [diff] [blame] | 277 | bool SendPaddingAccordingToBitrate(int8_t payload_type, |
| 278 | uint32_t capture_timestamp, |
| 279 | int64_t capture_time_ms); |
phoglund@webrtc.org | baaf243 | 2012-05-31 10:47:35 +0000 | [diff] [blame] | 280 | |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 281 | void BuildRtxPacket(uint8_t* buffer, uint16_t* length, |
| 282 | uint8_t* buffer_rtx); |
mikhal@webrtc.org | bda7f30 | 2013-03-15 23:21:52 +0000 | [diff] [blame] | 283 | |
pwestin@webrtc.org | b0061f9 | 2013-04-27 00:41:08 +0000 | [diff] [blame] | 284 | bool SendPacketToNetwork(const uint8_t *packet, uint32_t size); |
| 285 | |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 286 | int32_t id_; |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 287 | const bool audio_configured_; |
| 288 | RTPSenderAudio *audio_; |
| 289 | RTPSenderVideo *video_; |
phoglund@webrtc.org | baaf243 | 2012-05-31 10:47:35 +0000 | [diff] [blame] | 290 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 291 | PacedSender *paced_sender_; |
| 292 | CriticalSectionWrapper *send_critsect_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 293 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 294 | Transport *transport_; |
| 295 | bool sending_media_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 296 | |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 297 | uint16_t max_payload_length_; |
| 298 | uint16_t target_send_bitrate_; |
| 299 | uint16_t packet_over_head_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 300 | |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 301 | int8_t payload_type_; |
| 302 | std::map<int8_t, ModuleRTPUtility::Payload *> payload_type_map_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 303 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 304 | RtpHeaderExtensionMap rtp_header_extension_map_; |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 305 | int32_t transmission_time_offset_; |
solenberg@webrtc.org | 7ebbea1 | 2013-05-16 11:10:31 +0000 | [diff] [blame] | 306 | uint32_t absolute_send_time_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 307 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 308 | // NACK |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 309 | uint32_t nack_byte_count_times_[NACK_BYTECOUNT_SIZE]; |
| 310 | int32_t nack_byte_count_[NACK_BYTECOUNT_SIZE]; |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 311 | Bitrate nack_bitrate_; |
asapersson@webrtc.org | 5249cc8 | 2011-12-16 14:31:37 +0000 | [diff] [blame] | 312 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 313 | RTPPacketHistory *packet_history_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 314 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 315 | // Statistics |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 316 | uint32_t packets_sent_; |
| 317 | uint32_t payload_bytes_sent_; |
asapersson@webrtc.org | 0b3c35a | 2012-01-16 11:06:31 +0000 | [diff] [blame] | 318 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 319 | // RTP variables |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 320 | bool start_time_stamp_forced_; |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 321 | uint32_t start_time_stamp_; |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 322 | SSRCDatabase &ssrc_db_; |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 323 | uint32_t remote_ssrc_; |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 324 | bool sequence_number_forced_; |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 325 | uint16_t sequence_number_; |
| 326 | uint16_t sequence_number_rtx_; |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 327 | bool ssrc_forced_; |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 328 | uint32_t ssrc_; |
stefan@webrtc.org | a817962 | 2013-06-04 13:47:36 +0000 | [diff] [blame] | 329 | uint32_t timestamp_; |
stefan@webrtc.org | 508a84b | 2013-06-17 12:53:37 +0000 | [diff] [blame] | 330 | int64_t capture_time_ms_; |
stefan@webrtc.org | 8ccb9f9 | 2013-06-19 14:13:42 +0000 | [diff] [blame] | 331 | bool last_packet_marker_bit_; |
stefan@webrtc.org | a817962 | 2013-06-04 13:47:36 +0000 | [diff] [blame] | 332 | uint8_t num_csrcs_; |
| 333 | uint32_t csrcs_[kRtpCsrcSize]; |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 334 | bool include_csrcs_; |
mikhal@webrtc.org | bda7f30 | 2013-03-15 23:21:52 +0000 | [diff] [blame] | 335 | RtxMode rtx_; |
pbos@webrtc.org | 2f44673 | 2013-04-08 11:08:41 +0000 | [diff] [blame] | 336 | uint32_t ssrc_rtx_; |
mflodman@webrtc.org | 9f5ebb5 | 2013-04-12 14:55:46 +0000 | [diff] [blame] | 337 | int payload_type_rtx_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 338 | }; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 339 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 340 | } // namespace webrtc |
| 341 | |
| 342 | #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_H_ |