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

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

Issue 2337283003: Merge RtcpReceive::Handle<Packet>Item functions into Handle<Packet> (Closed)
Patch Set: Created 4 years, 3 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 704 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 RTC_DCHECK(receiveInfo); 715 RTC_DCHECK(receiveInfo);
716 716
717 *tmmbr_owner = TMMBRHelp::IsOwner(receiveInfo->tmmbn, main_ssrc_); 717 *tmmbr_owner = TMMBRHelp::IsOwner(receiveInfo->tmmbn, main_ssrc_);
718 return receiveInfo->tmmbn; 718 return receiveInfo->tmmbn;
719 } 719 }
720 720
721 void RTCPReceiver::HandleSDES(RTCPUtility::RTCPParserV2& rtcpParser, 721 void RTCPReceiver::HandleSDES(RTCPUtility::RTCPParserV2& rtcpParser,
722 RTCPPacketInformation& rtcpPacketInformation) { 722 RTCPPacketInformation& rtcpPacketInformation) {
723 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate(); 723 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate();
724 while (pktType == RTCPPacketTypes::kSdesChunk) { 724 while (pktType == RTCPPacketTypes::kSdesChunk) {
725 HandleSDESChunk(rtcpParser); 725 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet();
726 RTCPCnameInformation* cnameInfo =
727 CreateCnameInformation(rtcpPacket.CName.SenderSSRC);
728 assert(cnameInfo);
philipel 2016/09/15 15:30:00 RTC_CHECK
danilchap 2016/09/15 16:31:47 Done. RTC_DCHECK
729
730 cnameInfo->name[RTCP_CNAME_SIZE - 1] = 0;
731 strncpy(cnameInfo->name, rtcpPacket.CName.CName, RTCP_CNAME_SIZE - 1);
732 {
733 rtc::CritScope lock(&_criticalSectionFeedbacks);
734 if (stats_callback_ != NULL) {
philipel 2016/09/15 15:30:00 nullptr
danilchap 2016/09/15 16:31:47 Done. recommended actually just if(stats_callback_
735 stats_callback_->CNameChanged(rtcpPacket.CName.CName,
736 rtcpPacket.CName.SenderSSRC);
737 }
738 }
739
726 pktType = rtcpParser.Iterate(); 740 pktType = rtcpParser.Iterate();
727 } 741 }
728 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpSdes; 742 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpSdes;
729 } 743 }
730 744
731 void RTCPReceiver::HandleSDESChunk(RTCPUtility::RTCPParserV2& rtcpParser) {
732 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet();
733 RTCPCnameInformation* cnameInfo =
734 CreateCnameInformation(rtcpPacket.CName.SenderSSRC);
735 assert(cnameInfo);
736
737 cnameInfo->name[RTCP_CNAME_SIZE - 1] = 0;
738 strncpy(cnameInfo->name, rtcpPacket.CName.CName, RTCP_CNAME_SIZE - 1);
739 {
740 rtc::CritScope lock(&_criticalSectionFeedbacks);
741 if (stats_callback_ != NULL) {
742 stats_callback_->CNameChanged(rtcpPacket.CName.CName,
743 rtcpPacket.CName.SenderSSRC);
744 }
745 }
746 }
747
748 void RTCPReceiver::HandleNACK(RTCPUtility::RTCPParserV2& rtcpParser, 745 void RTCPReceiver::HandleNACK(RTCPUtility::RTCPParserV2& rtcpParser,
749 RTCPPacketInformation& rtcpPacketInformation) { 746 RTCPPacketInformation& rtcpPacketInformation) {
750 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet(); 747 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet();
751 if (receiver_only_ || main_ssrc_ != rtcpPacket.NACK.MediaSSRC) { 748 if (receiver_only_ || main_ssrc_ != rtcpPacket.NACK.MediaSSRC) {
752 // Not to us. 749 // Not to us.
753 rtcpParser.Iterate(); 750 rtcpParser.Iterate();
754 return; 751 return;
755 } 752 }
756 rtcpPacketInformation.ResetNACKPacketIdArray(); 753 rtcpPacketInformation.ResetNACKPacketIdArray();
757 754
758 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate(); 755 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate();
759 while (pktType == RTCPPacketTypes::kRtpfbNackItem) { 756 while (pktType == RTCPPacketTypes::kRtpfbNackItem) {
760 HandleNACKItem(rtcpPacket, rtcpPacketInformation); 757 rtcpPacketInformation.AddNACKPacket(rtcpPacket.NACKItem.PacketID);
758 nack_stats_.ReportRequest(rtcpPacket.NACKItem.PacketID);
759
760 uint16_t bitMask = rtcpPacket.NACKItem.BitMask;
761 if (bitMask) {
762 for (int i = 1; i <= 16; ++i) {
763 if (bitMask & 0x01) {
764 rtcpPacketInformation.AddNACKPacket(rtcpPacket.NACKItem.PacketID + i);
765 nack_stats_.ReportRequest(rtcpPacket.NACKItem.PacketID + i);
766 }
767 bitMask = bitMask >> 1;
768 }
769 }
770 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpNack;
771
761 pktType = rtcpParser.Iterate(); 772 pktType = rtcpParser.Iterate();
762 } 773 }
763 774
764 if (rtcpPacketInformation.rtcpPacketTypeFlags & kRtcpNack) { 775 if (rtcpPacketInformation.rtcpPacketTypeFlags & kRtcpNack) {
765 ++packet_type_counter_.nack_packets; 776 ++packet_type_counter_.nack_packets;
766 packet_type_counter_.nack_requests = nack_stats_.requests(); 777 packet_type_counter_.nack_requests = nack_stats_.requests();
767 packet_type_counter_.unique_nack_requests = nack_stats_.unique_requests(); 778 packet_type_counter_.unique_nack_requests = nack_stats_.unique_requests();
768 } 779 }
769 } 780 }
770 781
771 void RTCPReceiver::HandleNACKItem(
772 const RTCPUtility::RTCPPacket& rtcpPacket,
773 RTCPPacketInformation& rtcpPacketInformation) {
774 rtcpPacketInformation.AddNACKPacket(rtcpPacket.NACKItem.PacketID);
775 nack_stats_.ReportRequest(rtcpPacket.NACKItem.PacketID);
776
777 uint16_t bitMask = rtcpPacket.NACKItem.BitMask;
778 if (bitMask) {
779 for (int i = 1; i <= 16; ++i) {
780 if (bitMask & 0x01) {
781 rtcpPacketInformation.AddNACKPacket(rtcpPacket.NACKItem.PacketID + i);
782 nack_stats_.ReportRequest(rtcpPacket.NACKItem.PacketID + i);
783 }
784 bitMask = bitMask >> 1;
785 }
786 }
787 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpNack;
788 }
789
790 void RTCPReceiver::HandleBYE(RTCPUtility::RTCPParserV2& rtcpParser) { 782 void RTCPReceiver::HandleBYE(RTCPUtility::RTCPParserV2& rtcpParser) {
791 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet(); 783 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet();
792 784
793 // clear our lists 785 // clear our lists
794 ReportBlockMap::iterator it = _receivedReportBlockMap.begin(); 786 ReportBlockMap::iterator it = _receivedReportBlockMap.begin();
795 for (; it != _receivedReportBlockMap.end(); ++it) { 787 for (; it != _receivedReportBlockMap.end(); ++it) {
796 ReportBlockInfoMap* info_map = &(it->second); 788 ReportBlockInfoMap* info_map = &(it->second);
797 ReportBlockInfoMap::iterator it_info = 789 ReportBlockInfoMap::iterator it_info =
798 info_map->find(rtcpPacket.BYE.SenderSSRC); 790 info_map->find(rtcpPacket.BYE.SenderSSRC);
799 if (it_info != info_map->end()) { 791 if (it_info != info_map->end()) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 } 843 }
852 844
853 void RTCPReceiver::HandleXrDlrrReportBlock( 845 void RTCPReceiver::HandleXrDlrrReportBlock(
854 RTCPUtility::RTCPParserV2& parser, 846 RTCPUtility::RTCPParserV2& parser,
855 RTCPPacketInformation& rtcpPacketInformation) { 847 RTCPPacketInformation& rtcpPacketInformation) {
856 const RTCPUtility::RTCPPacket& packet = parser.Packet(); 848 const RTCPUtility::RTCPPacket& packet = parser.Packet();
857 // Iterate through sub-block(s), if any. 849 // Iterate through sub-block(s), if any.
858 RTCPUtility::RTCPPacketTypes packet_type = parser.Iterate(); 850 RTCPUtility::RTCPPacketTypes packet_type = parser.Iterate();
859 851
860 while (packet_type == RTCPPacketTypes::kXrDlrrReportBlockItem) { 852 while (packet_type == RTCPPacketTypes::kXrDlrrReportBlockItem) {
861 HandleXrDlrrReportBlockItem(packet, rtcpPacketInformation); 853 if (registered_ssrcs_.find(packet.XRDLRRReportBlockItem.SSRC) ==
854 registered_ssrcs_.end()) {
855 // Not to us.
856 return;
857 }
858
859 rtcpPacketInformation.xr_dlrr_item = true;
860
861 // Caller should explicitly enable rtt calculation using extended reports.
862 if (!xr_rrtr_status_)
863 return;
864
865 // The send_time and delay_rr fields are in units of 1/2^16 sec.
866 uint32_t send_time = packet.XRDLRRReportBlockItem.LastRR;
867 // RFC3611, section 4.5, LRR field discription states:
868 // If no such block has been received, the field is set to zero.
869 if (send_time == 0)
870 return;
871
872 uint32_t delay_rr = packet.XRDLRRReportBlockItem.DelayLastRR;
873 uint32_t now = CompactNtp(NtpTime(*_clock));
874
875 uint32_t rtt_ntp = now - delay_rr - send_time;
876 xr_rr_rtt_ms_ = CompactNtpRttToMs(rtt_ntp);
877
878 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpXrDlrrReportBlock;
879
862 packet_type = parser.Iterate(); 880 packet_type = parser.Iterate();
863 } 881 }
864 } 882 }
865 883
866 void RTCPReceiver::HandleXrDlrrReportBlockItem(
867 const RTCPUtility::RTCPPacket& packet,
868 RTCPPacketInformation& rtcpPacketInformation)
869 EXCLUSIVE_LOCKS_REQUIRED(_criticalSectionRTCPReceiver) {
870 if (registered_ssrcs_.find(packet.XRDLRRReportBlockItem.SSRC) ==
871 registered_ssrcs_.end()) {
872 // Not to us.
873 return;
874 }
875
876 rtcpPacketInformation.xr_dlrr_item = true;
877
878 // Caller should explicitly enable rtt calculation using extended reports.
879 if (!xr_rrtr_status_)
880 return;
881
882 // The send_time and delay_rr fields are in units of 1/2^16 sec.
883 uint32_t send_time = packet.XRDLRRReportBlockItem.LastRR;
884 // RFC3611, section 4.5, LRR field discription states:
885 // If no such block has been received, the field is set to zero.
886 if (send_time == 0)
887 return;
888
889 uint32_t delay_rr = packet.XRDLRRReportBlockItem.DelayLastRR;
890 uint32_t now = CompactNtp(NtpTime(*_clock));
891
892 uint32_t rtt_ntp = now - delay_rr - send_time;
893 xr_rr_rtt_ms_ = CompactNtpRttToMs(rtt_ntp);
894
895 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpXrDlrrReportBlock;
896 }
897
898 void RTCPReceiver::HandlePLI(RTCPUtility::RTCPParserV2& rtcpParser, 884 void RTCPReceiver::HandlePLI(RTCPUtility::RTCPParserV2& rtcpParser,
899 RTCPPacketInformation& rtcpPacketInformation) { 885 RTCPPacketInformation& rtcpPacketInformation) {
900 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet(); 886 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet();
901 if (main_ssrc_ == rtcpPacket.PLI.MediaSSRC) { 887 if (main_ssrc_ == rtcpPacket.PLI.MediaSSRC) {
902 TRACE_EVENT_INSTANT0(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "PLI"); 888 TRACE_EVENT_INSTANT0(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "PLI");
903 889
904 ++packet_type_counter_.pli_packets; 890 ++packet_type_counter_.pli_packets;
905 // Received a signal that we need to send a new key frame. 891 // Received a signal that we need to send a new key frame.
906 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpPli; 892 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpPli;
907 } 893 }
(...skipping 23 matching lines...) Expand all
931 917
932 // sanity, we can't have more than what's in one packet 918 // sanity, we can't have more than what's in one packet
933 if (maxNumOfTMMBRBlocks > 200) { 919 if (maxNumOfTMMBRBlocks > 200) {
934 assert(false); 920 assert(false);
935 rtcpParser.Iterate(); 921 rtcpParser.Iterate();
936 return; 922 return;
937 } 923 }
938 924
939 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate(); 925 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate();
940 while (pktType == RTCPPacketTypes::kRtpfbTmmbrItem) { 926 while (pktType == RTCPPacketTypes::kRtpfbTmmbrItem) {
941 HandleTMMBRItem(*ptrReceiveInfo, rtcpPacket, rtcpPacketInformation, 927 if (main_ssrc_ == rtcpPacket.TMMBRItem.SSRC &&
942 senderSSRC); 928 rtcpPacket.TMMBRItem.MaxTotalMediaBitRate > 0) {
929 ptrReceiveInfo->InsertTmmbrItem(
930 senderSSRC,
931 rtcp::TmmbItem(rtcpPacket.TMMBRItem.SSRC,
932 rtcpPacket.TMMBRItem.MaxTotalMediaBitRate * 1000,
933 rtcpPacket.TMMBRItem.MeasuredOverhead),
934 _clock->TimeInMilliseconds());
935 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpTmmbr;
936 }
937
943 pktType = rtcpParser.Iterate(); 938 pktType = rtcpParser.Iterate();
944 } 939 }
945 } 940 }
946 941
947 void RTCPReceiver::HandleTMMBRItem(RTCPReceiveInformation& receiveInfo,
948 const RTCPUtility::RTCPPacket& rtcpPacket,
949 RTCPPacketInformation& rtcpPacketInformation,
950 uint32_t senderSSRC) {
951 if (main_ssrc_ == rtcpPacket.TMMBRItem.SSRC &&
952 rtcpPacket.TMMBRItem.MaxTotalMediaBitRate > 0) {
953 receiveInfo.InsertTmmbrItem(
954 senderSSRC,
955 rtcp::TmmbItem(rtcpPacket.TMMBRItem.SSRC,
956 rtcpPacket.TMMBRItem.MaxTotalMediaBitRate * 1000,
957 rtcpPacket.TMMBRItem.MeasuredOverhead),
958 _clock->TimeInMilliseconds());
959 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpTmmbr;
960 }
961 }
962
963 void RTCPReceiver::HandleTMMBN(RTCPUtility::RTCPParserV2& rtcpParser, 942 void RTCPReceiver::HandleTMMBN(RTCPUtility::RTCPParserV2& rtcpParser,
964 RTCPPacketInformation& rtcpPacketInformation) { 943 RTCPPacketInformation& rtcpPacketInformation) {
965 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet(); 944 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet();
966 RTCPReceiveInformation* ptrReceiveInfo = 945 RTCPReceiveInformation* ptrReceiveInfo =
967 GetReceiveInformation(rtcpPacket.TMMBN.SenderSSRC); 946 GetReceiveInformation(rtcpPacket.TMMBN.SenderSSRC);
968 if (ptrReceiveInfo == NULL) { 947 if (ptrReceiveInfo == NULL) {
969 // This remote SSRC must be saved before. 948 // This remote SSRC must be saved before.
970 rtcpParser.Iterate(); 949 rtcpParser.Iterate();
971 return; 950 return;
972 } 951 }
973 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpTmmbn; 952 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpTmmbn;
974 // Use packet length to calc max number of TMMBN blocks 953 // Use packet length to calc max number of TMMBN blocks
975 // each TMMBN block is 8 bytes 954 // each TMMBN block is 8 bytes
976 ptrdiff_t maxNumOfTMMBNBlocks = rtcpParser.LengthLeft() / 8; 955 ptrdiff_t maxNumOfTMMBNBlocks = rtcpParser.LengthLeft() / 8;
977 956
978 // sanity, we cant have more than what's in one packet 957 // sanity, we cant have more than what's in one packet
979 if (maxNumOfTMMBNBlocks > 200) { 958 if (maxNumOfTMMBNBlocks > 200) {
980 assert(false); 959 assert(false);
981 rtcpParser.Iterate(); 960 rtcpParser.Iterate();
982 return; 961 return;
983 } 962 }
984 963
985 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate(); 964 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate();
986 while (pktType == RTCPPacketTypes::kRtpfbTmmbnItem) { 965 while (pktType == RTCPPacketTypes::kRtpfbTmmbnItem) {
987 HandleTMMBNItem(*ptrReceiveInfo, rtcpPacket); 966 ptrReceiveInfo->tmmbn.emplace_back(
967 rtcpPacket.TMMBNItem.SSRC,
968 rtcpPacket.TMMBNItem.MaxTotalMediaBitRate * 1000,
969 rtcpPacket.TMMBNItem.MeasuredOverhead);
988 pktType = rtcpParser.Iterate(); 970 pktType = rtcpParser.Iterate();
989 } 971 }
990 } 972 }
991 973
992 void RTCPReceiver::HandleSR_REQ(RTCPUtility::RTCPParserV2& rtcpParser, 974 void RTCPReceiver::HandleSR_REQ(RTCPUtility::RTCPParserV2& rtcpParser,
993 RTCPPacketInformation& rtcpPacketInformation) { 975 RTCPPacketInformation& rtcpPacketInformation) {
994 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpSrReq; 976 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpSrReq;
995 rtcpParser.Iterate(); 977 rtcpParser.Iterate();
996 } 978 }
997 979
998 void RTCPReceiver::HandleTMMBNItem(RTCPReceiveInformation& receiveInfo,
999 const RTCPUtility::RTCPPacket& rtcpPacket) {
1000 receiveInfo.tmmbn.emplace_back(
1001 rtcpPacket.TMMBNItem.SSRC,
1002 rtcpPacket.TMMBNItem.MaxTotalMediaBitRate * 1000,
1003 rtcpPacket.TMMBNItem.MeasuredOverhead);
1004 }
1005
1006 void RTCPReceiver::HandleSLI(RTCPUtility::RTCPParserV2& rtcpParser, 980 void RTCPReceiver::HandleSLI(RTCPUtility::RTCPParserV2& rtcpParser,
1007 RTCPPacketInformation& rtcpPacketInformation) { 981 RTCPPacketInformation& rtcpPacketInformation) {
1008 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet(); 982 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet();
1009 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate(); 983 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate();
1010 while (pktType == RTCPPacketTypes::kPsfbSliItem) { 984 while (pktType == RTCPPacketTypes::kPsfbSliItem) {
1011 HandleSLIItem(rtcpPacket, rtcpPacketInformation); 985 // in theory there could be multiple slices lost
986 rtcpPacketInformation.rtcpPacketTypeFlags |=
987 kRtcpSli; // received signal that we need to refresh a slice
988 rtcpPacketInformation.sliPictureId = rtcpPacket.SLIItem.PictureId;
989
1012 pktType = rtcpParser.Iterate(); 990 pktType = rtcpParser.Iterate();
1013 } 991 }
1014 } 992 }
1015 993
1016 void RTCPReceiver::HandleSLIItem(const RTCPUtility::RTCPPacket& rtcpPacket,
1017 RTCPPacketInformation& rtcpPacketInformation) {
1018 // in theory there could be multiple slices lost
1019 rtcpPacketInformation.rtcpPacketTypeFlags |=
1020 kRtcpSli; // received signal that we need to refresh a slice
1021 rtcpPacketInformation.sliPictureId = rtcpPacket.SLIItem.PictureId;
1022 }
1023
1024 void RTCPReceiver::HandleRPSI( 994 void RTCPReceiver::HandleRPSI(
1025 RTCPUtility::RTCPParserV2& rtcpParser, 995 RTCPUtility::RTCPParserV2& rtcpParser,
1026 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation) { 996 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation) {
1027 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet(); 997 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet();
1028 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate(); 998 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate();
1029 if (pktType == RTCPPacketTypes::kPsfbRpsiItem) { 999 if (pktType == RTCPPacketTypes::kPsfbRpsiItem) {
1030 if (rtcpPacket.RPSI.NumberOfValidBits % 8 != 0) { 1000 if (rtcpPacket.RPSI.NumberOfValidBits % 8 != 0) {
1031 // to us unknown 1001 // to us unknown
1032 // continue 1002 // continue
1033 rtcpParser.Iterate(); 1003 rtcpParser.Iterate();
(...skipping 14 matching lines...) Expand all
1048 (rtcpPacket.RPSI.NativeBitString[numberOfBytes - 1] & 0x7f); 1018 (rtcpPacket.RPSI.NativeBitString[numberOfBytes - 1] & 0x7f);
1049 } 1019 }
1050 } 1020 }
1051 1021
1052 void RTCPReceiver::HandlePsfbApp(RTCPUtility::RTCPParserV2& rtcpParser, 1022 void RTCPReceiver::HandlePsfbApp(RTCPUtility::RTCPParserV2& rtcpParser,
1053 RTCPPacketInformation& rtcpPacketInformation) { 1023 RTCPPacketInformation& rtcpPacketInformation) {
1054 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate(); 1024 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate();
1055 if (pktType == RTCPPacketTypes::kPsfbRemb) { 1025 if (pktType == RTCPPacketTypes::kPsfbRemb) {
1056 pktType = rtcpParser.Iterate(); 1026 pktType = rtcpParser.Iterate();
1057 if (pktType == RTCPPacketTypes::kPsfbRembItem) { 1027 if (pktType == RTCPPacketTypes::kPsfbRembItem) {
1058 HandleREMBItem(rtcpParser, rtcpPacketInformation); 1028 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet();
1029 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpRemb;
1030 rtcpPacketInformation.receiverEstimatedMaxBitrate =
1031 rtcpPacket.REMBItem.BitRate;
1032
1059 rtcpParser.Iterate(); 1033 rtcpParser.Iterate();
1060 } 1034 }
1061 } 1035 }
1062 } 1036 }
1063 1037
1064 void RTCPReceiver::HandleREMBItem(
1065 RTCPUtility::RTCPParserV2& rtcpParser,
1066 RTCPPacketInformation& rtcpPacketInformation) {
1067 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet();
1068 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpRemb;
1069 rtcpPacketInformation.receiverEstimatedMaxBitrate =
1070 rtcpPacket.REMBItem.BitRate;
1071 }
1072
1073 void RTCPReceiver::HandleFIR(RTCPUtility::RTCPParserV2& rtcpParser, 1038 void RTCPReceiver::HandleFIR(RTCPUtility::RTCPParserV2& rtcpParser,
1074 RTCPPacketInformation& rtcpPacketInformation) { 1039 RTCPPacketInformation& rtcpPacketInformation) {
1075 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet(); 1040 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet();
1076 RTCPReceiveInformation* ptrReceiveInfo = 1041 RTCPReceiveInformation* ptrReceiveInfo =
1077 GetReceiveInformation(rtcpPacket.FIR.SenderSSRC); 1042 GetReceiveInformation(rtcpPacket.FIR.SenderSSRC);
1078 1043
1079 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate(); 1044 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate();
1080 while (pktType == RTCPPacketTypes::kPsfbFirItem) { 1045 while (pktType == RTCPPacketTypes::kPsfbFirItem) {
1081 HandleFIRItem(ptrReceiveInfo, rtcpPacket, rtcpPacketInformation); 1046 // Is it our sender that is requested to generate a new keyframe
1047 if (main_ssrc_ != rtcpPacket.FIRItem.SSRC) {
1048 return;
1049 }
1050
1051 ++packet_type_counter_.fir_packets;
1052
1053 // rtcpPacket.FIR.MediaSSRC SHOULD be 0 but we ignore to check it
1054 // we don't know who this originate from
1055 if (ptrReceiveInfo) {
1056 // check if we have reported this FIRSequenceNumber before
1057 if (rtcpPacket.FIRItem.CommandSequenceNumber !=
1058 ptrReceiveInfo->last_fir_sequence_number) {
1059 int64_t now = _clock->TimeInMilliseconds();
1060 // sanity; don't go crazy with the callbacks
1061 if ((now - ptrReceiveInfo->last_fir_request_ms) >
1062 RTCP_MIN_FRAME_LENGTH_MS) {
1063 ptrReceiveInfo->last_fir_request_ms = now;
1064 ptrReceiveInfo->last_fir_sequence_number =
1065 rtcpPacket.FIRItem.CommandSequenceNumber;
1066 // received signal that we need to send a new key frame
1067 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpFir;
1068 }
1069 }
1070 } else {
1071 // received signal that we need to send a new key frame
1072 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpFir;
1073 }
1074
1082 pktType = rtcpParser.Iterate(); 1075 pktType = rtcpParser.Iterate();
1083 } 1076 }
1084 } 1077 }
1085 1078
1086 void RTCPReceiver::HandleFIRItem(RTCPReceiveInformation* receiveInfo,
1087 const RTCPUtility::RTCPPacket& rtcpPacket,
1088 RTCPPacketInformation& rtcpPacketInformation) {
1089 // Is it our sender that is requested to generate a new keyframe
1090 if (main_ssrc_ != rtcpPacket.FIRItem.SSRC) {
1091 return;
1092 }
1093
1094 ++packet_type_counter_.fir_packets;
1095
1096 // rtcpPacket.FIR.MediaSSRC SHOULD be 0 but we ignore to check it
1097 // we don't know who this originate from
1098 if (receiveInfo) {
1099 // check if we have reported this FIRSequenceNumber before
1100 if (rtcpPacket.FIRItem.CommandSequenceNumber !=
1101 receiveInfo->last_fir_sequence_number) {
1102 int64_t now = _clock->TimeInMilliseconds();
1103 // sanity; don't go crazy with the callbacks
1104 if ((now - receiveInfo->last_fir_request_ms) > RTCP_MIN_FRAME_LENGTH_MS) {
1105 receiveInfo->last_fir_request_ms = now;
1106 receiveInfo->last_fir_sequence_number =
1107 rtcpPacket.FIRItem.CommandSequenceNumber;
1108 // received signal that we need to send a new key frame
1109 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpFir;
1110 }
1111 }
1112 } else {
1113 // received signal that we need to send a new key frame
1114 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpFir;
1115 }
1116 }
1117
1118 void RTCPReceiver::HandleTransportFeedback( 1079 void RTCPReceiver::HandleTransportFeedback(
1119 RTCPUtility::RTCPParserV2* rtcp_parser, 1080 RTCPUtility::RTCPParserV2* rtcp_parser,
1120 RTCPHelp::RTCPPacketInformation* rtcp_packet_information) { 1081 RTCPHelp::RTCPPacketInformation* rtcp_packet_information) {
1121 rtcp::RtcpPacket* packet = rtcp_parser->ReleaseRtcpPacket(); 1082 rtcp::RtcpPacket* packet = rtcp_parser->ReleaseRtcpPacket();
1122 RTC_DCHECK(packet != nullptr); 1083 RTC_DCHECK(packet != nullptr);
1123 rtcp_packet_information->rtcpPacketTypeFlags |= kRtcpTransportFeedback; 1084 rtcp_packet_information->rtcpPacketTypeFlags |= kRtcpTransportFeedback;
1124 rtcp_packet_information->transport_feedback_.reset( 1085 rtcp_packet_information->transport_feedback_.reset(
1125 static_cast<rtcp::TransportFeedback*>(packet)); 1086 static_cast<rtcp::TransportFeedback*>(packet));
1126 1087
1127 rtcp_parser->Iterate(); 1088 rtcp_parser->Iterate();
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
1283 1244
1284 for (const auto& kv : _receivedInfoMap) { 1245 for (const auto& kv : _receivedInfoMap) {
1285 RTCPReceiveInformation* receive_info = kv.second; 1246 RTCPReceiveInformation* receive_info = kv.second;
1286 RTC_DCHECK(receive_info); 1247 RTC_DCHECK(receive_info);
1287 receive_info->GetTmmbrSet(now_ms, &candidates); 1248 receive_info->GetTmmbrSet(now_ms, &candidates);
1288 } 1249 }
1289 return candidates; 1250 return candidates;
1290 } 1251 }
1291 1252
1292 } // namespace webrtc 1253 } // 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