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

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtcp_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/rtcp_sender.h" 11 #include "webrtc/modules/rtp_rtcp/source/rtcp_sender.h"
12 12
13 #include <assert.h> // assert 13 #include <assert.h> // assert
14 #include <string.h> // memcpy 14 #include <string.h> // memcpy
15 15
16 #include <algorithm> // min 16 #include <algorithm> // min
17 #include <limits> // max 17 #include <limits> // max
18 #include <utility> 18 #include <utility>
19 19
20 #include "webrtc/base/checks.h" 20 #include "webrtc/base/checks.h"
21 #include "webrtc/base/logging.h" 21 #include "webrtc/base/logging.h"
22 #include "webrtc/base/trace_event.h" 22 #include "webrtc/base/trace_event.h"
23 #include "webrtc/call.h"
24 #include "webrtc/call/rtc_event_log.h"
23 #include "webrtc/common_types.h" 25 #include "webrtc/common_types.h"
24 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" 26 #include "webrtc/modules/rtp_rtcp/source/byte_io.h"
25 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/app.h" 27 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/app.h"
26 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h" 28 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h"
27 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/compound_packet.h" 29 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/compound_packet.h"
28 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_reports.h" 30 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_reports.h"
29 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/fir.h" 31 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/fir.h"
30 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/nack.h" 32 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/nack.h"
31 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/pli.h" 33 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/pli.h"
32 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/receiver_report.h" 34 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/receiver_report.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 send_bitrate(0), 84 send_bitrate(0),
83 last_rr_ntp_secs(0), 85 last_rr_ntp_secs(0),
84 last_rr_ntp_frac(0), 86 last_rr_ntp_frac(0),
85 remote_sr(0), 87 remote_sr(0),
86 has_last_xr_rr(false), 88 has_last_xr_rr(false),
87 module(nullptr) {} 89 module(nullptr) {}
88 90
89 class PacketContainer : public rtcp::CompoundPacket, 91 class PacketContainer : public rtcp::CompoundPacket,
90 public rtcp::RtcpPacket::PacketReadyCallback { 92 public rtcp::RtcpPacket::PacketReadyCallback {
91 public: 93 public:
92 explicit PacketContainer(Transport* transport) 94 PacketContainer(Transport* transport, RtcEventLog* event_log)
93 : transport_(transport), bytes_sent_(0) {} 95 : transport_(transport), event_log_(event_log), bytes_sent_(0) {}
94 virtual ~PacketContainer() { 96 virtual ~PacketContainer() {
95 for (RtcpPacket* packet : appended_packets_) 97 for (RtcpPacket* packet : appended_packets_)
96 delete packet; 98 delete packet;
97 } 99 }
98 100
99 void OnPacketReady(uint8_t* data, size_t length) override { 101 void OnPacketReady(uint8_t* data, size_t length) override {
100 if (transport_->SendRtcp(data, length)) 102 if (transport_->SendRtcp(data, length)) {
101 bytes_sent_ += length; 103 bytes_sent_ += length;
104 if (event_log_) {
105 event_log_->LogRtcpPacket(kOutgoingPacket, MediaType::ANY, data,
106 length);
107 }
108 }
102 } 109 }
103 110
104 size_t SendPackets() { 111 size_t SendPackets() {
105 rtcp::CompoundPacket::Build(this); 112 rtcp::CompoundPacket::Build(this);
106 return bytes_sent_; 113 return bytes_sent_;
107 } 114 }
108 115
109 private: 116 private:
110 Transport* transport_; 117 Transport* transport_;
118 RtcEventLog* const event_log_;
111 size_t bytes_sent_; 119 size_t bytes_sent_;
120
121 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(PacketContainer);
112 }; 122 };
113 123
114 class RTCPSender::RtcpContext { 124 class RTCPSender::RtcpContext {
115 public: 125 public:
116 RtcpContext(const FeedbackState& feedback_state, 126 RtcpContext(const FeedbackState& feedback_state,
117 int32_t nack_size, 127 int32_t nack_size,
118 const uint16_t* nack_list, 128 const uint16_t* nack_list,
119 bool repeat, 129 bool repeat,
120 uint64_t picture_id, 130 uint64_t picture_id,
121 uint32_t ntp_sec, 131 uint32_t ntp_sec,
(...skipping 19 matching lines...) Expand all
141 const uint32_t ntp_frac_; 151 const uint32_t ntp_frac_;
142 152
143 PacketContainer* const container_; 153 PacketContainer* const container_;
144 }; 154 };
145 155
146 RTCPSender::RTCPSender( 156 RTCPSender::RTCPSender(
147 bool audio, 157 bool audio,
148 Clock* clock, 158 Clock* clock,
149 ReceiveStatistics* receive_statistics, 159 ReceiveStatistics* receive_statistics,
150 RtcpPacketTypeCounterObserver* packet_type_counter_observer, 160 RtcpPacketTypeCounterObserver* packet_type_counter_observer,
161 RtcEventLog* event_log,
151 Transport* outgoing_transport) 162 Transport* outgoing_transport)
152 : audio_(audio), 163 : audio_(audio),
153 clock_(clock), 164 clock_(clock),
154 random_(clock_->TimeInMicroseconds()), 165 random_(clock_->TimeInMicroseconds()),
155 method_(RtcpMode::kOff), 166 method_(RtcpMode::kOff),
167 event_log_(event_log),
156 transport_(outgoing_transport), 168 transport_(outgoing_transport),
157 169
158 critical_section_rtcp_sender_( 170 critical_section_rtcp_sender_(
159 CriticalSectionWrapper::CreateCriticalSection()), 171 CriticalSectionWrapper::CreateCriticalSection()),
160 using_nack_(false), 172 using_nack_(false),
161 sending_(false), 173 sending_(false),
162 remb_enabled_(false), 174 remb_enabled_(false),
163 next_time_to_send_rtcp_(0), 175 next_time_to_send_rtcp_(0),
164 start_timestamp_(0), 176 start_timestamp_(0),
165 last_rtp_timestamp_(0), 177 last_rtp_timestamp_(0),
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 nack_size, nack_list, repeat, pictureID); 810 nack_size, nack_list, repeat, pictureID);
799 } 811 }
800 812
801 int32_t RTCPSender::SendCompoundRTCP( 813 int32_t RTCPSender::SendCompoundRTCP(
802 const FeedbackState& feedback_state, 814 const FeedbackState& feedback_state,
803 const std::set<RTCPPacketType>& packet_types, 815 const std::set<RTCPPacketType>& packet_types,
804 int32_t nack_size, 816 int32_t nack_size,
805 const uint16_t* nack_list, 817 const uint16_t* nack_list,
806 bool repeat, 818 bool repeat,
807 uint64_t pictureID) { 819 uint64_t pictureID) {
808 PacketContainer container(transport_); 820 PacketContainer container(transport_, event_log_);
809 { 821 {
810 CriticalSectionScoped lock(critical_section_rtcp_sender_.get()); 822 CriticalSectionScoped lock(critical_section_rtcp_sender_.get());
811 if (method_ == RtcpMode::kOff) { 823 if (method_ == RtcpMode::kOff) {
812 LOG(LS_WARNING) << "Can't send rtcp if it is disabled."; 824 LOG(LS_WARNING) << "Can't send rtcp if it is disabled.";
813 return -1; 825 return -1;
814 } 826 }
815 827
816 // We need to send our NTP even if we haven't received any reports. 828 // We need to send our NTP even if we haven't received any reports.
817 uint32_t ntp_sec; 829 uint32_t ntp_sec;
818 uint32_t ntp_frac; 830 uint32_t ntp_frac;
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1040 for (const ReportFlag& flag : report_flags_) { 1052 for (const ReportFlag& flag : report_flags_) {
1041 if (flag.is_volatile) 1053 if (flag.is_volatile)
1042 return false; 1054 return false;
1043 } 1055 }
1044 return true; 1056 return true;
1045 } 1057 }
1046 1058
1047 bool RTCPSender::SendFeedbackPacket(const rtcp::TransportFeedback& packet) { 1059 bool RTCPSender::SendFeedbackPacket(const rtcp::TransportFeedback& packet) {
1048 class Sender : public rtcp::RtcpPacket::PacketReadyCallback { 1060 class Sender : public rtcp::RtcpPacket::PacketReadyCallback {
1049 public: 1061 public:
1050 explicit Sender(Transport* transport) 1062 Sender(Transport* transport, RtcEventLog* event_log)
1051 : transport_(transport), send_failure_(false) {} 1063 : transport_(transport), event_log_(event_log), send_failure_(false) {}
1052 1064
1053 void OnPacketReady(uint8_t* data, size_t length) override { 1065 void OnPacketReady(uint8_t* data, size_t length) override {
1054 if (!transport_->SendRtcp(data, length)) 1066 if (transport_->SendRtcp(data, length)) {
1067 if (event_log_) {
1068 event_log_->LogRtcpPacket(kOutgoingPacket, MediaType::ANY, data,
1069 length);
1070 }
1071 } else {
1055 send_failure_ = true; 1072 send_failure_ = true;
1073 }
1056 } 1074 }
1057 1075
1058 Transport* const transport_; 1076 Transport* const transport_;
1077 RtcEventLog* const event_log_;
1059 bool send_failure_; 1078 bool send_failure_;
1060 } sender(transport_); 1079 // TODO(terelius): We would like to
1080 // RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(Sender);
1081 // but we can't because of an incorrect warning (C4822) in MVS 2013.
1082 } sender(transport_, event_log_);
1061 1083
1062 uint8_t buffer[IP_PACKET_SIZE]; 1084 uint8_t buffer[IP_PACKET_SIZE];
1063 return packet.BuildExternalBuffer(buffer, IP_PACKET_SIZE, &sender) && 1085 return packet.BuildExternalBuffer(buffer, IP_PACKET_SIZE, &sender) &&
1064 !sender.send_failure_; 1086 !sender.send_failure_;
1065 } 1087 }
1066 1088
1067 } // namespace webrtc 1089 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtcp_sender.h ('k') | webrtc/modules/rtp_rtcp/source/rtcp_sender_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698