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 15 matching lines...) Expand all Loading... |
26 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h" | 26 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h" |
27 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/common_header.h" | 27 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/common_header.h" |
28 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/compound_packet.h" | 28 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/compound_packet.h" |
29 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_reports.h" | 29 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_reports.h" |
30 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/fir.h" | 30 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/fir.h" |
31 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/nack.h" | 31 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/nack.h" |
32 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/pli.h" | 32 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/pli.h" |
33 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rapid_resync_request.h" | 33 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rapid_resync_request.h" |
34 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/receiver_report.h" | 34 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/receiver_report.h" |
35 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/remb.h" | 35 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/remb.h" |
36 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rpsi.h" | |
37 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sdes.h" | 36 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sdes.h" |
38 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sender_report.h" | 37 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sender_report.h" |
39 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sli.h" | |
40 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/tmmbn.h" | 38 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/tmmbn.h" |
41 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/tmmbr.h" | 39 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/tmmbr.h" |
42 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" | 40 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" |
43 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_config.h" | 41 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_config.h" |
44 #include "webrtc/modules/rtp_rtcp/source/time_util.h" | 42 #include "webrtc/modules/rtp_rtcp/source/time_util.h" |
45 #include "webrtc/modules/rtp_rtcp/source/tmmbr_help.h" | 43 #include "webrtc/modules/rtp_rtcp/source/tmmbr_help.h" |
46 #include "webrtc/system_wrappers/include/ntp_time.h" | 44 #include "webrtc/system_wrappers/include/ntp_time.h" |
47 | 45 |
48 namespace webrtc { | 46 namespace webrtc { |
49 namespace { | 47 namespace { |
50 | 48 |
51 using rtcp::CommonHeader; | 49 using rtcp::CommonHeader; |
52 using rtcp::ReportBlock; | 50 using rtcp::ReportBlock; |
53 | 51 |
54 // The number of RTCP time intervals needed to trigger a timeout. | 52 // The number of RTCP time intervals needed to trigger a timeout. |
55 const int kRrTimeoutIntervals = 3; | 53 const int kRrTimeoutIntervals = 3; |
56 | 54 |
57 const int64_t kMaxWarningLogIntervalMs = 10000; | 55 const int64_t kMaxWarningLogIntervalMs = 10000; |
58 const int64_t kRtcpMinFrameLengthMs = 17; | 56 const int64_t kRtcpMinFrameLengthMs = 17; |
59 | 57 |
60 } // namespace | 58 } // namespace |
61 | 59 |
62 struct RTCPReceiver::PacketInformation { | 60 struct RTCPReceiver::PacketInformation { |
63 uint32_t packet_type_flags = 0; // RTCPPacketTypeFlags bit field. | 61 uint32_t packet_type_flags = 0; // RTCPPacketTypeFlags bit field. |
64 | 62 |
65 uint32_t remote_ssrc = 0; | 63 uint32_t remote_ssrc = 0; |
66 std::vector<uint16_t> nack_sequence_numbers; | 64 std::vector<uint16_t> nack_sequence_numbers; |
67 ReportBlockList report_blocks; | 65 ReportBlockList report_blocks; |
68 int64_t rtt_ms = 0; | 66 int64_t rtt_ms = 0; |
69 uint8_t sli_picture_id = 0; | |
70 uint64_t rpsi_picture_id = 0; | |
71 uint32_t receiver_estimated_max_bitrate_bps = 0; | 67 uint32_t receiver_estimated_max_bitrate_bps = 0; |
72 std::unique_ptr<rtcp::TransportFeedback> transport_feedback; | 68 std::unique_ptr<rtcp::TransportFeedback> transport_feedback; |
73 rtc::Optional<BitrateAllocation> target_bitrate_allocation; | 69 rtc::Optional<BitrateAllocation> target_bitrate_allocation; |
74 }; | 70 }; |
75 | 71 |
76 // Structure for handing TMMBR and TMMBN rtcp messages (RFC5104, section 3.5.4). | 72 // Structure for handing TMMBR and TMMBN rtcp messages (RFC5104, section 3.5.4). |
77 struct RTCPReceiver::TmmbrInformation { | 73 struct RTCPReceiver::TmmbrInformation { |
78 struct TimedTmmbrItem { | 74 struct TimedTmmbrItem { |
79 rtcp::TmmbItem tmmbr_item; | 75 rtcp::TmmbItem tmmbr_item; |
80 int64_t last_updated_ms; | 76 int64_t last_updated_ms; |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 default: | 348 default: |
353 ++num_skipped_packets_; | 349 ++num_skipped_packets_; |
354 break; | 350 break; |
355 } | 351 } |
356 break; | 352 break; |
357 case rtcp::Psfb::kPacketType: | 353 case rtcp::Psfb::kPacketType: |
358 switch (rtcp_block.fmt()) { | 354 switch (rtcp_block.fmt()) { |
359 case rtcp::Pli::kFeedbackMessageType: | 355 case rtcp::Pli::kFeedbackMessageType: |
360 HandlePli(rtcp_block, packet_information); | 356 HandlePli(rtcp_block, packet_information); |
361 break; | 357 break; |
362 case rtcp::Sli::kFeedbackMessageType: | |
363 HandleSli(rtcp_block, packet_information); | |
364 break; | |
365 case rtcp::Rpsi::kFeedbackMessageType: | |
366 HandleRpsi(rtcp_block, packet_information); | |
367 break; | |
368 case rtcp::Fir::kFeedbackMessageType: | 358 case rtcp::Fir::kFeedbackMessageType: |
369 HandleFir(rtcp_block, packet_information); | 359 HandleFir(rtcp_block, packet_information); |
370 break; | 360 break; |
371 case rtcp::Remb::kFeedbackMessageType: | 361 case rtcp::Remb::kFeedbackMessageType: |
372 HandlePsfbApp(rtcp_block, packet_information); | 362 HandlePsfbApp(rtcp_block, packet_information); |
373 break; | 363 break; |
374 default: | 364 default: |
375 ++num_skipped_packets_; | 365 ++num_skipped_packets_; |
376 break; | 366 break; |
377 } | 367 } |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
832 PacketInformation* packet_information) { | 822 PacketInformation* packet_information) { |
833 rtcp::RapidResyncRequest sr_req; | 823 rtcp::RapidResyncRequest sr_req; |
834 if (!sr_req.Parse(rtcp_block)) { | 824 if (!sr_req.Parse(rtcp_block)) { |
835 ++num_skipped_packets_; | 825 ++num_skipped_packets_; |
836 return; | 826 return; |
837 } | 827 } |
838 | 828 |
839 packet_information->packet_type_flags |= kRtcpSrReq; | 829 packet_information->packet_type_flags |= kRtcpSrReq; |
840 } | 830 } |
841 | 831 |
842 void RTCPReceiver::HandleSli(const CommonHeader& rtcp_block, | |
843 PacketInformation* packet_information) { | |
844 rtcp::Sli sli; | |
845 if (!sli.Parse(rtcp_block)) { | |
846 ++num_skipped_packets_; | |
847 return; | |
848 } | |
849 | |
850 for (const rtcp::Sli::Macroblocks& item : sli.macroblocks()) { | |
851 // In theory there could be multiple slices lost. | |
852 // Received signal that we need to refresh a slice. | |
853 packet_information->packet_type_flags |= kRtcpSli; | |
854 packet_information->sli_picture_id = item.picture_id(); | |
855 } | |
856 } | |
857 | |
858 void RTCPReceiver::HandleRpsi(const CommonHeader& rtcp_block, | |
859 PacketInformation* packet_information) { | |
860 rtcp::Rpsi rpsi; | |
861 if (!rpsi.Parse(rtcp_block)) { | |
862 ++num_skipped_packets_; | |
863 return; | |
864 } | |
865 | |
866 // Received signal that we have a confirmed reference picture. | |
867 packet_information->packet_type_flags |= kRtcpRpsi; | |
868 packet_information->rpsi_picture_id = rpsi.picture_id(); | |
869 } | |
870 | |
871 void RTCPReceiver::HandlePsfbApp(const CommonHeader& rtcp_block, | 832 void RTCPReceiver::HandlePsfbApp(const CommonHeader& rtcp_block, |
872 PacketInformation* packet_information) { | 833 PacketInformation* packet_information) { |
873 rtcp::Remb remb; | 834 rtcp::Remb remb; |
874 if (remb.Parse(rtcp_block)) { | 835 if (remb.Parse(rtcp_block)) { |
875 packet_information->packet_type_flags |= kRtcpRemb; | 836 packet_information->packet_type_flags |= kRtcpRemb; |
876 packet_information->receiver_estimated_max_bitrate_bps = remb.bitrate_bps(); | 837 packet_information->receiver_estimated_max_bitrate_bps = remb.bitrate_bps(); |
877 return; | 838 return; |
878 } | 839 } |
879 | 840 |
880 ++num_skipped_packets_; | 841 ++num_skipped_packets_; |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
996 (packet_information.packet_type_flags & kRtcpFir)) { | 957 (packet_information.packet_type_flags & kRtcpFir)) { |
997 if (packet_information.packet_type_flags & kRtcpPli) { | 958 if (packet_information.packet_type_flags & kRtcpPli) { |
998 LOG(LS_VERBOSE) << "Incoming PLI from SSRC " | 959 LOG(LS_VERBOSE) << "Incoming PLI from SSRC " |
999 << packet_information.remote_ssrc; | 960 << packet_information.remote_ssrc; |
1000 } else { | 961 } else { |
1001 LOG(LS_VERBOSE) << "Incoming FIR from SSRC " | 962 LOG(LS_VERBOSE) << "Incoming FIR from SSRC " |
1002 << packet_information.remote_ssrc; | 963 << packet_information.remote_ssrc; |
1003 } | 964 } |
1004 rtcp_intra_frame_observer_->OnReceivedIntraFrameRequest(local_ssrc); | 965 rtcp_intra_frame_observer_->OnReceivedIntraFrameRequest(local_ssrc); |
1005 } | 966 } |
1006 if (packet_information.packet_type_flags & kRtcpSli) { | |
1007 rtcp_intra_frame_observer_->OnReceivedSLI( | |
1008 local_ssrc, packet_information.sli_picture_id); | |
1009 } | |
1010 if (packet_information.packet_type_flags & kRtcpRpsi) { | |
1011 rtcp_intra_frame_observer_->OnReceivedRPSI( | |
1012 local_ssrc, packet_information.rpsi_picture_id); | |
1013 } | |
1014 } | 967 } |
1015 if (rtcp_bandwidth_observer_) { | 968 if (rtcp_bandwidth_observer_) { |
1016 RTC_DCHECK(!receiver_only_); | 969 RTC_DCHECK(!receiver_only_); |
1017 if (packet_information.packet_type_flags & kRtcpRemb) { | 970 if (packet_information.packet_type_flags & kRtcpRemb) { |
1018 LOG(LS_VERBOSE) << "Incoming REMB: " | 971 LOG(LS_VERBOSE) << "Incoming REMB: " |
1019 << packet_information.receiver_estimated_max_bitrate_bps; | 972 << packet_information.receiver_estimated_max_bitrate_bps; |
1020 rtcp_bandwidth_observer_->OnReceivedEstimatedBitrate( | 973 rtcp_bandwidth_observer_->OnReceivedEstimatedBitrate( |
1021 packet_information.receiver_estimated_max_bitrate_bps); | 974 packet_information.receiver_estimated_max_bitrate_bps); |
1022 } | 975 } |
1023 if ((packet_information.packet_type_flags & kRtcpSr) || | 976 if ((packet_information.packet_type_flags & kRtcpSr) || |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1095 } else { | 1048 } else { |
1096 candidates.push_back(it->second.tmmbr_item); | 1049 candidates.push_back(it->second.tmmbr_item); |
1097 ++it; | 1050 ++it; |
1098 } | 1051 } |
1099 } | 1052 } |
1100 } | 1053 } |
1101 return candidates; | 1054 return candidates; |
1102 } | 1055 } |
1103 | 1056 |
1104 } // namespace webrtc | 1057 } // namespace webrtc |
OLD | NEW |