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); |
stefan@webrtc.org | becf9c8 | 2013-02-01 15:09:57 +0000 | [diff] [blame^] | 162 | void OnReceivedNACK(const std::list<uint16_t>& nack_sequence_numbers, |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 163 | const WebRtc_UWord16 avg_rtt); |
asapersson@webrtc.org | 0b3c35a | 2012-01-16 11:06:31 +0000 | [diff] [blame] | 164 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 165 | void SetStorePacketsStatus(const bool enable, |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 166 | const WebRtc_UWord16 number_to_store); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 167 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 168 | bool StorePackets() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 169 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 170 | WebRtc_Word32 ReSendPacket(WebRtc_UWord16 packet_id, |
| 171 | WebRtc_UWord32 min_resend_time = 0); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 172 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 173 | WebRtc_Word32 ReSendToNetwork(const WebRtc_UWord8 *packet, |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 174 | const WebRtc_UWord32 size); |
pwestin@webrtc.org | 8281e7d | 2012-01-10 14:09:18 +0000 | [diff] [blame] | 175 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 176 | bool ProcessNACKBitRate(const WebRtc_UWord32 now); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 177 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 178 | // RTX. |
| 179 | void SetRTXStatus(const bool enable, const bool set_ssrc, |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 180 | const WebRtc_UWord32 SSRC); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 181 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 182 | void RTXStatus(bool *enable, WebRtc_UWord32 *SSRC) const; |
pwestin@webrtc.org | 8281e7d | 2012-01-10 14:09:18 +0000 | [diff] [blame] | 183 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 184 | // Functions wrapping RTPSenderInterface. |
| 185 | virtual WebRtc_Word32 BuildRTPheader( |
| 186 | WebRtc_UWord8 *data_buffer, const WebRtc_Word8 payload_type, |
| 187 | const bool marker_bit, const WebRtc_UWord32 capture_time_stamp, |
| 188 | const bool time_stamp_provided = true, |
| 189 | const bool inc_sequence_number = true); |
pwestin@webrtc.org | 8281e7d | 2012-01-10 14:09:18 +0000 | [diff] [blame] | 190 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 191 | virtual WebRtc_UWord16 RTPHeaderLength() const; |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 192 | virtual WebRtc_UWord16 IncrementSequenceNumber(); |
| 193 | virtual WebRtc_UWord16 MaxPayloadLength() const; |
| 194 | virtual WebRtc_UWord16 PacketOverHead() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 195 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 196 | // Current timestamp. |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 197 | virtual WebRtc_UWord32 Timestamp() const; |
| 198 | virtual WebRtc_UWord32 SSRC() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 199 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 200 | virtual WebRtc_Word32 SendToNetwork( |
| 201 | uint8_t *data_buffer, int payload_length, int rtp_header_length, |
| 202 | int64_t capture_time_ms, StorageType storage); |
| 203 | |
| 204 | // Audio. |
| 205 | |
| 206 | // Send a DTMF tone using RFC 2833 (4733). |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 207 | WebRtc_Word32 SendTelephoneEvent(const WebRtc_UWord8 key, |
| 208 | const WebRtc_UWord16 time_ms, |
| 209 | const WebRtc_UWord8 level); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 210 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 211 | bool SendTelephoneEventActive(WebRtc_Word8 *telephone_event) const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 212 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 213 | // 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] | 214 | // packet in silence (CNG). |
| 215 | WebRtc_Word32 SetAudioPacketSize(const WebRtc_UWord16 packet_size_samples); |
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 | // Set status and ID for header-extension-for-audio-level-indication. |
| 218 | WebRtc_Word32 SetAudioLevelIndicationStatus(const bool enable, |
| 219 | const WebRtc_UWord8 ID); |
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 | // Get status and ID for header-extension-for-audio-level-indication. |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 222 | WebRtc_Word32 AudioLevelIndicationStatus(bool *enable, |
| 223 | WebRtc_UWord8 *id) const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 224 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 225 | // Store the audio level in d_bov for |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 226 | // header-extension-for-audio-level-indication. |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 227 | WebRtc_Word32 SetAudioLevel(const WebRtc_UWord8 level_d_bov); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 228 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 229 | // Set payload type for Redundant Audio Data RFC 2198. |
| 230 | WebRtc_Word32 SetRED(const WebRtc_Word8 payload_type); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 231 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 232 | // Get payload type for Redundant Audio Data RFC 2198. |
| 233 | WebRtc_Word32 RED(WebRtc_Word8 *payload_type) 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 | // Video. |
| 236 | VideoCodecInformation *CodecInformationVideo(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 237 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 238 | RtpVideoCodecTypes VideoCodecType() const; |
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 | WebRtc_UWord32 MaxConfiguredBitrateVideo() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 241 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 242 | WebRtc_Word32 SendRTPIntraRequest(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 243 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 244 | // FEC. |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 245 | WebRtc_Word32 SetGenericFECStatus(const bool enable, |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 246 | const WebRtc_UWord8 payload_type_red, |
| 247 | const WebRtc_UWord8 payload_type_fec); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 248 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 249 | WebRtc_Word32 GenericFECStatus(bool *enable, WebRtc_UWord8 *payload_type_red, |
| 250 | WebRtc_UWord8 *payload_type_fec) const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 251 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 252 | WebRtc_Word32 SetFecParameters(const FecProtectionParams *delta_params, |
| 253 | const FecProtectionParams *key_params); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 254 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 255 | protected: |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 256 | WebRtc_Word32 CheckPayloadType(const WebRtc_Word8 payload_type, |
| 257 | RtpVideoCodecTypes *video_type); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 258 | |
pwestin@webrtc.org | c66e8b3 | 2012-11-07 17:01:04 +0000 | [diff] [blame] | 259 | private: |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 260 | void UpdateNACKBitRate(const WebRtc_UWord32 bytes, const WebRtc_UWord32 now); |
pwestin@webrtc.org | 8281e7d | 2012-01-10 14:09:18 +0000 | [diff] [blame] | 261 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 262 | WebRtc_Word32 SendPaddingAccordingToBitrate(WebRtc_Word8 payload_type, |
| 263 | WebRtc_UWord32 capture_timestamp, |
| 264 | int64_t capture_time_ms); |
phoglund@webrtc.org | baaf243 | 2012-05-31 10:47:35 +0000 | [diff] [blame] | 265 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 266 | WebRtc_Word32 id_; |
| 267 | const bool audio_configured_; |
| 268 | RTPSenderAudio *audio_; |
| 269 | RTPSenderVideo *video_; |
phoglund@webrtc.org | baaf243 | 2012-05-31 10:47:35 +0000 | [diff] [blame] | 270 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 271 | PacedSender *paced_sender_; |
| 272 | CriticalSectionWrapper *send_critsect_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 273 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 274 | Transport *transport_; |
| 275 | bool sending_media_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 276 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 277 | WebRtc_UWord16 max_payload_length_; |
| 278 | WebRtc_UWord16 target_send_bitrate_; |
| 279 | WebRtc_UWord16 packet_over_head_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 280 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 281 | WebRtc_Word8 payload_type_; |
| 282 | std::map<WebRtc_Word8, ModuleRTPUtility::Payload *> payload_type_map_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 283 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 284 | RtpHeaderExtensionMap rtp_header_extension_map_; |
| 285 | WebRtc_Word32 transmission_time_offset_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 286 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 287 | // NACK |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 288 | WebRtc_UWord32 nack_byte_count_times_[NACK_BYTECOUNT_SIZE]; |
| 289 | WebRtc_Word32 nack_byte_count_[NACK_BYTECOUNT_SIZE]; |
| 290 | Bitrate nack_bitrate_; |
asapersson@webrtc.org | 5249cc8 | 2011-12-16 14:31:37 +0000 | [diff] [blame] | 291 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 292 | RTPPacketHistory *packet_history_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 293 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 294 | // Statistics |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 295 | WebRtc_UWord32 packets_sent_; |
| 296 | WebRtc_UWord32 payload_bytes_sent_; |
asapersson@webrtc.org | 0b3c35a | 2012-01-16 11:06:31 +0000 | [diff] [blame] | 297 | |
pwestin@webrtc.org | 571a1c0 | 2012-11-13 21:12:39 +0000 | [diff] [blame] | 298 | // RTP variables |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 299 | bool start_time_stamp_forced_; |
| 300 | WebRtc_UWord32 start_time_stamp_; |
| 301 | SSRCDatabase &ssrc_db_; |
| 302 | WebRtc_UWord32 remote_ssrc_; |
| 303 | bool sequence_number_forced_; |
| 304 | WebRtc_UWord16 sequence_number_; |
| 305 | WebRtc_UWord16 sequence_number_rtx_; |
| 306 | bool ssrc_forced_; |
| 307 | WebRtc_UWord32 ssrc_; |
| 308 | WebRtc_UWord32 time_stamp_; |
| 309 | WebRtc_UWord8 csrcs_; |
| 310 | WebRtc_UWord32 csrc_[kRtpCsrcSize]; |
| 311 | bool include_csrcs_; |
| 312 | bool rtx_; |
| 313 | WebRtc_UWord32 ssrc_rtx_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 314 | }; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 315 | |
phoglund@webrtc.org | 43da54a | 2013-01-25 10:53:38 +0000 | [diff] [blame] | 316 | } // namespace webrtc |
| 317 | |
| 318 | #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_H_ |