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

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

Issue 1401463003: Avoid data race in RtcpReceiver. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Formatting 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
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtcp_receiver.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 LOG(LS_WARNING) 380 LOG(LS_WARNING)
381 << num_skipped_packets_ 381 << num_skipped_packets_
382 << " RTCP blocks were skipped due to being malformed or of " 382 << " RTCP blocks were skipped due to being malformed or of "
383 "unrecognized/unsupported type, during the past " 383 "unrecognized/unsupported type, during the past "
384 << (kMaxWarningLogIntervalMs / 1000) << " second period."; 384 << (kMaxWarningLogIntervalMs / 1000) << " second period.";
385 } 385 }
386 386
387 return 0; 387 return 0;
388 } 388 }
389 389
390 // no need for critsect we have _criticalSectionRTCPReceiver
391 void 390 void
392 RTCPReceiver::HandleSenderReceiverReport(RTCPUtility::RTCPParserV2& rtcpParser, 391 RTCPReceiver::HandleSenderReceiverReport(RTCPUtility::RTCPParserV2& rtcpParser,
393 RTCPPacketInformation& rtcpPacketInform ation) 392 RTCPPacketInformation& rtcpPacketInform ation)
394 { 393 {
395 RTCPUtility::RTCPPacketTypes rtcpPacketType = rtcpParser.PacketType(); 394 RTCPUtility::RTCPPacketTypes rtcpPacketType = rtcpParser.PacketType();
396 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet(); 395 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet();
397 396
398 assert((rtcpPacketType == RTCPPacketTypes::kRr) || 397 assert((rtcpPacketType == RTCPPacketTypes::kRr) ||
399 (rtcpPacketType == RTCPPacketTypes::kSr)); 398 (rtcpPacketType == RTCPPacketTypes::kSr));
400 399
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 UpdateReceiveInformation(*ptrReceiveInfo); 455 UpdateReceiveInformation(*ptrReceiveInfo);
457 456
458 rtcpPacketType = rtcpParser.Iterate(); 457 rtcpPacketType = rtcpParser.Iterate();
459 458
460 while (rtcpPacketType == RTCPPacketTypes::kReportBlockItem) { 459 while (rtcpPacketType == RTCPPacketTypes::kReportBlockItem) {
461 HandleReportBlock(rtcpPacket, rtcpPacketInformation, remoteSSRC); 460 HandleReportBlock(rtcpPacket, rtcpPacketInformation, remoteSSRC);
462 rtcpPacketType = rtcpParser.Iterate(); 461 rtcpPacketType = rtcpParser.Iterate();
463 } 462 }
464 } 463 }
465 464
466 // no need for critsect we have _criticalSectionRTCPReceiver
467 void RTCPReceiver::HandleReportBlock( 465 void RTCPReceiver::HandleReportBlock(
468 const RTCPUtility::RTCPPacket& rtcpPacket, 466 const RTCPUtility::RTCPPacket& rtcpPacket,
469 RTCPPacketInformation& rtcpPacketInformation, 467 RTCPPacketInformation& rtcpPacketInformation,
470 uint32_t remoteSSRC) 468 uint32_t remoteSSRC)
471 EXCLUSIVE_LOCKS_REQUIRED(_criticalSectionRTCPReceiver) { 469 EXCLUSIVE_LOCKS_REQUIRED(_criticalSectionRTCPReceiver) {
472 // This will be called once per report block in the RTCP packet. 470 // This will be called once per report block in the RTCP packet.
473 // We filter out all report blocks that are not for us. 471 // We filter out all report blocks that are not for us.
474 // Each packet has max 31 RR blocks. 472 // Each packet has max 31 RR blocks.
475 // 473 //
476 // We can calc RTT if we send a send report and get a report block back. 474 // We can calc RTT if we send a send report and get a report block back.
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 } 766 }
769 boundingSetRec->SetEntry(i, 767 boundingSetRec->SetEntry(i,
770 receiveInfo->TmmbnBoundingSet.Tmmbr(i), 768 receiveInfo->TmmbnBoundingSet.Tmmbr(i),
771 receiveInfo->TmmbnBoundingSet.PacketOH(i), 769 receiveInfo->TmmbnBoundingSet.PacketOH(i),
772 receiveInfo->TmmbnBoundingSet.Ssrc(i)); 770 receiveInfo->TmmbnBoundingSet.Ssrc(i));
773 } 771 }
774 } 772 }
775 return receiveInfo->TmmbnBoundingSet.lengthOfSet(); 773 return receiveInfo->TmmbnBoundingSet.lengthOfSet();
776 } 774 }
777 775
778 // no need for critsect we have _criticalSectionRTCPReceiver
779 void RTCPReceiver::HandleSDES(RTCPUtility::RTCPParserV2& rtcpParser, 776 void RTCPReceiver::HandleSDES(RTCPUtility::RTCPParserV2& rtcpParser,
780 RTCPPacketInformation& rtcpPacketInformation) { 777 RTCPPacketInformation& rtcpPacketInformation) {
781 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate(); 778 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate();
782 while (pktType == RTCPPacketTypes::kSdesChunk) { 779 while (pktType == RTCPPacketTypes::kSdesChunk) {
783 HandleSDESChunk(rtcpParser); 780 HandleSDESChunk(rtcpParser);
784 pktType = rtcpParser.Iterate(); 781 pktType = rtcpParser.Iterate();
785 } 782 }
786 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpSdes; 783 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpSdes;
787 } 784 }
788 785
789 // no need for critsect we have _criticalSectionRTCPReceiver
790 void RTCPReceiver::HandleSDESChunk(RTCPUtility::RTCPParserV2& rtcpParser) { 786 void RTCPReceiver::HandleSDESChunk(RTCPUtility::RTCPParserV2& rtcpParser) {
791 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet(); 787 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet();
792 RTCPCnameInformation* cnameInfo = 788 RTCPCnameInformation* cnameInfo =
793 CreateCnameInformation(rtcpPacket.CName.SenderSSRC); 789 CreateCnameInformation(rtcpPacket.CName.SenderSSRC);
794 assert(cnameInfo); 790 assert(cnameInfo);
795 791
796 cnameInfo->name[RTCP_CNAME_SIZE - 1] = 0; 792 cnameInfo->name[RTCP_CNAME_SIZE - 1] = 0;
797 strncpy(cnameInfo->name, rtcpPacket.CName.CName, RTCP_CNAME_SIZE - 1); 793 strncpy(cnameInfo->name, rtcpPacket.CName.CName, RTCP_CNAME_SIZE - 1);
798 { 794 {
799 CriticalSectionScoped lock(_criticalSectionFeedbacks); 795 CriticalSectionScoped lock(_criticalSectionFeedbacks);
800 if (stats_callback_ != NULL) { 796 if (stats_callback_ != NULL) {
801 stats_callback_->CNameChanged(rtcpPacket.CName.CName, 797 stats_callback_->CNameChanged(rtcpPacket.CName.CName,
802 rtcpPacket.CName.SenderSSRC); 798 rtcpPacket.CName.SenderSSRC);
803 } 799 }
804 } 800 }
805 } 801 }
806 802
807 // no need for critsect we have _criticalSectionRTCPReceiver
808 void RTCPReceiver::HandleNACK(RTCPUtility::RTCPParserV2& rtcpParser, 803 void RTCPReceiver::HandleNACK(RTCPUtility::RTCPParserV2& rtcpParser,
809 RTCPPacketInformation& rtcpPacketInformation) { 804 RTCPPacketInformation& rtcpPacketInformation) {
810 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet(); 805 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet();
811 if (receiver_only_ || main_ssrc_ != rtcpPacket.NACK.MediaSSRC) { 806 if (receiver_only_ || main_ssrc_ != rtcpPacket.NACK.MediaSSRC) {
812 // Not to us. 807 // Not to us.
813 rtcpParser.Iterate(); 808 rtcpParser.Iterate();
814 return; 809 return;
815 } 810 }
816 rtcpPacketInformation.ResetNACKPacketIdArray(); 811 rtcpPacketInformation.ResetNACKPacketIdArray();
817 812
818 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate(); 813 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate();
819 while (pktType == RTCPPacketTypes::kRtpfbNackItem) { 814 while (pktType == RTCPPacketTypes::kRtpfbNackItem) {
820 HandleNACKItem(rtcpPacket, rtcpPacketInformation); 815 HandleNACKItem(rtcpPacket, rtcpPacketInformation);
821 pktType = rtcpParser.Iterate(); 816 pktType = rtcpParser.Iterate();
822 } 817 }
823 818
824 if (rtcpPacketInformation.rtcpPacketTypeFlags & kRtcpNack) { 819 if (rtcpPacketInformation.rtcpPacketTypeFlags & kRtcpNack) {
825 ++packet_type_counter_.nack_packets; 820 ++packet_type_counter_.nack_packets;
826 packet_type_counter_.nack_requests = nack_stats_.requests(); 821 packet_type_counter_.nack_requests = nack_stats_.requests();
827 packet_type_counter_.unique_nack_requests = nack_stats_.unique_requests(); 822 packet_type_counter_.unique_nack_requests = nack_stats_.unique_requests();
828 } 823 }
829 } 824 }
830 825
831 // no need for critsect we have _criticalSectionRTCPReceiver
832 void 826 void
833 RTCPReceiver::HandleNACKItem(const RTCPUtility::RTCPPacket& rtcpPacket, 827 RTCPReceiver::HandleNACKItem(const RTCPUtility::RTCPPacket& rtcpPacket,
834 RTCPPacketInformation& rtcpPacketInformation) { 828 RTCPPacketInformation& rtcpPacketInformation) {
835 rtcpPacketInformation.AddNACKPacket(rtcpPacket.NACKItem.PacketID); 829 rtcpPacketInformation.AddNACKPacket(rtcpPacket.NACKItem.PacketID);
836 nack_stats_.ReportRequest(rtcpPacket.NACKItem.PacketID); 830 nack_stats_.ReportRequest(rtcpPacket.NACKItem.PacketID);
837 831
838 uint16_t bitMask = rtcpPacket.NACKItem.BitMask; 832 uint16_t bitMask = rtcpPacket.NACKItem.BitMask;
839 if (bitMask) { 833 if (bitMask) {
840 for (int i=1; i <= 16; ++i) { 834 for (int i=1; i <= 16; ++i) {
841 if (bitMask & 0x01) { 835 if (bitMask & 0x01) {
842 rtcpPacketInformation.AddNACKPacket(rtcpPacket.NACKItem.PacketID + i); 836 rtcpPacketInformation.AddNACKPacket(rtcpPacket.NACKItem.PacketID + i);
843 nack_stats_.ReportRequest(rtcpPacket.NACKItem.PacketID + i); 837 nack_stats_.ReportRequest(rtcpPacket.NACKItem.PacketID + i);
844 } 838 }
845 bitMask = bitMask >>1; 839 bitMask = bitMask >>1;
846 } 840 }
847 } 841 }
848 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpNack; 842 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpNack;
849 } 843 }
850 844
851 // no need for critsect we have _criticalSectionRTCPReceiver
852 void RTCPReceiver::HandleBYE(RTCPUtility::RTCPParserV2& rtcpParser) { 845 void RTCPReceiver::HandleBYE(RTCPUtility::RTCPParserV2& rtcpParser) {
853 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet(); 846 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet();
854 847
855 // clear our lists 848 // clear our lists
856 CriticalSectionScoped lock(_criticalSectionRTCPReceiver);
857 ReportBlockMap::iterator it = _receivedReportBlockMap.begin(); 849 ReportBlockMap::iterator it = _receivedReportBlockMap.begin();
858 for (; it != _receivedReportBlockMap.end(); ++it) { 850 for (; it != _receivedReportBlockMap.end(); ++it) {
859 ReportBlockInfoMap* info_map = &(it->second); 851 ReportBlockInfoMap* info_map = &(it->second);
860 ReportBlockInfoMap::iterator it_info = info_map->find( 852 ReportBlockInfoMap::iterator it_info = info_map->find(
861 rtcpPacket.BYE.SenderSSRC); 853 rtcpPacket.BYE.SenderSSRC);
862 if (it_info != info_map->end()) { 854 if (it_info != info_map->end()) {
863 delete it_info->second; 855 delete it_info->second;
864 info_map->erase(it_info); 856 info_map->erase(it_info);
865 } 857 }
866 } 858 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
957 (((packet.XRDLRRReportBlockItem.DelayLastRR & 0x0000ffff) * 1000) >> 16) + 949 (((packet.XRDLRRReportBlockItem.DelayLastRR & 0x0000ffff) * 1000) >> 16) +
958 (((packet.XRDLRRReportBlockItem.DelayLastRR & 0xffff0000) >> 16) * 1000); 950 (((packet.XRDLRRReportBlockItem.DelayLastRR & 0xffff0000) >> 16) * 1000);
959 951
960 int64_t rtt = _clock->CurrentNtpInMilliseconds() - delay_rr_ms - send_time_ms; 952 int64_t rtt = _clock->CurrentNtpInMilliseconds() - delay_rr_ms - send_time_ms;
961 953
962 xr_rr_rtt_ms_ = std::max<int64_t>(rtt, 1); 954 xr_rr_rtt_ms_ = std::max<int64_t>(rtt, 1);
963 955
964 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpXrDlrrReportBlock; 956 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpXrDlrrReportBlock;
965 } 957 }
966 958
967 // no need for critsect we have _criticalSectionRTCPReceiver
968 void 959 void
969 RTCPReceiver::HandleXRVOIPMetric(RTCPUtility::RTCPParserV2& rtcpParser, 960 RTCPReceiver::HandleXRVOIPMetric(RTCPUtility::RTCPParserV2& rtcpParser,
970 RTCPPacketInformation& rtcpPacketInformation) 961 RTCPPacketInformation& rtcpPacketInformation)
971 { 962 {
972 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet(); 963 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet();
973 964
974 CriticalSectionScoped lock(_criticalSectionRTCPReceiver);
975
976 if(rtcpPacket.XRVOIPMetricItem.SSRC == main_ssrc_) 965 if(rtcpPacket.XRVOIPMetricItem.SSRC == main_ssrc_)
977 { 966 {
978 // Store VoIP metrics block if it's about me 967 // Store VoIP metrics block if it's about me
979 // from OriginatorSSRC do we filter it? 968 // from OriginatorSSRC do we filter it?
980 // rtcpPacket.XR.OriginatorSSRC; 969 // rtcpPacket.XR.OriginatorSSRC;
981 970
982 RTCPVoIPMetric receivedVoIPMetrics; 971 RTCPVoIPMetric receivedVoIPMetrics;
983 receivedVoIPMetrics.burstDensity = rtcpPacket.XRVOIPMetricItem.burstDens ity; 972 receivedVoIPMetrics.burstDensity = rtcpPacket.XRVOIPMetricItem.burstDens ity;
984 receivedVoIPMetrics.burstDuration = rtcpPacket.XRVOIPMetricItem.burstDur ation; 973 receivedVoIPMetrics.burstDuration = rtcpPacket.XRVOIPMetricItem.burstDur ation;
985 receivedVoIPMetrics.discardRate = rtcpPacket.XRVOIPMetricItem.discardRat e; 974 receivedVoIPMetrics.discardRate = rtcpPacket.XRVOIPMetricItem.discardRat e;
(...skipping 15 matching lines...) Expand all
1001 receivedVoIPMetrics.RXconfig = rtcpPacket.XRVOIPMetricItem.RXconfig; 990 receivedVoIPMetrics.RXconfig = rtcpPacket.XRVOIPMetricItem.RXconfig;
1002 receivedVoIPMetrics.signalLevel = rtcpPacket.XRVOIPMetricItem.signalLeve l; 991 receivedVoIPMetrics.signalLevel = rtcpPacket.XRVOIPMetricItem.signalLeve l;
1003 992
1004 rtcpPacketInformation.AddVoIPMetric(&receivedVoIPMetrics); 993 rtcpPacketInformation.AddVoIPMetric(&receivedVoIPMetrics);
1005 994
1006 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpXrVoipMetric; // recei ved signal 995 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpXrVoipMetric; // recei ved signal
1007 } 996 }
1008 rtcpParser.Iterate(); 997 rtcpParser.Iterate();
1009 } 998 }
1010 999
1011 // no need for critsect we have _criticalSectionRTCPReceiver
1012 void RTCPReceiver::HandlePLI(RTCPUtility::RTCPParserV2& rtcpParser, 1000 void RTCPReceiver::HandlePLI(RTCPUtility::RTCPParserV2& rtcpParser,
1013 RTCPPacketInformation& rtcpPacketInformation) { 1001 RTCPPacketInformation& rtcpPacketInformation) {
1014 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet(); 1002 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet();
1015 if (main_ssrc_ == rtcpPacket.PLI.MediaSSRC) { 1003 if (main_ssrc_ == rtcpPacket.PLI.MediaSSRC) {
1016 TRACE_EVENT_INSTANT0(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "PLI"); 1004 TRACE_EVENT_INSTANT0(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "PLI");
1017 1005
1018 ++packet_type_counter_.pli_packets; 1006 ++packet_type_counter_.pli_packets;
1019 // Received a signal that we need to send a new key frame. 1007 // Received a signal that we need to send a new key frame.
1020 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpPli; 1008 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpPli;
1021 } 1009 }
1022 rtcpParser.Iterate(); 1010 rtcpParser.Iterate();
1023 } 1011 }
1024 1012
1025 // no need for critsect we have _criticalSectionRTCPReceiver
1026 void RTCPReceiver::HandleTMMBR(RTCPUtility::RTCPParserV2& rtcpParser, 1013 void RTCPReceiver::HandleTMMBR(RTCPUtility::RTCPParserV2& rtcpParser,
1027 RTCPPacketInformation& rtcpPacketInformation) { 1014 RTCPPacketInformation& rtcpPacketInformation) {
1028 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet(); 1015 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet();
1029 1016
1030 uint32_t senderSSRC = rtcpPacket.TMMBR.SenderSSRC; 1017 uint32_t senderSSRC = rtcpPacket.TMMBR.SenderSSRC;
1031 RTCPReceiveInformation* ptrReceiveInfo = GetReceiveInformation(senderSSRC); 1018 RTCPReceiveInformation* ptrReceiveInfo = GetReceiveInformation(senderSSRC);
1032 if (ptrReceiveInfo == NULL) { 1019 if (ptrReceiveInfo == NULL) {
1033 // This remote SSRC must be saved before. 1020 // This remote SSRC must be saved before.
1034 rtcpParser.Iterate(); 1021 rtcpParser.Iterate();
1035 return; 1022 return;
(...skipping 16 matching lines...) Expand all
1052 } 1039 }
1053 ptrReceiveInfo->VerifyAndAllocateTMMBRSet((uint32_t)maxNumOfTMMBRBlocks); 1040 ptrReceiveInfo->VerifyAndAllocateTMMBRSet((uint32_t)maxNumOfTMMBRBlocks);
1054 1041
1055 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate(); 1042 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate();
1056 while (pktType == RTCPPacketTypes::kRtpfbTmmbrItem) { 1043 while (pktType == RTCPPacketTypes::kRtpfbTmmbrItem) {
1057 HandleTMMBRItem(*ptrReceiveInfo, rtcpPacket, rtcpPacketInformation, senderSS RC); 1044 HandleTMMBRItem(*ptrReceiveInfo, rtcpPacket, rtcpPacketInformation, senderSS RC);
1058 pktType = rtcpParser.Iterate(); 1045 pktType = rtcpParser.Iterate();
1059 } 1046 }
1060 } 1047 }
1061 1048
1062 // no need for critsect we have _criticalSectionRTCPReceiver
1063 void RTCPReceiver::HandleTMMBRItem(RTCPReceiveInformation& receiveInfo, 1049 void RTCPReceiver::HandleTMMBRItem(RTCPReceiveInformation& receiveInfo,
1064 const RTCPUtility::RTCPPacket& rtcpPacket, 1050 const RTCPUtility::RTCPPacket& rtcpPacket,
1065 RTCPPacketInformation& rtcpPacketInformation, 1051 RTCPPacketInformation& rtcpPacketInformation,
1066 uint32_t senderSSRC) { 1052 uint32_t senderSSRC) {
1067 if (main_ssrc_ == rtcpPacket.TMMBRItem.SSRC && 1053 if (main_ssrc_ == rtcpPacket.TMMBRItem.SSRC &&
1068 rtcpPacket.TMMBRItem.MaxTotalMediaBitRate > 0) { 1054 rtcpPacket.TMMBRItem.MaxTotalMediaBitRate > 0) {
1069 receiveInfo.InsertTMMBRItem(senderSSRC, rtcpPacket.TMMBRItem, 1055 receiveInfo.InsertTMMBRItem(senderSSRC, rtcpPacket.TMMBRItem,
1070 _clock->TimeInMilliseconds()); 1056 _clock->TimeInMilliseconds());
1071 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpTmmbr; 1057 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpTmmbr;
1072 } 1058 }
1073 } 1059 }
1074 1060
1075 // no need for critsect we have _criticalSectionRTCPReceiver
1076 void RTCPReceiver::HandleTMMBN(RTCPUtility::RTCPParserV2& rtcpParser, 1061 void RTCPReceiver::HandleTMMBN(RTCPUtility::RTCPParserV2& rtcpParser,
1077 RTCPPacketInformation& rtcpPacketInformation) { 1062 RTCPPacketInformation& rtcpPacketInformation) {
1078 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet(); 1063 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet();
1079 RTCPReceiveInformation* ptrReceiveInfo = GetReceiveInformation( 1064 RTCPReceiveInformation* ptrReceiveInfo = GetReceiveInformation(
1080 rtcpPacket.TMMBN.SenderSSRC); 1065 rtcpPacket.TMMBN.SenderSSRC);
1081 if (ptrReceiveInfo == NULL) { 1066 if (ptrReceiveInfo == NULL) {
1082 // This remote SSRC must be saved before. 1067 // This remote SSRC must be saved before.
1083 rtcpParser.Iterate(); 1068 rtcpParser.Iterate();
1084 return; 1069 return;
1085 } 1070 }
(...skipping 11 matching lines...) Expand all
1097 1082
1098 ptrReceiveInfo->VerifyAndAllocateBoundingSet((uint32_t)maxNumOfTMMBNBlocks); 1083 ptrReceiveInfo->VerifyAndAllocateBoundingSet((uint32_t)maxNumOfTMMBNBlocks);
1099 1084
1100 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate(); 1085 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate();
1101 while (pktType == RTCPPacketTypes::kRtpfbTmmbnItem) { 1086 while (pktType == RTCPPacketTypes::kRtpfbTmmbnItem) {
1102 HandleTMMBNItem(*ptrReceiveInfo, rtcpPacket); 1087 HandleTMMBNItem(*ptrReceiveInfo, rtcpPacket);
1103 pktType = rtcpParser.Iterate(); 1088 pktType = rtcpParser.Iterate();
1104 } 1089 }
1105 } 1090 }
1106 1091
1107 // no need for critsect we have _criticalSectionRTCPReceiver
1108 void RTCPReceiver::HandleSR_REQ(RTCPUtility::RTCPParserV2& rtcpParser, 1092 void RTCPReceiver::HandleSR_REQ(RTCPUtility::RTCPParserV2& rtcpParser,
1109 RTCPPacketInformation& rtcpPacketInformation) { 1093 RTCPPacketInformation& rtcpPacketInformation) {
1110 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpSrReq; 1094 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpSrReq;
1111 rtcpParser.Iterate(); 1095 rtcpParser.Iterate();
1112 } 1096 }
1113 1097
1114 // no need for critsect we have _criticalSectionRTCPReceiver
1115 void RTCPReceiver::HandleTMMBNItem(RTCPReceiveInformation& receiveInfo, 1098 void RTCPReceiver::HandleTMMBNItem(RTCPReceiveInformation& receiveInfo,
1116 const RTCPUtility::RTCPPacket& rtcpPacket) { 1099 const RTCPUtility::RTCPPacket& rtcpPacket) {
1117 receiveInfo.TmmbnBoundingSet.AddEntry( 1100 receiveInfo.TmmbnBoundingSet.AddEntry(
1118 rtcpPacket.TMMBNItem.MaxTotalMediaBitRate, 1101 rtcpPacket.TMMBNItem.MaxTotalMediaBitRate,
1119 rtcpPacket.TMMBNItem.MeasuredOverhead, 1102 rtcpPacket.TMMBNItem.MeasuredOverhead,
1120 rtcpPacket.TMMBNItem.SSRC); 1103 rtcpPacket.TMMBNItem.SSRC);
1121 } 1104 }
1122 1105
1123 // no need for critsect we have _criticalSectionRTCPReceiver
1124 void RTCPReceiver::HandleSLI(RTCPUtility::RTCPParserV2& rtcpParser, 1106 void RTCPReceiver::HandleSLI(RTCPUtility::RTCPParserV2& rtcpParser,
1125 RTCPPacketInformation& rtcpPacketInformation) { 1107 RTCPPacketInformation& rtcpPacketInformation) {
1126 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet(); 1108 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet();
1127 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate(); 1109 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate();
1128 while (pktType == RTCPPacketTypes::kPsfbSliItem) { 1110 while (pktType == RTCPPacketTypes::kPsfbSliItem) {
1129 HandleSLIItem(rtcpPacket, rtcpPacketInformation); 1111 HandleSLIItem(rtcpPacket, rtcpPacketInformation);
1130 pktType = rtcpParser.Iterate(); 1112 pktType = rtcpParser.Iterate();
1131 } 1113 }
1132 } 1114 }
1133 1115
1134 // no need for critsect we have _criticalSectionRTCPReceiver
1135 void RTCPReceiver::HandleSLIItem(const RTCPUtility::RTCPPacket& rtcpPacket, 1116 void RTCPReceiver::HandleSLIItem(const RTCPUtility::RTCPPacket& rtcpPacket,
1136 RTCPPacketInformation& rtcpPacketInformation) { 1117 RTCPPacketInformation& rtcpPacketInformation) {
1137 // in theory there could be multiple slices lost 1118 // in theory there could be multiple slices lost
1138 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpSli; // received signal that we need to refresh a slice 1119 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpSli; // received signal that we need to refresh a slice
1139 rtcpPacketInformation.sliPictureId = rtcpPacket.SLIItem.PictureId; 1120 rtcpPacketInformation.sliPictureId = rtcpPacket.SLIItem.PictureId;
1140 } 1121 }
1141 1122
1142 void 1123 void
1143 RTCPReceiver::HandleRPSI(RTCPUtility::RTCPParserV2& rtcpParser, 1124 RTCPReceiver::HandleRPSI(RTCPUtility::RTCPParserV2& rtcpParser,
1144 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation) 1125 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation)
(...skipping 15 matching lines...) Expand all
1160 uint8_t numberOfBytes = rtcpPacket.RPSI.NumberOfValidBits /8; 1141 uint8_t numberOfBytes = rtcpPacket.RPSI.NumberOfValidBits /8;
1161 for(uint8_t n = 0; n < (numberOfBytes-1); n++) 1142 for(uint8_t n = 0; n < (numberOfBytes-1); n++)
1162 { 1143 {
1163 rtcpPacketInformation.rpsiPictureId += (rtcpPacket.RPSI.NativeBitStr ing[n] & 0x7f); 1144 rtcpPacketInformation.rpsiPictureId += (rtcpPacket.RPSI.NativeBitStr ing[n] & 0x7f);
1164 rtcpPacketInformation.rpsiPictureId <<= 7; // prepare next 1145 rtcpPacketInformation.rpsiPictureId <<= 7; // prepare next
1165 } 1146 }
1166 rtcpPacketInformation.rpsiPictureId += (rtcpPacket.RPSI.NativeBitString[ numberOfBytes-1] & 0x7f); 1147 rtcpPacketInformation.rpsiPictureId += (rtcpPacket.RPSI.NativeBitString[ numberOfBytes-1] & 0x7f);
1167 } 1148 }
1168 } 1149 }
1169 1150
1170 // no need for critsect we have _criticalSectionRTCPReceiver
1171 void RTCPReceiver::HandlePsfbApp(RTCPUtility::RTCPParserV2& rtcpParser, 1151 void RTCPReceiver::HandlePsfbApp(RTCPUtility::RTCPParserV2& rtcpParser,
1172 RTCPPacketInformation& rtcpPacketInformation) { 1152 RTCPPacketInformation& rtcpPacketInformation) {
1173 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate(); 1153 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate();
1174 if (pktType == RTCPPacketTypes::kPsfbRemb) { 1154 if (pktType == RTCPPacketTypes::kPsfbRemb) {
1175 pktType = rtcpParser.Iterate(); 1155 pktType = rtcpParser.Iterate();
1176 if (pktType == RTCPPacketTypes::kPsfbRembItem) { 1156 if (pktType == RTCPPacketTypes::kPsfbRembItem) {
1177 HandleREMBItem(rtcpParser, rtcpPacketInformation); 1157 HandleREMBItem(rtcpParser, rtcpPacketInformation);
1178 rtcpParser.Iterate(); 1158 rtcpParser.Iterate();
1179 } 1159 }
1180 } 1160 }
1181 } 1161 }
1182 1162
1183 // no need for critsect we have _criticalSectionRTCPReceiver
1184 void RTCPReceiver::HandleIJ(RTCPUtility::RTCPParserV2& rtcpParser, 1163 void RTCPReceiver::HandleIJ(RTCPUtility::RTCPParserV2& rtcpParser,
1185 RTCPPacketInformation& rtcpPacketInformation) { 1164 RTCPPacketInformation& rtcpPacketInformation) {
1186 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet(); 1165 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet();
1187 1166
1188 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate(); 1167 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate();
1189 while (pktType == RTCPPacketTypes::kExtendedIjItem) { 1168 while (pktType == RTCPPacketTypes::kExtendedIjItem) {
1190 HandleIJItem(rtcpPacket, rtcpPacketInformation); 1169 HandleIJItem(rtcpPacket, rtcpPacketInformation);
1191 pktType = rtcpParser.Iterate(); 1170 pktType = rtcpParser.Iterate();
1192 } 1171 }
1193 } 1172 }
1194 1173
1195 void RTCPReceiver::HandleIJItem(const RTCPUtility::RTCPPacket& rtcpPacket, 1174 void RTCPReceiver::HandleIJItem(const RTCPUtility::RTCPPacket& rtcpPacket,
1196 RTCPPacketInformation& rtcpPacketInformation) { 1175 RTCPPacketInformation& rtcpPacketInformation) {
1197 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpTransmissionTimeOffset; 1176 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpTransmissionTimeOffset;
1198 rtcpPacketInformation.interArrivalJitter = 1177 rtcpPacketInformation.interArrivalJitter =
1199 rtcpPacket.ExtendedJitterReportItem.Jitter; 1178 rtcpPacket.ExtendedJitterReportItem.Jitter;
1200 } 1179 }
1201 1180
1202 void RTCPReceiver::HandleREMBItem( 1181 void RTCPReceiver::HandleREMBItem(
1203 RTCPUtility::RTCPParserV2& rtcpParser, 1182 RTCPUtility::RTCPParserV2& rtcpParser,
1204 RTCPPacketInformation& rtcpPacketInformation) { 1183 RTCPPacketInformation& rtcpPacketInformation) {
1205 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet(); 1184 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet();
1206 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpRemb; 1185 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpRemb;
1207 rtcpPacketInformation.receiverEstimatedMaxBitrate = 1186 rtcpPacketInformation.receiverEstimatedMaxBitrate =
1208 rtcpPacket.REMBItem.BitRate; 1187 rtcpPacket.REMBItem.BitRate;
1209 } 1188 }
1210 1189
1211 // no need for critsect we have _criticalSectionRTCPReceiver
1212 void RTCPReceiver::HandleFIR(RTCPUtility::RTCPParserV2& rtcpParser, 1190 void RTCPReceiver::HandleFIR(RTCPUtility::RTCPParserV2& rtcpParser,
1213 RTCPPacketInformation& rtcpPacketInformation) { 1191 RTCPPacketInformation& rtcpPacketInformation) {
1214 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet(); 1192 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet();
1215 RTCPReceiveInformation* ptrReceiveInfo = 1193 RTCPReceiveInformation* ptrReceiveInfo =
1216 GetReceiveInformation(rtcpPacket.FIR.SenderSSRC); 1194 GetReceiveInformation(rtcpPacket.FIR.SenderSSRC);
1217 1195
1218 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate(); 1196 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate();
1219 while (pktType == RTCPPacketTypes::kPsfbFirItem) { 1197 while (pktType == RTCPPacketTypes::kPsfbFirItem) {
1220 HandleFIRItem(ptrReceiveInfo, rtcpPacket, rtcpPacketInformation); 1198 HandleFIRItem(ptrReceiveInfo, rtcpPacket, rtcpPacketInformation);
1221 pktType = rtcpParser.Iterate(); 1199 pktType = rtcpParser.Iterate();
1222 } 1200 }
1223 } 1201 }
1224 1202
1225 // no need for critsect we have _criticalSectionRTCPReceiver
1226 void RTCPReceiver::HandleFIRItem(RTCPReceiveInformation* receiveInfo, 1203 void RTCPReceiver::HandleFIRItem(RTCPReceiveInformation* receiveInfo,
1227 const RTCPUtility::RTCPPacket& rtcpPacket, 1204 const RTCPUtility::RTCPPacket& rtcpPacket,
1228 RTCPPacketInformation& rtcpPacketInformation) { 1205 RTCPPacketInformation& rtcpPacketInformation) {
1229 // Is it our sender that is requested to generate a new keyframe 1206 // Is it our sender that is requested to generate a new keyframe
1230 if (main_ssrc_ != rtcpPacket.FIRItem.SSRC) { 1207 if (main_ssrc_ != rtcpPacket.FIRItem.SSRC) {
1231 return; 1208 return;
1232 } 1209 }
1233 1210
1234 ++packet_type_counter_.fir_packets; 1211 ++packet_type_counter_.fir_packets;
1235 1212
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1341 1318
1342 // Holding no Critical section 1319 // Holding no Critical section
1343 void RTCPReceiver::TriggerCallbacksFromRTCPPacket( 1320 void RTCPReceiver::TriggerCallbacksFromRTCPPacket(
1344 RTCPPacketInformation& rtcpPacketInformation) { 1321 RTCPPacketInformation& rtcpPacketInformation) {
1345 // Process TMMBR and REMB first to avoid multiple callbacks 1322 // Process TMMBR and REMB first to avoid multiple callbacks
1346 // to OnNetworkChanged. 1323 // to OnNetworkChanged.
1347 if (rtcpPacketInformation.rtcpPacketTypeFlags & kRtcpTmmbr) { 1324 if (rtcpPacketInformation.rtcpPacketTypeFlags & kRtcpTmmbr) {
1348 // Might trigger a OnReceivedBandwidthEstimateUpdate. 1325 // Might trigger a OnReceivedBandwidthEstimateUpdate.
1349 UpdateTMMBR(); 1326 UpdateTMMBR();
1350 } 1327 }
1351 unsigned int local_ssrc; 1328 uint32_t local_ssrc;
1329 std::set<uint32_t> registered_ssrcs;
1352 { 1330 {
1353 // We don't want to hold this critsect when triggering the callbacks below. 1331 // We don't want to hold this critsect when triggering the callbacks below.
1354 CriticalSectionScoped lock(_criticalSectionRTCPReceiver); 1332 CriticalSectionScoped lock(_criticalSectionRTCPReceiver);
1355 local_ssrc = main_ssrc_; 1333 local_ssrc = main_ssrc_;
1334 registered_ssrcs = registered_ssrcs_;
1356 } 1335 }
1357 if (!receiver_only_ && 1336 if (!receiver_only_ &&
1358 (rtcpPacketInformation.rtcpPacketTypeFlags & kRtcpSrReq)) { 1337 (rtcpPacketInformation.rtcpPacketTypeFlags & kRtcpSrReq)) {
1359 _rtpRtcp.OnRequestSendReport(); 1338 _rtpRtcp.OnRequestSendReport();
1360 } 1339 }
1361 if (!receiver_only_ && 1340 if (!receiver_only_ &&
1362 (rtcpPacketInformation.rtcpPacketTypeFlags & kRtcpNack)) { 1341 (rtcpPacketInformation.rtcpPacketTypeFlags & kRtcpNack)) {
1363 if (rtcpPacketInformation.nackSequenceNumbers.size() > 0) { 1342 if (rtcpPacketInformation.nackSequenceNumbers.size() > 0) {
1364 LOG(LS_VERBOSE) << "Incoming NACK length: " 1343 LOG(LS_VERBOSE) << "Incoming NACK length: "
1365 << rtcpPacketInformation.nackSequenceNumbers.size(); 1344 << rtcpPacketInformation.nackSequenceNumbers.size();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1407 _cbRtcpBandwidthObserver->OnReceivedRtcpReceiverReport( 1386 _cbRtcpBandwidthObserver->OnReceivedRtcpReceiverReport(
1408 rtcpPacketInformation.report_blocks, 1387 rtcpPacketInformation.report_blocks,
1409 rtcpPacketInformation.rtt, 1388 rtcpPacketInformation.rtt,
1410 now); 1389 now);
1411 } 1390 }
1412 } 1391 }
1413 if (_cbTransportFeedbackObserver && 1392 if (_cbTransportFeedbackObserver &&
1414 (rtcpPacketInformation.rtcpPacketTypeFlags & kRtcpTransportFeedback)) { 1393 (rtcpPacketInformation.rtcpPacketTypeFlags & kRtcpTransportFeedback)) {
1415 uint32_t media_source_ssrc = 1394 uint32_t media_source_ssrc =
1416 rtcpPacketInformation.transport_feedback_->GetMediaSourceSsrc(); 1395 rtcpPacketInformation.transport_feedback_->GetMediaSourceSsrc();
1417 if (media_source_ssrc == main_ssrc_ || 1396 if (media_source_ssrc == local_ssrc ||
1418 registered_ssrcs_.find(media_source_ssrc) != 1397 registered_ssrcs.find(media_source_ssrc) != registered_ssrcs.end()) {
1419 registered_ssrcs_.end()) {
1420 _cbTransportFeedbackObserver->OnTransportFeedback( 1398 _cbTransportFeedbackObserver->OnTransportFeedback(
1421 *rtcpPacketInformation.transport_feedback_.get()); 1399 *rtcpPacketInformation.transport_feedback_.get());
1422 } 1400 }
1423 } 1401 }
1424 } 1402 }
1425 1403
1426 if (!receiver_only_) { 1404 if (!receiver_only_) {
1427 CriticalSectionScoped cs(_criticalSectionFeedbacks); 1405 CriticalSectionScoped cs(_criticalSectionFeedbacks);
1428 if (stats_callback_) { 1406 if (stats_callback_) {
1429 for (ReportBlockList::const_iterator it = 1407 for (ReportBlockList::const_iterator it =
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1490 return -1; 1468 return -1;
1491 } 1469 }
1492 num += receiveInfo->TmmbrSet.lengthOfSet(); 1470 num += receiveInfo->TmmbrSet.lengthOfSet();
1493 receiveInfoIt++; 1471 receiveInfoIt++;
1494 } 1472 }
1495 } 1473 }
1496 return num; 1474 return num;
1497 } 1475 }
1498 1476
1499 } // namespace webrtc 1477 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtcp_receiver.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698