| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 ModuleRtpRtcp* owner) | 112 ModuleRtpRtcp* owner) |
| 113 : clock_(clock), | 113 : clock_(clock), |
| 114 receiver_only_(receiver_only), | 114 receiver_only_(receiver_only), |
| 115 rtp_rtcp_(owner), | 115 rtp_rtcp_(owner), |
| 116 rtcp_bandwidth_observer_(rtcp_bandwidth_observer), | 116 rtcp_bandwidth_observer_(rtcp_bandwidth_observer), |
| 117 rtcp_intra_frame_observer_(rtcp_intra_frame_observer), | 117 rtcp_intra_frame_observer_(rtcp_intra_frame_observer), |
| 118 transport_feedback_observer_(transport_feedback_observer), | 118 transport_feedback_observer_(transport_feedback_observer), |
| 119 bitrate_allocation_observer_(bitrate_allocation_observer), | 119 bitrate_allocation_observer_(bitrate_allocation_observer), |
| 120 main_ssrc_(0), | 120 main_ssrc_(0), |
| 121 remote_ssrc_(0), | 121 remote_ssrc_(0), |
| 122 remote_sender_rtp_time_(0), |
| 122 xr_rrtr_status_(false), | 123 xr_rrtr_status_(false), |
| 123 xr_rr_rtt_ms_(0), | 124 xr_rr_rtt_ms_(0), |
| 124 oldest_tmmbr_info_ms_(0), | 125 oldest_tmmbr_info_ms_(0), |
| 125 last_received_rr_ms_(0), | 126 last_received_rr_ms_(0), |
| 126 last_increased_sequence_number_ms_(0), | 127 last_increased_sequence_number_ms_(0), |
| 127 stats_callback_(nullptr), | 128 stats_callback_(nullptr), |
| 128 packet_type_counter_observer_(packet_type_counter_observer), | 129 packet_type_counter_observer_(packet_type_counter_observer), |
| 129 num_skipped_packets_(0), | 130 num_skipped_packets_(0), |
| 130 last_skipped_packets_warning_ms_(clock->TimeInMilliseconds()) { | 131 last_skipped_packets_warning_ms_(clock->TimeInMilliseconds()) { |
| 131 RTC_DCHECK(owner); | 132 RTC_DCHECK(owner); |
| 132 memset(&remote_sender_info_, 0, sizeof(remote_sender_info_)); | |
| 133 } | 133 } |
| 134 | 134 |
| 135 RTCPReceiver::~RTCPReceiver() {} | 135 RTCPReceiver::~RTCPReceiver() {} |
| 136 | 136 |
| 137 bool RTCPReceiver::IncomingPacket(const uint8_t* packet, size_t packet_size) { | 137 bool RTCPReceiver::IncomingPacket(const uint8_t* packet, size_t packet_size) { |
| 138 if (packet_size == 0) { | 138 if (packet_size == 0) { |
| 139 LOG(LS_WARNING) << "Incoming empty RTCP packet"; | 139 LOG(LS_WARNING) << "Incoming empty RTCP packet"; |
| 140 return false; | 140 return false; |
| 141 } | 141 } |
| 142 | 142 |
| 143 PacketInformation packet_information; | 143 PacketInformation packet_information; |
| 144 if (!ParseCompoundPacket(packet, packet + packet_size, &packet_information)) | 144 if (!ParseCompoundPacket(packet, packet + packet_size, &packet_information)) |
| 145 return false; | 145 return false; |
| 146 TriggerCallbacksFromRtcpPacket(packet_information); | 146 TriggerCallbacksFromRtcpPacket(packet_information); |
| 147 return true; | 147 return true; |
| 148 } | 148 } |
| 149 | 149 |
| 150 int64_t RTCPReceiver::LastReceivedReceiverReport() const { | 150 int64_t RTCPReceiver::LastReceivedReceiverReport() const { |
| 151 rtc::CritScope lock(&rtcp_receiver_lock_); | 151 rtc::CritScope lock(&rtcp_receiver_lock_); |
| 152 return last_received_rr_ms_; | 152 return last_received_rr_ms_; |
| 153 } | 153 } |
| 154 | 154 |
| 155 void RTCPReceiver::SetRemoteSSRC(uint32_t ssrc) { | 155 void RTCPReceiver::SetRemoteSSRC(uint32_t ssrc) { |
| 156 rtc::CritScope lock(&rtcp_receiver_lock_); | 156 rtc::CritScope lock(&rtcp_receiver_lock_); |
| 157 // New SSRC reset old reports. | 157 // New SSRC reset old reports. |
| 158 memset(&remote_sender_info_, 0, sizeof(remote_sender_info_)); | |
| 159 last_received_sr_ntp_.Reset(); | 158 last_received_sr_ntp_.Reset(); |
| 160 remote_ssrc_ = ssrc; | 159 remote_ssrc_ = ssrc; |
| 161 } | 160 } |
| 162 | 161 |
| 163 uint32_t RTCPReceiver::RemoteSSRC() const { | 162 uint32_t RTCPReceiver::RemoteSSRC() const { |
| 164 rtc::CritScope lock(&rtcp_receiver_lock_); | 163 rtc::CritScope lock(&rtcp_receiver_lock_); |
| 165 return remote_ssrc_; | 164 return remote_ssrc_; |
| 166 } | 165 } |
| 167 | 166 |
| 168 void RTCPReceiver::SetSsrcs(uint32_t main_ssrc, | 167 void RTCPReceiver::SetSsrcs(uint32_t main_ssrc, |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 uint32_t* received_ntp_frac, | 226 uint32_t* received_ntp_frac, |
| 228 uint32_t* rtcp_arrival_time_secs, | 227 uint32_t* rtcp_arrival_time_secs, |
| 229 uint32_t* rtcp_arrival_time_frac, | 228 uint32_t* rtcp_arrival_time_frac, |
| 230 uint32_t* rtcp_timestamp) const { | 229 uint32_t* rtcp_timestamp) const { |
| 231 rtc::CritScope lock(&rtcp_receiver_lock_); | 230 rtc::CritScope lock(&rtcp_receiver_lock_); |
| 232 if (!last_received_sr_ntp_.Valid()) | 231 if (!last_received_sr_ntp_.Valid()) |
| 233 return false; | 232 return false; |
| 234 | 233 |
| 235 // NTP from incoming SenderReport. | 234 // NTP from incoming SenderReport. |
| 236 if (received_ntp_secs) | 235 if (received_ntp_secs) |
| 237 *received_ntp_secs = remote_sender_info_.NTPseconds; | 236 *received_ntp_secs = remote_sender_ntp_time_.seconds(); |
| 238 if (received_ntp_frac) | 237 if (received_ntp_frac) |
| 239 *received_ntp_frac = remote_sender_info_.NTPfraction; | 238 *received_ntp_frac = remote_sender_ntp_time_.fractions(); |
| 240 | 239 |
| 241 // Rtp time from incoming SenderReport. | 240 // Rtp time from incoming SenderReport. |
| 242 if (rtcp_timestamp) | 241 if (rtcp_timestamp) |
| 243 *rtcp_timestamp = remote_sender_info_.RTPtimeStamp; | 242 *rtcp_timestamp = remote_sender_rtp_time_; |
| 244 | 243 |
| 245 // Local NTP time when we received a RTCP packet with a send block. | 244 // Local NTP time when we received a RTCP packet with a send block. |
| 246 if (rtcp_arrival_time_secs) | 245 if (rtcp_arrival_time_secs) |
| 247 *rtcp_arrival_time_secs = last_received_sr_ntp_.seconds(); | 246 *rtcp_arrival_time_secs = last_received_sr_ntp_.seconds(); |
| 248 if (rtcp_arrival_time_frac) | 247 if (rtcp_arrival_time_frac) |
| 249 *rtcp_arrival_time_frac = last_received_sr_ntp_.fractions(); | 248 *rtcp_arrival_time_frac = last_received_sr_ntp_.fractions(); |
| 250 | 249 |
| 251 return true; | 250 return true; |
| 252 } | 251 } |
| 253 | 252 |
| 254 bool RTCPReceiver::LastReceivedXrReferenceTimeInfo( | 253 bool RTCPReceiver::LastReceivedXrReferenceTimeInfo( |
| 255 rtcp::ReceiveTimeInfo* info) const { | 254 rtcp::ReceiveTimeInfo* info) const { |
| 256 RTC_DCHECK(info); | 255 RTC_DCHECK(info); |
| 257 rtc::CritScope lock(&rtcp_receiver_lock_); | 256 rtc::CritScope lock(&rtcp_receiver_lock_); |
| 258 if (!last_received_xr_ntp_.Valid()) | 257 if (!last_received_xr_ntp_.Valid()) |
| 259 return false; | 258 return false; |
| 260 | 259 |
| 261 info->ssrc = remote_time_info_.ssrc; | 260 info->ssrc = remote_time_info_.ssrc; |
| 262 info->last_rr = remote_time_info_.last_rr; | 261 info->last_rr = remote_time_info_.last_rr; |
| 263 | 262 |
| 264 // Get the delay since last received report (RFC 3611). | 263 // Get the delay since last received report (RFC 3611). |
| 265 uint32_t receive_time_ntp = CompactNtp(last_received_xr_ntp_); | 264 uint32_t receive_time_ntp = CompactNtp(last_received_xr_ntp_); |
| 266 uint32_t now_ntp = CompactNtp(clock_->CurrentNtpTime()); | 265 uint32_t now_ntp = CompactNtp(clock_->CurrentNtpTime()); |
| 267 | 266 |
| 268 info->delay_since_last_rr = now_ntp - receive_time_ntp; | 267 info->delay_since_last_rr = now_ntp - receive_time_ntp; |
| 269 return true; | 268 return true; |
| 270 } | 269 } |
| 271 | 270 |
| 272 int32_t RTCPReceiver::SenderInfoReceived(RTCPSenderInfo* sender_info) const { | |
| 273 RTC_DCHECK(sender_info); | |
| 274 rtc::CritScope lock(&rtcp_receiver_lock_); | |
| 275 if (!last_received_sr_ntp_.Valid()) | |
| 276 return -1; | |
| 277 | |
| 278 memcpy(sender_info, &remote_sender_info_, sizeof(RTCPSenderInfo)); | |
| 279 return 0; | |
| 280 } | |
| 281 | |
| 282 // We can get multiple receive reports when we receive the report from a CE. | 271 // We can get multiple receive reports when we receive the report from a CE. |
| 283 int32_t RTCPReceiver::StatisticsReceived( | 272 int32_t RTCPReceiver::StatisticsReceived( |
| 284 std::vector<RTCPReportBlock>* receive_blocks) const { | 273 std::vector<RTCPReportBlock>* receive_blocks) const { |
| 285 RTC_DCHECK(receive_blocks); | 274 RTC_DCHECK(receive_blocks); |
| 286 rtc::CritScope lock(&rtcp_receiver_lock_); | 275 rtc::CritScope lock(&rtcp_receiver_lock_); |
| 287 for (const auto& reports_per_receiver : received_report_blocks_) | 276 for (const auto& reports_per_receiver : received_report_blocks_) |
| 288 for (const auto& report : reports_per_receiver.second) | 277 for (const auto& report : reports_per_receiver.second) |
| 289 receive_blocks->push_back(report.second.report_block); | 278 receive_blocks->push_back(report.second.report_block); |
| 290 return 0; | 279 return 0; |
| 291 } | 280 } |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 UpdateTmmbrRemoteIsAlive(remote_ssrc); | 395 UpdateTmmbrRemoteIsAlive(remote_ssrc); |
| 407 | 396 |
| 408 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "SR", | 397 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "SR", |
| 409 "remote_ssrc", remote_ssrc, "ssrc", main_ssrc_); | 398 "remote_ssrc", remote_ssrc, "ssrc", main_ssrc_); |
| 410 | 399 |
| 411 // Have I received RTP packets from this party? | 400 // Have I received RTP packets from this party? |
| 412 if (remote_ssrc_ == remote_ssrc) { | 401 if (remote_ssrc_ == remote_ssrc) { |
| 413 // Only signal that we have received a SR when we accept one. | 402 // Only signal that we have received a SR when we accept one. |
| 414 packet_information->packet_type_flags |= kRtcpSr; | 403 packet_information->packet_type_flags |= kRtcpSr; |
| 415 | 404 |
| 416 // Save the NTP time of this report. | 405 remote_sender_ntp_time_ = sender_report.ntp(); |
| 417 remote_sender_info_.NTPseconds = sender_report.ntp().seconds(); | 406 remote_sender_rtp_time_ = sender_report.rtp_timestamp(); |
| 418 remote_sender_info_.NTPfraction = sender_report.ntp().fractions(); | |
| 419 remote_sender_info_.RTPtimeStamp = sender_report.rtp_timestamp(); | |
| 420 remote_sender_info_.sendPacketCount = sender_report.sender_packet_count(); | |
| 421 remote_sender_info_.sendOctetCount = sender_report.sender_octet_count(); | |
| 422 | |
| 423 last_received_sr_ntp_ = clock_->CurrentNtpTime(); | 407 last_received_sr_ntp_ = clock_->CurrentNtpTime(); |
| 424 } else { | 408 } else { |
| 425 // We will only store the send report from one source, but | 409 // We will only store the send report from one source, but |
| 426 // we will store all the receive blocks. | 410 // we will store all the receive blocks. |
| 427 packet_information->packet_type_flags |= kRtcpRr; | 411 packet_information->packet_type_flags |= kRtcpRr; |
| 428 } | 412 } |
| 429 | 413 |
| 430 for (const rtcp::ReportBlock report_block : sender_report.report_blocks()) | 414 for (const rtcp::ReportBlock report_block : sender_report.report_blocks()) |
| 431 HandleReportBlock(report_block, packet_information, remote_ssrc); | 415 HandleReportBlock(report_block, packet_information, remote_ssrc); |
| 432 } | 416 } |
| (...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1049 } else { | 1033 } else { |
| 1050 candidates.push_back(it->second.tmmbr_item); | 1034 candidates.push_back(it->second.tmmbr_item); |
| 1051 ++it; | 1035 ++it; |
| 1052 } | 1036 } |
| 1053 } | 1037 } |
| 1054 } | 1038 } |
| 1055 return candidates; | 1039 return candidates; |
| 1056 } | 1040 } |
| 1057 | 1041 |
| 1058 } // namespace webrtc | 1042 } // namespace webrtc |
| OLD | NEW |