| OLD | NEW |
| 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 21 matching lines...) Expand all Loading... |
| 32 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rapid_resync_request.h" | 32 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rapid_resync_request.h" |
| 33 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/receiver_report.h" | 33 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/receiver_report.h" |
| 34 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/remb.h" | 34 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/remb.h" |
| 35 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rpsi.h" | 35 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rpsi.h" |
| 36 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sdes.h" | 36 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sdes.h" |
| 37 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sender_report.h" | 37 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sender_report.h" |
| 38 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sli.h" | 38 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sli.h" |
| 39 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/tmmbn.h" | 39 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/tmmbn.h" |
| 40 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/tmmbr.h" | 40 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/tmmbr.h" |
| 41 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" | 41 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" |
| 42 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" | |
| 43 #include "webrtc/modules/rtp_rtcp/source/time_util.h" | 42 #include "webrtc/modules/rtp_rtcp/source/time_util.h" |
| 44 #include "webrtc/modules/rtp_rtcp/source/tmmbr_help.h" | 43 #include "webrtc/modules/rtp_rtcp/source/tmmbr_help.h" |
| 45 #include "webrtc/system_wrappers/include/ntp_time.h" | 44 #include "webrtc/system_wrappers/include/ntp_time.h" |
| 46 | 45 |
| 47 namespace webrtc { | 46 namespace webrtc { |
| 48 namespace { | 47 namespace { |
| 49 | 48 |
| 50 using rtcp::CommonHeader; | 49 using rtcp::CommonHeader; |
| 51 using rtcp::ReportBlock; | 50 using rtcp::ReportBlock; |
| 52 | 51 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 ModuleRtpRtcp* owner) | 106 ModuleRtpRtcp* owner) |
| 108 : _clock(clock), | 107 : _clock(clock), |
| 109 receiver_only_(receiver_only), | 108 receiver_only_(receiver_only), |
| 110 _rtpRtcp(*owner), | 109 _rtpRtcp(*owner), |
| 111 _cbRtcpBandwidthObserver(rtcp_bandwidth_observer), | 110 _cbRtcpBandwidthObserver(rtcp_bandwidth_observer), |
| 112 _cbRtcpIntraFrameObserver(rtcp_intra_frame_observer), | 111 _cbRtcpIntraFrameObserver(rtcp_intra_frame_observer), |
| 113 _cbTransportFeedbackObserver(transport_feedback_observer), | 112 _cbTransportFeedbackObserver(transport_feedback_observer), |
| 114 main_ssrc_(0), | 113 main_ssrc_(0), |
| 115 _remoteSSRC(0), | 114 _remoteSSRC(0), |
| 116 _remoteSenderInfo(), | 115 _remoteSenderInfo(), |
| 117 _lastReceivedSRNTPsecs(0), | |
| 118 _lastReceivedSRNTPfrac(0), | |
| 119 _lastReceivedXRNTPsecs(0), | |
| 120 _lastReceivedXRNTPfrac(0), | |
| 121 xr_rrtr_status_(false), | 116 xr_rrtr_status_(false), |
| 122 xr_rr_rtt_ms_(0), | 117 xr_rr_rtt_ms_(0), |
| 123 _lastReceivedRrMs(0), | 118 _lastReceivedRrMs(0), |
| 124 _lastIncreasedSequenceNumberMs(0), | 119 _lastIncreasedSequenceNumberMs(0), |
| 125 stats_callback_(NULL), | 120 stats_callback_(NULL), |
| 126 packet_type_counter_observer_(packet_type_counter_observer), | 121 packet_type_counter_observer_(packet_type_counter_observer), |
| 127 num_skipped_packets_(0), | 122 num_skipped_packets_(0), |
| 128 last_skipped_packets_warning_(clock->TimeInMilliseconds()) { | 123 last_skipped_packets_warning_(clock->TimeInMilliseconds()) { |
| 129 memset(&_remoteSenderInfo, 0, sizeof(_remoteSenderInfo)); | 124 memset(&_remoteSenderInfo, 0, sizeof(_remoteSenderInfo)); |
| 130 } | 125 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 151 if (kv.second.last_time_received_ms > last_received_rr) | 146 if (kv.second.last_time_received_ms > last_received_rr) |
| 152 last_received_rr = kv.second.last_time_received_ms; | 147 last_received_rr = kv.second.last_time_received_ms; |
| 153 return last_received_rr; | 148 return last_received_rr; |
| 154 } | 149 } |
| 155 | 150 |
| 156 void RTCPReceiver::SetRemoteSSRC(uint32_t ssrc) { | 151 void RTCPReceiver::SetRemoteSSRC(uint32_t ssrc) { |
| 157 rtc::CritScope lock(&_criticalSectionRTCPReceiver); | 152 rtc::CritScope lock(&_criticalSectionRTCPReceiver); |
| 158 | 153 |
| 159 // new SSRC reset old reports | 154 // new SSRC reset old reports |
| 160 memset(&_remoteSenderInfo, 0, sizeof(_remoteSenderInfo)); | 155 memset(&_remoteSenderInfo, 0, sizeof(_remoteSenderInfo)); |
| 161 _lastReceivedSRNTPsecs = 0; | 156 last_received_sr_ntp_.Reset(); |
| 162 _lastReceivedSRNTPfrac = 0; | |
| 163 | 157 |
| 164 _remoteSSRC = ssrc; | 158 _remoteSSRC = ssrc; |
| 165 } | 159 } |
| 166 | 160 |
| 167 uint32_t RTCPReceiver::RemoteSSRC() const { | 161 uint32_t RTCPReceiver::RemoteSSRC() const { |
| 168 rtc::CritScope lock(&_criticalSectionRTCPReceiver); | 162 rtc::CritScope lock(&_criticalSectionRTCPReceiver); |
| 169 return _remoteSSRC; | 163 return _remoteSSRC; |
| 170 } | 164 } |
| 171 | 165 |
| 172 void RTCPReceiver::SetSsrcs(uint32_t main_ssrc, | 166 void RTCPReceiver::SetSsrcs(uint32_t main_ssrc, |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 assert(rtt_ms); | 223 assert(rtt_ms); |
| 230 rtc::CritScope lock(&_criticalSectionRTCPReceiver); | 224 rtc::CritScope lock(&_criticalSectionRTCPReceiver); |
| 231 if (xr_rr_rtt_ms_ == 0) { | 225 if (xr_rr_rtt_ms_ == 0) { |
| 232 return false; | 226 return false; |
| 233 } | 227 } |
| 234 *rtt_ms = xr_rr_rtt_ms_; | 228 *rtt_ms = xr_rr_rtt_ms_; |
| 235 xr_rr_rtt_ms_ = 0; | 229 xr_rr_rtt_ms_ = 0; |
| 236 return true; | 230 return true; |
| 237 } | 231 } |
| 238 | 232 |
| 239 // TODO(pbos): Make this fail when we haven't received NTP. | |
| 240 bool RTCPReceiver::NTP(uint32_t* ReceivedNTPsecs, | 233 bool RTCPReceiver::NTP(uint32_t* ReceivedNTPsecs, |
| 241 uint32_t* ReceivedNTPfrac, | 234 uint32_t* ReceivedNTPfrac, |
| 242 uint32_t* RTCPArrivalTimeSecs, | 235 uint32_t* RTCPArrivalTimeSecs, |
| 243 uint32_t* RTCPArrivalTimeFrac, | 236 uint32_t* RTCPArrivalTimeFrac, |
| 244 uint32_t* rtcp_timestamp) const { | 237 uint32_t* rtcp_timestamp) const { |
| 245 rtc::CritScope lock(&_criticalSectionRTCPReceiver); | 238 rtc::CritScope lock(&_criticalSectionRTCPReceiver); |
| 246 if (ReceivedNTPsecs) { | 239 if (!last_received_sr_ntp_.Valid()) |
| 247 *ReceivedNTPsecs = | 240 return false; |
| 248 _remoteSenderInfo.NTPseconds; // NTP from incoming SendReport | 241 |
| 249 } | 242 // NTP from incoming SenderReport. |
| 250 if (ReceivedNTPfrac) { | 243 if (ReceivedNTPsecs) |
| 244 *ReceivedNTPsecs = _remoteSenderInfo.NTPseconds; |
| 245 if (ReceivedNTPfrac) |
| 251 *ReceivedNTPfrac = _remoteSenderInfo.NTPfraction; | 246 *ReceivedNTPfrac = _remoteSenderInfo.NTPfraction; |
| 252 } | 247 |
| 253 if (RTCPArrivalTimeFrac) { | 248 // Rtp time from incoming SenderReport. |
| 254 *RTCPArrivalTimeFrac = _lastReceivedSRNTPfrac; // local NTP time when we | 249 if (rtcp_timestamp) |
| 255 // received a RTCP packet | |
| 256 // with a send block | |
| 257 } | |
| 258 if (RTCPArrivalTimeSecs) { | |
| 259 *RTCPArrivalTimeSecs = _lastReceivedSRNTPsecs; | |
| 260 } | |
| 261 if (rtcp_timestamp) { | |
| 262 *rtcp_timestamp = _remoteSenderInfo.RTPtimeStamp; | 250 *rtcp_timestamp = _remoteSenderInfo.RTPtimeStamp; |
| 263 } | 251 |
| 252 // Local NTP time when we received a RTCP packet with a send block. |
| 253 if (RTCPArrivalTimeSecs) |
| 254 *RTCPArrivalTimeSecs = last_received_sr_ntp_.seconds(); |
| 255 if (RTCPArrivalTimeFrac) |
| 256 *RTCPArrivalTimeFrac = last_received_sr_ntp_.fractions(); |
| 257 |
| 264 return true; | 258 return true; |
| 265 } | 259 } |
| 266 | 260 |
| 267 bool RTCPReceiver::LastReceivedXrReferenceTimeInfo( | 261 bool RTCPReceiver::LastReceivedXrReferenceTimeInfo( |
| 268 rtcp::ReceiveTimeInfo* info) const { | 262 rtcp::ReceiveTimeInfo* info) const { |
| 269 assert(info); | 263 RTC_DCHECK(info); |
| 270 rtc::CritScope lock(&_criticalSectionRTCPReceiver); | 264 rtc::CritScope lock(&_criticalSectionRTCPReceiver); |
| 271 if (_lastReceivedXRNTPsecs == 0 && _lastReceivedXRNTPfrac == 0) { | 265 if (!last_received_xr_ntp_.Valid()) |
| 272 return false; | 266 return false; |
| 273 } | |
| 274 | 267 |
| 275 info->ssrc = remote_time_info_.ssrc; | 268 info->ssrc = remote_time_info_.ssrc; |
| 276 info->last_rr = remote_time_info_.last_rr; | 269 info->last_rr = remote_time_info_.last_rr; |
| 277 | 270 |
| 278 // Get the delay since last received report (RFC 3611). | 271 // Get the delay since last received report (RFC 3611). |
| 279 uint32_t receive_time = | 272 uint32_t receive_time = CompactNtp(last_received_xr_ntp_); |
| 280 RTCPUtility::MidNtp(_lastReceivedXRNTPsecs, _lastReceivedXRNTPfrac); | 273 uint32_t now = CompactNtp(NtpTime(*_clock)); |
| 281 | |
| 282 uint32_t ntp_sec = 0; | |
| 283 uint32_t ntp_frac = 0; | |
| 284 _clock->CurrentNtp(ntp_sec, ntp_frac); | |
| 285 uint32_t now = RTCPUtility::MidNtp(ntp_sec, ntp_frac); | |
| 286 | 274 |
| 287 info->delay_since_last_rr = now - receive_time; | 275 info->delay_since_last_rr = now - receive_time; |
| 288 return true; | 276 return true; |
| 289 } | 277 } |
| 290 | 278 |
| 291 int32_t RTCPReceiver::SenderInfoReceived(RTCPSenderInfo* senderInfo) const { | 279 int32_t RTCPReceiver::SenderInfoReceived(RTCPSenderInfo* senderInfo) const { |
| 292 assert(senderInfo); | 280 assert(senderInfo); |
| 293 rtc::CritScope lock(&_criticalSectionRTCPReceiver); | 281 rtc::CritScope lock(&_criticalSectionRTCPReceiver); |
| 294 if (_lastReceivedSRNTPsecs == 0) { | 282 if (!last_received_sr_ntp_.Valid()) |
| 295 return -1; | 283 return -1; |
| 296 } | 284 |
| 297 memcpy(senderInfo, &(_remoteSenderInfo), sizeof(RTCPSenderInfo)); | 285 memcpy(senderInfo, &(_remoteSenderInfo), sizeof(RTCPSenderInfo)); |
| 298 return 0; | 286 return 0; |
| 299 } | 287 } |
| 300 | 288 |
| 301 // We can get multiple receive reports when we receive the report from a CE. | 289 // We can get multiple receive reports when we receive the report from a CE. |
| 302 int32_t RTCPReceiver::StatisticsReceived( | 290 int32_t RTCPReceiver::StatisticsReceived( |
| 303 std::vector<RTCPReportBlock>* receive_blocks) const { | 291 std::vector<RTCPReportBlock>* receive_blocks) const { |
| 304 RTC_DCHECK(receive_blocks); | 292 RTC_DCHECK(receive_blocks); |
| 305 rtc::CritScope lock(&_criticalSectionRTCPReceiver); | 293 rtc::CritScope lock(&_criticalSectionRTCPReceiver); |
| 306 for (const auto& reports_per_receiver : received_report_blocks_) | 294 for (const auto& reports_per_receiver : received_report_blocks_) |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 // Only signal that we have received a SR when we accept one. | 426 // Only signal that we have received a SR when we accept one. |
| 439 packet_information->packet_type_flags |= kRtcpSr; | 427 packet_information->packet_type_flags |= kRtcpSr; |
| 440 | 428 |
| 441 // Save the NTP time of this report. | 429 // Save the NTP time of this report. |
| 442 _remoteSenderInfo.NTPseconds = sender_report.ntp().seconds(); | 430 _remoteSenderInfo.NTPseconds = sender_report.ntp().seconds(); |
| 443 _remoteSenderInfo.NTPfraction = sender_report.ntp().fractions(); | 431 _remoteSenderInfo.NTPfraction = sender_report.ntp().fractions(); |
| 444 _remoteSenderInfo.RTPtimeStamp = sender_report.rtp_timestamp(); | 432 _remoteSenderInfo.RTPtimeStamp = sender_report.rtp_timestamp(); |
| 445 _remoteSenderInfo.sendPacketCount = sender_report.sender_packet_count(); | 433 _remoteSenderInfo.sendPacketCount = sender_report.sender_packet_count(); |
| 446 _remoteSenderInfo.sendOctetCount = sender_report.sender_octet_count(); | 434 _remoteSenderInfo.sendOctetCount = sender_report.sender_octet_count(); |
| 447 | 435 |
| 448 _clock->CurrentNtp(_lastReceivedSRNTPsecs, _lastReceivedSRNTPfrac); | 436 last_received_sr_ntp_.SetCurrent(*_clock); |
| 449 } else { | 437 } else { |
| 450 // We will only store the send report from one source, but | 438 // We will only store the send report from one source, but |
| 451 // we will store all the receive blocks. | 439 // we will store all the receive blocks. |
| 452 packet_information->packet_type_flags |= kRtcpRr; | 440 packet_information->packet_type_flags |= kRtcpRr; |
| 453 } | 441 } |
| 454 | 442 |
| 455 for (const rtcp::ReportBlock report_block : sender_report.report_blocks()) | 443 for (const rtcp::ReportBlock report_block : sender_report.report_blocks()) |
| 456 HandleReportBlock(report_block, packet_information, remoteSSRC); | 444 HandleReportBlock(report_block, packet_information, remoteSSRC); |
| 457 } | 445 } |
| 458 | 446 |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 for (const rtcp::ReceiveTimeInfo& time_info : dlrr.sub_blocks()) | 702 for (const rtcp::ReceiveTimeInfo& time_info : dlrr.sub_blocks()) |
| 715 HandleXrDlrrReportBlock(time_info); | 703 HandleXrDlrrReportBlock(time_info); |
| 716 } | 704 } |
| 717 } | 705 } |
| 718 | 706 |
| 719 void RTCPReceiver::HandleXrReceiveReferenceTime( | 707 void RTCPReceiver::HandleXrReceiveReferenceTime( |
| 720 uint32_t sender_ssrc, | 708 uint32_t sender_ssrc, |
| 721 const rtcp::Rrtr& rrtr) { | 709 const rtcp::Rrtr& rrtr) { |
| 722 remote_time_info_.ssrc = sender_ssrc; | 710 remote_time_info_.ssrc = sender_ssrc; |
| 723 remote_time_info_.last_rr = CompactNtp(rrtr.ntp()); | 711 remote_time_info_.last_rr = CompactNtp(rrtr.ntp()); |
| 724 _clock->CurrentNtp(_lastReceivedXRNTPsecs, _lastReceivedXRNTPfrac); | 712 last_received_xr_ntp_.SetCurrent(*_clock); |
| 725 } | 713 } |
| 726 | 714 |
| 727 void RTCPReceiver::HandleXrDlrrReportBlock(const rtcp::ReceiveTimeInfo& rti) { | 715 void RTCPReceiver::HandleXrDlrrReportBlock(const rtcp::ReceiveTimeInfo& rti) { |
| 728 if (registered_ssrcs_.count(rti.ssrc) == 0) // Not to us. | 716 if (registered_ssrcs_.count(rti.ssrc) == 0) // Not to us. |
| 729 return; | 717 return; |
| 730 | 718 |
| 731 // Caller should explicitly enable rtt calculation using extended reports. | 719 // Caller should explicitly enable rtt calculation using extended reports. |
| 732 if (!xr_rrtr_status_) | 720 if (!xr_rrtr_status_) |
| 733 return; | 721 return; |
| 734 | 722 |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1074 } else { | 1062 } else { |
| 1075 candidates.push_back(it->second.tmmbr_item); | 1063 candidates.push_back(it->second.tmmbr_item); |
| 1076 ++it; | 1064 ++it; |
| 1077 } | 1065 } |
| 1078 } | 1066 } |
| 1079 } | 1067 } |
| 1080 return candidates; | 1068 return candidates; |
| 1081 } | 1069 } |
| 1082 | 1070 |
| 1083 } // namespace webrtc | 1071 } // namespace webrtc |
| OLD | NEW |