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

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: Added RTC_DISALLOW_IMPLICT_CONSTRUCTORS 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/nack.h" 29 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/nack.h"
28 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/pli.h" 30 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/pli.h"
29 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/receiver_report.h" 31 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/receiver_report.h"
30 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" 32 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h"
31 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h" 33 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h"
32 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" 34 #include "webrtc/system_wrappers/include/critical_section_wrapper.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 send_bitrate(0), 74 send_bitrate(0),
73 last_rr_ntp_secs(0), 75 last_rr_ntp_secs(0),
74 last_rr_ntp_frac(0), 76 last_rr_ntp_frac(0),
75 remote_sr(0), 77 remote_sr(0),
76 has_last_xr_rr(false), 78 has_last_xr_rr(false),
77 module(nullptr) {} 79 module(nullptr) {}
78 80
79 class PacketContainer : public rtcp::Empty, 81 class PacketContainer : public rtcp::Empty,
80 public rtcp::RtcpPacket::PacketReadyCallback { 82 public rtcp::RtcpPacket::PacketReadyCallback {
81 public: 83 public:
82 explicit PacketContainer(Transport* transport) 84 PacketContainer(Transport* transport, RtcEventLog* event_log)
83 : transport_(transport), bytes_sent_(0) {} 85 : transport_(transport), event_log_(event_log), bytes_sent_(0) {}
84 virtual ~PacketContainer() { 86 virtual ~PacketContainer() {
85 for (RtcpPacket* packet : appended_packets_) 87 for (RtcpPacket* packet : appended_packets_)
86 delete packet; 88 delete packet;
87 } 89 }
88 90
89 void OnPacketReady(uint8_t* data, size_t length) override { 91 void OnPacketReady(uint8_t* data, size_t length) override {
90 if (transport_->SendRtcp(data, length)) 92 if (transport_->SendRtcp(data, length)) {
91 bytes_sent_ += length; 93 bytes_sent_ += length;
94 if (event_log_) {
95 event_log_->LogRtcpPacket(false, MediaType::ANY, data, length);
96 }
97 }
92 } 98 }
93 99
94 size_t SendPackets() { 100 size_t SendPackets() {
95 rtcp::Empty::Build(this); 101 rtcp::Empty::Build(this);
96 return bytes_sent_; 102 return bytes_sent_;
97 } 103 }
98 104
99 private: 105 private:
100 Transport* transport_; 106 Transport* transport_;
107 RtcEventLog* event_log_;
101 size_t bytes_sent_; 108 size_t bytes_sent_;
109
110 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(PacketContainer);
102 }; 111 };
103 112
104 class RTCPSender::RtcpContext { 113 class RTCPSender::RtcpContext {
105 public: 114 public:
106 RtcpContext(const FeedbackState& feedback_state, 115 RtcpContext(const FeedbackState& feedback_state,
107 int32_t nack_size, 116 int32_t nack_size,
108 const uint16_t* nack_list, 117 const uint16_t* nack_list,
109 bool repeat, 118 bool repeat,
110 uint64_t picture_id, 119 uint64_t picture_id,
111 uint32_t ntp_sec, 120 uint32_t ntp_sec,
(...skipping 19 matching lines...) Expand all
131 const uint32_t ntp_frac_; 140 const uint32_t ntp_frac_;
132 141
133 PacketContainer* const container_; 142 PacketContainer* const container_;
134 }; 143 };
135 144
136 RTCPSender::RTCPSender( 145 RTCPSender::RTCPSender(
137 bool audio, 146 bool audio,
138 Clock* clock, 147 Clock* clock,
139 ReceiveStatistics* receive_statistics, 148 ReceiveStatistics* receive_statistics,
140 RtcpPacketTypeCounterObserver* packet_type_counter_observer, 149 RtcpPacketTypeCounterObserver* packet_type_counter_observer,
150 RtcEventLog* event_log,
141 Transport* outgoing_transport) 151 Transport* outgoing_transport)
142 : audio_(audio), 152 : audio_(audio),
143 clock_(clock), 153 clock_(clock),
144 random_(clock_->TimeInMicroseconds()), 154 random_(clock_->TimeInMicroseconds()),
145 method_(RtcpMode::kOff), 155 method_(RtcpMode::kOff),
156 event_log_(event_log),
146 transport_(outgoing_transport), 157 transport_(outgoing_transport),
147 158
148 critical_section_rtcp_sender_( 159 critical_section_rtcp_sender_(
149 CriticalSectionWrapper::CreateCriticalSection()), 160 CriticalSectionWrapper::CreateCriticalSection()),
150 using_nack_(false), 161 using_nack_(false),
151 sending_(false), 162 sending_(false),
152 remb_enabled_(false), 163 remb_enabled_(false),
153 next_time_to_send_rtcp_(0), 164 next_time_to_send_rtcp_(0),
154 start_timestamp_(0), 165 start_timestamp_(0),
155 last_rtp_timestamp_(0), 166 last_rtp_timestamp_(0),
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 nack_size, nack_list, repeat, pictureID); 802 nack_size, nack_list, repeat, pictureID);
792 } 803 }
793 804
794 int32_t RTCPSender::SendCompoundRTCP( 805 int32_t RTCPSender::SendCompoundRTCP(
795 const FeedbackState& feedback_state, 806 const FeedbackState& feedback_state,
796 const std::set<RTCPPacketType>& packet_types, 807 const std::set<RTCPPacketType>& packet_types,
797 int32_t nack_size, 808 int32_t nack_size,
798 const uint16_t* nack_list, 809 const uint16_t* nack_list,
799 bool repeat, 810 bool repeat,
800 uint64_t pictureID) { 811 uint64_t pictureID) {
801 PacketContainer container(transport_); 812 PacketContainer container(transport_, event_log_);
802 { 813 {
803 CriticalSectionScoped lock(critical_section_rtcp_sender_.get()); 814 CriticalSectionScoped lock(critical_section_rtcp_sender_.get());
804 if (method_ == RtcpMode::kOff) { 815 if (method_ == RtcpMode::kOff) {
805 LOG(LS_WARNING) << "Can't send rtcp if it is disabled."; 816 LOG(LS_WARNING) << "Can't send rtcp if it is disabled.";
806 return -1; 817 return -1;
807 } 818 }
808 819
809 // We need to send our NTP even if we haven't received any reports. 820 // We need to send our NTP even if we haven't received any reports.
810 uint32_t ntp_sec; 821 uint32_t ntp_sec;
811 uint32_t ntp_frac; 822 uint32_t ntp_frac;
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 for (const ReportFlag& flag : report_flags_) { 1044 for (const ReportFlag& flag : report_flags_) {
1034 if (flag.is_volatile) 1045 if (flag.is_volatile)
1035 return false; 1046 return false;
1036 } 1047 }
1037 return true; 1048 return true;
1038 } 1049 }
1039 1050
1040 bool RTCPSender::SendFeedbackPacket(const rtcp::TransportFeedback& packet) { 1051 bool RTCPSender::SendFeedbackPacket(const rtcp::TransportFeedback& packet) {
1041 class Sender : public rtcp::RtcpPacket::PacketReadyCallback { 1052 class Sender : public rtcp::RtcpPacket::PacketReadyCallback {
1042 public: 1053 public:
1043 explicit Sender(Transport* transport) 1054 Sender(Transport* transport, RtcEventLog* event_log)
1044 : transport_(transport), send_failure_(false) {} 1055 : transport_(transport), event_log_(event_log), send_failure_(false) {}
1045 1056
1046 void OnPacketReady(uint8_t* data, size_t length) override { 1057 void OnPacketReady(uint8_t* data, size_t length) override {
1047 if (!transport_->SendRtcp(data, length)) 1058 if (transport_->SendRtcp(data, length)) {
1059 if (event_log_) {
1060 event_log_->LogRtcpPacket(false, MediaType::ANY, data, length);
1061 }
1062 } else {
1048 send_failure_ = true; 1063 send_failure_ = true;
1064 }
1049 } 1065 }
1050 1066
1051 Transport* const transport_; 1067 Transport* const transport_;
1068 RtcEventLog* event_log_;
1052 bool send_failure_; 1069 bool send_failure_;
1053 } sender(transport_); 1070 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(Sender);
1071 } sender(transport_, event_log_);
1054 1072
1055 uint8_t buffer[IP_PACKET_SIZE]; 1073 uint8_t buffer[IP_PACKET_SIZE];
1056 return packet.BuildExternalBuffer(buffer, IP_PACKET_SIZE, &sender) && 1074 return packet.BuildExternalBuffer(buffer, IP_PACKET_SIZE, &sender) &&
1057 !sender.send_failure_; 1075 !sender.send_failure_;
1058 } 1076 }
1059 1077
1060 } // namespace webrtc 1078 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698