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

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtcp_receiver.cc

Issue 2250633002: Cleanup RtcpReceiver::TMMBRReceived function (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 4 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
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 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1227 RTCPUtility::RTCPParserV2* rtcp_parser, 1227 RTCPUtility::RTCPParserV2* rtcp_parser,
1228 RTCPHelp::RTCPPacketInformation* rtcp_packet_information) { 1228 RTCPHelp::RTCPPacketInformation* rtcp_packet_information) {
1229 rtcp::RtcpPacket* packet = rtcp_parser->ReleaseRtcpPacket(); 1229 rtcp::RtcpPacket* packet = rtcp_parser->ReleaseRtcpPacket();
1230 RTC_DCHECK(packet != nullptr); 1230 RTC_DCHECK(packet != nullptr);
1231 rtcp_packet_information->rtcpPacketTypeFlags |= kRtcpTransportFeedback; 1231 rtcp_packet_information->rtcpPacketTypeFlags |= kRtcpTransportFeedback;
1232 rtcp_packet_information->transport_feedback_.reset( 1232 rtcp_packet_information->transport_feedback_.reset(
1233 static_cast<rtcp::TransportFeedback*>(packet)); 1233 static_cast<rtcp::TransportFeedback*>(packet));
1234 1234
1235 rtcp_parser->Iterate(); 1235 rtcp_parser->Iterate();
1236 } 1236 }
1237
1237 int32_t RTCPReceiver::UpdateTMMBR() { 1238 int32_t RTCPReceiver::UpdateTMMBR() {
1238 int32_t size = TMMBRReceived(0, 0, NULL);
1239 TMMBRSet candidates;
1240 if (size > 0) {
1241 candidates.reserve(size);
1242 // Get candidate set from receiver.
1243 TMMBRReceived(size, 0, &candidates);
1244 }
1245 // Find bounding set 1239 // Find bounding set
1246 std::vector<rtcp::TmmbItem> bounding = 1240 std::vector<rtcp::TmmbItem> bounding =
1247 TMMBRHelp::FindBoundingSet(std::move(candidates)); 1241 TMMBRHelp::FindBoundingSet(TMMBRReceived());
1248 // Set bounding set 1242 // Set bounding set
1249 // Inform remote clients about the new bandwidth 1243 // Inform remote clients about the new bandwidth
1250 // inform the remote client 1244 // inform the remote client
1251 _rtpRtcp.SetTMMBN(&bounding); 1245 _rtpRtcp.SetTMMBN(&bounding);
1252 1246
1253 // might trigger a TMMBN 1247 // might trigger a TMMBN
1254 if (bounding.empty()) { 1248 if (bounding.empty()) {
1255 // owner of max bitrate request has timed out 1249 // owner of max bitrate request has timed out
1256 // empty bounding set has been sent 1250 // empty bounding set has been sent
1257 return 0; 1251 return 0;
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1392 rtc::CritScope lock(&_criticalSectionRTCPReceiver); 1386 rtc::CritScope lock(&_criticalSectionRTCPReceiver);
1393 RTCPCnameInformation* cnameInfo = GetCnameInformation(remoteSSRC); 1387 RTCPCnameInformation* cnameInfo = GetCnameInformation(remoteSSRC);
1394 if (cnameInfo == NULL) { 1388 if (cnameInfo == NULL) {
1395 return -1; 1389 return -1;
1396 } 1390 }
1397 cName[RTCP_CNAME_SIZE - 1] = 0; 1391 cName[RTCP_CNAME_SIZE - 1] = 0;
1398 strncpy(cName, cnameInfo->name, RTCP_CNAME_SIZE - 1); 1392 strncpy(cName, cnameInfo->name, RTCP_CNAME_SIZE - 1);
1399 return 0; 1393 return 0;
1400 } 1394 }
1401 1395
1402 // no callbacks allowed inside this function 1396 std::vector<rtcp::TmmbItem> RTCPReceiver::TMMBRReceived() const {
1403 int32_t RTCPReceiver::TMMBRReceived(uint32_t size,
1404 uint32_t accNumCandidates,
1405 TMMBRSet* candidateSet) const {
1406 rtc::CritScope lock(&_criticalSectionRTCPReceiver); 1397 rtc::CritScope lock(&_criticalSectionRTCPReceiver);
1398 std::vector<rtcp::TmmbItem> candidates;
1407 1399
1408 std::map<uint32_t, RTCPReceiveInformation*>::const_iterator 1400 int64_t now_ms = _clock->TimeInMilliseconds();
1409 receiveInfoIt = _receivedInfoMap.begin(); 1401
1410 if (receiveInfoIt == _receivedInfoMap.end()) { 1402 for (const auto& kv : _receivedInfoMap) {
1411 return -1; 1403 RTCPReceiveInformation* receive_info = kv.second;
1404 RTC_DCHECK(receive_info);
1405 receive_info->GetTMMBRSet(now_ms, &candidates);
1412 } 1406 }
1413 uint32_t num = accNumCandidates; 1407 return candidates;
1414 if (candidateSet) {
1415 while( num < size && receiveInfoIt != _receivedInfoMap.end()) {
1416 RTCPReceiveInformation* receiveInfo = receiveInfoIt->second;
1417 if (receiveInfo == NULL) {
1418 return 0;
1419 }
1420 for (uint32_t i = 0;
1421 (num < size) && (i < receiveInfo->TmmbrSet.lengthOfSet()); i++) {
1422 if (receiveInfo->GetTMMBRSet(i, num, candidateSet,
1423 _clock->TimeInMilliseconds()) == 0) {
1424 num++;
1425 }
1426 }
1427 receiveInfoIt++;
1428 }
1429 } else {
1430 while (receiveInfoIt != _receivedInfoMap.end()) {
1431 RTCPReceiveInformation* receiveInfo = receiveInfoIt->second;
1432 if(receiveInfo == NULL) {
1433 return -1;
1434 }
1435 num += receiveInfo->TmmbrSet.lengthOfSet();
1436 receiveInfoIt++;
1437 }
1438 }
1439 return num;
1440 } 1408 }
1441 1409
1442 } // namespace webrtc 1410 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698