Chromium Code Reviews| 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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 292 if (packet_type_counter_.first_packet_time_ms == -1) { | 292 if (packet_type_counter_.first_packet_time_ms == -1) { |
| 293 packet_type_counter_.first_packet_time_ms = _lastReceived; | 293 packet_type_counter_.first_packet_time_ms = _lastReceived; |
| 294 } | 294 } |
| 295 | 295 |
| 296 RTCPUtility::RTCPPacketTypes pktType = rtcpParser->Begin(); | 296 RTCPUtility::RTCPPacketTypes pktType = rtcpParser->Begin(); |
| 297 while (pktType != RTCPPacketTypes::kInvalid) { | 297 while (pktType != RTCPPacketTypes::kInvalid) { |
| 298 // Each "case" is responsible for iterate the parser to the | 298 // Each "case" is responsible for iterate the parser to the |
| 299 // next top level packet. | 299 // next top level packet. |
| 300 switch (pktType) { | 300 switch (pktType) { |
| 301 case RTCPPacketTypes::kSr: | 301 case RTCPPacketTypes::kSr: |
| 302 HandleSenderReport(*rtcpParser, rtcpPacketInformation); | |
| 303 break; | |
| 302 case RTCPPacketTypes::kRr: | 304 case RTCPPacketTypes::kRr: |
| 303 HandleSenderReceiverReport(*rtcpParser, rtcpPacketInformation); | 305 HandleReceiverReport(*rtcpParser, rtcpPacketInformation); |
| 304 break; | 306 break; |
| 305 case RTCPPacketTypes::kSdes: | 307 case RTCPPacketTypes::kSdes: |
| 306 HandleSDES(*rtcpParser, rtcpPacketInformation); | 308 HandleSDES(*rtcpParser, rtcpPacketInformation); |
| 307 break; | 309 break; |
| 308 case RTCPPacketTypes::kXrHeader: | 310 case RTCPPacketTypes::kXrHeader: |
| 309 HandleXrHeader(*rtcpParser, rtcpPacketInformation); | 311 HandleXrHeader(*rtcpParser, rtcpPacketInformation); |
| 310 break; | 312 break; |
| 311 case RTCPPacketTypes::kXrReceiverReferenceTime: | 313 case RTCPPacketTypes::kXrReceiverReferenceTime: |
| 312 HandleXrReceiveReferenceTime(*rtcpParser, rtcpPacketInformation); | 314 HandleXrReceiveReferenceTime(*rtcpParser, rtcpPacketInformation); |
| 313 break; | 315 break; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 367 last_skipped_packets_warning_ = now; | 369 last_skipped_packets_warning_ = now; |
| 368 LOG(LS_WARNING) << num_skipped_packets_ | 370 LOG(LS_WARNING) << num_skipped_packets_ |
| 369 << " RTCP blocks were skipped due to being malformed or of " | 371 << " RTCP blocks were skipped due to being malformed or of " |
| 370 "unrecognized/unsupported type, during the past " | 372 "unrecognized/unsupported type, during the past " |
| 371 << (kMaxWarningLogIntervalMs / 1000) << " second period."; | 373 << (kMaxWarningLogIntervalMs / 1000) << " second period."; |
| 372 } | 374 } |
| 373 | 375 |
| 374 return 0; | 376 return 0; |
| 375 } | 377 } |
| 376 | 378 |
| 377 void RTCPReceiver::HandleSenderReceiverReport( | 379 void RTCPReceiver::HandleSenderReport( |
| 378 RTCPUtility::RTCPParserV2& rtcpParser, | 380 RTCPUtility::RTCPParserV2& rtcpParser, |
| 379 RTCPPacketInformation& rtcpPacketInformation) { | 381 RTCPPacketInformation& rtcpPacketInformation) { |
| 380 RTCPUtility::RTCPPacketTypes rtcpPacketType = rtcpParser.PacketType(); | 382 RTCPUtility::RTCPPacketTypes rtcpPacketType = rtcpParser.PacketType(); |
| 381 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet(); | 383 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet(); |
| 382 | 384 |
| 383 assert((rtcpPacketType == RTCPPacketTypes::kRr) || | 385 RTC_DCHECK(rtcpPacketType == RTCPPacketTypes::kSr); |
| 384 (rtcpPacketType == RTCPPacketTypes::kSr)); | |
| 385 | 386 |
| 386 // SR.SenderSSRC | 387 // SR.SenderSSRC |
| 387 // The synchronization source identifier for the originator of this SR packet | 388 // The synchronization source identifier for the originator of this SR packet |
| 388 | 389 |
| 389 // rtcpPacket.RR.SenderSSRC | 390 const uint32_t remoteSSRC = rtcpPacket.SR.SenderSSRC; |
| 390 // The source of the packet sender, same as of SR? or is this a CE? | |
| 391 | |
| 392 const uint32_t remoteSSRC = (rtcpPacketType == RTCPPacketTypes::kRr) | |
| 393 ? rtcpPacket.RR.SenderSSRC | |
| 394 : rtcpPacket.SR.SenderSSRC; | |
| 395 | 391 |
| 396 rtcpPacketInformation.remoteSSRC = remoteSSRC; | 392 rtcpPacketInformation.remoteSSRC = remoteSSRC; |
| 397 | 393 |
| 398 RTCPReceiveInformation* ptrReceiveInfo = CreateReceiveInformation(remoteSSRC); | 394 RTCPReceiveInformation* ptrReceiveInfo = CreateReceiveInformation(remoteSSRC); |
| 399 if (!ptrReceiveInfo) { | 395 if (!ptrReceiveInfo) { |
| 400 rtcpParser.Iterate(); | 396 rtcpParser.Iterate(); |
| 401 return; | 397 return; |
| 402 } | 398 } |
| 403 | 399 |
| 404 if (rtcpPacketType == RTCPPacketTypes::kSr) { | 400 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "SR", |
| 405 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "SR", | 401 "remote_ssrc", remoteSSRC, "ssrc", main_ssrc_); |
| 406 "remote_ssrc", remoteSSRC, "ssrc", main_ssrc_); | |
| 407 | 402 |
| 408 if (_remoteSSRC == | 403 if (_remoteSSRC == |
| 409 remoteSSRC) // have I received RTP packets from this party | 404 remoteSSRC) // have I received RTP packets from this party |
|
philipel
2016/09/15 11:58:19
format
danilchap
2016/09/15 12:17:30
Done.
| |
| 410 { | 405 { |
| 411 // only signal that we have received a SR when we accept one | 406 // only signal that we have received a SR when we accept one |
| 412 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpSr; | 407 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpSr; |
| 413 | 408 |
| 414 rtcpPacketInformation.ntp_secs = rtcpPacket.SR.NTPMostSignificant; | 409 rtcpPacketInformation.ntp_secs = rtcpPacket.SR.NTPMostSignificant; |
| 415 rtcpPacketInformation.ntp_frac = rtcpPacket.SR.NTPLeastSignificant; | 410 rtcpPacketInformation.ntp_frac = rtcpPacket.SR.NTPLeastSignificant; |
| 416 rtcpPacketInformation.rtp_timestamp = rtcpPacket.SR.RTPTimestamp; | 411 rtcpPacketInformation.rtp_timestamp = rtcpPacket.SR.RTPTimestamp; |
| 417 | 412 |
| 418 // We will only store the send report from one source, but | 413 // We will only store the send report from one source, but |
| 419 // we will store all the receive block | 414 // we will store all the receive block |
| 420 | 415 |
| 421 // Save the NTP time of this report | 416 // Save the NTP time of this report |
| 422 _remoteSenderInfo.NTPseconds = rtcpPacket.SR.NTPMostSignificant; | 417 _remoteSenderInfo.NTPseconds = rtcpPacket.SR.NTPMostSignificant; |
| 423 _remoteSenderInfo.NTPfraction = rtcpPacket.SR.NTPLeastSignificant; | 418 _remoteSenderInfo.NTPfraction = rtcpPacket.SR.NTPLeastSignificant; |
| 424 _remoteSenderInfo.RTPtimeStamp = rtcpPacket.SR.RTPTimestamp; | 419 _remoteSenderInfo.RTPtimeStamp = rtcpPacket.SR.RTPTimestamp; |
| 425 _remoteSenderInfo.sendPacketCount = rtcpPacket.SR.SenderPacketCount; | 420 _remoteSenderInfo.sendPacketCount = rtcpPacket.SR.SenderPacketCount; |
| 426 _remoteSenderInfo.sendOctetCount = rtcpPacket.SR.SenderOctetCount; | 421 _remoteSenderInfo.sendOctetCount = rtcpPacket.SR.SenderOctetCount; |
| 427 | 422 |
| 428 _clock->CurrentNtp(_lastReceivedSRNTPsecs, _lastReceivedSRNTPfrac); | 423 _clock->CurrentNtp(_lastReceivedSRNTPsecs, _lastReceivedSRNTPfrac); |
| 429 } else { | |
| 430 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpRr; | |
| 431 } | |
| 432 } else { | 424 } else { |
| 433 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "RR", | |
| 434 "remote_ssrc", remoteSSRC, "ssrc", main_ssrc_); | |
| 435 | |
| 436 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpRr; | 425 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpRr; |
|
philipel
2016/09/15 11:58:19
This line look suspicious, do we say that this rtc
danilchap
2016/09/15 12:17:30
This behavior is unchanged.
Treat sender report as
| |
| 437 } | 426 } |
| 438 // Update that this remote is alive. | 427 // Update that this remote is alive. |
| 439 ptrReceiveInfo->last_time_received_ms = _clock->TimeInMilliseconds(); | 428 ptrReceiveInfo->last_time_received_ms = _clock->TimeInMilliseconds(); |
| 440 | 429 |
| 441 rtcpPacketType = rtcpParser.Iterate(); | 430 rtcpPacketType = rtcpParser.Iterate(); |
| 442 | 431 |
| 443 while (rtcpPacketType == RTCPPacketTypes::kReportBlockItem) { | 432 while (rtcpPacketType == RTCPPacketTypes::kReportBlockItem) { |
| 444 HandleReportBlock(rtcpPacket, rtcpPacketInformation, remoteSSRC); | 433 HandleReportBlock(rtcpPacket, rtcpPacketInformation, remoteSSRC); |
| 445 rtcpPacketType = rtcpParser.Iterate(); | 434 rtcpPacketType = rtcpParser.Iterate(); |
| 446 } | 435 } |
| 447 } | 436 } |
| 448 | 437 |
| 438 void RTCPReceiver::HandleReceiverReport( | |
| 439 RTCPUtility::RTCPParserV2& rtcpParser, | |
| 440 RTCPPacketInformation& rtcpPacketInformation) { | |
| 441 RTCPUtility::RTCPPacketTypes rtcpPacketType = rtcpParser.PacketType(); | |
| 442 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet(); | |
| 443 | |
| 444 RTC_DCHECK(rtcpPacketType == RTCPPacketTypes::kRr); | |
| 445 | |
| 446 // rtcpPacket.RR.SenderSSRC | |
| 447 // The source of the packet sender, same as of SR? or is this a CE? | |
| 448 | |
| 449 const uint32_t remoteSSRC = rtcpPacket.RR.SenderSSRC; | |
| 450 | |
| 451 rtcpPacketInformation.remoteSSRC = remoteSSRC; | |
| 452 | |
| 453 RTCPReceiveInformation* ptrReceiveInfo = CreateReceiveInformation(remoteSSRC); | |
| 454 if (!ptrReceiveInfo) { | |
| 455 rtcpParser.Iterate(); | |
| 456 return; | |
| 457 } | |
| 458 | |
| 459 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "RR", | |
| 460 "remote_ssrc", remoteSSRC, "ssrc", main_ssrc_); | |
| 461 | |
| 462 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpRr; | |
| 463 | |
| 464 // Update that this remote is alive. | |
| 465 ptrReceiveInfo->last_time_received_ms = _clock->TimeInMilliseconds(); | |
| 466 | |
| 467 rtcpPacketType = rtcpParser.Iterate(); | |
| 468 | |
| 469 while (rtcpPacketType == RTCPPacketTypes::kReportBlockItem) { | |
| 470 HandleReportBlock(rtcpPacket, rtcpPacketInformation, remoteSSRC); | |
| 471 rtcpPacketType = rtcpParser.Iterate(); | |
| 472 } | |
| 473 } | |
| 474 | |
| 449 void RTCPReceiver::HandleReportBlock( | 475 void RTCPReceiver::HandleReportBlock( |
| 450 const RTCPUtility::RTCPPacket& rtcpPacket, | 476 const RTCPUtility::RTCPPacket& rtcpPacket, |
| 451 RTCPPacketInformation& rtcpPacketInformation, | 477 RTCPPacketInformation& rtcpPacketInformation, |
| 452 uint32_t remoteSSRC) | 478 uint32_t remoteSSRC) |
| 453 EXCLUSIVE_LOCKS_REQUIRED(_criticalSectionRTCPReceiver) { | 479 EXCLUSIVE_LOCKS_REQUIRED(_criticalSectionRTCPReceiver) { |
| 454 // This will be called once per report block in the RTCP packet. | 480 // This will be called once per report block in the RTCP packet. |
| 455 // We filter out all report blocks that are not for us. | 481 // We filter out all report blocks that are not for us. |
| 456 // Each packet has max 31 RR blocks. | 482 // Each packet has max 31 RR blocks. |
| 457 // | 483 // |
| 458 // We can calc RTT if we send a send report and get a report block back. | 484 // We can calc RTT if we send a send report and get a report block back. |
| (...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1283 | 1309 |
| 1284 for (const auto& kv : _receivedInfoMap) { | 1310 for (const auto& kv : _receivedInfoMap) { |
| 1285 RTCPReceiveInformation* receive_info = kv.second; | 1311 RTCPReceiveInformation* receive_info = kv.second; |
| 1286 RTC_DCHECK(receive_info); | 1312 RTC_DCHECK(receive_info); |
| 1287 receive_info->GetTmmbrSet(now_ms, &candidates); | 1313 receive_info->GetTmmbrSet(now_ms, &candidates); |
| 1288 } | 1314 } |
| 1289 return candidates; | 1315 return candidates; |
| 1290 } | 1316 } |
| 1291 | 1317 |
| 1292 } // namespace webrtc | 1318 } // namespace webrtc |
| OLD | NEW |