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 18 matching lines...) Expand all Loading... | |
29 #include "webrtc/modules/rtp_rtcp/source/rtp_sender_audio.h" | 29 #include "webrtc/modules/rtp_rtcp/source/rtp_sender_audio.h" |
30 #include "webrtc/modules/rtp_rtcp/source/rtp_sender_video.h" | 30 #include "webrtc/modules/rtp_rtcp/source/rtp_sender_video.h" |
31 #include "webrtc/modules/rtp_rtcp/source/time_util.h" | 31 #include "webrtc/modules/rtp_rtcp/source/time_util.h" |
32 #include "webrtc/system_wrappers/include/field_trial.h" | 32 #include "webrtc/system_wrappers/include/field_trial.h" |
33 | 33 |
34 namespace webrtc { | 34 namespace webrtc { |
35 | 35 |
36 namespace { | 36 namespace { |
37 // Max in the RFC 3550 is 255 bytes, we limit it to be modulus 32 for SRTP. | 37 // Max in the RFC 3550 is 255 bytes, we limit it to be modulus 32 for SRTP. |
38 constexpr size_t kMaxPaddingLength = 224; | 38 constexpr size_t kMaxPaddingLength = 224; |
39 constexpr size_t kMinAudioPaddingLength = 50; | |
39 constexpr int kSendSideDelayWindowMs = 1000; | 40 constexpr int kSendSideDelayWindowMs = 1000; |
40 constexpr size_t kRtpHeaderLength = 12; | 41 constexpr size_t kRtpHeaderLength = 12; |
41 constexpr uint16_t kMaxInitRtpSeqNumber = 32767; // 2^15 -1. | 42 constexpr uint16_t kMaxInitRtpSeqNumber = 32767; // 2^15 -1. |
42 constexpr uint32_t kTimestampTicksPerMs = 90; | 43 constexpr uint32_t kTimestampTicksPerMs = 90; |
43 constexpr int kBitrateStatisticsWindowMs = 1000; | 44 constexpr int kBitrateStatisticsWindowMs = 1000; |
44 | 45 |
45 constexpr size_t kMinFlexfecPacketsToStoreForPacing = 50; | 46 constexpr size_t kMinFlexfecPacketsToStoreForPacing = 50; |
46 | 47 |
47 const char* FrameTypeToString(FrameType frame_type) { | 48 const char* FrameTypeToString(FrameType frame_type) { |
48 switch (frame_type) { | 49 switch (frame_type) { |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
474 break; | 475 break; |
475 bytes_left -= payload_size; | 476 bytes_left -= payload_size; |
476 } | 477 } |
477 return bytes_to_send - bytes_left; | 478 return bytes_to_send - bytes_left; |
478 } | 479 } |
479 | 480 |
480 size_t RTPSender::SendPadData(size_t bytes, int probe_cluster_id) { | 481 size_t RTPSender::SendPadData(size_t bytes, int probe_cluster_id) { |
481 // Always send full padding packets. This is accounted for by the | 482 // Always send full padding packets. This is accounted for by the |
482 // RtpPacketSender, which will make sure we don't send too much padding even | 483 // RtpPacketSender, which will make sure we don't send too much padding even |
483 // if a single packet is larger than requested. | 484 // if a single packet is larger than requested. |
484 size_t padding_bytes_in_packet = | 485 size_t padding_bytes_in_packet = |
mflodman
2017/01/26 14:03:37
Can we do this if (!audio_configured_) {} else {}
stefan-webrtc
2017/01/27 12:53:01
Didn't become that much better, but it's hopefully
| |
485 std::min(MaxPayloadSize(), kMaxPaddingLength); | 486 std::min(MaxPayloadSize(), kMaxPaddingLength); |
487 if (audio_configured_) { | |
488 // Allow smaller padding packets for audio. | |
489 padding_bytes_in_packet = std::max(std::min(bytes, padding_bytes_in_packet), | |
490 kMinAudioPaddingLength); | |
491 } | |
486 size_t bytes_sent = 0; | 492 size_t bytes_sent = 0; |
487 while (bytes_sent < bytes) { | 493 while (bytes_sent < bytes) { |
488 int64_t now_ms = clock_->TimeInMilliseconds(); | 494 int64_t now_ms = clock_->TimeInMilliseconds(); |
489 uint32_t ssrc; | 495 uint32_t ssrc; |
490 uint32_t timestamp; | 496 uint32_t timestamp; |
491 int64_t capture_time_ms; | 497 int64_t capture_time_ms; |
492 uint16_t sequence_number; | 498 uint16_t sequence_number; |
493 int payload_type; | 499 int payload_type; |
494 bool over_rtx; | 500 bool over_rtx; |
495 { | 501 { |
496 rtc::CritScope lock(&send_critsect_); | 502 rtc::CritScope lock(&send_critsect_); |
497 if (!sending_media_) | 503 if (!sending_media_) |
498 break; | 504 break; |
499 timestamp = last_rtp_timestamp_; | 505 timestamp = last_rtp_timestamp_; |
500 capture_time_ms = capture_time_ms_; | 506 capture_time_ms = capture_time_ms_; |
501 if (rtx_ == kRtxOff) { | 507 if (rtx_ == kRtxOff) { |
502 // Without RTX we can't send padding in the middle of frames. | 508 // Without RTX we can't send padding in the middle of frames. |
503 if (!last_packet_marker_bit_) | 509 if (!audio_configured_ && !last_packet_marker_bit_) { |
stefan-webrtc
2017/01/24 15:34:02
Audio streams typically don't use the marker bit,
mflodman
2017/01/26 14:03:37
Marker bits are used in the beginning of a talk sp
stefan-webrtc
2017/01/27 12:53:01
Done.
mflodman
2017/01/27 13:03:39
Thanks!
| |
504 break; | 510 break; |
511 } | |
505 ssrc = ssrc_; | 512 ssrc = ssrc_; |
506 sequence_number = sequence_number_; | 513 sequence_number = sequence_number_; |
507 ++sequence_number_; | 514 ++sequence_number_; |
508 payload_type = payload_type_; | 515 payload_type = payload_type_; |
509 over_rtx = false; | 516 over_rtx = false; |
510 } else { | 517 } else { |
511 // Without abs-send-time or transport sequence number a media packet | 518 // Without abs-send-time or transport sequence number a media packet |
512 // must be sent before padding so that the timestamps used for | 519 // must be sent before padding so that the timestamps used for |
513 // estimation are correct. | 520 // estimation are correct. |
514 if (!media_has_been_sent_ && | 521 if (!media_has_been_sent_ && |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
786 | 793 |
787 // RED+ULPFEC. | 794 // RED+ULPFEC. |
788 int pt_red; | 795 int pt_red; |
789 int pt_fec; | 796 int pt_fec; |
790 video_->GetUlpfecConfig(&pt_red, &pt_fec); | 797 video_->GetUlpfecConfig(&pt_red, &pt_fec); |
791 return static_cast<int>(packet.PayloadType()) == pt_red && | 798 return static_cast<int>(packet.PayloadType()) == pt_red && |
792 static_cast<int>(packet.payload()[0]) == pt_fec; | 799 static_cast<int>(packet.payload()[0]) == pt_fec; |
793 } | 800 } |
794 | 801 |
795 size_t RTPSender::TimeToSendPadding(size_t bytes, int probe_cluster_id) { | 802 size_t RTPSender::TimeToSendPadding(size_t bytes, int probe_cluster_id) { |
796 if (audio_configured_ || bytes == 0) | 803 if (bytes == 0) |
797 return 0; | 804 return 0; |
798 size_t bytes_sent = TrySendRedundantPayloads(bytes, probe_cluster_id); | 805 size_t bytes_sent = TrySendRedundantPayloads(bytes, probe_cluster_id); |
799 if (bytes_sent < bytes) | 806 if (bytes_sent < bytes) |
800 bytes_sent += SendPadData(bytes - bytes_sent, probe_cluster_id); | 807 bytes_sent += SendPadData(bytes - bytes_sent, probe_cluster_id); |
801 return bytes_sent; | 808 return bytes_sent; |
802 } | 809 } |
803 | 810 |
804 bool RTPSender::SendToNetwork(std::unique_ptr<RtpPacketToSend> packet, | 811 bool RTPSender::SendToNetwork(std::unique_ptr<RtpPacketToSend> packet, |
805 StorageType storage, | 812 StorageType storage, |
806 RtpPacketSender::Priority priority) { | 813 RtpPacketSender::Priority priority) { |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1276 if (rtp_overhead_bytes_per_packet_ == packet.headers_size()) { | 1283 if (rtp_overhead_bytes_per_packet_ == packet.headers_size()) { |
1277 return; | 1284 return; |
1278 } | 1285 } |
1279 rtp_overhead_bytes_per_packet_ = packet.headers_size(); | 1286 rtp_overhead_bytes_per_packet_ = packet.headers_size(); |
1280 overhead_bytes_per_packet = rtp_overhead_bytes_per_packet_; | 1287 overhead_bytes_per_packet = rtp_overhead_bytes_per_packet_; |
1281 } | 1288 } |
1282 overhead_observer_->OnOverheadChanged(overhead_bytes_per_packet); | 1289 overhead_observer_->OnOverheadChanged(overhead_bytes_per_packet); |
1283 } | 1290 } |
1284 | 1291 |
1285 } // namespace webrtc | 1292 } // namespace webrtc |
OLD | NEW |