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

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: Rebase nits 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 727 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 RTC_DCHECK(receiveInfo); 738 RTC_DCHECK(receiveInfo);
739 739
740 *tmmbr_owner = TMMBRHelp::IsOwner(receiveInfo->tmmbn, main_ssrc_); 740 *tmmbr_owner = TMMBRHelp::IsOwner(receiveInfo->tmmbn, main_ssrc_);
741 return receiveInfo->tmmbn; 741 return receiveInfo->tmmbn;
742 } 742 }
743 743
744 void RTCPReceiver::HandleSDES(RTCPUtility::RTCPParserV2& rtcpParser, 744 void RTCPReceiver::HandleSDES(RTCPUtility::RTCPParserV2& rtcpParser,
745 RTCPPacketInformation& rtcpPacketInformation) { 745 RTCPPacketInformation& rtcpPacketInformation) {
746 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate(); 746 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate();
747 while (pktType == RTCPPacketTypes::kSdesChunk) { 747 while (pktType == RTCPPacketTypes::kSdesChunk) {
748 HandleSDESChunk(rtcpParser); 748 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet();
749 RTCPCnameInformation* cnameInfo =
750 CreateCnameInformation(rtcpPacket.CName.SenderSSRC);
751 RTC_DCHECK(cnameInfo);
752
753 cnameInfo->name[RTCP_CNAME_SIZE - 1] = 0;
754 strncpy(cnameInfo->name, rtcpPacket.CName.CName, RTCP_CNAME_SIZE - 1);
755 {
756 rtc::CritScope lock(&_criticalSectionFeedbacks);
757 if (stats_callback_) {
758 stats_callback_->CNameChanged(rtcpPacket.CName.CName,
759 rtcpPacket.CName.SenderSSRC);
760 }
761 }
762
749 pktType = rtcpParser.Iterate(); 763 pktType = rtcpParser.Iterate();
750 } 764 }
751 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpSdes; 765 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpSdes;
752 } 766 }
753 767
754 void RTCPReceiver::HandleSDESChunk(RTCPUtility::RTCPParserV2& rtcpParser) {
755 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet();
756 RTCPCnameInformation* cnameInfo =
757 CreateCnameInformation(rtcpPacket.CName.SenderSSRC);
758 assert(cnameInfo);
759
760 cnameInfo->name[RTCP_CNAME_SIZE - 1] = 0;
761 strncpy(cnameInfo->name, rtcpPacket.CName.CName, RTCP_CNAME_SIZE - 1);
762 {
763 rtc::CritScope lock(&_criticalSectionFeedbacks);
764 if (stats_callback_ != NULL) {
765 stats_callback_->CNameChanged(rtcpPacket.CName.CName,
766 rtcpPacket.CName.SenderSSRC);
767 }
768 }
769 }
770
771 void RTCPReceiver::HandleNACK(RTCPUtility::RTCPParserV2& rtcpParser, 768 void RTCPReceiver::HandleNACK(RTCPUtility::RTCPParserV2& rtcpParser,
772 RTCPPacketInformation& rtcpPacketInformation) { 769 RTCPPacketInformation& rtcpPacketInformation) {
773 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet(); 770 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet();
774 if (receiver_only_ || main_ssrc_ != rtcpPacket.NACK.MediaSSRC) { 771 if (receiver_only_ || main_ssrc_ != rtcpPacket.NACK.MediaSSRC) {
775 // Not to us. 772 // Not to us.
776 rtcpParser.Iterate(); 773 rtcpParser.Iterate();
777 return; 774 return;
778 } 775 }
779 rtcpPacketInformation.ResetNACKPacketIdArray(); 776 rtcpPacketInformation.ResetNACKPacketIdArray();
780 777
781 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate(); 778 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate();
782 while (pktType == RTCPPacketTypes::kRtpfbNackItem) { 779 while (pktType == RTCPPacketTypes::kRtpfbNackItem) {
783 HandleNACKItem(rtcpPacket, rtcpPacketInformation); 780 rtcpPacketInformation.AddNACKPacket(rtcpPacket.NACKItem.PacketID);
781 nack_stats_.ReportRequest(rtcpPacket.NACKItem.PacketID);
782
783 uint16_t bitMask = rtcpPacket.NACKItem.BitMask;
784 if (bitMask) {
785 for (int i = 1; i <= 16; ++i) {
786 if (bitMask & 0x01) {
787 rtcpPacketInformation.AddNACKPacket(rtcpPacket.NACKItem.PacketID + i);
788 nack_stats_.ReportRequest(rtcpPacket.NACKItem.PacketID + i);
789 }
790 bitMask = bitMask >> 1;
791 }
792 }
793 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpNack;
794
784 pktType = rtcpParser.Iterate(); 795 pktType = rtcpParser.Iterate();
785 } 796 }
786 797
787 if (rtcpPacketInformation.rtcpPacketTypeFlags & kRtcpNack) { 798 if (rtcpPacketInformation.rtcpPacketTypeFlags & kRtcpNack) {
788 ++packet_type_counter_.nack_packets; 799 ++packet_type_counter_.nack_packets;
789 packet_type_counter_.nack_requests = nack_stats_.requests(); 800 packet_type_counter_.nack_requests = nack_stats_.requests();
790 packet_type_counter_.unique_nack_requests = nack_stats_.unique_requests(); 801 packet_type_counter_.unique_nack_requests = nack_stats_.unique_requests();
791 } 802 }
792 } 803 }
793 804
794 void RTCPReceiver::HandleNACKItem(
795 const RTCPUtility::RTCPPacket& rtcpPacket,
796 RTCPPacketInformation& rtcpPacketInformation) {
797 rtcpPacketInformation.AddNACKPacket(rtcpPacket.NACKItem.PacketID);
798 nack_stats_.ReportRequest(rtcpPacket.NACKItem.PacketID);
799
800 uint16_t bitMask = rtcpPacket.NACKItem.BitMask;
801 if (bitMask) {
802 for (int i = 1; i <= 16; ++i) {
803 if (bitMask & 0x01) {
804 rtcpPacketInformation.AddNACKPacket(rtcpPacket.NACKItem.PacketID + i);
805 nack_stats_.ReportRequest(rtcpPacket.NACKItem.PacketID + i);
806 }
807 bitMask = bitMask >> 1;
808 }
809 }
810 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpNack;
811 }
812
813 void RTCPReceiver::HandleBYE(RTCPUtility::RTCPParserV2& rtcpParser) { 805 void RTCPReceiver::HandleBYE(RTCPUtility::RTCPParserV2& rtcpParser) {
814 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet(); 806 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet();
815 807
816 // clear our lists 808 // clear our lists
817 ReportBlockMap::iterator it = _receivedReportBlockMap.begin(); 809 ReportBlockMap::iterator it = _receivedReportBlockMap.begin();
818 for (; it != _receivedReportBlockMap.end(); ++it) { 810 for (; it != _receivedReportBlockMap.end(); ++it) {
819 ReportBlockInfoMap* info_map = &(it->second); 811 ReportBlockInfoMap* info_map = &(it->second);
820 ReportBlockInfoMap::iterator it_info = 812 ReportBlockInfoMap::iterator it_info =
821 info_map->find(rtcpPacket.BYE.SenderSSRC); 813 info_map->find(rtcpPacket.BYE.SenderSSRC);
822 if (it_info != info_map->end()) { 814 if (it_info != info_map->end()) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 } 866 }
875 867
876 void RTCPReceiver::HandleXrDlrrReportBlock( 868 void RTCPReceiver::HandleXrDlrrReportBlock(
877 RTCPUtility::RTCPParserV2& parser, 869 RTCPUtility::RTCPParserV2& parser,
878 RTCPPacketInformation& rtcpPacketInformation) { 870 RTCPPacketInformation& rtcpPacketInformation) {
879 const RTCPUtility::RTCPPacket& packet = parser.Packet(); 871 const RTCPUtility::RTCPPacket& packet = parser.Packet();
880 // Iterate through sub-block(s), if any. 872 // Iterate through sub-block(s), if any.
881 RTCPUtility::RTCPPacketTypes packet_type = parser.Iterate(); 873 RTCPUtility::RTCPPacketTypes packet_type = parser.Iterate();
882 874
883 while (packet_type == RTCPPacketTypes::kXrDlrrReportBlockItem) { 875 while (packet_type == RTCPPacketTypes::kXrDlrrReportBlockItem) {
884 HandleXrDlrrReportBlockItem(packet, rtcpPacketInformation); 876 if (registered_ssrcs_.find(packet.XRDLRRReportBlockItem.SSRC) ==
877 registered_ssrcs_.end()) {
878 // Not to us.
879 return;
880 }
881
882 rtcpPacketInformation.xr_dlrr_item = true;
883
884 // Caller should explicitly enable rtt calculation using extended reports.
885 if (!xr_rrtr_status_)
886 return;
887
888 // The send_time and delay_rr fields are in units of 1/2^16 sec.
889 uint32_t send_time = packet.XRDLRRReportBlockItem.LastRR;
890 // RFC3611, section 4.5, LRR field discription states:
891 // If no such block has been received, the field is set to zero.
892 if (send_time == 0)
893 return;
894
895 uint32_t delay_rr = packet.XRDLRRReportBlockItem.DelayLastRR;
896 uint32_t now = CompactNtp(NtpTime(*_clock));
897
898 uint32_t rtt_ntp = now - delay_rr - send_time;
899 xr_rr_rtt_ms_ = CompactNtpRttToMs(rtt_ntp);
900
901 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpXrDlrrReportBlock;
902
885 packet_type = parser.Iterate(); 903 packet_type = parser.Iterate();
886 } 904 }
887 } 905 }
888 906
889 void RTCPReceiver::HandleXrDlrrReportBlockItem(
890 const RTCPUtility::RTCPPacket& packet,
891 RTCPPacketInformation& rtcpPacketInformation)
892 EXCLUSIVE_LOCKS_REQUIRED(_criticalSectionRTCPReceiver) {
893 if (registered_ssrcs_.find(packet.XRDLRRReportBlockItem.SSRC) ==
894 registered_ssrcs_.end()) {
895 // Not to us.
896 return;
897 }
898
899 rtcpPacketInformation.xr_dlrr_item = true;
900
901 // Caller should explicitly enable rtt calculation using extended reports.
902 if (!xr_rrtr_status_)
903 return;
904
905 // The send_time and delay_rr fields are in units of 1/2^16 sec.
906 uint32_t send_time = packet.XRDLRRReportBlockItem.LastRR;
907 // RFC3611, section 4.5, LRR field discription states:
908 // If no such block has been received, the field is set to zero.
909 if (send_time == 0)
910 return;
911
912 uint32_t delay_rr = packet.XRDLRRReportBlockItem.DelayLastRR;
913 uint32_t now = CompactNtp(NtpTime(*_clock));
914
915 uint32_t rtt_ntp = now - delay_rr - send_time;
916 xr_rr_rtt_ms_ = CompactNtpRttToMs(rtt_ntp);
917
918 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpXrDlrrReportBlock;
919 }
920
921 void RTCPReceiver::HandlePLI(RTCPUtility::RTCPParserV2& rtcpParser, 907 void RTCPReceiver::HandlePLI(RTCPUtility::RTCPParserV2& rtcpParser,
922 RTCPPacketInformation& rtcpPacketInformation) { 908 RTCPPacketInformation& rtcpPacketInformation) {
923 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet(); 909 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet();
924 if (main_ssrc_ == rtcpPacket.PLI.MediaSSRC) { 910 if (main_ssrc_ == rtcpPacket.PLI.MediaSSRC) {
925 TRACE_EVENT_INSTANT0(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "PLI"); 911 TRACE_EVENT_INSTANT0(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "PLI");
926 912
927 ++packet_type_counter_.pli_packets; 913 ++packet_type_counter_.pli_packets;
928 // Received a signal that we need to send a new key frame. 914 // Received a signal that we need to send a new key frame.
929 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpPli; 915 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpPli;
930 } 916 }
(...skipping 23 matching lines...) Expand all
954 940
955 // sanity, we can't have more than what's in one packet 941 // sanity, we can't have more than what's in one packet
956 if (maxNumOfTMMBRBlocks > 200) { 942 if (maxNumOfTMMBRBlocks > 200) {
957 assert(false); 943 assert(false);
958 rtcpParser.Iterate(); 944 rtcpParser.Iterate();
959 return; 945 return;
960 } 946 }
961 947
962 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate(); 948 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate();
963 while (pktType == RTCPPacketTypes::kRtpfbTmmbrItem) { 949 while (pktType == RTCPPacketTypes::kRtpfbTmmbrItem) {
964 HandleTMMBRItem(*ptrReceiveInfo, rtcpPacket, rtcpPacketInformation, 950 if (main_ssrc_ == rtcpPacket.TMMBRItem.SSRC &&
965 senderSSRC); 951 rtcpPacket.TMMBRItem.MaxTotalMediaBitRate > 0) {
952 ptrReceiveInfo->InsertTmmbrItem(
953 senderSSRC,
954 rtcp::TmmbItem(rtcpPacket.TMMBRItem.SSRC,
955 rtcpPacket.TMMBRItem.MaxTotalMediaBitRate * 1000,
956 rtcpPacket.TMMBRItem.MeasuredOverhead),
957 _clock->TimeInMilliseconds());
958 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpTmmbr;
959 }
960
966 pktType = rtcpParser.Iterate(); 961 pktType = rtcpParser.Iterate();
967 } 962 }
968 } 963 }
969 964
970 void RTCPReceiver::HandleTMMBRItem(RTCPReceiveInformation& receiveInfo,
971 const RTCPUtility::RTCPPacket& rtcpPacket,
972 RTCPPacketInformation& rtcpPacketInformation,
973 uint32_t senderSSRC) {
974 if (main_ssrc_ == rtcpPacket.TMMBRItem.SSRC &&
975 rtcpPacket.TMMBRItem.MaxTotalMediaBitRate > 0) {
976 receiveInfo.InsertTmmbrItem(
977 senderSSRC,
978 rtcp::TmmbItem(rtcpPacket.TMMBRItem.SSRC,
979 rtcpPacket.TMMBRItem.MaxTotalMediaBitRate * 1000,
980 rtcpPacket.TMMBRItem.MeasuredOverhead),
981 _clock->TimeInMilliseconds());
982 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpTmmbr;
983 }
984 }
985
986 void RTCPReceiver::HandleTMMBN(RTCPUtility::RTCPParserV2& rtcpParser, 965 void RTCPReceiver::HandleTMMBN(RTCPUtility::RTCPParserV2& rtcpParser,
987 RTCPPacketInformation& rtcpPacketInformation) { 966 RTCPPacketInformation& rtcpPacketInformation) {
988 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet(); 967 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet();
989 RTCPReceiveInformation* ptrReceiveInfo = 968 RTCPReceiveInformation* ptrReceiveInfo =
990 GetReceiveInformation(rtcpPacket.TMMBN.SenderSSRC); 969 GetReceiveInformation(rtcpPacket.TMMBN.SenderSSRC);
991 if (ptrReceiveInfo == NULL) { 970 if (ptrReceiveInfo == NULL) {
992 // This remote SSRC must be saved before. 971 // This remote SSRC must be saved before.
993 rtcpParser.Iterate(); 972 rtcpParser.Iterate();
994 return; 973 return;
995 } 974 }
996 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpTmmbn; 975 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpTmmbn;
997 // Use packet length to calc max number of TMMBN blocks 976 // Use packet length to calc max number of TMMBN blocks
998 // each TMMBN block is 8 bytes 977 // each TMMBN block is 8 bytes
999 ptrdiff_t maxNumOfTMMBNBlocks = rtcpParser.LengthLeft() / 8; 978 ptrdiff_t maxNumOfTMMBNBlocks = rtcpParser.LengthLeft() / 8;
1000 979
1001 // sanity, we cant have more than what's in one packet 980 // sanity, we cant have more than what's in one packet
1002 if (maxNumOfTMMBNBlocks > 200) { 981 if (maxNumOfTMMBNBlocks > 200) {
1003 assert(false); 982 assert(false);
1004 rtcpParser.Iterate(); 983 rtcpParser.Iterate();
1005 return; 984 return;
1006 } 985 }
1007 986
1008 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate(); 987 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate();
1009 while (pktType == RTCPPacketTypes::kRtpfbTmmbnItem) { 988 while (pktType == RTCPPacketTypes::kRtpfbTmmbnItem) {
1010 HandleTMMBNItem(*ptrReceiveInfo, rtcpPacket); 989 ptrReceiveInfo->tmmbn.emplace_back(
990 rtcpPacket.TMMBNItem.SSRC,
991 rtcpPacket.TMMBNItem.MaxTotalMediaBitRate * 1000,
992 rtcpPacket.TMMBNItem.MeasuredOverhead);
1011 pktType = rtcpParser.Iterate(); 993 pktType = rtcpParser.Iterate();
1012 } 994 }
1013 } 995 }
1014 996
1015 void RTCPReceiver::HandleSR_REQ(RTCPUtility::RTCPParserV2& rtcpParser, 997 void RTCPReceiver::HandleSR_REQ(RTCPUtility::RTCPParserV2& rtcpParser,
1016 RTCPPacketInformation& rtcpPacketInformation) { 998 RTCPPacketInformation& rtcpPacketInformation) {
1017 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpSrReq; 999 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpSrReq;
1018 rtcpParser.Iterate(); 1000 rtcpParser.Iterate();
1019 } 1001 }
1020 1002
1021 void RTCPReceiver::HandleTMMBNItem(RTCPReceiveInformation& receiveInfo,
1022 const RTCPUtility::RTCPPacket& rtcpPacket) {
1023 receiveInfo.tmmbn.emplace_back(
1024 rtcpPacket.TMMBNItem.SSRC,
1025 rtcpPacket.TMMBNItem.MaxTotalMediaBitRate * 1000,
1026 rtcpPacket.TMMBNItem.MeasuredOverhead);
1027 }
1028
1029 void RTCPReceiver::HandleSLI(RTCPUtility::RTCPParserV2& rtcpParser, 1003 void RTCPReceiver::HandleSLI(RTCPUtility::RTCPParserV2& rtcpParser,
1030 RTCPPacketInformation& rtcpPacketInformation) { 1004 RTCPPacketInformation& rtcpPacketInformation) {
1031 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet(); 1005 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet();
1032 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate(); 1006 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate();
1033 while (pktType == RTCPPacketTypes::kPsfbSliItem) { 1007 while (pktType == RTCPPacketTypes::kPsfbSliItem) {
1034 HandleSLIItem(rtcpPacket, rtcpPacketInformation); 1008 // in theory there could be multiple slices lost
1009 rtcpPacketInformation.rtcpPacketTypeFlags |=
1010 kRtcpSli; // received signal that we need to refresh a slice
1011 rtcpPacketInformation.sliPictureId = rtcpPacket.SLIItem.PictureId;
1012
1035 pktType = rtcpParser.Iterate(); 1013 pktType = rtcpParser.Iterate();
1036 } 1014 }
1037 } 1015 }
1038 1016
1039 void RTCPReceiver::HandleSLIItem(const RTCPUtility::RTCPPacket& rtcpPacket,
1040 RTCPPacketInformation& rtcpPacketInformation) {
1041 // in theory there could be multiple slices lost
1042 rtcpPacketInformation.rtcpPacketTypeFlags |=
1043 kRtcpSli; // received signal that we need to refresh a slice
1044 rtcpPacketInformation.sliPictureId = rtcpPacket.SLIItem.PictureId;
1045 }
1046
1047 void RTCPReceiver::HandleRPSI( 1017 void RTCPReceiver::HandleRPSI(
1048 RTCPUtility::RTCPParserV2& rtcpParser, 1018 RTCPUtility::RTCPParserV2& rtcpParser,
1049 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation) { 1019 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation) {
1050 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet(); 1020 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet();
1051 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate(); 1021 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate();
1052 if (pktType == RTCPPacketTypes::kPsfbRpsiItem) { 1022 if (pktType == RTCPPacketTypes::kPsfbRpsiItem) {
1053 if (rtcpPacket.RPSI.NumberOfValidBits % 8 != 0) { 1023 if (rtcpPacket.RPSI.NumberOfValidBits % 8 != 0) {
1054 // to us unknown 1024 // to us unknown
1055 // continue 1025 // continue
1056 rtcpParser.Iterate(); 1026 rtcpParser.Iterate();
(...skipping 14 matching lines...) Expand all
1071 (rtcpPacket.RPSI.NativeBitString[numberOfBytes - 1] & 0x7f); 1041 (rtcpPacket.RPSI.NativeBitString[numberOfBytes - 1] & 0x7f);
1072 } 1042 }
1073 } 1043 }
1074 1044
1075 void RTCPReceiver::HandlePsfbApp(RTCPUtility::RTCPParserV2& rtcpParser, 1045 void RTCPReceiver::HandlePsfbApp(RTCPUtility::RTCPParserV2& rtcpParser,
1076 RTCPPacketInformation& rtcpPacketInformation) { 1046 RTCPPacketInformation& rtcpPacketInformation) {
1077 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate(); 1047 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate();
1078 if (pktType == RTCPPacketTypes::kPsfbRemb) { 1048 if (pktType == RTCPPacketTypes::kPsfbRemb) {
1079 pktType = rtcpParser.Iterate(); 1049 pktType = rtcpParser.Iterate();
1080 if (pktType == RTCPPacketTypes::kPsfbRembItem) { 1050 if (pktType == RTCPPacketTypes::kPsfbRembItem) {
1081 HandleREMBItem(rtcpParser, rtcpPacketInformation); 1051 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet();
1052 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpRemb;
1053 rtcpPacketInformation.receiverEstimatedMaxBitrate =
1054 rtcpPacket.REMBItem.BitRate;
1055
1082 rtcpParser.Iterate(); 1056 rtcpParser.Iterate();
1083 } 1057 }
1084 } 1058 }
1085 } 1059 }
1086 1060
1087 void RTCPReceiver::HandleREMBItem(
1088 RTCPUtility::RTCPParserV2& rtcpParser,
1089 RTCPPacketInformation& rtcpPacketInformation) {
1090 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet();
1091 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpRemb;
1092 rtcpPacketInformation.receiverEstimatedMaxBitrate =
1093 rtcpPacket.REMBItem.BitRate;
1094 }
1095
1096 void RTCPReceiver::HandleFIR(RTCPUtility::RTCPParserV2& rtcpParser, 1061 void RTCPReceiver::HandleFIR(RTCPUtility::RTCPParserV2& rtcpParser,
1097 RTCPPacketInformation& rtcpPacketInformation) { 1062 RTCPPacketInformation& rtcpPacketInformation) {
1098 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet(); 1063 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet();
1099 RTCPReceiveInformation* ptrReceiveInfo = 1064 RTCPReceiveInformation* ptrReceiveInfo =
1100 GetReceiveInformation(rtcpPacket.FIR.SenderSSRC); 1065 GetReceiveInformation(rtcpPacket.FIR.SenderSSRC);
1101 1066
1102 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate(); 1067 RTCPUtility::RTCPPacketTypes pktType = rtcpParser.Iterate();
1103 while (pktType == RTCPPacketTypes::kPsfbFirItem) { 1068 while (pktType == RTCPPacketTypes::kPsfbFirItem) {
1104 HandleFIRItem(ptrReceiveInfo, rtcpPacket, rtcpPacketInformation); 1069 // Is it our sender that is requested to generate a new keyframe
1070 if (main_ssrc_ != rtcpPacket.FIRItem.SSRC) {
1071 return;
1072 }
1073
1074 ++packet_type_counter_.fir_packets;
1075
1076 // rtcpPacket.FIR.MediaSSRC SHOULD be 0 but we ignore to check it
1077 // we don't know who this originate from
1078 if (ptrReceiveInfo) {
1079 // check if we have reported this FIRSequenceNumber before
1080 if (rtcpPacket.FIRItem.CommandSequenceNumber !=
1081 ptrReceiveInfo->last_fir_sequence_number) {
1082 int64_t now = _clock->TimeInMilliseconds();
1083 // sanity; don't go crazy with the callbacks
1084 if ((now - ptrReceiveInfo->last_fir_request_ms) >
1085 RTCP_MIN_FRAME_LENGTH_MS) {
1086 ptrReceiveInfo->last_fir_request_ms = now;
1087 ptrReceiveInfo->last_fir_sequence_number =
1088 rtcpPacket.FIRItem.CommandSequenceNumber;
1089 // received signal that we need to send a new key frame
1090 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpFir;
1091 }
1092 }
1093 } else {
1094 // received signal that we need to send a new key frame
1095 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpFir;
1096 }
1097
1105 pktType = rtcpParser.Iterate(); 1098 pktType = rtcpParser.Iterate();
1106 } 1099 }
1107 } 1100 }
1108 1101
1109 void RTCPReceiver::HandleFIRItem(RTCPReceiveInformation* receiveInfo,
1110 const RTCPUtility::RTCPPacket& rtcpPacket,
1111 RTCPPacketInformation& rtcpPacketInformation) {
1112 // Is it our sender that is requested to generate a new keyframe
1113 if (main_ssrc_ != rtcpPacket.FIRItem.SSRC) {
1114 return;
1115 }
1116
1117 ++packet_type_counter_.fir_packets;
1118
1119 // rtcpPacket.FIR.MediaSSRC SHOULD be 0 but we ignore to check it
1120 // we don't know who this originate from
1121 if (receiveInfo) {
1122 // check if we have reported this FIRSequenceNumber before
1123 if (rtcpPacket.FIRItem.CommandSequenceNumber !=
1124 receiveInfo->last_fir_sequence_number) {
1125 int64_t now = _clock->TimeInMilliseconds();
1126 // sanity; don't go crazy with the callbacks
1127 if ((now - receiveInfo->last_fir_request_ms) > RTCP_MIN_FRAME_LENGTH_MS) {
1128 receiveInfo->last_fir_request_ms = now;
1129 receiveInfo->last_fir_sequence_number =
1130 rtcpPacket.FIRItem.CommandSequenceNumber;
1131 // received signal that we need to send a new key frame
1132 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpFir;
1133 }
1134 }
1135 } else {
1136 // received signal that we need to send a new key frame
1137 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpFir;
1138 }
1139 }
1140
1141 void RTCPReceiver::HandleTransportFeedback( 1102 void RTCPReceiver::HandleTransportFeedback(
1142 RTCPUtility::RTCPParserV2* rtcp_parser, 1103 RTCPUtility::RTCPParserV2* rtcp_parser,
1143 RTCPHelp::RTCPPacketInformation* rtcp_packet_information) { 1104 RTCPHelp::RTCPPacketInformation* rtcp_packet_information) {
1144 rtcp::RtcpPacket* packet = rtcp_parser->ReleaseRtcpPacket(); 1105 rtcp::RtcpPacket* packet = rtcp_parser->ReleaseRtcpPacket();
1145 RTC_DCHECK(packet != nullptr); 1106 RTC_DCHECK(packet != nullptr);
1146 rtcp_packet_information->rtcpPacketTypeFlags |= kRtcpTransportFeedback; 1107 rtcp_packet_information->rtcpPacketTypeFlags |= kRtcpTransportFeedback;
1147 rtcp_packet_information->transport_feedback_.reset( 1108 rtcp_packet_information->transport_feedback_.reset(
1148 static_cast<rtcp::TransportFeedback*>(packet)); 1109 static_cast<rtcp::TransportFeedback*>(packet));
1149 1110
1150 rtcp_parser->Iterate(); 1111 rtcp_parser->Iterate();
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
1306 1267
1307 for (const auto& kv : _receivedInfoMap) { 1268 for (const auto& kv : _receivedInfoMap) {
1308 RTCPReceiveInformation* receive_info = kv.second; 1269 RTCPReceiveInformation* receive_info = kv.second;
1309 RTC_DCHECK(receive_info); 1270 RTC_DCHECK(receive_info);
1310 receive_info->GetTmmbrSet(now_ms, &candidates); 1271 receive_info->GetTmmbrSet(now_ms, &candidates);
1311 } 1272 }
1312 return candidates; 1273 return candidates;
1313 } 1274 }
1314 1275
1315 } // namespace webrtc 1276 } // 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