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

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

Issue 2005313003: Propagate probing cluster id to SendTimeHistory. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 6 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
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 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 } else if (frame_type == kVideoFrameDelta) { 536 } else if (frame_type == kVideoFrameDelta) {
537 ++frame_counts_.delta_frames; 537 ++frame_counts_.delta_frames;
538 } 538 }
539 if (frame_count_observer_) { 539 if (frame_count_observer_) {
540 frame_count_observer_->FrameCountUpdated(frame_counts_, ssrc); 540 frame_count_observer_->FrameCountUpdated(frame_counts_, ssrc);
541 } 541 }
542 542
543 return ret_val; 543 return ret_val;
544 } 544 }
545 545
546 size_t RTPSender::TrySendRedundantPayloads(size_t bytes_to_send) { 546 size_t RTPSender::TrySendRedundantPayloads(size_t bytes_to_send,
547 int probe_cluster_id) {
547 { 548 {
548 rtc::CritScope lock(&send_critsect_); 549 rtc::CritScope lock(&send_critsect_);
549 if (!sending_media_) 550 if (!sending_media_)
550 return 0; 551 return 0;
551 if ((rtx_ & kRtxRedundantPayloads) == 0) 552 if ((rtx_ & kRtxRedundantPayloads) == 0)
552 return 0; 553 return 0;
553 } 554 }
554 555
555 uint8_t buffer[IP_PACKET_SIZE]; 556 uint8_t buffer[IP_PACKET_SIZE];
556 int bytes_left = static_cast<int>(bytes_to_send); 557 int bytes_left = static_cast<int>(bytes_to_send);
557 while (bytes_left > 0) { 558 while (bytes_left > 0) {
558 size_t length = bytes_left; 559 size_t length = bytes_left;
559 int64_t capture_time_ms; 560 int64_t capture_time_ms;
560 if (!packet_history_.GetBestFittingPacket(buffer, &length, 561 if (!packet_history_.GetBestFittingPacket(buffer, &length,
561 &capture_time_ms)) { 562 &capture_time_ms)) {
562 break; 563 break;
563 } 564 }
564 if (!PrepareAndSendPacket(buffer, length, capture_time_ms, true, false)) 565 if (!PrepareAndSendPacket(buffer, length, capture_time_ms, true, false,
566 probe_cluster_id))
565 break; 567 break;
566 RtpUtility::RtpHeaderParser rtp_parser(buffer, length); 568 RtpUtility::RtpHeaderParser rtp_parser(buffer, length);
567 RTPHeader rtp_header; 569 RTPHeader rtp_header;
568 rtp_parser.Parse(&rtp_header); 570 rtp_parser.Parse(&rtp_header);
569 bytes_left -= static_cast<int>(length - rtp_header.headerLength); 571 bytes_left -= static_cast<int>(length - rtp_header.headerLength);
570 } 572 }
571 return bytes_to_send - bytes_left; 573 return bytes_to_send - bytes_left;
572 } 574 }
573 575
574 void RTPSender::BuildPaddingPacket(uint8_t* packet, 576 void RTPSender::BuildPaddingPacket(uint8_t* packet,
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 corrected_capture_tims_ms, length - header.headerLength, true); 728 corrected_capture_tims_ms, length - header.headerLength, true);
727 729
728 return length; 730 return length;
729 } 731 }
730 int rtx = kRtxOff; 732 int rtx = kRtxOff;
731 { 733 {
732 rtc::CritScope lock(&send_critsect_); 734 rtc::CritScope lock(&send_critsect_);
733 rtx = rtx_; 735 rtx = rtx_;
734 } 736 }
735 if (!PrepareAndSendPacket(data_buffer, length, capture_time_ms, 737 if (!PrepareAndSendPacket(data_buffer, length, capture_time_ms,
736 (rtx & kRtxRetransmitted) > 0, true)) { 738 (rtx & kRtxRetransmitted) > 0, true, -1)) {
737 return -1; 739 return -1;
738 } 740 }
739 return static_cast<int32_t>(length); 741 return static_cast<int32_t>(length);
740 } 742 }
741 743
742 bool RTPSender::SendPacketToNetwork(const uint8_t* packet, 744 bool RTPSender::SendPacketToNetwork(const uint8_t* packet,
743 size_t size, 745 size_t size,
744 const PacketOptions& options) { 746 const PacketOptions& options) {
745 int bytes_sent = -1; 747 int bytes_sent = -1;
746 if (transport_) { 748 if (transport_) {
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 nack_byte_count_[i + 1] = nack_byte_count_[i]; 864 nack_byte_count_[i + 1] = nack_byte_count_[i];
863 nack_byte_count_times_[i + 1] = nack_byte_count_times_[i]; 865 nack_byte_count_times_[i + 1] = nack_byte_count_times_[i];
864 } 866 }
865 nack_byte_count_[0] = bytes; 867 nack_byte_count_[0] = bytes;
866 nack_byte_count_times_[0] = now; 868 nack_byte_count_times_[0] = now;
867 } 869 }
868 870
869 // Called from pacer when we can send the packet. 871 // Called from pacer when we can send the packet.
870 bool RTPSender::TimeToSendPacket(uint16_t sequence_number, 872 bool RTPSender::TimeToSendPacket(uint16_t sequence_number,
871 int64_t capture_time_ms, 873 int64_t capture_time_ms,
872 bool retransmission) { 874 bool retransmission,
875 int probe_cluster_id) {
873 size_t length = IP_PACKET_SIZE; 876 size_t length = IP_PACKET_SIZE;
874 uint8_t data_buffer[IP_PACKET_SIZE]; 877 uint8_t data_buffer[IP_PACKET_SIZE];
875 int64_t stored_time_ms; 878 int64_t stored_time_ms;
876 879
877 if (!packet_history_.GetPacketAndSetSendTime(sequence_number, 880 if (!packet_history_.GetPacketAndSetSendTime(sequence_number,
878 0, 881 0,
879 retransmission, 882 retransmission,
880 data_buffer, 883 data_buffer,
881 &length, 884 &length,
882 &stored_time_ms)) { 885 &stored_time_ms)) {
883 // Packet cannot be found. Allow sending to continue. 886 // Packet cannot be found. Allow sending to continue.
884 return true; 887 return true;
885 } 888 }
886 889
887 int rtx; 890 int rtx;
888 { 891 {
889 rtc::CritScope lock(&send_critsect_); 892 rtc::CritScope lock(&send_critsect_);
890 rtx = rtx_; 893 rtx = rtx_;
891 } 894 }
892 return PrepareAndSendPacket(data_buffer, 895 return PrepareAndSendPacket(data_buffer, length, capture_time_ms,
893 length,
894 capture_time_ms,
895 retransmission && (rtx & kRtxRetransmitted) > 0, 896 retransmission && (rtx & kRtxRetransmitted) > 0,
896 retransmission); 897 retransmission, probe_cluster_id);
897 } 898 }
898 899
899 bool RTPSender::PrepareAndSendPacket(uint8_t* buffer, 900 bool RTPSender::PrepareAndSendPacket(uint8_t* buffer,
900 size_t length, 901 size_t length,
901 int64_t capture_time_ms, 902 int64_t capture_time_ms,
902 bool send_over_rtx, 903 bool send_over_rtx,
903 bool is_retransmit) { 904 bool is_retransmit,
905 int probe_cluster_id) {
904 uint8_t* buffer_to_send_ptr = buffer; 906 uint8_t* buffer_to_send_ptr = buffer;
905 907
906 RtpUtility::RtpHeaderParser rtp_parser(buffer, length); 908 RtpUtility::RtpHeaderParser rtp_parser(buffer, length);
907 RTPHeader rtp_header; 909 RTPHeader rtp_header;
908 rtp_parser.Parse(&rtp_header); 910 rtp_parser.Parse(&rtp_header);
909 if (!is_retransmit && rtp_header.markerBit) { 911 if (!is_retransmit && rtp_header.markerBit) {
910 TRACE_EVENT_ASYNC_END0(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "PacedSend", 912 TRACE_EVENT_ASYNC_END0(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "PacedSend",
911 capture_time_ms); 913 capture_time_ms);
912 } 914 }
913 915
(...skipping 12 matching lines...) Expand all
926 UpdateTransmissionTimeOffset(buffer_to_send_ptr, length, rtp_header, 928 UpdateTransmissionTimeOffset(buffer_to_send_ptr, length, rtp_header,
927 diff_ms); 929 diff_ms);
928 UpdateAbsoluteSendTime(buffer_to_send_ptr, length, rtp_header, now_ms); 930 UpdateAbsoluteSendTime(buffer_to_send_ptr, length, rtp_header, now_ms);
929 931
930 PacketOptions options; 932 PacketOptions options;
931 if (AllocateTransportSequenceNumber(&options.packet_id)) { 933 if (AllocateTransportSequenceNumber(&options.packet_id)) {
932 if (UpdateTransportSequenceNumber(options.packet_id, buffer_to_send_ptr, 934 if (UpdateTransportSequenceNumber(options.packet_id, buffer_to_send_ptr,
933 length, rtp_header)) { 935 length, rtp_header)) {
934 if (transport_feedback_observer_) 936 if (transport_feedback_observer_)
935 transport_feedback_observer_->AddPacket(options.packet_id, length, 937 transport_feedback_observer_->AddPacket(options.packet_id, length,
936 true); 938 probe_cluster_id);
937 } 939 }
938 } 940 }
939 941
940 if (!is_retransmit && !send_over_rtx) { 942 if (!is_retransmit && !send_over_rtx) {
941 UpdateDelayStatistics(capture_time_ms, now_ms); 943 UpdateDelayStatistics(capture_time_ms, now_ms);
942 UpdateOnSendPacket(options.packet_id, capture_time_ms, rtp_header.ssrc); 944 UpdateOnSendPacket(options.packet_id, capture_time_ms, rtp_header.ssrc);
943 } 945 }
944 946
945 bool ret = SendPacketToNetwork(buffer_to_send_ptr, length, options); 947 bool ret = SendPacketToNetwork(buffer_to_send_ptr, length, options);
946 if (ret) { 948 if (ret) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 } 995 }
994 bool fec_enabled; 996 bool fec_enabled;
995 uint8_t pt_red; 997 uint8_t pt_red;
996 uint8_t pt_fec; 998 uint8_t pt_fec;
997 video_->GenericFECStatus(&fec_enabled, &pt_red, &pt_fec); 999 video_->GenericFECStatus(&fec_enabled, &pt_red, &pt_fec);
998 return fec_enabled && 1000 return fec_enabled &&
999 header.payloadType == pt_red && 1001 header.payloadType == pt_red &&
1000 buffer[header.headerLength] == pt_fec; 1002 buffer[header.headerLength] == pt_fec;
1001 } 1003 }
1002 1004
1003 size_t RTPSender::TimeToSendPadding(size_t bytes) { 1005 size_t RTPSender::TimeToSendPadding(size_t bytes, int probe_cluster_id) {
1004 if (audio_configured_ || bytes == 0) 1006 if (audio_configured_ || bytes == 0)
1005 return 0; 1007 return 0;
1006 size_t bytes_sent = TrySendRedundantPayloads(bytes); 1008 size_t bytes_sent = TrySendRedundantPayloads(bytes, probe_cluster_id);
1007 if (bytes_sent < bytes) 1009 if (bytes_sent < bytes)
1008 bytes_sent += SendPadData(bytes - bytes_sent, false, 0, 0); 1010 bytes_sent += SendPadData(bytes - bytes_sent, false, 0, 0);
1009 return bytes_sent; 1011 return bytes_sent;
1010 } 1012 }
1011 1013
1012 // TODO(pwestin): send in the RtpHeaderParser to avoid parsing it again. 1014 // TODO(pwestin): send in the RtpHeaderParser to avoid parsing it again.
1013 int32_t RTPSender::SendToNetwork(uint8_t* buffer, 1015 int32_t RTPSender::SendToNetwork(uint8_t* buffer,
1014 size_t payload_length, 1016 size_t payload_length,
1015 size_t rtp_header_length, 1017 size_t rtp_header_length,
1016 int64_t capture_time_ms, 1018 int64_t capture_time_ms,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1056 } 1058 }
1057 return 0; 1059 return 0;
1058 } 1060 }
1059 1061
1060 PacketOptions options; 1062 PacketOptions options;
1061 if (AllocateTransportSequenceNumber(&options.packet_id)) { 1063 if (AllocateTransportSequenceNumber(&options.packet_id)) {
1062 if (UpdateTransportSequenceNumber(options.packet_id, buffer, length, 1064 if (UpdateTransportSequenceNumber(options.packet_id, buffer, length,
1063 rtp_header)) { 1065 rtp_header)) {
1064 if (transport_feedback_observer_) 1066 if (transport_feedback_observer_)
1065 transport_feedback_observer_->AddPacket(options.packet_id, length, 1067 transport_feedback_observer_->AddPacket(options.packet_id, length,
1066 true); 1068 true);
danilchap 2016/05/25 13:00:54 AddPacket already take probe_cluster_id as last pa
philipel 2016/05/26 09:59:12 The definition was already changed, but since bool
1067 } 1069 }
1068 } 1070 }
1069 UpdateDelayStatistics(capture_time_ms, now_ms); 1071 UpdateDelayStatistics(capture_time_ms, now_ms);
1070 UpdateOnSendPacket(options.packet_id, capture_time_ms, rtp_header.ssrc); 1072 UpdateOnSendPacket(options.packet_id, capture_time_ms, rtp_header.ssrc);
1071 1073
1072 bool sent = SendPacketToNetwork(buffer, length, options); 1074 bool sent = SendPacketToNetwork(buffer, length, options);
1073 1075
1074 // Mark the packet as sent in the history even if send failed. Dropping a 1076 // Mark the packet as sent in the history even if send failed. Dropping a
1075 // packet here should be treated as any other packet drop so we should be 1077 // packet here should be treated as any other packet drop so we should be
1076 // ready for a retransmission. 1078 // ready for a retransmission.
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after
1911 rtc::CritScope lock(&send_critsect_); 1913 rtc::CritScope lock(&send_critsect_);
1912 1914
1913 RtpState state; 1915 RtpState state;
1914 state.sequence_number = sequence_number_rtx_; 1916 state.sequence_number = sequence_number_rtx_;
1915 state.start_timestamp = start_timestamp_; 1917 state.start_timestamp = start_timestamp_;
1916 1918
1917 return state; 1919 return state;
1918 } 1920 }
1919 1921
1920 } // namespace webrtc 1922 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698