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 18 matching lines...) Expand all Loading... | |
29 // The number of RTCP time intervals needed to trigger a timeout. | 29 // The number of RTCP time intervals needed to trigger a timeout. |
30 const int kRrTimeoutIntervals = 3; | 30 const int kRrTimeoutIntervals = 3; |
31 | 31 |
32 RTCPReceiver::RTCPReceiver( | 32 RTCPReceiver::RTCPReceiver( |
33 int32_t id, | 33 int32_t id, |
34 Clock* clock, | 34 Clock* clock, |
35 bool receiver_only, | 35 bool receiver_only, |
36 RtcpPacketTypeCounterObserver* packet_type_counter_observer, | 36 RtcpPacketTypeCounterObserver* packet_type_counter_observer, |
37 RtcpBandwidthObserver* rtcp_bandwidth_observer, | 37 RtcpBandwidthObserver* rtcp_bandwidth_observer, |
38 RtcpIntraFrameObserver* rtcp_intra_frame_observer, | 38 RtcpIntraFrameObserver* rtcp_intra_frame_observer, |
39 TransportFeedbackObserver* transport_feedback_observer, | |
39 ModuleRtpRtcpImpl* owner) | 40 ModuleRtpRtcpImpl* owner) |
40 : TMMBRHelp(), | 41 : TMMBRHelp(), |
41 _clock(clock), | 42 _clock(clock), |
42 receiver_only_(receiver_only), | 43 receiver_only_(receiver_only), |
43 _method(kRtcpOff), | 44 _method(kRtcpOff), |
44 _lastReceived(0), | 45 _lastReceived(0), |
45 _rtpRtcp(*owner), | 46 _rtpRtcp(*owner), |
46 _criticalSectionFeedbacks( | 47 _criticalSectionFeedbacks( |
47 CriticalSectionWrapper::CreateCriticalSection()), | 48 CriticalSectionWrapper::CreateCriticalSection()), |
48 _cbRtcpBandwidthObserver(rtcp_bandwidth_observer), | 49 _cbRtcpBandwidthObserver(rtcp_bandwidth_observer), |
49 _cbRtcpIntraFrameObserver(rtcp_intra_frame_observer), | 50 _cbRtcpIntraFrameObserver(rtcp_intra_frame_observer), |
51 _cbTransportFeedbackObserver(transport_feedback_observer), | |
50 _criticalSectionRTCPReceiver( | 52 _criticalSectionRTCPReceiver( |
51 CriticalSectionWrapper::CreateCriticalSection()), | 53 CriticalSectionWrapper::CreateCriticalSection()), |
52 main_ssrc_(0), | 54 main_ssrc_(0), |
53 _remoteSSRC(0), | 55 _remoteSSRC(0), |
54 _remoteSenderInfo(), | 56 _remoteSenderInfo(), |
55 _lastReceivedSRNTPsecs(0), | 57 _lastReceivedSRNTPsecs(0), |
56 _lastReceivedSRNTPfrac(0), | 58 _lastReceivedSRNTPfrac(0), |
57 _lastReceivedXRNTPsecs(0), | 59 _lastReceivedXRNTPsecs(0), |
58 _lastReceivedXRNTPfrac(0), | 60 _lastReceivedXRNTPfrac(0), |
59 xr_rr_rtt_ms_(0), | 61 xr_rr_rtt_ms_(0), |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
343 HandlePsfbApp(*rtcpParser, rtcpPacketInformation); | 345 HandlePsfbApp(*rtcpParser, rtcpPacketInformation); |
344 break; | 346 break; |
345 case RTCPPacketTypes::kApp: | 347 case RTCPPacketTypes::kApp: |
346 // generic application messages | 348 // generic application messages |
347 HandleAPP(*rtcpParser, rtcpPacketInformation); | 349 HandleAPP(*rtcpParser, rtcpPacketInformation); |
348 break; | 350 break; |
349 case RTCPPacketTypes::kAppItem: | 351 case RTCPPacketTypes::kAppItem: |
350 // generic application messages | 352 // generic application messages |
351 HandleAPPItem(*rtcpParser, rtcpPacketInformation); | 353 HandleAPPItem(*rtcpParser, rtcpPacketInformation); |
352 break; | 354 break; |
355 case RTCPPacketTypes::kTransportFeedback: | |
356 HandleTransportFeedback(rtcpParser, &rtcpPacketInformation); | |
357 break; | |
353 default: | 358 default: |
354 rtcpParser->Iterate(); | 359 rtcpParser->Iterate(); |
355 break; | 360 break; |
356 } | 361 } |
357 pktType = rtcpParser->PacketType(); | 362 pktType = rtcpParser->PacketType(); |
358 } | 363 } |
359 | 364 |
360 if (packet_type_counter_observer_ != NULL) { | 365 if (packet_type_counter_observer_ != NULL) { |
361 packet_type_counter_observer_->RtcpPacketTypesCounterUpdated( | 366 packet_type_counter_observer_->RtcpPacketTypesCounterUpdated( |
362 main_ssrc_, packet_type_counter_); | 367 main_ssrc_, packet_type_counter_); |
(...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1246 | 1251 |
1247 void RTCPReceiver::HandleAPPItem(RTCPUtility::RTCPParserV2& rtcpParser, | 1252 void RTCPReceiver::HandleAPPItem(RTCPUtility::RTCPParserV2& rtcpParser, |
1248 RTCPPacketInformation& rtcpPacketInformation) { | 1253 RTCPPacketInformation& rtcpPacketInformation) { |
1249 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet(); | 1254 const RTCPUtility::RTCPPacket& rtcpPacket = rtcpParser.Packet(); |
1250 | 1255 |
1251 rtcpPacketInformation.AddApplicationData(rtcpPacket.APP.Data, rtcpPacket.APP.S ize); | 1256 rtcpPacketInformation.AddApplicationData(rtcpPacket.APP.Data, rtcpPacket.APP.S ize); |
1252 | 1257 |
1253 rtcpParser.Iterate(); | 1258 rtcpParser.Iterate(); |
1254 } | 1259 } |
1255 | 1260 |
1261 void RTCPReceiver::HandleTransportFeedback( | |
1262 RTCPUtility::RTCPParserV2* rtcp_parser, | |
1263 RTCPHelp::RTCPPacketInformation* rtcp_packet_information) { | |
1264 rtcp::RtcpPacket* packet = rtcp_parser->ReleaseRtcpPacket(); | |
1265 DCHECK(packet != nullptr); | |
1266 rtcp_packet_information->rtcpPacketTypeFlags |= kRtcpTransportFeedback; | |
stefan-webrtc
2015/09/17 10:33:19
I find it a bit strange that we use this flag when
sprang_webrtc
2015/09/17 15:08:28
Yeah. I'm just following suit. Definitely the whol
stefan-webrtc
2015/09/18 10:57:23
I think we have to outline how this is going to lo
sprang_webrtc
2015/09/21 10:44:10
Why would we want to end up somewhere suboptimal?
stefan-webrtc
2015/09/21 11:13:16
I mostly meant that we probably should have an ide
| |
1267 rtcp_packet_information->transport_feedback_.reset( | |
1268 static_cast<rtcp::TransportFeedback*>(packet)); | |
1269 | |
1270 rtcp_parser->Iterate(); | |
1271 } | |
1256 int32_t RTCPReceiver::UpdateTMMBR() { | 1272 int32_t RTCPReceiver::UpdateTMMBR() { |
1257 int32_t numBoundingSet = 0; | 1273 int32_t numBoundingSet = 0; |
1258 uint32_t bitrate = 0; | 1274 uint32_t bitrate = 0; |
1259 uint32_t accNumCandidates = 0; | 1275 uint32_t accNumCandidates = 0; |
1260 | 1276 |
1261 int32_t size = TMMBRReceived(0, 0, NULL); | 1277 int32_t size = TMMBRReceived(0, 0, NULL); |
1262 if (size > 0) { | 1278 if (size > 0) { |
1263 TMMBRSet* candidateSet = VerifyAndAllocateCandidateSet(size); | 1279 TMMBRSet* candidateSet = VerifyAndAllocateCandidateSet(size); |
1264 // Get candidate set from receiver. | 1280 // Get candidate set from receiver. |
1265 accNumCandidates = TMMBRReceived(size, accNumCandidates, candidateSet); | 1281 accNumCandidates = TMMBRReceived(size, accNumCandidates, candidateSet); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1315 // Might trigger a OnReceivedBandwidthEstimateUpdate. | 1331 // Might trigger a OnReceivedBandwidthEstimateUpdate. |
1316 UpdateTMMBR(); | 1332 UpdateTMMBR(); |
1317 } | 1333 } |
1318 unsigned int local_ssrc; | 1334 unsigned int local_ssrc; |
1319 { | 1335 { |
1320 // We don't want to hold this critsect when triggering the callbacks below. | 1336 // We don't want to hold this critsect when triggering the callbacks below. |
1321 CriticalSectionScoped lock(_criticalSectionRTCPReceiver); | 1337 CriticalSectionScoped lock(_criticalSectionRTCPReceiver); |
1322 local_ssrc = main_ssrc_; | 1338 local_ssrc = main_ssrc_; |
1323 } | 1339 } |
1324 if (!receiver_only_ && | 1340 if (!receiver_only_ && |
1325 rtcpPacketInformation.rtcpPacketTypeFlags & kRtcpSrReq) { | 1341 (rtcpPacketInformation.rtcpPacketTypeFlags & kRtcpSrReq)) { |
1326 _rtpRtcp.OnRequestSendReport(); | 1342 _rtpRtcp.OnRequestSendReport(); |
1327 } | 1343 } |
1328 if (!receiver_only_ && | 1344 if (!receiver_only_ && |
1329 rtcpPacketInformation.rtcpPacketTypeFlags & kRtcpNack) { | 1345 (rtcpPacketInformation.rtcpPacketTypeFlags & kRtcpNack)) { |
1330 if (rtcpPacketInformation.nackSequenceNumbers.size() > 0) { | 1346 if (rtcpPacketInformation.nackSequenceNumbers.size() > 0) { |
1331 LOG(LS_VERBOSE) << "Incoming NACK length: " | 1347 LOG(LS_VERBOSE) << "Incoming NACK length: " |
1332 << rtcpPacketInformation.nackSequenceNumbers.size(); | 1348 << rtcpPacketInformation.nackSequenceNumbers.size(); |
1333 _rtpRtcp.OnReceivedNACK(rtcpPacketInformation.nackSequenceNumbers); | 1349 _rtpRtcp.OnReceivedNACK(rtcpPacketInformation.nackSequenceNumbers); |
1334 } | 1350 } |
1335 } | 1351 } |
1336 { | 1352 { |
1337 // We need feedback that we have received a report block(s) so that we | 1353 // We need feedback that we have received a report block(s) so that we |
1338 // can generate a new packet in a conference relay scenario, one received | 1354 // can generate a new packet in a conference relay scenario, one received |
1339 // report can generate several RTCP packets, based on number relayed/mixed | 1355 // report can generate several RTCP packets, based on number relayed/mixed |
(...skipping 30 matching lines...) Expand all Loading... | |
1370 } | 1386 } |
1371 if ((rtcpPacketInformation.rtcpPacketTypeFlags & kRtcpSr) || | 1387 if ((rtcpPacketInformation.rtcpPacketTypeFlags & kRtcpSr) || |
1372 (rtcpPacketInformation.rtcpPacketTypeFlags & kRtcpRr)) { | 1388 (rtcpPacketInformation.rtcpPacketTypeFlags & kRtcpRr)) { |
1373 int64_t now = _clock->TimeInMilliseconds(); | 1389 int64_t now = _clock->TimeInMilliseconds(); |
1374 _cbRtcpBandwidthObserver->OnReceivedRtcpReceiverReport( | 1390 _cbRtcpBandwidthObserver->OnReceivedRtcpReceiverReport( |
1375 rtcpPacketInformation.report_blocks, | 1391 rtcpPacketInformation.report_blocks, |
1376 rtcpPacketInformation.rtt, | 1392 rtcpPacketInformation.rtt, |
1377 now); | 1393 now); |
1378 } | 1394 } |
1379 } | 1395 } |
1396 if (_cbTransportFeedbackObserver && | |
1397 (rtcpPacketInformation.rtcpPacketTypeFlags & kRtcpTransportFeedback)) { | |
1398 uint32_t media_source_ssrc = | |
1399 rtcpPacketInformation.transport_feedback_->GetMediaSourceSsrc(); | |
1400 if (media_source_ssrc == main_ssrc_ || | |
1401 registered_ssrcs_.find(media_source_ssrc) != | |
1402 registered_ssrcs_.end()) { | |
1403 _cbTransportFeedbackObserver->OnTransportFeedback( | |
1404 *rtcpPacketInformation.transport_feedback_.get()); | |
1405 } | |
1406 } | |
1380 } | 1407 } |
1381 | 1408 |
1382 if (!receiver_only_) { | 1409 if (!receiver_only_) { |
1383 CriticalSectionScoped cs(_criticalSectionFeedbacks); | 1410 CriticalSectionScoped cs(_criticalSectionFeedbacks); |
1384 if (stats_callback_) { | 1411 if (stats_callback_) { |
1385 for (ReportBlockList::const_iterator it = | 1412 for (ReportBlockList::const_iterator it = |
1386 rtcpPacketInformation.report_blocks.begin(); | 1413 rtcpPacketInformation.report_blocks.begin(); |
1387 it != rtcpPacketInformation.report_blocks.end(); | 1414 it != rtcpPacketInformation.report_blocks.end(); |
1388 ++it) { | 1415 ++it) { |
1389 RtcpStatistics stats; | 1416 RtcpStatistics stats; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1446 return -1; | 1473 return -1; |
1447 } | 1474 } |
1448 num += receiveInfo->TmmbrSet.lengthOfSet(); | 1475 num += receiveInfo->TmmbrSet.lengthOfSet(); |
1449 receiveInfoIt++; | 1476 receiveInfoIt++; |
1450 } | 1477 } |
1451 } | 1478 } |
1452 return num; | 1479 return num; |
1453 } | 1480 } |
1454 | 1481 |
1455 } // namespace webrtc | 1482 } // namespace webrtc |
OLD | NEW |