OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 int8_t payload_type, | 107 int8_t payload_type, |
108 uint32_t timestamp, | 108 uint32_t timestamp, |
109 int64_t capture_time_ms, | 109 int64_t capture_time_ms, |
110 const uint8_t* payload_data, | 110 const uint8_t* payload_data, |
111 size_t payload_size, | 111 size_t payload_size, |
112 const RTPFragmentationHeader* fragmentation, | 112 const RTPFragmentationHeader* fragmentation, |
113 const RTPVideoHeader* rtp_header, | 113 const RTPVideoHeader* rtp_header, |
114 uint32_t* transport_frame_id_out); | 114 uint32_t* transport_frame_id_out); |
115 | 115 |
116 // RTP header extension | 116 // RTP header extension |
117 int32_t SetTransmissionTimeOffset(int32_t transmission_time_offset); | |
118 int32_t SetAbsoluteSendTime(uint32_t absolute_send_time); | |
119 void SetVideoRotation(VideoRotation rotation); | |
120 int32_t SetTransportSequenceNumber(uint16_t sequence_number); | |
121 | |
122 int32_t RegisterRtpHeaderExtension(RTPExtensionType type, uint8_t id); | 117 int32_t RegisterRtpHeaderExtension(RTPExtensionType type, uint8_t id); |
123 bool IsRtpHeaderExtensionRegistered(RTPExtensionType type); | 118 bool IsRtpHeaderExtensionRegistered(RTPExtensionType type); |
124 int32_t DeregisterRtpHeaderExtension(RTPExtensionType type); | 119 int32_t DeregisterRtpHeaderExtension(RTPExtensionType type); |
125 | 120 |
126 size_t RtpHeaderExtensionLength() const; | 121 size_t RtpHeaderExtensionLength() const; |
127 | 122 |
128 uint16_t BuildRtpHeaderExtension(uint8_t* data_buffer, bool marker_bit) const | |
129 EXCLUSIVE_LOCKS_REQUIRED(send_critsect_); | |
130 | |
131 uint8_t BuildTransmissionTimeOffsetExtension(uint8_t* data_buffer) const | |
132 EXCLUSIVE_LOCKS_REQUIRED(send_critsect_); | |
133 uint8_t BuildAudioLevelExtension(uint8_t* data_buffer) const | |
134 EXCLUSIVE_LOCKS_REQUIRED(send_critsect_); | |
135 uint8_t BuildAbsoluteSendTimeExtension(uint8_t* data_buffer) const | |
136 EXCLUSIVE_LOCKS_REQUIRED(send_critsect_); | |
137 uint8_t BuildVideoRotationExtension(uint8_t* data_buffer) const | |
138 EXCLUSIVE_LOCKS_REQUIRED(send_critsect_); | |
139 uint8_t BuildTransportSequenceNumberExtension(uint8_t* data_buffer, | |
140 uint16_t sequence_number) const | |
141 EXCLUSIVE_LOCKS_REQUIRED(send_critsect_); | |
142 uint8_t BuildPlayoutDelayExtension(uint8_t* data_buffer, | |
143 uint16_t min_playout_delay_ms, | |
144 uint16_t max_playout_delay_ms) const | |
145 EXCLUSIVE_LOCKS_REQUIRED(send_critsect_); | |
146 | |
147 // Verifies that the specified extension is registered, and that it is | |
148 // present in rtp packet. If extension is not registered kNotRegistered is | |
149 // returned. If extension cannot be found in the rtp header, or if it is | |
150 // malformed, kError is returned. Otherwise *extension_offset is set to the | |
151 // offset of the extension from the beginning of the rtp packet and kOk is | |
152 // returned. | |
153 enum class ExtensionStatus { | |
154 kNotRegistered, | |
155 kOk, | |
156 kError, | |
157 }; | |
158 ExtensionStatus VerifyExtension(RTPExtensionType extension_type, | |
159 uint8_t* rtp_packet, | |
160 size_t rtp_packet_length, | |
161 const RTPHeader& rtp_header, | |
162 size_t extension_length_bytes, | |
163 size_t* extension_offset) const | |
164 EXCLUSIVE_LOCKS_REQUIRED(send_critsect_); | |
165 | |
166 bool UpdateAudioLevel(uint8_t* rtp_packet, | |
167 size_t rtp_packet_length, | |
168 const RTPHeader& rtp_header, | |
169 bool is_voiced, | |
170 uint8_t dBov) const; | |
171 | |
172 bool UpdateVideoRotation(uint8_t* rtp_packet, | |
173 size_t rtp_packet_length, | |
174 const RTPHeader& rtp_header, | |
175 VideoRotation rotation) const; | |
176 | |
177 bool TimeToSendPacket(uint16_t sequence_number, | 123 bool TimeToSendPacket(uint16_t sequence_number, |
178 int64_t capture_time_ms, | 124 int64_t capture_time_ms, |
179 bool retransmission, | 125 bool retransmission, |
180 int probe_cluster_id); | 126 int probe_cluster_id); |
181 size_t TimeToSendPadding(size_t bytes, int probe_cluster_id); | 127 size_t TimeToSendPadding(size_t bytes, int probe_cluster_id); |
182 | 128 |
183 // NACK. | 129 // NACK. |
184 int SelectiveRetransmissions() const; | 130 int SelectiveRetransmissions() const; |
185 int SetSelectiveRetransmissions(uint8_t settings); | 131 int SetSelectiveRetransmissions(uint8_t settings); |
186 void OnReceivedNACK(const std::list<uint16_t>& nack_sequence_numbers, | 132 void OnReceivedNACK(const std::list<uint16_t>& nack_sequence_numbers, |
(...skipping 10 matching lines...) Expand all Loading... |
197 | 143 |
198 // RTX. | 144 // RTX. |
199 void SetRtxStatus(int mode); | 145 void SetRtxStatus(int mode); |
200 int RtxStatus() const; | 146 int RtxStatus() const; |
201 | 147 |
202 uint32_t RtxSsrc() const; | 148 uint32_t RtxSsrc() const; |
203 void SetRtxSsrc(uint32_t ssrc); | 149 void SetRtxSsrc(uint32_t ssrc); |
204 | 150 |
205 void SetRtxPayloadType(int payload_type, int associated_payload_type); | 151 void SetRtxPayloadType(int payload_type, int associated_payload_type); |
206 | 152 |
207 // Functions wrapping RTPSenderInterface. | 153 // Create empty packet, fills ssrc. Unless |minimalistic| flag is set |
208 int32_t BuildRTPheader(uint8_t* data_buffer, | 154 // also set csrcs and reserve place for registered header extensions |
209 int8_t payload_type, | 155 // RtpSender updates before sending. |
210 bool marker_bit, | 156 std::unique_ptr<RtpPacketToSend> AllocatePacket(bool minimalistic) const; |
211 uint32_t capture_timestamp, | 157 // Allocates sequence_number, update packet->Timstamp() with start_timestamp_ |
212 int64_t capture_time_ms, | 158 // offset, updates RtpSender last_send fields with values from |packet|. |
213 bool timestamp_provided = true, | 159 // Return false of RtpSender not ready to send any more (i.e. destructing). |
214 bool inc_sequence_number = true); | 160 bool PrepareToSend(RtpPacketToSend* packet); |
215 int32_t BuildRtpHeader(uint8_t* data_buffer, | 161 |
216 int8_t payload_type, | 162 uint32_t TimestampOffset(uint32_t capture_rtp_timestamp) const; |
217 bool marker_bit, | |
218 uint32_t capture_timestamp, | |
219 int64_t capture_time_ms); | |
220 | 163 |
221 size_t RtpHeaderLength() const; | 164 size_t RtpHeaderLength() const; |
222 uint16_t AllocateSequenceNumber(uint16_t packets_to_send); | 165 uint16_t AllocateSequenceNumber(uint16_t packets_to_send); |
223 size_t MaxPayloadLength() const; | 166 size_t MaxPayloadLength() const; |
224 | 167 |
225 // Current timestamp. | 168 // Current timestamp. |
226 uint32_t Timestamp() const; | 169 uint32_t Timestamp() const; |
227 uint32_t SSRC() const; | 170 uint32_t SSRC() const; |
228 | 171 |
229 // Deprecated. Create RtpPacketToSend instead and use next function. | |
230 bool SendToNetwork(uint8_t* data_buffer, | |
231 size_t payload_length, | |
232 size_t rtp_header_length, | |
233 int64_t capture_time_ms, | |
234 StorageType storage, | |
235 RtpPacketSender::Priority priority); | |
236 bool SendToNetwork(std::unique_ptr<RtpPacketToSend> packet, | 172 bool SendToNetwork(std::unique_ptr<RtpPacketToSend> packet, |
237 StorageType storage, | 173 StorageType storage, |
238 RtpPacketSender::Priority priority); | 174 RtpPacketSender::Priority priority); |
239 | 175 |
240 // Audio. | 176 // Audio. |
241 | 177 |
242 // Send a DTMF tone using RFC 2833 (4733). | 178 // Send a DTMF tone using RFC 2833 (4733). |
243 int32_t SendTelephoneEvent(uint8_t key, uint16_t time_ms, uint8_t level); | 179 int32_t SendTelephoneEvent(uint8_t key, uint16_t time_ms, uint8_t level); |
244 | 180 |
245 // Set audio packet size, used to determine when it's time to send a DTMF | 181 // Set audio packet size, used to determine when it's time to send a DTMF |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 // Called on update of RTP statistics. | 221 // Called on update of RTP statistics. |
286 void RegisterRtpStatisticsCallback(StreamDataCountersCallback* callback); | 222 void RegisterRtpStatisticsCallback(StreamDataCountersCallback* callback); |
287 StreamDataCountersCallback* GetRtpStatisticsCallback() const; | 223 StreamDataCountersCallback* GetRtpStatisticsCallback() const; |
288 | 224 |
289 uint32_t BitrateSent() const; | 225 uint32_t BitrateSent() const; |
290 | 226 |
291 void SetRtpState(const RtpState& rtp_state); | 227 void SetRtpState(const RtpState& rtp_state); |
292 RtpState GetRtpState() const; | 228 RtpState GetRtpState() const; |
293 void SetRtxRtpState(const RtpState& rtp_state); | 229 void SetRtxRtpState(const RtpState& rtp_state); |
294 RtpState GetRtxRtpState() const; | 230 RtpState GetRtxRtpState() const; |
295 bool ActivateCVORtpHeaderExtension(); | |
296 | 231 |
297 protected: | 232 protected: |
298 int32_t CheckPayloadType(int8_t payload_type, RtpVideoCodecTypes* video_type); | 233 int32_t CheckPayloadType(int8_t payload_type, RtpVideoCodecTypes* video_type); |
299 | 234 |
300 private: | 235 private: |
301 // Maps capture time in milliseconds to send-side delay in milliseconds. | 236 // Maps capture time in milliseconds to send-side delay in milliseconds. |
302 // Send-side delay is the difference between transmission time and capture | 237 // Send-side delay is the difference between transmission time and capture |
303 // time. | 238 // time. |
304 typedef std::map<int64_t, int> SendDelayMap; | 239 typedef std::map<int64_t, int> SendDelayMap; |
305 | 240 |
(...skipping 21 matching lines...) Expand all Loading... |
327 bool SendPacketToNetwork(const RtpPacketToSend& packet, | 262 bool SendPacketToNetwork(const RtpPacketToSend& packet, |
328 const PacketOptions& options); | 263 const PacketOptions& options); |
329 | 264 |
330 void UpdateDelayStatistics(int64_t capture_time_ms, int64_t now_ms); | 265 void UpdateDelayStatistics(int64_t capture_time_ms, int64_t now_ms); |
331 void UpdateOnSendPacket(int packet_id, | 266 void UpdateOnSendPacket(int packet_id, |
332 int64_t capture_time_ms, | 267 int64_t capture_time_ms, |
333 uint32_t ssrc); | 268 uint32_t ssrc); |
334 | 269 |
335 // Find the byte position of the RTP extension as indicated by |type| in | 270 // Find the byte position of the RTP extension as indicated by |type| in |
336 // |rtp_packet|. Return false if such extension doesn't exist. | 271 // |rtp_packet|. Return false if such extension doesn't exist. |
337 bool FindHeaderExtensionPosition(RTPExtensionType type, | |
338 const uint8_t* rtp_packet, | |
339 size_t rtp_packet_length, | |
340 const RTPHeader& rtp_header, | |
341 size_t* position) const | |
342 EXCLUSIVE_LOCKS_REQUIRED(send_critsect_); | |
343 | |
344 bool UpdateTransportSequenceNumber(RtpPacketToSend* packet, | 272 bool UpdateTransportSequenceNumber(RtpPacketToSend* packet, |
345 int* packet_id) const; | 273 int* packet_id) const; |
346 | 274 |
347 void UpdatePlayoutDelayLimits(uint8_t* rtp_packet, | 275 void UpdatePlayoutDelayLimits(uint8_t* rtp_packet, |
348 size_t rtp_packet_length, | 276 size_t rtp_packet_length, |
349 const RTPHeader& rtp_header, | 277 const RTPHeader& rtp_header, |
350 uint16_t min_playout_delay, | 278 uint16_t min_playout_delay, |
351 uint16_t max_playout_delay) const; | 279 uint16_t max_playout_delay) const; |
352 | 280 |
353 void UpdateRtpStats(const RtpPacketToSend& packet, | 281 void UpdateRtpStats(const RtpPacketToSend& packet, |
(...skipping 17 matching lines...) Expand all Loading... |
371 | 299 |
372 Transport *transport_; | 300 Transport *transport_; |
373 bool sending_media_ GUARDED_BY(send_critsect_); | 301 bool sending_media_ GUARDED_BY(send_critsect_); |
374 | 302 |
375 size_t max_payload_length_; | 303 size_t max_payload_length_; |
376 | 304 |
377 int8_t payload_type_ GUARDED_BY(send_critsect_); | 305 int8_t payload_type_ GUARDED_BY(send_critsect_); |
378 std::map<int8_t, RtpUtility::Payload*> payload_type_map_; | 306 std::map<int8_t, RtpUtility::Payload*> payload_type_map_; |
379 | 307 |
380 RtpHeaderExtensionMap rtp_header_extension_map_ GUARDED_BY(send_critsect_); | 308 RtpHeaderExtensionMap rtp_header_extension_map_ GUARDED_BY(send_critsect_); |
381 int32_t transmission_time_offset_; | |
382 uint32_t absolute_send_time_; | |
383 VideoRotation rotation_; | |
384 bool video_rotation_active_; | |
385 uint16_t transport_sequence_number_; | |
386 | 309 |
387 // Tracks the current request for playout delay limits from application | 310 // Tracks the current request for playout delay limits from application |
388 // and decides whether the current RTP frame should include the playout | 311 // and decides whether the current RTP frame should include the playout |
389 // delay extension on header. | 312 // delay extension on header. |
390 PlayoutDelayOracle playout_delay_oracle_; | 313 PlayoutDelayOracle playout_delay_oracle_; |
391 bool playout_delay_active_ GUARDED_BY(send_critsect_); | 314 bool playout_delay_active_ GUARDED_BY(send_critsect_); |
392 | 315 |
393 RtpPacketHistory packet_history_; | 316 RtpPacketHistory packet_history_; |
394 | 317 |
395 // Statistics | 318 // Statistics |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 std::map<int8_t, int8_t> rtx_payload_type_map_ GUARDED_BY(send_critsect_); | 352 std::map<int8_t, int8_t> rtx_payload_type_map_ GUARDED_BY(send_critsect_); |
430 | 353 |
431 RateLimiter* const retransmission_rate_limiter_; | 354 RateLimiter* const retransmission_rate_limiter_; |
432 | 355 |
433 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(RTPSender); | 356 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(RTPSender); |
434 }; | 357 }; |
435 | 358 |
436 } // namespace webrtc | 359 } // namespace webrtc |
437 | 360 |
438 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_H_ | 361 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_H_ |
OLD | NEW |