| 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 |
| 11 #include "webrtc/modules/rtp_rtcp/source/rtcp_receiver.h" | 11 #include "webrtc/modules/rtp_rtcp/source/rtcp_receiver.h" |
| 12 | 12 |
| 13 #include <assert.h> | 13 #include <assert.h> |
| 14 #include <string.h> | 14 #include <string.h> |
| 15 | 15 |
| 16 #include <limits> | 16 #include <limits> |
| 17 | 17 |
| 18 #include "webrtc/base/checks.h" | 18 #include "webrtc/base/checks.h" |
| 19 #include "webrtc/base/logging.h" | 19 #include "webrtc/base/logging.h" |
| 20 #include "webrtc/base/trace_event.h" | 20 #include "webrtc/base/trace_event.h" |
| 21 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" | 21 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" |
| 22 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" | 22 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" |
| 23 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h" | |
| 24 #include "webrtc/modules/rtp_rtcp/source/time_util.h" | 23 #include "webrtc/modules/rtp_rtcp/source/time_util.h" |
| 25 #include "webrtc/modules/rtp_rtcp/source/tmmbr_help.h" | 24 #include "webrtc/modules/rtp_rtcp/source/tmmbr_help.h" |
| 26 #include "webrtc/system_wrappers/include/ntp_time.h" | 25 #include "webrtc/system_wrappers/include/ntp_time.h" |
| 27 | 26 |
| 28 namespace webrtc { | 27 namespace webrtc { |
| 29 using RTCPHelp::RTCPPacketInformation; | 28 using RTCPHelp::RTCPPacketInformation; |
| 30 using RTCPHelp::RTCPReceiveInformation; | 29 using RTCPHelp::RTCPReceiveInformation; |
| 31 using RTCPHelp::RTCPReportBlockInformation; | 30 using RTCPHelp::RTCPReportBlockInformation; |
| 32 using RTCPUtility::kBtVoipMetric; | 31 using RTCPUtility::kBtVoipMetric; |
| 33 using RTCPUtility::RTCPCnameInformation; | 32 using RTCPUtility::RTCPCnameInformation; |
| 34 using RTCPUtility::RTCPPacketReportBlockItem; | 33 using RTCPUtility::RTCPPacketReportBlockItem; |
| 35 using RTCPUtility::RTCPPacketTypes; | 34 using RTCPUtility::RTCPPacketTypes; |
| 36 | 35 |
| 37 // The number of RTCP time intervals needed to trigger a timeout. | 36 // The number of RTCP time intervals needed to trigger a timeout. |
| 38 const int kRrTimeoutIntervals = 3; | 37 const int kRrTimeoutIntervals = 3; |
| 39 | 38 |
| 40 const int64_t kMaxWarningLogIntervalMs = 10000; | 39 const int64_t kMaxWarningLogIntervalMs = 10000; |
| 41 | 40 |
| 42 RTCPReceiver::RTCPReceiver( | 41 RTCPReceiver::RTCPReceiver( |
| 43 Clock* clock, | 42 Clock* clock, |
| 44 bool receiver_only, | 43 bool receiver_only, |
| 45 RtcpPacketTypeCounterObserver* packet_type_counter_observer, | 44 RtcpPacketTypeCounterObserver* packet_type_counter_observer, |
| 46 RtcpBandwidthObserver* rtcp_bandwidth_observer, | 45 RtcpBandwidthObserver* rtcp_bandwidth_observer, |
| 47 RtcpIntraFrameObserver* rtcp_intra_frame_observer, | 46 RtcpIntraFrameObserver* rtcp_intra_frame_observer, |
| 48 TransportFeedbackObserver* transport_feedback_observer, | 47 TransportFeedbackObserver* transport_feedback_observer, |
| 49 ModuleRtpRtcpImpl* owner) | 48 ModuleRtpRtcp* owner) |
| 50 : _clock(clock), | 49 : _clock(clock), |
| 51 receiver_only_(receiver_only), | 50 receiver_only_(receiver_only), |
| 52 _lastReceived(0), | 51 _lastReceived(0), |
| 53 _rtpRtcp(*owner), | 52 _rtpRtcp(*owner), |
| 54 _cbRtcpBandwidthObserver(rtcp_bandwidth_observer), | 53 _cbRtcpBandwidthObserver(rtcp_bandwidth_observer), |
| 55 _cbRtcpIntraFrameObserver(rtcp_intra_frame_observer), | 54 _cbRtcpIntraFrameObserver(rtcp_intra_frame_observer), |
| 56 _cbTransportFeedbackObserver(transport_feedback_observer), | 55 _cbTransportFeedbackObserver(transport_feedback_observer), |
| 57 main_ssrc_(0), | 56 main_ssrc_(0), |
| 58 _remoteSSRC(0), | 57 _remoteSSRC(0), |
| 59 _remoteSenderInfo(), | 58 _remoteSenderInfo(), |
| (...skipping 30 matching lines...) Expand all Loading... |
| 90 _receivedInfoMap.erase(first); | 89 _receivedInfoMap.erase(first); |
| 91 } | 90 } |
| 92 while (!_receivedCnameMap.empty()) { | 91 while (!_receivedCnameMap.empty()) { |
| 93 std::map<uint32_t, RTCPCnameInformation*>::iterator first = | 92 std::map<uint32_t, RTCPCnameInformation*>::iterator first = |
| 94 _receivedCnameMap.begin(); | 93 _receivedCnameMap.begin(); |
| 95 delete first->second; | 94 delete first->second; |
| 96 _receivedCnameMap.erase(first); | 95 _receivedCnameMap.erase(first); |
| 97 } | 96 } |
| 98 } | 97 } |
| 99 | 98 |
| 99 bool RTCPReceiver::IncomingPacket(const uint8_t* packet, size_t packet_size) { |
| 100 // Allow receive of non-compound RTCP packets. |
| 101 RTCPUtility::RTCPParserV2 rtcp_parser(packet, packet_size, true); |
| 102 |
| 103 if (!rtcp_parser.IsValid()) { |
| 104 LOG(LS_WARNING) << "Incoming invalid RTCP packet"; |
| 105 return false; |
| 106 } |
| 107 RTCPHelp::RTCPPacketInformation rtcp_packet_information; |
| 108 IncomingRTCPPacket(rtcp_packet_information, &rtcp_parser); |
| 109 TriggerCallbacksFromRTCPPacket(rtcp_packet_information); |
| 110 return true; |
| 111 } |
| 112 |
| 100 int64_t RTCPReceiver::LastReceived() { | 113 int64_t RTCPReceiver::LastReceived() { |
| 101 rtc::CritScope lock(&_criticalSectionRTCPReceiver); | 114 rtc::CritScope lock(&_criticalSectionRTCPReceiver); |
| 102 return _lastReceived; | 115 return _lastReceived; |
| 103 } | 116 } |
| 104 | 117 |
| 105 int64_t RTCPReceiver::LastReceivedReceiverReport() const { | 118 int64_t RTCPReceiver::LastReceivedReceiverReport() const { |
| 106 rtc::CritScope lock(&_criticalSectionRTCPReceiver); | 119 rtc::CritScope lock(&_criticalSectionRTCPReceiver); |
| 107 int64_t last_received_rr = -1; | 120 int64_t last_received_rr = -1; |
| 108 for (ReceivedInfoMap::const_iterator it = _receivedInfoMap.begin(); | 121 for (ReceivedInfoMap::const_iterator it = _receivedInfoMap.begin(); |
| 109 it != _receivedInfoMap.end(); ++it) { | 122 it != _receivedInfoMap.end(); ++it) { |
| (...skipping 1256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1366 | 1379 |
| 1367 for (const auto& kv : _receivedInfoMap) { | 1380 for (const auto& kv : _receivedInfoMap) { |
| 1368 RTCPReceiveInformation* receive_info = kv.second; | 1381 RTCPReceiveInformation* receive_info = kv.second; |
| 1369 RTC_DCHECK(receive_info); | 1382 RTC_DCHECK(receive_info); |
| 1370 receive_info->GetTmmbrSet(now_ms, &candidates); | 1383 receive_info->GetTmmbrSet(now_ms, &candidates); |
| 1371 } | 1384 } |
| 1372 return candidates; | 1385 return candidates; |
| 1373 } | 1386 } |
| 1374 | 1387 |
| 1375 } // namespace webrtc | 1388 } // namespace webrtc |
| OLD | NEW |