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 "webrtc/base/checks.h" | 16 #include "webrtc/base/checks.h" |
17 #include "webrtc/base/logging.h" | 17 #include "webrtc/base/logging.h" |
18 #include "webrtc/base/trace_event.h" | 18 #include "webrtc/base/trace_event.h" |
19 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" | 19 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" |
20 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" | 20 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" |
21 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h" | 21 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h" |
22 #include "webrtc/modules/rtp_rtcp/source/time_util.h" | 22 #include "webrtc/modules/rtp_rtcp/source/time_util.h" |
| 23 #include "webrtc/modules/rtp_rtcp/source/tmmbr_help.h" |
23 #include "webrtc/system_wrappers/include/ntp_time.h" | 24 #include "webrtc/system_wrappers/include/ntp_time.h" |
24 | 25 |
25 namespace webrtc { | 26 namespace webrtc { |
26 using RTCPHelp::RTCPPacketInformation; | 27 using RTCPHelp::RTCPPacketInformation; |
27 using RTCPHelp::RTCPReceiveInformation; | 28 using RTCPHelp::RTCPReceiveInformation; |
28 using RTCPHelp::RTCPReportBlockInformation; | 29 using RTCPHelp::RTCPReportBlockInformation; |
29 using RTCPUtility::kBtVoipMetric; | 30 using RTCPUtility::kBtVoipMetric; |
30 using RTCPUtility::RTCPCnameInformation; | 31 using RTCPUtility::RTCPCnameInformation; |
31 using RTCPUtility::RTCPPacketReportBlockItem; | 32 using RTCPUtility::RTCPPacketReportBlockItem; |
32 using RTCPUtility::RTCPPacketTypes; | 33 using RTCPUtility::RTCPPacketTypes; |
33 | 34 |
34 // The number of RTCP time intervals needed to trigger a timeout. | 35 // The number of RTCP time intervals needed to trigger a timeout. |
35 const int kRrTimeoutIntervals = 3; | 36 const int kRrTimeoutIntervals = 3; |
36 | 37 |
37 const int64_t kMaxWarningLogIntervalMs = 10000; | 38 const int64_t kMaxWarningLogIntervalMs = 10000; |
38 | 39 |
39 RTCPReceiver::RTCPReceiver( | 40 RTCPReceiver::RTCPReceiver( |
40 Clock* clock, | 41 Clock* clock, |
41 bool receiver_only, | 42 bool receiver_only, |
42 RtcpPacketTypeCounterObserver* packet_type_counter_observer, | 43 RtcpPacketTypeCounterObserver* packet_type_counter_observer, |
43 RtcpBandwidthObserver* rtcp_bandwidth_observer, | 44 RtcpBandwidthObserver* rtcp_bandwidth_observer, |
44 RtcpIntraFrameObserver* rtcp_intra_frame_observer, | 45 RtcpIntraFrameObserver* rtcp_intra_frame_observer, |
45 TransportFeedbackObserver* transport_feedback_observer, | 46 TransportFeedbackObserver* transport_feedback_observer, |
46 ModuleRtpRtcpImpl* owner) | 47 ModuleRtpRtcpImpl* owner) |
47 : TMMBRHelp(), | 48 : _clock(clock), |
48 _clock(clock), | |
49 receiver_only_(receiver_only), | 49 receiver_only_(receiver_only), |
50 _lastReceived(0), | 50 _lastReceived(0), |
51 _rtpRtcp(*owner), | 51 _rtpRtcp(*owner), |
52 _cbRtcpBandwidthObserver(rtcp_bandwidth_observer), | 52 _cbRtcpBandwidthObserver(rtcp_bandwidth_observer), |
53 _cbRtcpIntraFrameObserver(rtcp_intra_frame_observer), | 53 _cbRtcpIntraFrameObserver(rtcp_intra_frame_observer), |
54 _cbTransportFeedbackObserver(transport_feedback_observer), | 54 _cbTransportFeedbackObserver(transport_feedback_observer), |
55 main_ssrc_(0), | 55 main_ssrc_(0), |
56 _remoteSSRC(0), | 56 _remoteSSRC(0), |
57 _remoteSenderInfo(), | 57 _remoteSenderInfo(), |
58 _lastReceivedSRNTPsecs(0), | 58 _lastReceivedSRNTPsecs(0), |
(...skipping 1167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1226 RTCPHelp::RTCPPacketInformation* rtcp_packet_information) { | 1226 RTCPHelp::RTCPPacketInformation* rtcp_packet_information) { |
1227 rtcp::RtcpPacket* packet = rtcp_parser->ReleaseRtcpPacket(); | 1227 rtcp::RtcpPacket* packet = rtcp_parser->ReleaseRtcpPacket(); |
1228 RTC_DCHECK(packet != nullptr); | 1228 RTC_DCHECK(packet != nullptr); |
1229 rtcp_packet_information->rtcpPacketTypeFlags |= kRtcpTransportFeedback; | 1229 rtcp_packet_information->rtcpPacketTypeFlags |= kRtcpTransportFeedback; |
1230 rtcp_packet_information->transport_feedback_.reset( | 1230 rtcp_packet_information->transport_feedback_.reset( |
1231 static_cast<rtcp::TransportFeedback*>(packet)); | 1231 static_cast<rtcp::TransportFeedback*>(packet)); |
1232 | 1232 |
1233 rtcp_parser->Iterate(); | 1233 rtcp_parser->Iterate(); |
1234 } | 1234 } |
1235 int32_t RTCPReceiver::UpdateTMMBR() { | 1235 int32_t RTCPReceiver::UpdateTMMBR() { |
| 1236 TMMBRHelp tmmbr_help; |
1236 int32_t numBoundingSet = 0; | 1237 int32_t numBoundingSet = 0; |
1237 uint32_t bitrate = 0; | 1238 uint32_t bitrate = 0; |
1238 uint32_t accNumCandidates = 0; | 1239 uint32_t accNumCandidates = 0; |
1239 | 1240 |
1240 int32_t size = TMMBRReceived(0, 0, NULL); | 1241 int32_t size = TMMBRReceived(0, 0, NULL); |
1241 if (size > 0) { | 1242 if (size > 0) { |
1242 TMMBRSet* candidateSet = VerifyAndAllocateCandidateSet(size); | 1243 TMMBRSet* candidateSet = tmmbr_help.VerifyAndAllocateCandidateSet(size); |
1243 // Get candidate set from receiver. | 1244 // Get candidate set from receiver. |
1244 accNumCandidates = TMMBRReceived(size, accNumCandidates, candidateSet); | 1245 accNumCandidates = TMMBRReceived(size, accNumCandidates, candidateSet); |
1245 } else { | |
1246 // Candidate set empty. | |
1247 VerifyAndAllocateCandidateSet(0); // resets candidate set | |
1248 } | 1246 } |
1249 // Find bounding set | 1247 // Find bounding set |
1250 TMMBRSet* boundingSet = NULL; | 1248 TMMBRSet* boundingSet = NULL; |
1251 numBoundingSet = FindTMMBRBoundingSet(boundingSet); | 1249 numBoundingSet = tmmbr_help.FindTMMBRBoundingSet(boundingSet); |
1252 if (numBoundingSet == -1) { | 1250 if (numBoundingSet == -1) { |
1253 LOG(LS_WARNING) << "Failed to find TMMBR bounding set."; | 1251 LOG(LS_WARNING) << "Failed to find TMMBR bounding set."; |
1254 return -1; | 1252 return -1; |
1255 } | 1253 } |
1256 // Set bounding set | 1254 // Set bounding set |
1257 // Inform remote clients about the new bandwidth | 1255 // Inform remote clients about the new bandwidth |
1258 // inform the remote client | 1256 // inform the remote client |
1259 _rtpRtcp.SetTMMBN(boundingSet); | 1257 _rtpRtcp.SetTMMBN(boundingSet); |
1260 | 1258 |
1261 // might trigger a TMMBN | 1259 // might trigger a TMMBN |
1262 if (numBoundingSet == 0) { | 1260 if (numBoundingSet == 0) { |
1263 // owner of max bitrate request has timed out | 1261 // owner of max bitrate request has timed out |
1264 // empty bounding set has been sent | 1262 // empty bounding set has been sent |
1265 return 0; | 1263 return 0; |
1266 } | 1264 } |
1267 // Get net bitrate from bounding set depending on sent packet rate | 1265 // Get net bitrate from bounding set depending on sent packet rate |
1268 if (CalcMinBitRate(&bitrate)) { | 1266 if (tmmbr_help.CalcMinBitRate(&bitrate)) { |
1269 // we have a new bandwidth estimate on this channel | 1267 // we have a new bandwidth estimate on this channel |
1270 if (_cbRtcpBandwidthObserver) { | 1268 if (_cbRtcpBandwidthObserver) { |
1271 _cbRtcpBandwidthObserver->OnReceivedEstimatedBitrate(bitrate * 1000); | 1269 _cbRtcpBandwidthObserver->OnReceivedEstimatedBitrate(bitrate * 1000); |
1272 } | 1270 } |
1273 } | 1271 } |
1274 return 0; | 1272 return 0; |
1275 } | 1273 } |
1276 | 1274 |
1277 void RTCPReceiver::RegisterRtcpStatisticsCallback( | 1275 void RTCPReceiver::RegisterRtcpStatisticsCallback( |
1278 RtcpStatisticsCallback* callback) { | 1276 RtcpStatisticsCallback* callback) { |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1437 return -1; | 1435 return -1; |
1438 } | 1436 } |
1439 num += receiveInfo->TmmbrSet.lengthOfSet(); | 1437 num += receiveInfo->TmmbrSet.lengthOfSet(); |
1440 receiveInfoIt++; | 1438 receiveInfoIt++; |
1441 } | 1439 } |
1442 } | 1440 } |
1443 return num; | 1441 return num; |
1444 } | 1442 } |
1445 | 1443 |
1446 } // namespace webrtc | 1444 } // namespace webrtc |
OLD | NEW |