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

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

Issue 1373903003: Unify newapi::RtcpMode and RTCPMethod. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: ehm, compile the code Created 5 years, 2 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 }; 132 };
133 133
134 RTCPSender::RTCPSender( 134 RTCPSender::RTCPSender(
135 bool audio, 135 bool audio,
136 Clock* clock, 136 Clock* clock,
137 ReceiveStatistics* receive_statistics, 137 ReceiveStatistics* receive_statistics,
138 RtcpPacketTypeCounterObserver* packet_type_counter_observer, 138 RtcpPacketTypeCounterObserver* packet_type_counter_observer,
139 Transport* outgoing_transport) 139 Transport* outgoing_transport)
140 : audio_(audio), 140 : audio_(audio),
141 clock_(clock), 141 clock_(clock),
142 method_(kRtcpOff), 142 method_(RtcpMode::kOff),
143 transport_(outgoing_transport), 143 transport_(outgoing_transport),
144 144
145 critical_section_rtcp_sender_( 145 critical_section_rtcp_sender_(
146 CriticalSectionWrapper::CreateCriticalSection()), 146 CriticalSectionWrapper::CreateCriticalSection()),
147 using_nack_(false), 147 using_nack_(false),
148 sending_(false), 148 sending_(false),
149 remb_enabled_(false), 149 remb_enabled_(false),
150 next_time_to_send_rtcp_(0), 150 next_time_to_send_rtcp_(0),
151 start_timestamp_(0), 151 start_timestamp_(0),
152 last_rtp_timestamp_(0), 152 last_rtp_timestamp_(0),
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 builders_[kRtcpNack] = &RTCPSender::BuildNACK; 189 builders_[kRtcpNack] = &RTCPSender::BuildNACK;
190 builders_[kRtcpXrVoipMetric] = &RTCPSender::BuildVoIPMetric; 190 builders_[kRtcpXrVoipMetric] = &RTCPSender::BuildVoIPMetric;
191 builders_[kRtcpXrReceiverReferenceTime] = 191 builders_[kRtcpXrReceiverReferenceTime] =
192 &RTCPSender::BuildReceiverReferenceTime; 192 &RTCPSender::BuildReceiverReferenceTime;
193 builders_[kRtcpXrDlrrReportBlock] = &RTCPSender::BuildDlrr; 193 builders_[kRtcpXrDlrrReportBlock] = &RTCPSender::BuildDlrr;
194 } 194 }
195 195
196 RTCPSender::~RTCPSender() { 196 RTCPSender::~RTCPSender() {
197 } 197 }
198 198
199 RTCPMethod RTCPSender::Status() const { 199 RtcpMode RTCPSender::Status() const {
200 CriticalSectionScoped lock(critical_section_rtcp_sender_.get()); 200 CriticalSectionScoped lock(critical_section_rtcp_sender_.get());
201 return method_; 201 return method_;
202 } 202 }
203 203
204 void RTCPSender::SetRTCPStatus(RTCPMethod method) { 204 void RTCPSender::SetRTCPStatus(RtcpMode method) {
205 CriticalSectionScoped lock(critical_section_rtcp_sender_.get()); 205 CriticalSectionScoped lock(critical_section_rtcp_sender_.get());
206 method_ = method; 206 method_ = method;
207 207
208 if (method == kRtcpOff) 208 if (method == RtcpMode::kOff)
209 return; 209 return;
210 next_time_to_send_rtcp_ = 210 next_time_to_send_rtcp_ =
211 clock_->TimeInMilliseconds() + 211 clock_->TimeInMilliseconds() +
212 (audio_ ? RTCP_INTERVAL_AUDIO_MS / 2 : RTCP_INTERVAL_VIDEO_MS / 2); 212 (audio_ ? RTCP_INTERVAL_AUDIO_MS / 2 : RTCP_INTERVAL_VIDEO_MS / 2);
213 } 213 }
214 214
215 bool RTCPSender::Sending() const { 215 bool RTCPSender::Sending() const {
216 CriticalSectionScoped lock(critical_section_rtcp_sender_.get()); 216 CriticalSectionScoped lock(critical_section_rtcp_sender_.get());
217 return sending_; 217 return sending_;
218 } 218 }
219 219
220 int32_t RTCPSender::SetSendingStatus(const FeedbackState& feedback_state, 220 int32_t RTCPSender::SetSendingStatus(const FeedbackState& feedback_state,
221 bool sending) { 221 bool sending) {
222 bool sendRTCPBye = false; 222 bool sendRTCPBye = false;
223 { 223 {
224 CriticalSectionScoped lock(critical_section_rtcp_sender_.get()); 224 CriticalSectionScoped lock(critical_section_rtcp_sender_.get());
225 225
226 if (method_ != kRtcpOff) { 226 if (method_ != RtcpMode::kOff) {
227 if (sending == false && sending_ == true) { 227 if (sending == false && sending_ == true) {
228 // Trigger RTCP bye 228 // Trigger RTCP bye
229 sendRTCPBye = true; 229 sendRTCPBye = true;
230 } 230 }
231 } 231 }
232 sending_ = sending; 232 sending_ = sending;
233 } 233 }
234 if (sendRTCPBye) 234 if (sendRTCPBye)
235 return SendRTCP(feedback_state, kRtcpBye); 235 return SendRTCP(feedback_state, kRtcpBye);
236 return 0; 236 return 0;
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 395
396 5. The resulting value of T is divided by e-3/2=1.21828 to compensate 396 5. The resulting value of T is divided by e-3/2=1.21828 to compensate
397 for the fact that the timer reconsideration algorithm converges to 397 for the fact that the timer reconsideration algorithm converges to
398 a value of the RTCP bandwidth below the intended average 398 a value of the RTCP bandwidth below the intended average
399 */ 399 */
400 400
401 int64_t now = clock_->TimeInMilliseconds(); 401 int64_t now = clock_->TimeInMilliseconds();
402 402
403 CriticalSectionScoped lock(critical_section_rtcp_sender_.get()); 403 CriticalSectionScoped lock(critical_section_rtcp_sender_.get());
404 404
405 if (method_ == kRtcpOff) 405 if (method_ == RtcpMode::kOff)
406 return false; 406 return false;
407 407
408 if (!audio_ && sendKeyframeBeforeRTP) { 408 if (!audio_ && sendKeyframeBeforeRTP) {
409 // for video key-frames we want to send the RTCP before the large key-frame 409 // for video key-frames we want to send the RTCP before the large key-frame
410 // if we have a 100 ms margin 410 // if we have a 100 ms margin
411 now += RTCP_SEND_BEFORE_KEY_FRAME_MS; 411 now += RTCP_SEND_BEFORE_KEY_FRAME_MS;
412 } 412 }
413 413
414 if (now >= next_time_to_send_rtcp_) { 414 if (now >= next_time_to_send_rtcp_) {
415 return true; 415 return true;
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 926
927 int32_t RTCPSender::SendCompoundRTCP( 927 int32_t RTCPSender::SendCompoundRTCP(
928 const FeedbackState& feedback_state, 928 const FeedbackState& feedback_state,
929 const std::set<RTCPPacketType>& packetTypes, 929 const std::set<RTCPPacketType>& packetTypes,
930 int32_t nack_size, 930 int32_t nack_size,
931 const uint16_t* nack_list, 931 const uint16_t* nack_list,
932 bool repeat, 932 bool repeat,
933 uint64_t pictureID) { 933 uint64_t pictureID) {
934 { 934 {
935 CriticalSectionScoped lock(critical_section_rtcp_sender_.get()); 935 CriticalSectionScoped lock(critical_section_rtcp_sender_.get());
936 if (method_ == kRtcpOff) { 936 if (method_ == RtcpMode::kOff) {
937 LOG(LS_WARNING) << "Can't send rtcp if it is disabled."; 937 LOG(LS_WARNING) << "Can't send rtcp if it is disabled.";
938 return -1; 938 return -1;
939 } 939 }
940 } 940 }
941 uint8_t rtcp_buffer[IP_PACKET_SIZE]; 941 uint8_t rtcp_buffer[IP_PACKET_SIZE];
942 int rtcp_length = 942 int rtcp_length =
943 PrepareRTCP(feedback_state, packetTypes, nack_size, nack_list, repeat, 943 PrepareRTCP(feedback_state, packetTypes, nack_size, nack_list, repeat,
944 pictureID, rtcp_buffer, IP_PACKET_SIZE); 944 pictureID, rtcp_buffer, IP_PACKET_SIZE);
945 945
946 // Sanity don't send empty packets. 946 // Sanity don't send empty packets.
(...skipping 23 matching lines...) Expand all
970 if (packet_type_counter_.first_packet_time_ms == -1) 970 if (packet_type_counter_.first_packet_time_ms == -1)
971 packet_type_counter_.first_packet_time_ms = clock_->TimeInMilliseconds(); 971 packet_type_counter_.first_packet_time_ms = clock_->TimeInMilliseconds();
972 972
973 bool generate_report; 973 bool generate_report;
974 if (IsFlagPresent(kRtcpSr) || IsFlagPresent(kRtcpRr)) { 974 if (IsFlagPresent(kRtcpSr) || IsFlagPresent(kRtcpRr)) {
975 // Report type already explicitly set, don't automatically populate. 975 // Report type already explicitly set, don't automatically populate.
976 generate_report = true; 976 generate_report = true;
977 RTC_DCHECK(ConsumeFlag(kRtcpReport) == false); 977 RTC_DCHECK(ConsumeFlag(kRtcpReport) == false);
978 } else { 978 } else {
979 generate_report = 979 generate_report =
980 (ConsumeFlag(kRtcpReport) && method_ == kRtcpNonCompound) || 980 (ConsumeFlag(kRtcpReport) && method_ == RtcpMode::kReducedSize) ||
981 method_ == kRtcpCompound; 981 method_ == RtcpMode::kCompound;
982 if (generate_report) 982 if (generate_report)
983 SetFlag(sending_ ? kRtcpSr : kRtcpRr, true); 983 SetFlag(sending_ ? kRtcpSr : kRtcpRr, true);
984 } 984 }
985 985
986 if (IsFlagPresent(kRtcpSr) || (IsFlagPresent(kRtcpRr) && !cname_.empty())) 986 if (IsFlagPresent(kRtcpSr) || (IsFlagPresent(kRtcpRr) && !cname_.empty()))
987 SetFlag(kRtcpSdes, true); 987 SetFlag(kRtcpSdes, true);
988 988
989 // We need to send our NTP even if we haven't received any reports. 989 // We need to send our NTP even if we haven't received any reports.
990 clock_->CurrentNtp(context.ntp_sec, context.ntp_frac); 990 clock_->CurrentNtp(context.ntp_sec, context.ntp_frac);
991 991
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
1214 Transport* const transport_; 1214 Transport* const transport_;
1215 bool send_failure_; 1215 bool send_failure_;
1216 } sender(transport_); 1216 } sender(transport_);
1217 1217
1218 uint8_t buffer[IP_PACKET_SIZE]; 1218 uint8_t buffer[IP_PACKET_SIZE];
1219 return packet.BuildExternalBuffer(buffer, IP_PACKET_SIZE, &sender) && 1219 return packet.BuildExternalBuffer(buffer, IP_PACKET_SIZE, &sender) &&
1220 !sender.send_failure_; 1220 !sender.send_failure_;
1221 } 1221 }
1222 1222
1223 } // namespace webrtc 1223 } // 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