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" |
| 19 | #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h" |
phoglund@webrtc.org | c38eef8 | 2013-01-07 10:18:30 +0000 | [diff] [blame] | 20 | #include "webrtc/modules/rtp_rtcp/source/bitrate.h" |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 21 | #include "webrtc/modules/rtp_rtcp/source/rtp_header_extension.h" |
| 22 | #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_config.h" |
| 23 | #include "webrtc/modules/rtp_rtcp/source/ssrc_database.h" |
| 24 | #include "webrtc/modules/rtp_rtcp/source/video_codec_information.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 25 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 26 | #define MAX_INIT_RTP_SEQ_NUMBER 32767 // 2^15 -1 |
| 27 | |
| 28 | namespace webrtc { |
| 29 | class CriticalSectionWrapper; |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 30 | class PacedSender; |
asapersson@webrtc.org | 0b3c35a | 2012-01-16 11:06:31 +0000 | [diff] [blame] | 31 | class RTPPacketHistory; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 32 | class RTPSenderAudio; |
| 33 | class RTPSenderVideo; |
| 34 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 35 | class RTPSenderInterface { |
| 36 | public: |
| 37 | RTPSenderInterface() {} |
| 38 | virtual ~RTPSenderInterface() {} |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 39 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 40 | virtual WebRtc_UWord32 SSRC() const = 0; |
| 41 | virtual WebRtc_UWord32 Timestamp() const = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 42 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 43 | virtual WebRtc_Word32 BuildRTPheader(WebRtc_UWord8* dataBuffer, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 44 | const WebRtc_Word8 payloadType, |
| 45 | const bool markerBit, |
| 46 | const WebRtc_UWord32 captureTimeStamp, |
| 47 | const bool timeStampProvided = true, |
| 48 | const bool incSequenceNumber = true) = 0; |
| 49 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 50 | virtual WebRtc_UWord16 RTPHeaderLength() const = 0; |
| 51 | virtual WebRtc_UWord16 IncrementSequenceNumber() = 0; |
| 52 | virtual WebRtc_UWord16 SequenceNumber() const = 0; |
| 53 | virtual WebRtc_UWord16 MaxPayloadLength() const = 0; |
| 54 | virtual WebRtc_UWord16 MaxDataPayloadLength() const = 0; |
| 55 | virtual WebRtc_UWord16 PacketOverHead() const = 0; |
| 56 | virtual WebRtc_UWord16 ActualSendBitrateKbit() const = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 57 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 58 | virtual WebRtc_Word32 SendToNetwork(uint8_t* data_buffer, |
| 59 | int payload_length, |
| 60 | int rtp_header_length, |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 61 | int64_t capture_time_ms, |
| 62 | StorageType storage) = 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: |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 67 | RTPSender(const WebRtc_Word32 id, |
| 68 | const bool audio, |
stefan@webrtc.org | 20ed36d | 2013-01-17 14:01:20 +0000 | [diff] [blame] | 69 | Clock* clock, |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 70 | Transport* transport, |
| 71 | RtpAudioFeedback* audio_feedback, |
| 72 | PacedSender* paced_sender); |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 73 | virtual ~RTPSender(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 74 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 75 | void ProcessBitrate(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 76 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 77 | WebRtc_UWord16 ActualSendBitrateKbit() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 78 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 79 | WebRtc_UWord32 VideoBitrateSent() const; |
| 80 | WebRtc_UWord32 FecOverheadRate() const; |
| 81 | WebRtc_UWord32 NackOverheadRate() const; |
stefan@webrtc.org | d0bdab0 | 2011-10-14 14:24:54 +0000 | [diff] [blame] | 82 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 83 | void SetTargetSendBitrate(const WebRtc_UWord32 bits); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 84 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 85 | WebRtc_UWord16 MaxDataPayloadLength() const; // with RTP and FEC headers |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 86 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 87 | WebRtc_Word32 RegisterPayload( |
| 88 | const char payloadName[RTP_PAYLOAD_NAME_SIZE], |
| 89 | const WebRtc_Word8 payloadType, |
| 90 | const WebRtc_UWord32 frequency, |
| 91 | const WebRtc_UWord8 channels, |
| 92 | const WebRtc_UWord32 rate); |
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 | WebRtc_Word32 DeRegisterSendPayload(const WebRtc_Word8 payloadType); |
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 | WebRtc_Word8 SendPayloadType() const; |
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 | int SendPayloadFrequency() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 99 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 100 | void SetSendingStatus(const bool enabled); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 101 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 102 | void SetSendingMediaStatus(const bool enabled); |
| 103 | bool SendingMedia() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 104 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 105 | // number of sent RTP packets |
| 106 | WebRtc_UWord32 Packets() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 107 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 108 | // number of sent RTP bytes |
| 109 | WebRtc_UWord32 Bytes() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 110 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 111 | void ResetDataCounters(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 112 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 113 | WebRtc_UWord32 StartTimestamp() const; |
| 114 | void SetStartTimestamp(WebRtc_UWord32 timestamp, bool force); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 115 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 116 | WebRtc_UWord32 GenerateNewSSRC(); |
| 117 | void SetSSRC(const WebRtc_UWord32 ssrc); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 118 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 119 | WebRtc_UWord16 SequenceNumber() const; |
| 120 | void SetSequenceNumber(WebRtc_UWord16 seq); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 121 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 122 | WebRtc_Word32 CSRCs(WebRtc_UWord32 arrOfCSRC[kRtpCsrcSize]) const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 123 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 124 | void SetCSRCStatus(const bool include); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 125 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 126 | void SetCSRCs(const WebRtc_UWord32 arrOfCSRC[kRtpCsrcSize], |
| 127 | const WebRtc_UWord8 arrLength); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 128 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 129 | WebRtc_Word32 SetMaxPayloadLength(const WebRtc_UWord16 length, |
| 130 | const WebRtc_UWord16 packetOverHead); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 131 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 132 | WebRtc_Word32 SendOutgoingData(const FrameType frameType, |
| 133 | const WebRtc_Word8 payloadType, |
| 134 | const WebRtc_UWord32 timeStamp, |
| 135 | int64_t capture_time_ms, |
| 136 | const WebRtc_UWord8* payloadData, |
| 137 | const WebRtc_UWord32 payloadSize, |
| 138 | const RTPFragmentationHeader* fragmentation, |
| 139 | VideoCodecInformation* codecInfo = NULL, |
| 140 | const RTPVideoTypeHeader* rtpTypeHdr = NULL); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 141 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 142 | WebRtc_Word32 SendPadData(WebRtc_Word8 payload_type, |
| 143 | WebRtc_UWord32 capture_timestamp, |
| 144 | int64_t capture_time_ms, |
| 145 | WebRtc_Word32 bytes); |
| 146 | /* |
| 147 | * RTP header extension |
| 148 | */ |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 149 | WebRtc_Word32 SetTransmissionTimeOffset( |
| 150 | const WebRtc_Word32 transmissionTimeOffset); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 151 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 152 | WebRtc_Word32 RegisterRtpHeaderExtension(const RTPExtensionType type, |
| 153 | const WebRtc_UWord8 id); |
asapersson@webrtc.org | 5249cc8 | 2011-12-16 14:31:37 +0000 | [diff] [blame] | 154 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 155 | WebRtc_Word32 DeregisterRtpHeaderExtension(const RTPExtensionType type); |
asapersson@webrtc.org | 5249cc8 | 2011-12-16 14:31:37 +0000 | [diff] [blame] | 156 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 157 | WebRtc_UWord16 RtpHeaderExtensionTotalLength() const; |
asapersson@webrtc.org | 5249cc8 | 2011-12-16 14:31:37 +0000 | [diff] [blame] | 158 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 159 | WebRtc_UWord16 BuildRTPHeaderExtension(WebRtc_UWord8* dataBuffer) const; |
asapersson@webrtc.org | 5249cc8 | 2011-12-16 14:31:37 +0000 | [diff] [blame] | 160 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 161 | WebRtc_UWord8 BuildTransmissionTimeOffsetExtension( |
| 162 | WebRtc_UWord8* dataBuffer) const; |
asapersson@webrtc.org | 5249cc8 | 2011-12-16 14:31:37 +0000 | [diff] [blame] | 163 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 164 | bool UpdateTransmissionTimeOffset(WebRtc_UWord8* rtp_packet, |
| 165 | const WebRtc_UWord16 rtp_packet_length, |
| 166 | const WebRtcRTPHeader& rtp_header, |
| 167 | const WebRtc_Word64 time_diff_ms) const; |
asapersson@webrtc.org | 5249cc8 | 2011-12-16 14:31:37 +0000 | [diff] [blame] | 168 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 169 | void TimeToSendPacket(uint16_t sequence_number, int64_t capture_time_ms); |
asapersson@webrtc.org | 0b3c35a | 2012-01-16 11:06:31 +0000 | [diff] [blame] | 170 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 171 | /* |
| 172 | * NACK |
| 173 | */ |
| 174 | int SelectiveRetransmissions() const; |
| 175 | int SetSelectiveRetransmissions(uint8_t settings); |
| 176 | void OnReceivedNACK(const WebRtc_UWord16 nackSequenceNumbersLength, |
| 177 | const WebRtc_UWord16* nackSequenceNumbers, |
| 178 | const WebRtc_UWord16 avgRTT); |
asapersson@webrtc.org | 0b3c35a | 2012-01-16 11:06:31 +0000 | [diff] [blame] | 179 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 180 | void SetStorePacketsStatus(const bool enable, |
| 181 | const WebRtc_UWord16 numberToStore); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 182 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 183 | bool StorePackets() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 184 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 185 | WebRtc_Word32 ReSendPacket(WebRtc_UWord16 packet_id, |
| 186 | WebRtc_UWord32 min_resend_time = 0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 187 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 188 | WebRtc_Word32 ReSendToNetwork(const WebRtc_UWord8* packet, |
| 189 | const WebRtc_UWord32 size); |
pwestin@webrtc.org | 8281e7d | 2012-01-10 14:09:18 +0000 | [diff] [blame] | 190 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 191 | bool ProcessNACKBitRate(const WebRtc_UWord32 now); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 192 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 193 | /* |
| 194 | * RTX |
| 195 | */ |
| 196 | void SetRTXStatus(const bool enable, |
| 197 | const bool setSSRC, |
| 198 | const WebRtc_UWord32 SSRC); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 199 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 200 | void RTXStatus(bool* enable, WebRtc_UWord32* SSRC) const; |
pwestin@webrtc.org | 8281e7d | 2012-01-10 14:09:18 +0000 | [diff] [blame] | 201 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 202 | /* |
| 203 | * Functions wrapping RTPSenderInterface |
| 204 | */ |
| 205 | virtual WebRtc_Word32 BuildRTPheader(WebRtc_UWord8* dataBuffer, |
| 206 | const WebRtc_Word8 payloadType, |
| 207 | const bool markerBit, |
| 208 | const WebRtc_UWord32 captureTimeStamp, |
| 209 | const bool timeStampProvided = true, |
| 210 | const bool incSequenceNumber = true); |
pwestin@webrtc.org | 8281e7d | 2012-01-10 14:09:18 +0000 | [diff] [blame] | 211 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 212 | virtual WebRtc_UWord16 RTPHeaderLength() const ; |
| 213 | virtual WebRtc_UWord16 IncrementSequenceNumber(); |
| 214 | virtual WebRtc_UWord16 MaxPayloadLength() const; |
| 215 | virtual WebRtc_UWord16 PacketOverHead() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 216 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 217 | // current timestamp |
| 218 | virtual WebRtc_UWord32 Timestamp() const; |
| 219 | virtual WebRtc_UWord32 SSRC() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 220 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 221 | virtual WebRtc_Word32 SendToNetwork(uint8_t* data_buffer, |
| 222 | int payload_length, |
| 223 | int rtp_header_length, |
| 224 | int64_t capture_time_ms, |
| 225 | StorageType storage); |
| 226 | /* |
| 227 | * Audio |
| 228 | */ |
| 229 | // Send a DTMF tone using RFC 2833 (4733) |
| 230 | WebRtc_Word32 SendTelephoneEvent(const WebRtc_UWord8 key, |
| 231 | const WebRtc_UWord16 time_ms, |
| 232 | const WebRtc_UWord8 level); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 233 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 234 | bool SendTelephoneEventActive(WebRtc_Word8& telephoneEvent) const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 235 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 236 | // Set audio packet size, used to determine when it's time to send a DTMF |
| 237 | // packet in silence (CNG) |
| 238 | WebRtc_Word32 SetAudioPacketSize(const WebRtc_UWord16 packetSizeSamples); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 239 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 240 | // Set status and ID for header-extension-for-audio-level-indication. |
| 241 | WebRtc_Word32 SetAudioLevelIndicationStatus(const bool enable, |
| 242 | const WebRtc_UWord8 ID); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 243 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 244 | // Get status and ID for header-extension-for-audio-level-indication. |
| 245 | WebRtc_Word32 AudioLevelIndicationStatus(bool& enable, |
| 246 | WebRtc_UWord8& ID) const; |
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 | // Store the audio level in dBov for |
| 249 | // header-extension-for-audio-level-indication. |
| 250 | WebRtc_Word32 SetAudioLevel(const WebRtc_UWord8 level_dBov); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 251 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 252 | // Set payload type for Redundant Audio Data RFC 2198 |
| 253 | WebRtc_Word32 SetRED(const WebRtc_Word8 payloadType); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 254 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 255 | // Get payload type for Redundant Audio Data RFC 2198 |
| 256 | WebRtc_Word32 RED(WebRtc_Word8& payloadType) const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 257 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 258 | /* |
| 259 | * Video |
| 260 | */ |
| 261 | VideoCodecInformation* CodecInformationVideo(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 262 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 263 | RtpVideoCodecTypes VideoCodecType() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 264 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 265 | WebRtc_UWord32 MaxConfiguredBitrateVideo() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 266 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 267 | WebRtc_Word32 SendRTPIntraRequest(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 268 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 269 | // FEC |
| 270 | WebRtc_Word32 SetGenericFECStatus(const bool enable, |
| 271 | const WebRtc_UWord8 payloadTypeRED, |
| 272 | const WebRtc_UWord8 payloadTypeFEC); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 273 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 274 | WebRtc_Word32 GenericFECStatus(bool& enable, |
| 275 | WebRtc_UWord8& payloadTypeRED, |
| 276 | WebRtc_UWord8& payloadTypeFEC) const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 277 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 278 | WebRtc_Word32 SetFecParameters( |
| 279 | const FecProtectionParams* delta_params, |
| 280 | const FecProtectionParams* key_params); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 281 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 282 | protected: |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 283 | WebRtc_Word32 CheckPayloadType(const WebRtc_Word8 payloadType, |
| 284 | RtpVideoCodecTypes& videoType); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 285 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 286 | private: |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 287 | void UpdateNACKBitRate(const WebRtc_UWord32 bytes, |
| 288 | const WebRtc_UWord32 now); |
pwestin@webrtc.org | 8281e7d | 2012-01-10 14:09:18 +0000 | [diff] [blame] | 289 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 290 | WebRtc_Word32 SendPaddingAccordingToBitrate( |
| 291 | WebRtc_Word8 payload_type, |
| 292 | WebRtc_UWord32 capture_timestamp, |
| 293 | int64_t capture_time_ms); |
phoglund@webrtc.org | baaf243 | 2012-05-31 10:47:35 +0000 | [diff] [blame] | 294 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 295 | WebRtc_Word32 _id; |
| 296 | const bool _audioConfigured; |
| 297 | RTPSenderAudio* _audio; |
| 298 | RTPSenderVideo* _video; |
phoglund@webrtc.org | baaf243 | 2012-05-31 10:47:35 +0000 | [diff] [blame] | 299 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 300 | PacedSender* paced_sender_; |
| 301 | CriticalSectionWrapper* _sendCritsect; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 302 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 303 | Transport* _transport; |
| 304 | bool _sendingMedia; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 305 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 306 | WebRtc_UWord16 _maxPayloadLength; |
| 307 | WebRtc_UWord16 _targetSendBitrate; |
| 308 | WebRtc_UWord16 _packetOverHead; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 309 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 310 | WebRtc_Word8 _payloadType; |
| 311 | std::map<WebRtc_Word8, ModuleRTPUtility::Payload*> _payloadTypeMap; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 312 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 313 | RtpHeaderExtensionMap _rtpHeaderExtensionMap; |
| 314 | WebRtc_Word32 _transmissionTimeOffset; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 315 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 316 | // NACK |
| 317 | WebRtc_UWord32 _nackByteCountTimes[NACK_BYTECOUNT_SIZE]; |
| 318 | WebRtc_Word32 _nackByteCount[NACK_BYTECOUNT_SIZE]; |
| 319 | Bitrate _nackBitrate; |
asapersson@webrtc.org | 5249cc8 | 2011-12-16 14:31:37 +0000 | [diff] [blame] | 320 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 321 | RTPPacketHistory* _packetHistory; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 322 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 323 | // Statistics |
| 324 | WebRtc_UWord32 _packetsSent; |
| 325 | WebRtc_UWord32 _payloadBytesSent; |
asapersson@webrtc.org | 0b3c35a | 2012-01-16 11:06:31 +0000 | [diff] [blame] | 326 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 327 | // RTP variables |
| 328 | bool _startTimeStampForced; |
| 329 | WebRtc_UWord32 _startTimeStamp; |
| 330 | SSRCDatabase& _ssrcDB; |
| 331 | WebRtc_UWord32 _remoteSSRC; |
| 332 | bool _sequenceNumberForced; |
| 333 | WebRtc_UWord16 _sequenceNumber; |
| 334 | WebRtc_UWord16 _sequenceNumberRTX; |
| 335 | bool _ssrcForced; |
| 336 | WebRtc_UWord32 _ssrc; |
| 337 | WebRtc_UWord32 _timeStamp; |
| 338 | WebRtc_UWord8 _CSRCs; |
| 339 | WebRtc_UWord32 _CSRC[kRtpCsrcSize]; |
| 340 | bool _includeCSRCs; |
| 341 | bool _RTX; |
| 342 | WebRtc_UWord32 _ssrcRTX; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 343 | }; |
| 344 | } // namespace webrtc |
| 345 | |
| 346 | #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_H_ |