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> |
| 17 |
16 #include "webrtc/base/checks.h" | 18 #include "webrtc/base/checks.h" |
17 #include "webrtc/base/logging.h" | 19 #include "webrtc/base/logging.h" |
18 #include "webrtc/base/trace_event.h" | 20 #include "webrtc/base/trace_event.h" |
19 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" | 21 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" |
20 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" | 22 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" |
21 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h" | 23 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h" |
22 #include "webrtc/modules/rtp_rtcp/source/time_util.h" | 24 #include "webrtc/modules/rtp_rtcp/source/time_util.h" |
23 #include "webrtc/modules/rtp_rtcp/source/tmmbr_help.h" | 25 #include "webrtc/modules/rtp_rtcp/source/tmmbr_help.h" |
24 #include "webrtc/system_wrappers/include/ntp_time.h" | 26 #include "webrtc/system_wrappers/include/ntp_time.h" |
25 | 27 |
(...skipping 1200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1226 RTCPHelp::RTCPPacketInformation* rtcp_packet_information) { | 1228 RTCPHelp::RTCPPacketInformation* rtcp_packet_information) { |
1227 rtcp::RtcpPacket* packet = rtcp_parser->ReleaseRtcpPacket(); | 1229 rtcp::RtcpPacket* packet = rtcp_parser->ReleaseRtcpPacket(); |
1228 RTC_DCHECK(packet != nullptr); | 1230 RTC_DCHECK(packet != nullptr); |
1229 rtcp_packet_information->rtcpPacketTypeFlags |= kRtcpTransportFeedback; | 1231 rtcp_packet_information->rtcpPacketTypeFlags |= kRtcpTransportFeedback; |
1230 rtcp_packet_information->transport_feedback_.reset( | 1232 rtcp_packet_information->transport_feedback_.reset( |
1231 static_cast<rtcp::TransportFeedback*>(packet)); | 1233 static_cast<rtcp::TransportFeedback*>(packet)); |
1232 | 1234 |
1233 rtcp_parser->Iterate(); | 1235 rtcp_parser->Iterate(); |
1234 } | 1236 } |
1235 int32_t RTCPReceiver::UpdateTMMBR() { | 1237 int32_t RTCPReceiver::UpdateTMMBR() { |
1236 TMMBRHelp tmmbr_help; | |
1237 uint32_t bitrate = 0; | |
1238 uint32_t accNumCandidates = 0; | |
1239 | |
1240 int32_t size = TMMBRReceived(0, 0, NULL); | 1238 int32_t size = TMMBRReceived(0, 0, NULL); |
| 1239 TMMBRSet candidates; |
1241 if (size > 0) { | 1240 if (size > 0) { |
1242 TMMBRSet* candidateSet = tmmbr_help.VerifyAndAllocateCandidateSet(size); | 1241 candidates.reserve(size); |
1243 // Get candidate set from receiver. | 1242 // Get candidate set from receiver. |
1244 accNumCandidates = TMMBRReceived(size, accNumCandidates, candidateSet); | 1243 TMMBRReceived(size, 0, &candidates); |
1245 } | 1244 } |
1246 // Find bounding set | 1245 // Find bounding set |
1247 std::vector<rtcp::TmmbItem> bounding = tmmbr_help.FindTMMBRBoundingSet(); | 1246 std::vector<rtcp::TmmbItem> bounding = |
| 1247 TMMBRHelp::FindBoundingSet(std::move(candidates)); |
1248 // Set bounding set | 1248 // Set bounding set |
1249 // Inform remote clients about the new bandwidth | 1249 // Inform remote clients about the new bandwidth |
1250 // inform the remote client | 1250 // inform the remote client |
1251 _rtpRtcp.SetTMMBN(&bounding); | 1251 _rtpRtcp.SetTMMBN(&bounding); |
1252 | 1252 |
1253 // might trigger a TMMBN | 1253 // might trigger a TMMBN |
1254 if (bounding.empty()) { | 1254 if (bounding.empty()) { |
1255 // owner of max bitrate request has timed out | 1255 // owner of max bitrate request has timed out |
1256 // empty bounding set has been sent | 1256 // empty bounding set has been sent |
1257 return 0; | 1257 return 0; |
1258 } | 1258 } |
1259 // Get net bitrate from bounding set depending on sent packet rate | 1259 // We have a new bandwidth estimate on this channel. |
1260 if (tmmbr_help.CalcMinBitRate(&bitrate)) { | 1260 if (_cbRtcpBandwidthObserver) { |
1261 // we have a new bandwidth estimate on this channel | 1261 uint64_t bitrate_bps = TMMBRHelp::CalcMinBitrateBps(bounding); |
1262 if (_cbRtcpBandwidthObserver) { | 1262 if (bitrate_bps <= std::numeric_limits<uint32_t>::max()) |
1263 _cbRtcpBandwidthObserver->OnReceivedEstimatedBitrate(bitrate * 1000); | 1263 _cbRtcpBandwidthObserver->OnReceivedEstimatedBitrate(bitrate_bps); |
1264 } | |
1265 } | 1264 } |
1266 return 0; | 1265 return 0; |
1267 } | 1266 } |
1268 | 1267 |
1269 void RTCPReceiver::RegisterRtcpStatisticsCallback( | 1268 void RTCPReceiver::RegisterRtcpStatisticsCallback( |
1270 RtcpStatisticsCallback* callback) { | 1269 RtcpStatisticsCallback* callback) { |
1271 rtc::CritScope cs(&_criticalSectionFeedbacks); | 1270 rtc::CritScope cs(&_criticalSectionFeedbacks); |
1272 stats_callback_ = callback; | 1271 stats_callback_ = callback; |
1273 } | 1272 } |
1274 | 1273 |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1434 return -1; | 1433 return -1; |
1435 } | 1434 } |
1436 num += receiveInfo->TmmbrSet.lengthOfSet(); | 1435 num += receiveInfo->TmmbrSet.lengthOfSet(); |
1437 receiveInfoIt++; | 1436 receiveInfoIt++; |
1438 } | 1437 } |
1439 } | 1438 } |
1440 return num; | 1439 return num; |
1441 } | 1440 } |
1442 | 1441 |
1443 } // namespace webrtc | 1442 } // namespace webrtc |
OLD | NEW |