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 17 matching lines...) Expand all Loading... |
28 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extension.h" | 28 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extension.h" |
29 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_history.h" | 29 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_history.h" |
30 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_config.h" | 30 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_config.h" |
31 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" | 31 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" |
32 #include "webrtc/modules/rtp_rtcp/source/ssrc_database.h" | 32 #include "webrtc/modules/rtp_rtcp/source/ssrc_database.h" |
33 #include "webrtc/transport.h" | 33 #include "webrtc/transport.h" |
34 | 34 |
35 namespace webrtc { | 35 namespace webrtc { |
36 | 36 |
37 class RateLimiter; | 37 class RateLimiter; |
| 38 class RtcEventLog; |
| 39 class RtpPacketToSend; |
38 class RTPSenderAudio; | 40 class RTPSenderAudio; |
39 class RTPSenderVideo; | 41 class RTPSenderVideo; |
40 class RtcEventLog; | |
41 | 42 |
42 class RTPSenderInterface { | 43 class RTPSenderInterface { |
43 public: | 44 public: |
44 RTPSenderInterface() {} | 45 RTPSenderInterface() {} |
45 virtual ~RTPSenderInterface() {} | 46 virtual ~RTPSenderInterface() {} |
46 | 47 |
47 virtual uint32_t SSRC() const = 0; | 48 virtual uint32_t SSRC() const = 0; |
48 virtual uint32_t Timestamp() const = 0; | 49 virtual uint32_t Timestamp() const = 0; |
49 | 50 |
50 virtual int32_t BuildRTPheader(uint8_t* data_buffer, | 51 virtual int32_t BuildRTPheader(uint8_t* data_buffer, |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 const bool inc_sequence_number = true) override; | 256 const bool inc_sequence_number = true) override; |
256 | 257 |
257 size_t RtpHeaderLength() const override; | 258 size_t RtpHeaderLength() const override; |
258 uint16_t AllocateSequenceNumber(uint16_t packets_to_send) override; | 259 uint16_t AllocateSequenceNumber(uint16_t packets_to_send) override; |
259 size_t MaxPayloadLength() const override; | 260 size_t MaxPayloadLength() const override; |
260 | 261 |
261 // Current timestamp. | 262 // Current timestamp. |
262 uint32_t Timestamp() const override; | 263 uint32_t Timestamp() const override; |
263 uint32_t SSRC() const override; | 264 uint32_t SSRC() const override; |
264 | 265 |
| 266 // Deprecated. Create RtpPacketToSend instead and use next function. |
265 int32_t SendToNetwork(uint8_t* data_buffer, | 267 int32_t SendToNetwork(uint8_t* data_buffer, |
266 size_t payload_length, | 268 size_t payload_length, |
267 size_t rtp_header_length, | 269 size_t rtp_header_length, |
268 int64_t capture_time_ms, | 270 int64_t capture_time_ms, |
269 StorageType storage, | 271 StorageType storage, |
270 RtpPacketSender::Priority priority) override; | 272 RtpPacketSender::Priority priority) override; |
| 273 bool SendToNetwork(std::unique_ptr<RtpPacketToSend> packet, |
| 274 StorageType storage, |
| 275 RtpPacketSender::Priority priority); |
271 | 276 |
272 // Audio. | 277 // Audio. |
273 | 278 |
274 // Send a DTMF tone using RFC 2833 (4733). | 279 // Send a DTMF tone using RFC 2833 (4733). |
275 int32_t SendTelephoneEvent(uint8_t key, uint16_t time_ms, uint8_t level); | 280 int32_t SendTelephoneEvent(uint8_t key, uint16_t time_ms, uint8_t level); |
276 | 281 |
277 // Set audio packet size, used to determine when it's time to send a DTMF | 282 // Set audio packet size, used to determine when it's time to send a DTMF |
278 // packet in silence (CNG). | 283 // packet in silence (CNG). |
279 int32_t SetAudioPacketSize(uint16_t packet_size_samples); | 284 int32_t SetAudioPacketSize(uint16_t packet_size_samples); |
280 | 285 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 | 343 |
339 size_t CreateRtpHeader(uint8_t* header, | 344 size_t CreateRtpHeader(uint8_t* header, |
340 int8_t payload_type, | 345 int8_t payload_type, |
341 uint32_t ssrc, | 346 uint32_t ssrc, |
342 bool marker_bit, | 347 bool marker_bit, |
343 uint32_t timestamp, | 348 uint32_t timestamp, |
344 uint16_t sequence_number, | 349 uint16_t sequence_number, |
345 const std::vector<uint32_t>& csrcs) const | 350 const std::vector<uint32_t>& csrcs) const |
346 EXCLUSIVE_LOCKS_REQUIRED(send_critsect_); | 351 EXCLUSIVE_LOCKS_REQUIRED(send_critsect_); |
347 | 352 |
348 bool PrepareAndSendPacket(uint8_t* buffer, | 353 bool PrepareAndSendPacket(std::unique_ptr<RtpPacketToSend> packet, |
349 size_t length, | |
350 int64_t capture_time_ms, | |
351 bool send_over_rtx, | 354 bool send_over_rtx, |
352 bool is_retransmit, | 355 bool is_retransmit, |
353 int probe_cluster_id); | 356 int probe_cluster_id); |
354 | 357 |
355 // Return the number of bytes sent. Note that both of these functions may | 358 // Return the number of bytes sent. Note that both of these functions may |
356 // return a larger value that their argument. | 359 // return a larger value that their argument. |
357 size_t TrySendRedundantPayloads(size_t bytes, int probe_cluster_id); | 360 size_t TrySendRedundantPayloads(size_t bytes, int probe_cluster_id); |
358 | 361 |
359 void BuildPaddingPacket(uint8_t* packet, | 362 std::unique_ptr<RtpPacketToSend> BuildRtxPacket( |
360 size_t header_length, | 363 const RtpPacketToSend& packet); |
361 size_t padding_length); | |
362 | 364 |
363 void BuildRtxPacket(uint8_t* buffer, size_t* length, | 365 bool SendPacketToNetwork(const RtpPacketToSend& packet, |
364 uint8_t* buffer_rtx); | |
365 | |
366 bool SendPacketToNetwork(const uint8_t* packet, | |
367 size_t size, | |
368 const PacketOptions& options); | 366 const PacketOptions& options); |
369 | 367 |
370 void UpdateDelayStatistics(int64_t capture_time_ms, int64_t now_ms); | 368 void UpdateDelayStatistics(int64_t capture_time_ms, int64_t now_ms); |
371 void UpdateOnSendPacket(int packet_id, | 369 void UpdateOnSendPacket(int packet_id, |
372 int64_t capture_time_ms, | 370 int64_t capture_time_ms, |
373 uint32_t ssrc); | 371 uint32_t ssrc); |
374 | 372 |
375 // Find the byte position of the RTP extension as indicated by |type| in | 373 // Find the byte position of the RTP extension as indicated by |type| in |
376 // |rtp_packet|. Return false if such extension doesn't exist. | 374 // |rtp_packet|. Return false if such extension doesn't exist. |
377 bool FindHeaderExtensionPosition(RTPExtensionType type, | 375 bool FindHeaderExtensionPosition(RTPExtensionType type, |
378 const uint8_t* rtp_packet, | 376 const uint8_t* rtp_packet, |
379 size_t rtp_packet_length, | 377 size_t rtp_packet_length, |
380 const RTPHeader& rtp_header, | 378 const RTPHeader& rtp_header, |
381 size_t* position) const | 379 size_t* position) const |
382 EXCLUSIVE_LOCKS_REQUIRED(send_critsect_); | 380 EXCLUSIVE_LOCKS_REQUIRED(send_critsect_); |
383 | 381 |
384 void UpdateTransmissionTimeOffset(uint8_t* rtp_packet, | 382 bool UpdateTransportSequenceNumber(RtpPacketToSend* packet, |
385 size_t rtp_packet_length, | 383 int* packet_id) const; |
386 const RTPHeader& rtp_header, | |
387 int64_t time_diff_ms) const; | |
388 void UpdateAbsoluteSendTime(uint8_t* rtp_packet, | |
389 size_t rtp_packet_length, | |
390 const RTPHeader& rtp_header, | |
391 int64_t now_ms) const; | |
392 | |
393 bool UpdateTransportSequenceNumber(uint8_t* rtp_packet, | |
394 size_t rtp_packet_length, | |
395 const RTPHeader& rtp_header, | |
396 int* sequence_number) const; | |
397 | 384 |
398 void UpdatePlayoutDelayLimits(uint8_t* rtp_packet, | 385 void UpdatePlayoutDelayLimits(uint8_t* rtp_packet, |
399 size_t rtp_packet_length, | 386 size_t rtp_packet_length, |
400 const RTPHeader& rtp_header, | 387 const RTPHeader& rtp_header, |
401 uint16_t min_playout_delay, | 388 uint16_t min_playout_delay, |
402 uint16_t max_playout_delay) const; | 389 uint16_t max_playout_delay) const; |
403 | 390 |
404 bool AllocateTransportSequenceNumber(int* packet_id) const; | 391 void UpdateRtpStats(const RtpPacketToSend& packet, |
405 | |
406 void UpdateRtpStats(const uint8_t* buffer, | |
407 size_t packet_length, | |
408 const RTPHeader& header, | |
409 bool is_rtx, | 392 bool is_rtx, |
410 bool is_retransmit); | 393 bool is_retransmit); |
411 bool IsFecPacket(const uint8_t* buffer, const RTPHeader& header) const; | 394 bool IsFecPacket(const RtpPacketToSend& packet) const; |
412 | 395 |
413 Clock* const clock_; | 396 Clock* const clock_; |
414 const int64_t clock_delta_ms_; | 397 const int64_t clock_delta_ms_; |
415 Random random_ GUARDED_BY(send_critsect_); | 398 Random random_ GUARDED_BY(send_critsect_); |
416 | 399 |
417 const bool audio_configured_; | 400 const bool audio_configured_; |
418 const std::unique_ptr<RTPSenderAudio> audio_; | 401 const std::unique_ptr<RTPSenderAudio> audio_; |
419 const std::unique_ptr<RTPSenderVideo> video_; | 402 const std::unique_ptr<RTPSenderVideo> video_; |
420 | 403 |
421 RtpPacketSender* const paced_sender_; | 404 RtpPacketSender* const paced_sender_; |
(...skipping 16 matching lines...) Expand all Loading... |
438 VideoRotation rotation_; | 421 VideoRotation rotation_; |
439 bool video_rotation_active_; | 422 bool video_rotation_active_; |
440 uint16_t transport_sequence_number_; | 423 uint16_t transport_sequence_number_; |
441 | 424 |
442 // Tracks the current request for playout delay limits from application | 425 // Tracks the current request for playout delay limits from application |
443 // and decides whether the current RTP frame should include the playout | 426 // and decides whether the current RTP frame should include the playout |
444 // delay extension on header. | 427 // delay extension on header. |
445 PlayoutDelayOracle playout_delay_oracle_; | 428 PlayoutDelayOracle playout_delay_oracle_; |
446 bool playout_delay_active_ GUARDED_BY(send_critsect_); | 429 bool playout_delay_active_ GUARDED_BY(send_critsect_); |
447 | 430 |
448 RTPPacketHistory packet_history_; | 431 RtpPacketHistory packet_history_; |
449 | 432 |
450 // Statistics | 433 // Statistics |
451 rtc::CriticalSection statistics_crit_; | 434 rtc::CriticalSection statistics_crit_; |
452 SendDelayMap send_delays_ GUARDED_BY(statistics_crit_); | 435 SendDelayMap send_delays_ GUARDED_BY(statistics_crit_); |
453 FrameCounts frame_counts_ GUARDED_BY(statistics_crit_); | 436 FrameCounts frame_counts_ GUARDED_BY(statistics_crit_); |
454 StreamDataCounters rtp_stats_ GUARDED_BY(statistics_crit_); | 437 StreamDataCounters rtp_stats_ GUARDED_BY(statistics_crit_); |
455 StreamDataCounters rtx_rtp_stats_ GUARDED_BY(statistics_crit_); | 438 StreamDataCounters rtx_rtp_stats_ GUARDED_BY(statistics_crit_); |
456 StreamDataCountersCallback* rtp_stats_callback_ GUARDED_BY(statistics_crit_); | 439 StreamDataCountersCallback* rtp_stats_callback_ GUARDED_BY(statistics_crit_); |
457 RateStatistics total_bitrate_sent_ GUARDED_BY(statistics_crit_); | 440 RateStatistics total_bitrate_sent_ GUARDED_BY(statistics_crit_); |
458 RateStatistics nack_bitrate_sent_ GUARDED_BY(statistics_crit_); | 441 RateStatistics nack_bitrate_sent_ GUARDED_BY(statistics_crit_); |
(...skipping 25 matching lines...) Expand all Loading... |
484 std::map<int8_t, int8_t> rtx_payload_type_map_ GUARDED_BY(send_critsect_); | 467 std::map<int8_t, int8_t> rtx_payload_type_map_ GUARDED_BY(send_critsect_); |
485 | 468 |
486 RateLimiter* const retransmission_rate_limiter_; | 469 RateLimiter* const retransmission_rate_limiter_; |
487 | 470 |
488 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(RTPSender); | 471 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(RTPSender); |
489 }; | 472 }; |
490 | 473 |
491 } // namespace webrtc | 474 } // namespace webrtc |
492 | 475 |
493 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_H_ | 476 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_H_ |
OLD | NEW |