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