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

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

Issue 2393723004: replace NtpTime->Clock with Clock->NtpTime dependency (Closed)
Patch Set: . Created 3 years, 10 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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 RTC_DCHECK(info); 253 RTC_DCHECK(info);
254 rtc::CritScope lock(&rtcp_receiver_lock_); 254 rtc::CritScope lock(&rtcp_receiver_lock_);
255 if (!last_received_xr_ntp_.Valid()) 255 if (!last_received_xr_ntp_.Valid())
256 return false; 256 return false;
257 257
258 info->ssrc = remote_time_info_.ssrc; 258 info->ssrc = remote_time_info_.ssrc;
259 info->last_rr = remote_time_info_.last_rr; 259 info->last_rr = remote_time_info_.last_rr;
260 260
261 // Get the delay since last received report (RFC 3611). 261 // Get the delay since last received report (RFC 3611).
262 uint32_t receive_time_ntp = CompactNtp(last_received_xr_ntp_); 262 uint32_t receive_time_ntp = CompactNtp(last_received_xr_ntp_);
263 uint32_t now_ntp = CompactNtp(NtpTime(*clock_)); 263 uint32_t now_ntp = CompactNtp(clock_->CurrentNtpTime());
264 264
265 info->delay_since_last_rr = now_ntp - receive_time_ntp; 265 info->delay_since_last_rr = now_ntp - receive_time_ntp;
266 return true; 266 return true;
267 } 267 }
268 268
269 int32_t RTCPReceiver::SenderInfoReceived(RTCPSenderInfo* sender_info) const { 269 int32_t RTCPReceiver::SenderInfoReceived(RTCPSenderInfo* sender_info) const {
270 RTC_DCHECK(sender_info); 270 RTC_DCHECK(sender_info);
271 rtc::CritScope lock(&rtcp_receiver_lock_); 271 rtc::CritScope lock(&rtcp_receiver_lock_);
272 if (!last_received_sr_ntp_.Valid()) 272 if (!last_received_sr_ntp_.Valid())
273 return -1; 273 return -1;
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 // Only signal that we have received a SR when we accept one. 416 // Only signal that we have received a SR when we accept one.
417 packet_information->packet_type_flags |= kRtcpSr; 417 packet_information->packet_type_flags |= kRtcpSr;
418 418
419 // Save the NTP time of this report. 419 // Save the NTP time of this report.
420 remote_sender_info_.NTPseconds = sender_report.ntp().seconds(); 420 remote_sender_info_.NTPseconds = sender_report.ntp().seconds();
421 remote_sender_info_.NTPfraction = sender_report.ntp().fractions(); 421 remote_sender_info_.NTPfraction = sender_report.ntp().fractions();
422 remote_sender_info_.RTPtimeStamp = sender_report.rtp_timestamp(); 422 remote_sender_info_.RTPtimeStamp = sender_report.rtp_timestamp();
423 remote_sender_info_.sendPacketCount = sender_report.sender_packet_count(); 423 remote_sender_info_.sendPacketCount = sender_report.sender_packet_count();
424 remote_sender_info_.sendOctetCount = sender_report.sender_octet_count(); 424 remote_sender_info_.sendOctetCount = sender_report.sender_octet_count();
425 425
426 last_received_sr_ntp_.SetCurrent(*clock_); 426 last_received_sr_ntp_ = clock_->CurrentNtpTime();
427 } else { 427 } else {
428 // We will only store the send report from one source, but 428 // We will only store the send report from one source, but
429 // we will store all the receive blocks. 429 // we will store all the receive blocks.
430 packet_information->packet_type_flags |= kRtcpRr; 430 packet_information->packet_type_flags |= kRtcpRr;
431 } 431 }
432 432
433 for (const rtcp::ReportBlock report_block : sender_report.report_blocks()) 433 for (const rtcp::ReportBlock report_block : sender_report.report_blocks())
434 HandleReportBlock(report_block, packet_information, remote_ssrc); 434 HandleReportBlock(report_block, packet_information, remote_ssrc);
435 } 435 }
436 436
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 497
498 int64_t rtt_ms = 0; 498 int64_t rtt_ms = 0;
499 uint32_t send_time_ntp = report_block.last_sr(); 499 uint32_t send_time_ntp = report_block.last_sr();
500 // RFC3550, section 6.4.1, LSR field discription states: 500 // RFC3550, section 6.4.1, LSR field discription states:
501 // If no SR has been received yet, the field is set to zero. 501 // If no SR has been received yet, the field is set to zero.
502 // Receiver rtp_rtcp module is not expected to calculate rtt using 502 // Receiver rtp_rtcp module is not expected to calculate rtt using
503 // Sender Reports even if it accidentally can. 503 // Sender Reports even if it accidentally can.
504 if (!receiver_only_ && send_time_ntp != 0) { 504 if (!receiver_only_ && send_time_ntp != 0) {
505 uint32_t delay_ntp = report_block.delay_since_last_sr(); 505 uint32_t delay_ntp = report_block.delay_since_last_sr();
506 // Local NTP time. 506 // Local NTP time.
507 uint32_t receive_time_ntp = CompactNtp(NtpTime(*clock_)); 507 uint32_t receive_time_ntp = CompactNtp(clock_->CurrentNtpTime());
508 508
509 // RTT in 1/(2^16) seconds. 509 // RTT in 1/(2^16) seconds.
510 uint32_t rtt_ntp = receive_time_ntp - delay_ntp - send_time_ntp; 510 uint32_t rtt_ntp = receive_time_ntp - delay_ntp - send_time_ntp;
511 // Convert to 1/1000 seconds (milliseconds). 511 // Convert to 1/1000 seconds (milliseconds).
512 rtt_ms = CompactNtpRttToMs(rtt_ntp); 512 rtt_ms = CompactNtpRttToMs(rtt_ntp);
513 if (rtt_ms > report_block_info->max_rtt_ms) 513 if (rtt_ms > report_block_info->max_rtt_ms)
514 report_block_info->max_rtt_ms = rtt_ms; 514 report_block_info->max_rtt_ms = rtt_ms;
515 515
516 if (report_block_info->num_rtts == 0 || 516 if (report_block_info->num_rtts == 0 ||
517 rtt_ms < report_block_info->min_rtt_ms) 517 rtt_ms < report_block_info->min_rtt_ms)
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 HandleXrDlrrReportBlock(time_info); 702 HandleXrDlrrReportBlock(time_info);
703 703
704 if (xr.target_bitrate()) 704 if (xr.target_bitrate())
705 HandleXrTargetBitrate(*xr.target_bitrate(), packet_information); 705 HandleXrTargetBitrate(*xr.target_bitrate(), packet_information);
706 } 706 }
707 707
708 void RTCPReceiver::HandleXrReceiveReferenceTime(uint32_t sender_ssrc, 708 void RTCPReceiver::HandleXrReceiveReferenceTime(uint32_t sender_ssrc,
709 const rtcp::Rrtr& rrtr) { 709 const rtcp::Rrtr& rrtr) {
710 remote_time_info_.ssrc = sender_ssrc; 710 remote_time_info_.ssrc = sender_ssrc;
711 remote_time_info_.last_rr = CompactNtp(rrtr.ntp()); 711 remote_time_info_.last_rr = CompactNtp(rrtr.ntp());
712 last_received_xr_ntp_.SetCurrent(*clock_); 712 last_received_xr_ntp_ = clock_->CurrentNtpTime();
713 } 713 }
714 714
715 void RTCPReceiver::HandleXrDlrrReportBlock(const rtcp::ReceiveTimeInfo& rti) { 715 void RTCPReceiver::HandleXrDlrrReportBlock(const rtcp::ReceiveTimeInfo& rti) {
716 if (registered_ssrcs_.count(rti.ssrc) == 0) // Not to us. 716 if (registered_ssrcs_.count(rti.ssrc) == 0) // Not to us.
717 return; 717 return;
718 718
719 // Caller should explicitly enable rtt calculation using extended reports. 719 // Caller should explicitly enable rtt calculation using extended reports.
720 if (!xr_rrtr_status_) 720 if (!xr_rrtr_status_)
721 return; 721 return;
722 722
723 // The send_time and delay_rr fields are in units of 1/2^16 sec. 723 // The send_time and delay_rr fields are in units of 1/2^16 sec.
724 uint32_t send_time_ntp = rti.last_rr; 724 uint32_t send_time_ntp = rti.last_rr;
725 // RFC3611, section 4.5, LRR field discription states: 725 // RFC3611, section 4.5, LRR field discription states:
726 // If no such block has been received, the field is set to zero. 726 // If no such block has been received, the field is set to zero.
727 if (send_time_ntp == 0) 727 if (send_time_ntp == 0)
728 return; 728 return;
729 729
730 uint32_t delay_ntp = rti.delay_since_last_rr; 730 uint32_t delay_ntp = rti.delay_since_last_rr;
731 uint32_t now_ntp = CompactNtp(NtpTime(*clock_)); 731 uint32_t now_ntp = CompactNtp(clock_->CurrentNtpTime());
732 732
733 uint32_t rtt_ntp = now_ntp - delay_ntp - send_time_ntp; 733 uint32_t rtt_ntp = now_ntp - delay_ntp - send_time_ntp;
734 xr_rr_rtt_ms_ = CompactNtpRttToMs(rtt_ntp); 734 xr_rr_rtt_ms_ = CompactNtpRttToMs(rtt_ntp);
735 } 735 }
736 736
737 void RTCPReceiver::HandleXrTargetBitrate( 737 void RTCPReceiver::HandleXrTargetBitrate(
738 const rtcp::TargetBitrate& target_bitrate, 738 const rtcp::TargetBitrate& target_bitrate,
739 PacketInformation* packet_information) { 739 PacketInformation* packet_information) {
740 BitrateAllocation bitrate_allocation; 740 BitrateAllocation bitrate_allocation;
741 for (const auto& item : target_bitrate.GetTargetBitrates()) { 741 for (const auto& item : target_bitrate.GetTargetBitrates()) {
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 } else { 1085 } else {
1086 candidates.push_back(it->second.tmmbr_item); 1086 candidates.push_back(it->second.tmmbr_item);
1087 ++it; 1087 ++it;
1088 } 1088 }
1089 } 1089 }
1090 } 1090 }
1091 return candidates; 1091 return candidates;
1092 } 1092 }
1093 1093
1094 } // namespace webrtc 1094 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/receive_statistics_impl.cc ('k') | webrtc/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698