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

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

Issue 1571283002: Fixes a bug which incorrectly logs incoming RTCP as outgoing. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase Created 4 years, 11 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
11 #include "webrtc/modules/rtp_rtcp/source/rtp_sender.h" 11 #include "webrtc/modules/rtp_rtcp/source/rtp_sender.h"
12 12
13 #include <stdlib.h> // srand 13 #include <stdlib.h> // srand
14 #include <algorithm> 14 #include <algorithm>
15 #include <utility> 15 #include <utility>
16 16
17 #include "webrtc/base/checks.h" 17 #include "webrtc/base/checks.h"
18 #include "webrtc/base/logging.h" 18 #include "webrtc/base/logging.h"
19 #include "webrtc/base/trace_event.h" 19 #include "webrtc/base/trace_event.h"
20 #include "webrtc/call.h"
21 #include "webrtc/call/rtc_event_log.h"
20 #include "webrtc/modules/rtp_rtcp/include/rtp_cvo.h" 22 #include "webrtc/modules/rtp_rtcp/include/rtp_cvo.h"
21 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" 23 #include "webrtc/modules/rtp_rtcp/source/byte_io.h"
22 #include "webrtc/modules/rtp_rtcp/source/rtp_sender_audio.h" 24 #include "webrtc/modules/rtp_rtcp/source/rtp_sender_audio.h"
23 #include "webrtc/modules/rtp_rtcp/source/rtp_sender_video.h" 25 #include "webrtc/modules/rtp_rtcp/source/rtp_sender_video.h"
24 #include "webrtc/modules/rtp_rtcp/source/time_util.h" 26 #include "webrtc/modules/rtp_rtcp/source/time_util.h"
25 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" 27 #include "webrtc/system_wrappers/include/critical_section_wrapper.h"
26 #include "webrtc/system_wrappers/include/tick_util.h" 28 #include "webrtc/system_wrappers/include/tick_util.h"
27 29
28 namespace webrtc { 30 namespace webrtc {
29 31
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 RTPSender::RTPSender( 117 RTPSender::RTPSender(
116 bool audio, 118 bool audio,
117 Clock* clock, 119 Clock* clock,
118 Transport* transport, 120 Transport* transport,
119 RtpAudioFeedback* audio_feedback, 121 RtpAudioFeedback* audio_feedback,
120 RtpPacketSender* paced_sender, 122 RtpPacketSender* paced_sender,
121 TransportSequenceNumberAllocator* sequence_number_allocator, 123 TransportSequenceNumberAllocator* sequence_number_allocator,
122 TransportFeedbackObserver* transport_feedback_observer, 124 TransportFeedbackObserver* transport_feedback_observer,
123 BitrateStatisticsObserver* bitrate_callback, 125 BitrateStatisticsObserver* bitrate_callback,
124 FrameCountObserver* frame_count_observer, 126 FrameCountObserver* frame_count_observer,
125 SendSideDelayObserver* send_side_delay_observer) 127 SendSideDelayObserver* send_side_delay_observer,
128 RtcEventLog* event_log)
126 : clock_(clock), 129 : clock_(clock),
127 // TODO(holmer): Remove this conversion when we remove the use of 130 // TODO(holmer): Remove this conversion when we remove the use of
128 // TickTime. 131 // TickTime.
129 clock_delta_ms_(clock_->TimeInMilliseconds() - 132 clock_delta_ms_(clock_->TimeInMilliseconds() -
130 TickTime::MillisecondTimestamp()), 133 TickTime::MillisecondTimestamp()),
131 random_(clock_->TimeInMicroseconds()), 134 random_(clock_->TimeInMicroseconds()),
132 bitrates_(new BitrateAggregator(bitrate_callback)), 135 bitrates_(new BitrateAggregator(bitrate_callback)),
133 total_bitrate_sent_(clock, bitrates_->total_bitrate_observer()), 136 total_bitrate_sent_(clock, bitrates_->total_bitrate_observer()),
134 audio_configured_(audio), 137 audio_configured_(audio),
135 audio_(audio ? new RTPSenderAudio(clock, this, audio_feedback) : nullptr), 138 audio_(audio ? new RTPSenderAudio(clock, this, audio_feedback) : nullptr),
(...skipping 18 matching lines...) Expand all
154 // NACK. 157 // NACK.
155 nack_byte_count_times_(), 158 nack_byte_count_times_(),
156 nack_byte_count_(), 159 nack_byte_count_(),
157 nack_bitrate_(clock, bitrates_->retransmit_bitrate_observer()), 160 nack_bitrate_(clock, bitrates_->retransmit_bitrate_observer()),
158 packet_history_(clock), 161 packet_history_(clock),
159 // Statistics 162 // Statistics
160 statistics_crit_(CriticalSectionWrapper::CreateCriticalSection()), 163 statistics_crit_(CriticalSectionWrapper::CreateCriticalSection()),
161 rtp_stats_callback_(NULL), 164 rtp_stats_callback_(NULL),
162 frame_count_observer_(frame_count_observer), 165 frame_count_observer_(frame_count_observer),
163 send_side_delay_observer_(send_side_delay_observer), 166 send_side_delay_observer_(send_side_delay_observer),
167 event_log_(event_log),
164 // RTP variables 168 // RTP variables
165 start_timestamp_forced_(false), 169 start_timestamp_forced_(false),
166 start_timestamp_(0), 170 start_timestamp_(0),
167 ssrc_db_(*SSRCDatabase::GetSSRCDatabase()), 171 ssrc_db_(*SSRCDatabase::GetSSRCDatabase()),
168 remote_ssrc_(0), 172 remote_ssrc_(0),
169 sequence_number_forced_(false), 173 sequence_number_forced_(false),
170 ssrc_forced_(false), 174 ssrc_forced_(false),
171 timestamp_(0), 175 timestamp_(0),
172 capture_time_ms_(0), 176 capture_time_ms_(0),
173 last_timestamp_time_ms_(0), 177 last_timestamp_time_ms_(0),
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 } 752 }
749 753
750 bool RTPSender::SendPacketToNetwork(const uint8_t* packet, 754 bool RTPSender::SendPacketToNetwork(const uint8_t* packet,
751 size_t size, 755 size_t size,
752 const PacketOptions& options) { 756 const PacketOptions& options) {
753 int bytes_sent = -1; 757 int bytes_sent = -1;
754 if (transport_) { 758 if (transport_) {
755 bytes_sent = transport_->SendRtp(packet, size, options) 759 bytes_sent = transport_->SendRtp(packet, size, options)
756 ? static_cast<int>(size) 760 ? static_cast<int>(size)
757 : -1; 761 : -1;
762 if (event_log_ && bytes_sent > 0) {
763 event_log_->LogRtpHeader(kOutgoingPacket, MediaType::ANY, packet, size);
764 }
758 } 765 }
759 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), 766 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"),
760 "RTPSender::SendPacketToNetwork", "size", size, "sent", 767 "RTPSender::SendPacketToNetwork", "size", size, "sent",
761 bytes_sent); 768 bytes_sent);
762 // TODO(pwestin): Add a separate bitrate for sent bitrate after pacer. 769 // TODO(pwestin): Add a separate bitrate for sent bitrate after pacer.
763 if (bytes_sent <= 0) { 770 if (bytes_sent <= 0) {
764 LOG(LS_WARNING) << "Transport failed to send packet"; 771 LOG(LS_WARNING) << "Transport failed to send packet";
765 return false; 772 return false;
766 } 773 }
767 return true; 774 return true;
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 return bytes_sent; 1028 return bytes_sent;
1022 } 1029 }
1023 1030
1024 // TODO(pwestin): send in the RtpHeaderParser to avoid parsing it again. 1031 // TODO(pwestin): send in the RtpHeaderParser to avoid parsing it again.
1025 int32_t RTPSender::SendToNetwork(uint8_t* buffer, 1032 int32_t RTPSender::SendToNetwork(uint8_t* buffer,
1026 size_t payload_length, 1033 size_t payload_length,
1027 size_t rtp_header_length, 1034 size_t rtp_header_length,
1028 int64_t capture_time_ms, 1035 int64_t capture_time_ms,
1029 StorageType storage, 1036 StorageType storage,
1030 RtpPacketSender::Priority priority) { 1037 RtpPacketSender::Priority priority) {
1031 RtpUtility::RtpHeaderParser rtp_parser(buffer, 1038 size_t length = payload_length + rtp_header_length;
1032 payload_length + rtp_header_length); 1039 RtpUtility::RtpHeaderParser rtp_parser(buffer, length);
1040
1033 RTPHeader rtp_header; 1041 RTPHeader rtp_header;
1034 rtp_parser.Parse(&rtp_header); 1042 rtp_parser.Parse(&rtp_header);
1035 1043
1036 int64_t now_ms = clock_->TimeInMilliseconds(); 1044 int64_t now_ms = clock_->TimeInMilliseconds();
1037 1045
1038 // |capture_time_ms| <= 0 is considered invalid. 1046 // |capture_time_ms| <= 0 is considered invalid.
1039 // TODO(holmer): This should be changed all over Video Engine so that negative 1047 // TODO(holmer): This should be changed all over Video Engine so that negative
1040 // time is consider invalid, while 0 is considered a valid time. 1048 // time is consider invalid, while 0 is considered a valid time.
1041 if (capture_time_ms > 0) { 1049 if (capture_time_ms > 0) {
1042 UpdateTransmissionTimeOffset(buffer, payload_length + rtp_header_length, 1050 UpdateTransmissionTimeOffset(buffer, length, rtp_header,
1043 rtp_header, now_ms - capture_time_ms); 1051 now_ms - capture_time_ms);
1044 } 1052 }
1045 1053
1046 UpdateAbsoluteSendTime(buffer, payload_length + rtp_header_length, 1054 UpdateAbsoluteSendTime(buffer, length, rtp_header, now_ms);
1047 rtp_header, now_ms);
1048 1055
1049 // Used for NACK and to spread out the transmission of packets. 1056 // Used for NACK and to spread out the transmission of packets.
1050 if (packet_history_.PutRTPPacket(buffer, rtp_header_length + payload_length, 1057 if (packet_history_.PutRTPPacket(buffer, length, capture_time_ms, storage) !=
1051 capture_time_ms, storage) != 0) { 1058 0) {
1052 return -1; 1059 return -1;
1053 } 1060 }
1054 1061
1055 if (paced_sender_) { 1062 if (paced_sender_) {
1056 // Correct offset between implementations of millisecond time stamps in 1063 // Correct offset between implementations of millisecond time stamps in
1057 // TickTime and Clock. 1064 // TickTime and Clock.
1058 int64_t corrected_time_ms = capture_time_ms + clock_delta_ms_; 1065 int64_t corrected_time_ms = capture_time_ms + clock_delta_ms_;
1059 paced_sender_->InsertPacket(priority, rtp_header.ssrc, 1066 paced_sender_->InsertPacket(priority, rtp_header.ssrc,
1060 rtp_header.sequenceNumber, corrected_time_ms, 1067 rtp_header.sequenceNumber, corrected_time_ms,
1061 payload_length, false); 1068 payload_length, false);
1062 if (last_capture_time_ms_sent_ == 0 || 1069 if (last_capture_time_ms_sent_ == 0 ||
1063 corrected_time_ms > last_capture_time_ms_sent_) { 1070 corrected_time_ms > last_capture_time_ms_sent_) {
1064 last_capture_time_ms_sent_ = corrected_time_ms; 1071 last_capture_time_ms_sent_ = corrected_time_ms;
1065 TRACE_EVENT_ASYNC_BEGIN1(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), 1072 TRACE_EVENT_ASYNC_BEGIN1(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"),
1066 "PacedSend", corrected_time_ms, 1073 "PacedSend", corrected_time_ms,
1067 "capture_time_ms", corrected_time_ms); 1074 "capture_time_ms", corrected_time_ms);
1068 } 1075 }
1069 return 0; 1076 return 0;
1070 } 1077 }
1071 if (capture_time_ms > 0) { 1078 if (capture_time_ms > 0) {
1072 UpdateDelayStatistics(capture_time_ms, now_ms); 1079 UpdateDelayStatistics(capture_time_ms, now_ms);
1073 } 1080 }
1074 1081
1075 size_t length = payload_length + rtp_header_length;
1076 bool sent = SendPacketToNetwork(buffer, length, PacketOptions()); 1082 bool sent = SendPacketToNetwork(buffer, length, PacketOptions());
1077 1083
1078 // Mark the packet as sent in the history even if send failed. Dropping a 1084 // Mark the packet as sent in the history even if send failed. Dropping a
1079 // packet here should be treated as any other packet drop so we should be 1085 // packet here should be treated as any other packet drop so we should be
1080 // ready for a retransmission. 1086 // ready for a retransmission.
1081 packet_history_.SetSent(rtp_header.sequenceNumber); 1087 packet_history_.SetSent(rtp_header.sequenceNumber);
1082 1088
1083 if (!sent) 1089 if (!sent)
1084 return -1; 1090 return -1;
1085 1091
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after
1899 CriticalSectionScoped lock(send_critsect_.get()); 1905 CriticalSectionScoped lock(send_critsect_.get());
1900 1906
1901 RtpState state; 1907 RtpState state;
1902 state.sequence_number = sequence_number_rtx_; 1908 state.sequence_number = sequence_number_rtx_;
1903 state.start_timestamp = start_timestamp_; 1909 state.start_timestamp = start_timestamp_;
1904 1910
1905 return state; 1911 return state;
1906 } 1912 }
1907 1913
1908 } // namespace webrtc 1914 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtp_sender.h ('k') | webrtc/modules/rtp_rtcp/source/rtp_sender_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698