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 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 26 | #define MAX_INIT_RTP_SEQ_NUMBER 32767 // 2^15 -1. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 27 | |
| 28 | namespace webrtc { |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 29 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 30 | class CriticalSectionWrapper; |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 31 | class PacedSender; |
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 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 41 | virtual WebRtc_UWord32 SSRC() const = 0; |
| 42 | virtual WebRtc_UWord32 Timestamp() const = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 43 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 44 | virtual WebRtc_Word32 BuildRTPheader( |
| 45 | WebRtc_UWord8 *data_buffer, const WebRtc_Word8 payload_type, |
| 46 | const bool marker_bit, const WebRtc_UWord32 capture_time_stamp, |
| 47 | const bool time_stamp_provided = true, |
| 48 | const bool inc_sequence_number = true) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 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; |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 52 | virtual WebRtc_UWord16 SequenceNumber() const = 0; |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 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 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 58 | virtual WebRtc_Word32 SendToNetwork( |
| 59 | uint8_t *data_buffer, int payload_length, int rtp_header_length, |
| 60 | int64_t capture_time_ms, StorageType storage) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 61 | }; |
| 62 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 63 | class RTPSender : public Bitrate, public RTPSenderInterface { |
| 64 | public: |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 65 | RTPSender(const WebRtc_Word32 id, const bool audio, Clock *clock, |
| 66 | Transport *transport, RtpAudioFeedback *audio_feedback, |
| 67 | PacedSender *paced_sender); |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 68 | virtual ~RTPSender(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 69 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 70 | void ProcessBitrate(); |
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 | WebRtc_UWord16 ActualSendBitrateKbit() const; |
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_UWord32 VideoBitrateSent() const; |
| 75 | WebRtc_UWord32 FecOverheadRate() const; |
| 76 | WebRtc_UWord32 NackOverheadRate() const; |
stefan@webrtc.org | d0bdab0 | 2011-10-14 14:24:54 +0000 | [diff] [blame] | 77 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 78 | void SetTargetSendBitrate(const WebRtc_UWord32 bits); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 79 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 80 | WebRtc_UWord16 MaxDataPayloadLength() const; // with RTP and FEC headers. |
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_Word32 RegisterPayload( |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 83 | const char payload_name[RTP_PAYLOAD_NAME_SIZE], |
| 84 | const WebRtc_Word8 payload_type, const WebRtc_UWord32 frequency, |
| 85 | const WebRtc_UWord8 channels, const WebRtc_UWord32 rate); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 86 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 87 | WebRtc_Word32 DeRegisterSendPayload(const WebRtc_Word8 payload_type); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 88 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 89 | WebRtc_Word8 SendPayloadType() const; |
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 | int SendPayloadFrequency() const; |
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 | void SetSendingStatus(const bool enabled); |
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 | void SetSendingMediaStatus(const bool enabled); |
| 96 | bool SendingMedia() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 97 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 98 | // Number of sent RTP packets. |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 99 | WebRtc_UWord32 Packets() 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 bytes. |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 102 | WebRtc_UWord32 Bytes() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 103 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 104 | void ResetDataCounters(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 105 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 106 | WebRtc_UWord32 StartTimestamp() const; |
| 107 | void SetStartTimestamp(WebRtc_UWord32 timestamp, bool force); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 108 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 109 | WebRtc_UWord32 GenerateNewSSRC(); |
| 110 | void SetSSRC(const WebRtc_UWord32 ssrc); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 111 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 112 | WebRtc_UWord16 SequenceNumber() const; |
| 113 | void SetSequenceNumber(WebRtc_UWord16 seq); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 114 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 115 | WebRtc_Word32 CSRCs(WebRtc_UWord32 arr_of_csrc[kRtpCsrcSize]) const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 116 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 117 | void SetCSRCStatus(const bool include); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 118 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 119 | void SetCSRCs(const WebRtc_UWord32 arr_of_csrc[kRtpCsrcSize], |
| 120 | const WebRtc_UWord8 arr_length); |
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 SetMaxPayloadLength(const WebRtc_UWord16 length, |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 123 | const WebRtc_UWord16 packet_over_head); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 124 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 125 | WebRtc_Word32 SendOutgoingData( |
| 126 | const FrameType frame_type, const WebRtc_Word8 payload_type, |
| 127 | const WebRtc_UWord32 time_stamp, int64_t capture_time_ms, |
| 128 | const WebRtc_UWord8 *payload_data, const WebRtc_UWord32 payload_size, |
| 129 | const RTPFragmentationHeader *fragmentation, |
| 130 | VideoCodecInformation *codec_info = NULL, |
| 131 | const RTPVideoTypeHeader * rtp_type_hdr = NULL); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 132 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 133 | WebRtc_Word32 SendPadData(WebRtc_Word8 payload_type, |
| 134 | WebRtc_UWord32 capture_timestamp, |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 135 | int64_t capture_time_ms, WebRtc_Word32 bytes); |
| 136 | // RTP header extension |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 137 | WebRtc_Word32 SetTransmissionTimeOffset( |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 138 | const WebRtc_Word32 transmission_time_offset); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 139 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 140 | WebRtc_Word32 RegisterRtpHeaderExtension(const RTPExtensionType type, |
| 141 | const WebRtc_UWord8 id); |
asapersson@webrtc.org | 5249cc8 | 2011-12-16 14:31:37 +0000 | [diff] [blame] | 142 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 143 | WebRtc_Word32 DeregisterRtpHeaderExtension(const RTPExtensionType type); |
asapersson@webrtc.org | 5249cc8 | 2011-12-16 14:31:37 +0000 | [diff] [blame] | 144 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 145 | WebRtc_UWord16 RtpHeaderExtensionTotalLength() const; |
asapersson@webrtc.org | 5249cc8 | 2011-12-16 14:31:37 +0000 | [diff] [blame] | 146 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 147 | WebRtc_UWord16 BuildRTPHeaderExtension(WebRtc_UWord8 *data_buffer) const; |
asapersson@webrtc.org | 5249cc8 | 2011-12-16 14:31:37 +0000 | [diff] [blame] | 148 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 149 | WebRtc_UWord8 BuildTransmissionTimeOffsetExtension( |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 150 | WebRtc_UWord8 *data_buffer) const; |
asapersson@webrtc.org | 5249cc8 | 2011-12-16 14:31:37 +0000 | [diff] [blame] | 151 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 152 | bool UpdateTransmissionTimeOffset(WebRtc_UWord8 *rtp_packet, |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 153 | const WebRtc_UWord16 rtp_packet_length, |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 154 | const WebRtcRTPHeader &rtp_header, |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 155 | const WebRtc_Word64 time_diff_ms) const; |
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 | void TimeToSendPacket(uint16_t sequence_number, int64_t capture_time_ms); |
asapersson@webrtc.org | 0b3c35a | 2012-01-16 11:06:31 +0000 | [diff] [blame] | 158 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 159 | // NACK. |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 160 | int SelectiveRetransmissions() const; |
| 161 | int SetSelectiveRetransmissions(uint8_t settings); |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 162 | void OnReceivedNACK(const WebRtc_UWord16 nack_sequence_numbers_length, |
| 163 | const WebRtc_UWord16 *nack_sequence_numbers, |
| 164 | const WebRtc_UWord16 avg_rtt); |
asapersson@webrtc.org | 0b3c35a | 2012-01-16 11:06:31 +0000 | [diff] [blame] | 165 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 166 | void SetStorePacketsStatus(const bool enable, |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 167 | const WebRtc_UWord16 number_to_store); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 168 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 169 | bool StorePackets() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 170 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 171 | WebRtc_Word32 ReSendPacket(WebRtc_UWord16 packet_id, |
| 172 | WebRtc_UWord32 min_resend_time = 0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 173 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 174 | WebRtc_Word32 ReSendToNetwork(const WebRtc_UWord8 *packet, |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 175 | const WebRtc_UWord32 size); |
pwestin@webrtc.org | 8281e7d | 2012-01-10 14:09:18 +0000 | [diff] [blame] | 176 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 177 | bool ProcessNACKBitRate(const WebRtc_UWord32 now); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 178 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 179 | // RTX. |
| 180 | void SetRTXStatus(const bool enable, const bool set_ssrc, |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 181 | const WebRtc_UWord32 SSRC); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 182 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 183 | void RTXStatus(bool *enable, WebRtc_UWord32 *SSRC) const; |
pwestin@webrtc.org | 8281e7d | 2012-01-10 14:09:18 +0000 | [diff] [blame] | 184 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 185 | // Functions wrapping RTPSenderInterface. |
| 186 | virtual WebRtc_Word32 BuildRTPheader( |
| 187 | WebRtc_UWord8 *data_buffer, const WebRtc_Word8 payload_type, |
| 188 | const bool marker_bit, const WebRtc_UWord32 capture_time_stamp, |
| 189 | const bool time_stamp_provided = true, |
| 190 | const bool inc_sequence_number = true); |
pwestin@webrtc.org | 8281e7d | 2012-01-10 14:09:18 +0000 | [diff] [blame] | 191 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 192 | virtual WebRtc_UWord16 RTPHeaderLength() const; |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 193 | virtual WebRtc_UWord16 IncrementSequenceNumber(); |
| 194 | virtual WebRtc_UWord16 MaxPayloadLength() const; |
| 195 | virtual WebRtc_UWord16 PacketOverHead() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 196 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 197 | // Current timestamp. |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 198 | virtual WebRtc_UWord32 Timestamp() const; |
| 199 | virtual WebRtc_UWord32 SSRC() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 200 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 201 | virtual WebRtc_Word32 SendToNetwork( |
| 202 | uint8_t *data_buffer, int payload_length, int rtp_header_length, |
| 203 | int64_t capture_time_ms, StorageType storage); |
| 204 | |
| 205 | // Audio. |
| 206 | |
| 207 | // Send a DTMF tone using RFC 2833 (4733). |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 208 | WebRtc_Word32 SendTelephoneEvent(const WebRtc_UWord8 key, |
| 209 | const WebRtc_UWord16 time_ms, |
| 210 | const WebRtc_UWord8 level); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 211 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 212 | bool SendTelephoneEventActive(WebRtc_Word8 *telephone_event) const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 213 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 214 | // 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^] | 215 | // packet in silence (CNG). |
| 216 | WebRtc_Word32 SetAudioPacketSize(const WebRtc_UWord16 packet_size_samples); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 217 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 218 | // Set status and ID for header-extension-for-audio-level-indication. |
| 219 | WebRtc_Word32 SetAudioLevelIndicationStatus(const bool enable, |
| 220 | const WebRtc_UWord8 ID); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 221 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 222 | // Get status and ID for header-extension-for-audio-level-indication. |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 223 | WebRtc_Word32 AudioLevelIndicationStatus(bool *enable, |
| 224 | WebRtc_UWord8 *id) const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 225 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 226 | // Store the audio level in d_bov for |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 227 | // header-extension-for-audio-level-indication. |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 228 | WebRtc_Word32 SetAudioLevel(const WebRtc_UWord8 level_d_bov); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 229 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 230 | // Set payload type for Redundant Audio Data RFC 2198. |
| 231 | WebRtc_Word32 SetRED(const WebRtc_Word8 payload_type); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 232 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 233 | // Get payload type for Redundant Audio Data RFC 2198. |
| 234 | WebRtc_Word32 RED(WebRtc_Word8 *payload_type) const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 235 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 236 | // Video. |
| 237 | VideoCodecInformation *CodecInformationVideo(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 238 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 239 | RtpVideoCodecTypes VideoCodecType() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 240 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 241 | WebRtc_UWord32 MaxConfiguredBitrateVideo() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 242 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 243 | WebRtc_Word32 SendRTPIntraRequest(); |
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 | // FEC. |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 246 | WebRtc_Word32 SetGenericFECStatus(const bool enable, |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 247 | const WebRtc_UWord8 payload_type_red, |
| 248 | const WebRtc_UWord8 payload_type_fec); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 249 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 250 | WebRtc_Word32 GenericFECStatus(bool *enable, WebRtc_UWord8 *payload_type_red, |
| 251 | WebRtc_UWord8 *payload_type_fec) const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 252 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 253 | WebRtc_Word32 SetFecParameters(const FecProtectionParams *delta_params, |
| 254 | const FecProtectionParams *key_params); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 255 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 256 | protected: |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 257 | WebRtc_Word32 CheckPayloadType(const WebRtc_Word8 payload_type, |
| 258 | RtpVideoCodecTypes *video_type); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 259 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 260 | private: |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 261 | void UpdateNACKBitRate(const WebRtc_UWord32 bytes, const WebRtc_UWord32 now); |
pwestin@webrtc.org | 8281e7d | 2012-01-10 14:09:18 +0000 | [diff] [blame] | 262 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 263 | WebRtc_Word32 SendPaddingAccordingToBitrate(WebRtc_Word8 payload_type, |
| 264 | WebRtc_UWord32 capture_timestamp, |
| 265 | int64_t capture_time_ms); |
phoglund@webrtc.org | baaf243 | 2012-05-31 10:47:35 +0000 | [diff] [blame] | 266 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 267 | WebRtc_Word32 id_; |
| 268 | const bool audio_configured_; |
| 269 | RTPSenderAudio *audio_; |
| 270 | RTPSenderVideo *video_; |
phoglund@webrtc.org | baaf243 | 2012-05-31 10:47:35 +0000 | [diff] [blame] | 271 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 272 | PacedSender *paced_sender_; |
| 273 | CriticalSectionWrapper *send_critsect_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 274 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 275 | Transport *transport_; |
| 276 | bool sending_media_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 277 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 278 | WebRtc_UWord16 max_payload_length_; |
| 279 | WebRtc_UWord16 target_send_bitrate_; |
| 280 | WebRtc_UWord16 packet_over_head_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 281 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 282 | WebRtc_Word8 payload_type_; |
| 283 | std::map<WebRtc_Word8, ModuleRTPUtility::Payload *> payload_type_map_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 284 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 285 | RtpHeaderExtensionMap rtp_header_extension_map_; |
| 286 | WebRtc_Word32 transmission_time_offset_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 287 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 288 | // NACK |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 289 | WebRtc_UWord32 nack_byte_count_times_[NACK_BYTECOUNT_SIZE]; |
| 290 | WebRtc_Word32 nack_byte_count_[NACK_BYTECOUNT_SIZE]; |
| 291 | Bitrate nack_bitrate_; |
asapersson@webrtc.org | 5249cc8 | 2011-12-16 14:31:37 +0000 | [diff] [blame] | 292 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 293 | RTPPacketHistory *packet_history_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 294 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 295 | // Statistics |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 296 | WebRtc_UWord32 packets_sent_; |
| 297 | WebRtc_UWord32 payload_bytes_sent_; |
asapersson@webrtc.org | 0b3c35a | 2012-01-16 11:06:31 +0000 | [diff] [blame] | 298 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 299 | // RTP variables |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 300 | bool start_time_stamp_forced_; |
| 301 | WebRtc_UWord32 start_time_stamp_; |
| 302 | SSRCDatabase &ssrc_db_; |
| 303 | WebRtc_UWord32 remote_ssrc_; |
| 304 | bool sequence_number_forced_; |
| 305 | WebRtc_UWord16 sequence_number_; |
| 306 | WebRtc_UWord16 sequence_number_rtx_; |
| 307 | bool ssrc_forced_; |
| 308 | WebRtc_UWord32 ssrc_; |
| 309 | WebRtc_UWord32 time_stamp_; |
| 310 | WebRtc_UWord8 csrcs_; |
| 311 | WebRtc_UWord32 csrc_[kRtpCsrcSize]; |
| 312 | bool include_csrcs_; |
| 313 | bool rtx_; |
| 314 | WebRtc_UWord32 ssrc_rtx_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 315 | }; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 316 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame^] | 317 | } // namespace webrtc |
| 318 | |
| 319 | #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_H_ |