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

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: 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_;
the sun 2016/01/11 12:36:16 * const event_log_ = nullptr (there's a an implict
terelius 2016/01/11 15:04:03 Added RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(PacketCon
101 size_t bytes_sent_; 108 size_t bytes_sent_;
102 }; 109 };
103 110
104 class RTCPSender::RtcpContext { 111 class RTCPSender::RtcpContext {
105 public: 112 public:
106 RtcpContext(const FeedbackState& feedback_state, 113 RtcpContext(const FeedbackState& feedback_state,
107 int32_t nack_size, 114 int32_t nack_size,
108 const uint16_t* nack_list, 115 const uint16_t* nack_list,
109 bool repeat, 116 bool repeat,
110 uint64_t picture_id, 117 uint64_t picture_id,
(...skipping 20 matching lines...) Expand all
131 const uint32_t ntp_frac_; 138 const uint32_t ntp_frac_;
132 139
133 PacketContainer* const container_; 140 PacketContainer* const container_;
134 }; 141 };
135 142
136 RTCPSender::RTCPSender( 143 RTCPSender::RTCPSender(
137 bool audio, 144 bool audio,
138 Clock* clock, 145 Clock* clock,
139 ReceiveStatistics* receive_statistics, 146 ReceiveStatistics* receive_statistics,
140 RtcpPacketTypeCounterObserver* packet_type_counter_observer, 147 RtcpPacketTypeCounterObserver* packet_type_counter_observer,
148 RtcEventLog* event_log,
141 Transport* outgoing_transport) 149 Transport* outgoing_transport)
142 : audio_(audio), 150 : audio_(audio),
143 clock_(clock), 151 clock_(clock),
144 random_(clock_->TimeInMicroseconds()), 152 random_(clock_->TimeInMicroseconds()),
145 method_(RtcpMode::kOff), 153 method_(RtcpMode::kOff),
154 event_log_(event_log),
146 transport_(outgoing_transport), 155 transport_(outgoing_transport),
147 156
148 critical_section_rtcp_sender_( 157 critical_section_rtcp_sender_(
149 CriticalSectionWrapper::CreateCriticalSection()), 158 CriticalSectionWrapper::CreateCriticalSection()),
150 using_nack_(false), 159 using_nack_(false),
151 sending_(false), 160 sending_(false),
152 remb_enabled_(false), 161 remb_enabled_(false),
153 next_time_to_send_rtcp_(0), 162 next_time_to_send_rtcp_(0),
154 start_timestamp_(0), 163 start_timestamp_(0),
155 last_rtp_timestamp_(0), 164 last_rtp_timestamp_(0),
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 nack_size, nack_list, repeat, pictureID); 800 nack_size, nack_list, repeat, pictureID);
792 } 801 }
793 802
794 int32_t RTCPSender::SendCompoundRTCP( 803 int32_t RTCPSender::SendCompoundRTCP(
795 const FeedbackState& feedback_state, 804 const FeedbackState& feedback_state,
796 const std::set<RTCPPacketType>& packet_types, 805 const std::set<RTCPPacketType>& packet_types,
797 int32_t nack_size, 806 int32_t nack_size,
798 const uint16_t* nack_list, 807 const uint16_t* nack_list,
799 bool repeat, 808 bool repeat,
800 uint64_t pictureID) { 809 uint64_t pictureID) {
801 PacketContainer container(transport_); 810 PacketContainer container(transport_, event_log_);
802 { 811 {
803 CriticalSectionScoped lock(critical_section_rtcp_sender_.get()); 812 CriticalSectionScoped lock(critical_section_rtcp_sender_.get());
804 if (method_ == RtcpMode::kOff) { 813 if (method_ == RtcpMode::kOff) {
805 LOG(LS_WARNING) << "Can't send rtcp if it is disabled."; 814 LOG(LS_WARNING) << "Can't send rtcp if it is disabled.";
806 return -1; 815 return -1;
807 } 816 }
808 817
809 // We need to send our NTP even if we haven't received any reports. 818 // We need to send our NTP even if we haven't received any reports.
810 uint32_t ntp_sec; 819 uint32_t ntp_sec;
811 uint32_t ntp_frac; 820 uint32_t ntp_frac;
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 for (const ReportFlag& flag : report_flags_) { 1042 for (const ReportFlag& flag : report_flags_) {
1034 if (flag.is_volatile) 1043 if (flag.is_volatile)
1035 return false; 1044 return false;
1036 } 1045 }
1037 return true; 1046 return true;
1038 } 1047 }
1039 1048
1040 bool RTCPSender::SendFeedbackPacket(const rtcp::TransportFeedback& packet) { 1049 bool RTCPSender::SendFeedbackPacket(const rtcp::TransportFeedback& packet) {
1041 class Sender : public rtcp::RtcpPacket::PacketReadyCallback { 1050 class Sender : public rtcp::RtcpPacket::PacketReadyCallback {
1042 public: 1051 public:
1043 explicit Sender(Transport* transport) 1052 Sender(Transport* transport, RtcEventLog* event_log)
1044 : transport_(transport), send_failure_(false) {} 1053 : transport_(transport), event_log_(event_log), send_failure_(false) {}
1045 1054
1046 void OnPacketReady(uint8_t* data, size_t length) override { 1055 void OnPacketReady(uint8_t* data, size_t length) override {
1047 if (!transport_->SendRtcp(data, length)) 1056 if (transport_->SendRtcp(data, length)) {
1057 if (event_log_) {
1058 event_log_->LogRtcpPacket(false, MediaType::ANY, data, length);
1059 }
1060 } else {
1048 send_failure_ = true; 1061 send_failure_ = true;
1062 }
1049 } 1063 }
1050 1064
1051 Transport* const transport_; 1065 Transport* const transport_;
1066 RtcEventLog* event_log_;
1052 bool send_failure_; 1067 bool send_failure_;
1053 } sender(transport_); 1068 } sender(transport_, event_log_);
1054 1069
1055 uint8_t buffer[IP_PACKET_SIZE]; 1070 uint8_t buffer[IP_PACKET_SIZE];
1056 return packet.BuildExternalBuffer(buffer, IP_PACKET_SIZE, &sender) && 1071 return packet.BuildExternalBuffer(buffer, IP_PACKET_SIZE, &sender) &&
1057 !sender.send_failure_; 1072 !sender.send_failure_;
1058 } 1073 }
1059 1074
1060 } // namespace webrtc 1075 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698