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 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1203 RTCPHelp::RTCPPacketInformation* rtcp_packet_information) { | 1203 RTCPHelp::RTCPPacketInformation* rtcp_packet_information) { |
1204 rtcp::RtcpPacket* packet = rtcp_parser->ReleaseRtcpPacket(); | 1204 rtcp::RtcpPacket* packet = rtcp_parser->ReleaseRtcpPacket(); |
1205 RTC_DCHECK(packet != nullptr); | 1205 RTC_DCHECK(packet != nullptr); |
1206 rtcp_packet_information->rtcpPacketTypeFlags |= kRtcpTransportFeedback; | 1206 rtcp_packet_information->rtcpPacketTypeFlags |= kRtcpTransportFeedback; |
1207 rtcp_packet_information->transport_feedback_.reset( | 1207 rtcp_packet_information->transport_feedback_.reset( |
1208 static_cast<rtcp::TransportFeedback*>(packet)); | 1208 static_cast<rtcp::TransportFeedback*>(packet)); |
1209 | 1209 |
1210 rtcp_parser->Iterate(); | 1210 rtcp_parser->Iterate(); |
1211 } | 1211 } |
1212 | 1212 |
1213 int32_t RTCPReceiver::UpdateTMMBR() { | 1213 void RTCPReceiver::UpdateTmmbr() { |
1214 // Find bounding set | 1214 // Find bounding set. |
1215 std::vector<rtcp::TmmbItem> bounding = | 1215 std::vector<rtcp::TmmbItem> bounding = |
1216 TMMBRHelp::FindBoundingSet(TMMBRReceived()); | 1216 TMMBRHelp::FindBoundingSet(TmmbrReceived()); |
1217 // Set bounding set | |
1218 // Inform remote clients about the new bandwidth | |
1219 // inform the remote client | |
1220 _rtpRtcp.SetTMMBN(&bounding); | |
1221 | 1217 |
1222 // might trigger a TMMBN | 1218 if (!bounding.empty() && _cbRtcpBandwidthObserver) { |
1223 if (bounding.empty()) { | 1219 // We have a new bandwidth estimate on this channel. |
1224 // owner of max bitrate request has timed out | |
1225 // empty bounding set has been sent | |
1226 return 0; | |
1227 } | |
1228 // We have a new bandwidth estimate on this channel. | |
1229 if (_cbRtcpBandwidthObserver) { | |
1230 uint64_t bitrate_bps = TMMBRHelp::CalcMinBitrateBps(bounding); | 1220 uint64_t bitrate_bps = TMMBRHelp::CalcMinBitrateBps(bounding); |
1231 if (bitrate_bps <= std::numeric_limits<uint32_t>::max()) | 1221 if (bitrate_bps <= std::numeric_limits<uint32_t>::max()) |
1232 _cbRtcpBandwidthObserver->OnReceivedEstimatedBitrate(bitrate_bps); | 1222 _cbRtcpBandwidthObserver->OnReceivedEstimatedBitrate(bitrate_bps); |
1233 } | 1223 } |
1234 return 0; | 1224 |
| 1225 // Set bounding set: inform remote clients about the new bandwidth. |
| 1226 _rtpRtcp.SetTmmbn(std::move(bounding)); |
1235 } | 1227 } |
1236 | 1228 |
1237 void RTCPReceiver::RegisterRtcpStatisticsCallback( | 1229 void RTCPReceiver::RegisterRtcpStatisticsCallback( |
1238 RtcpStatisticsCallback* callback) { | 1230 RtcpStatisticsCallback* callback) { |
1239 rtc::CritScope cs(&_criticalSectionFeedbacks); | 1231 rtc::CritScope cs(&_criticalSectionFeedbacks); |
1240 stats_callback_ = callback; | 1232 stats_callback_ = callback; |
1241 } | 1233 } |
1242 | 1234 |
1243 RtcpStatisticsCallback* RTCPReceiver::GetRtcpStatisticsCallback() { | 1235 RtcpStatisticsCallback* RTCPReceiver::GetRtcpStatisticsCallback() { |
1244 rtc::CritScope cs(&_criticalSectionFeedbacks); | 1236 rtc::CritScope cs(&_criticalSectionFeedbacks); |
1245 return stats_callback_; | 1237 return stats_callback_; |
1246 } | 1238 } |
1247 | 1239 |
1248 // Holding no Critical section | 1240 // Holding no Critical section |
1249 void RTCPReceiver::TriggerCallbacksFromRTCPPacket( | 1241 void RTCPReceiver::TriggerCallbacksFromRTCPPacket( |
1250 RTCPPacketInformation& rtcpPacketInformation) { | 1242 RTCPPacketInformation& rtcpPacketInformation) { |
1251 // Process TMMBR and REMB first to avoid multiple callbacks | 1243 // Process TMMBR and REMB first to avoid multiple callbacks |
1252 // to OnNetworkChanged. | 1244 // to OnNetworkChanged. |
1253 if (rtcpPacketInformation.rtcpPacketTypeFlags & kRtcpTmmbr) { | 1245 if (rtcpPacketInformation.rtcpPacketTypeFlags & kRtcpTmmbr) { |
1254 // Might trigger a OnReceivedBandwidthEstimateUpdate. | 1246 // Might trigger a OnReceivedBandwidthEstimateUpdate. |
1255 UpdateTMMBR(); | 1247 UpdateTmmbr(); |
1256 } | 1248 } |
1257 uint32_t local_ssrc; | 1249 uint32_t local_ssrc; |
1258 std::set<uint32_t> registered_ssrcs; | 1250 std::set<uint32_t> registered_ssrcs; |
1259 { | 1251 { |
1260 // We don't want to hold this critsect when triggering the callbacks below. | 1252 // We don't want to hold this critsect when triggering the callbacks below. |
1261 rtc::CritScope lock(&_criticalSectionRTCPReceiver); | 1253 rtc::CritScope lock(&_criticalSectionRTCPReceiver); |
1262 local_ssrc = main_ssrc_; | 1254 local_ssrc = main_ssrc_; |
1263 registered_ssrcs = registered_ssrcs_; | 1255 registered_ssrcs = registered_ssrcs_; |
1264 } | 1256 } |
1265 if (!receiver_only_ && | 1257 if (!receiver_only_ && |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1359 rtc::CritScope lock(&_criticalSectionRTCPReceiver); | 1351 rtc::CritScope lock(&_criticalSectionRTCPReceiver); |
1360 RTCPCnameInformation* cnameInfo = GetCnameInformation(remoteSSRC); | 1352 RTCPCnameInformation* cnameInfo = GetCnameInformation(remoteSSRC); |
1361 if (cnameInfo == NULL) { | 1353 if (cnameInfo == NULL) { |
1362 return -1; | 1354 return -1; |
1363 } | 1355 } |
1364 cName[RTCP_CNAME_SIZE - 1] = 0; | 1356 cName[RTCP_CNAME_SIZE - 1] = 0; |
1365 strncpy(cName, cnameInfo->name, RTCP_CNAME_SIZE - 1); | 1357 strncpy(cName, cnameInfo->name, RTCP_CNAME_SIZE - 1); |
1366 return 0; | 1358 return 0; |
1367 } | 1359 } |
1368 | 1360 |
1369 std::vector<rtcp::TmmbItem> RTCPReceiver::TMMBRReceived() const { | 1361 std::vector<rtcp::TmmbItem> RTCPReceiver::TmmbrReceived() const { |
1370 rtc::CritScope lock(&_criticalSectionRTCPReceiver); | 1362 rtc::CritScope lock(&_criticalSectionRTCPReceiver); |
1371 std::vector<rtcp::TmmbItem> candidates; | 1363 std::vector<rtcp::TmmbItem> candidates; |
1372 | 1364 |
1373 int64_t now_ms = _clock->TimeInMilliseconds(); | 1365 int64_t now_ms = _clock->TimeInMilliseconds(); |
1374 | 1366 |
1375 for (const auto& kv : _receivedInfoMap) { | 1367 for (const auto& kv : _receivedInfoMap) { |
1376 RTCPReceiveInformation* receive_info = kv.second; | 1368 RTCPReceiveInformation* receive_info = kv.second; |
1377 RTC_DCHECK(receive_info); | 1369 RTC_DCHECK(receive_info); |
1378 receive_info->GetTmmbrSet(now_ms, &candidates); | 1370 receive_info->GetTmmbrSet(now_ms, &candidates); |
1379 } | 1371 } |
1380 return candidates; | 1372 return candidates; |
1381 } | 1373 } |
1382 | 1374 |
1383 } // namespace webrtc | 1375 } // namespace webrtc |
OLD | NEW |