Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtp_sender.cc

Issue 2669033003: Revert of Enable audio streams to send padding. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/modules/rtp_rtcp/source/rtp_sender_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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;
40 constexpr int kSendSideDelayWindowMs = 1000; 39 constexpr int kSendSideDelayWindowMs = 1000;
41 constexpr size_t kRtpHeaderLength = 12; 40 constexpr size_t kRtpHeaderLength = 12;
42 constexpr uint16_t kMaxInitRtpSeqNumber = 32767; // 2^15 -1. 41 constexpr uint16_t kMaxInitRtpSeqNumber = 32767; // 2^15 -1.
43 constexpr uint32_t kTimestampTicksPerMs = 90; 42 constexpr uint32_t kTimestampTicksPerMs = 90;
44 constexpr int kBitrateStatisticsWindowMs = 1000; 43 constexpr int kBitrateStatisticsWindowMs = 1000;
45 44
46 constexpr size_t kMinFlexfecPacketsToStoreForPacing = 50; 45 constexpr size_t kMinFlexfecPacketsToStoreForPacing = 50;
47 46
48 const char* FrameTypeToString(FrameType frame_type) { 47 const char* FrameTypeToString(FrameType frame_type) {
49 switch (frame_type) { 48 switch (frame_type) {
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 break; 474 break;
476 size_t payload_size = packet->payload_size(); 475 size_t payload_size = packet->payload_size();
477 if (!PrepareAndSendPacket(std::move(packet), true, false, probe_cluster_id)) 476 if (!PrepareAndSendPacket(std::move(packet), true, false, probe_cluster_id))
478 break; 477 break;
479 bytes_left -= payload_size; 478 bytes_left -= payload_size;
480 } 479 }
481 return bytes_to_send - bytes_left; 480 return bytes_to_send - bytes_left;
482 } 481 }
483 482
484 size_t RTPSender::SendPadData(size_t bytes, int probe_cluster_id) { 483 size_t RTPSender::SendPadData(size_t bytes, int probe_cluster_id) {
485 size_t padding_bytes_in_packet; 484 // Always send full padding packets. This is accounted for by the
486 if (audio_configured_) { 485 // RtpPacketSender, which will make sure we don't send too much padding even
487 // Allow smaller padding packets for audio. 486 // if a single packet is larger than requested.
488 padding_bytes_in_packet = std::max(std::min(bytes, MaxPayloadSize()), 487 size_t padding_bytes_in_packet =
489 kMinAudioPaddingLength); 488 std::min(MaxPayloadSize(), kMaxPaddingLength);
490 if (padding_bytes_in_packet > kMaxPaddingLength)
491 padding_bytes_in_packet = kMaxPaddingLength;
492 } else {
493 // Always send full padding packets. This is accounted for by the
494 // RtpPacketSender, which will make sure we don't send too much padding even
495 // if a single packet is larger than requested.
496 // We do this to avoid frequently sending small packets on higher bitrates.
497 padding_bytes_in_packet =
498 std::min(MaxPayloadSize(), kMaxPaddingLength);
499 }
500 size_t bytes_sent = 0; 489 size_t bytes_sent = 0;
501 while (bytes_sent < bytes) { 490 while (bytes_sent < bytes) {
502 int64_t now_ms = clock_->TimeInMilliseconds(); 491 int64_t now_ms = clock_->TimeInMilliseconds();
503 uint32_t ssrc; 492 uint32_t ssrc;
504 uint32_t timestamp; 493 uint32_t timestamp;
505 int64_t capture_time_ms; 494 int64_t capture_time_ms;
506 uint16_t sequence_number; 495 uint16_t sequence_number;
507 int payload_type; 496 int payload_type;
508 bool over_rtx; 497 bool over_rtx;
509 { 498 {
510 rtc::CritScope lock(&send_critsect_); 499 rtc::CritScope lock(&send_critsect_);
511 if (!sending_media_) 500 if (!sending_media_)
512 break; 501 break;
513 timestamp = last_rtp_timestamp_; 502 timestamp = last_rtp_timestamp_;
514 capture_time_ms = capture_time_ms_; 503 capture_time_ms = capture_time_ms_;
515 if (rtx_ == kRtxOff) { 504 if (rtx_ == kRtxOff) {
516 if (payload_type_ == -1) 505 // Without RTX we can't send padding in the middle of frames.
506 if (!last_packet_marker_bit_)
517 break; 507 break;
518 // Without RTX we can't send padding in the middle of frames.
519 // For audio marker bits doesn't mark the end of a frame and frames
520 // are usually a single packet, so for now we don't apply this rule
521 // for audio.
522 if (!audio_configured_ && !last_packet_marker_bit_) {
523 break;
524 }
525 ssrc = ssrc_; 508 ssrc = ssrc_;
526 sequence_number = sequence_number_; 509 sequence_number = sequence_number_;
527 ++sequence_number_; 510 ++sequence_number_;
528 payload_type = payload_type_; 511 payload_type = payload_type_;
529 over_rtx = false; 512 over_rtx = false;
530 } else { 513 } else {
531 // Without abs-send-time or transport sequence number a media packet 514 // Without abs-send-time or transport sequence number a media packet
532 // must be sent before padding so that the timestamps used for 515 // must be sent before padding so that the timestamps used for
533 // estimation are correct. 516 // estimation are correct.
534 if (!media_has_been_sent_ && 517 if (!media_has_been_sent_ &&
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 789
807 // RED+ULPFEC. 790 // RED+ULPFEC.
808 int pt_red; 791 int pt_red;
809 int pt_fec; 792 int pt_fec;
810 video_->GetUlpfecConfig(&pt_red, &pt_fec); 793 video_->GetUlpfecConfig(&pt_red, &pt_fec);
811 return static_cast<int>(packet.PayloadType()) == pt_red && 794 return static_cast<int>(packet.PayloadType()) == pt_red &&
812 static_cast<int>(packet.payload()[0]) == pt_fec; 795 static_cast<int>(packet.payload()[0]) == pt_fec;
813 } 796 }
814 797
815 size_t RTPSender::TimeToSendPadding(size_t bytes, int probe_cluster_id) { 798 size_t RTPSender::TimeToSendPadding(size_t bytes, int probe_cluster_id) {
816 if (bytes == 0) 799 if (audio_configured_ || bytes == 0)
817 return 0; 800 return 0;
818 size_t bytes_sent = TrySendRedundantPayloads(bytes, probe_cluster_id); 801 size_t bytes_sent = TrySendRedundantPayloads(bytes, probe_cluster_id);
819 if (bytes_sent < bytes) 802 if (bytes_sent < bytes)
820 bytes_sent += SendPadData(bytes - bytes_sent, probe_cluster_id); 803 bytes_sent += SendPadData(bytes - bytes_sent, probe_cluster_id);
821 return bytes_sent; 804 return bytes_sent;
822 } 805 }
823 806
824 bool RTPSender::SendToNetwork(std::unique_ptr<RtpPacketToSend> packet, 807 bool RTPSender::SendToNetwork(std::unique_ptr<RtpPacketToSend> packet,
825 StorageType storage, 808 StorageType storage,
826 RtpPacketSender::Priority priority) { 809 RtpPacketSender::Priority priority) {
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
1295 if (rtp_overhead_bytes_per_packet_ == packet.headers_size()) { 1278 if (rtp_overhead_bytes_per_packet_ == packet.headers_size()) {
1296 return; 1279 return;
1297 } 1280 }
1298 rtp_overhead_bytes_per_packet_ = packet.headers_size(); 1281 rtp_overhead_bytes_per_packet_ = packet.headers_size();
1299 overhead_bytes_per_packet = rtp_overhead_bytes_per_packet_; 1282 overhead_bytes_per_packet = rtp_overhead_bytes_per_packet_;
1300 } 1283 }
1301 overhead_observer_->OnOverheadChanged(overhead_bytes_per_packet); 1284 overhead_observer_->OnOverheadChanged(overhead_bytes_per_packet);
1302 } 1285 }
1303 1286
1304 } // namespace webrtc 1287 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/rtp_rtcp/source/rtp_sender_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698