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

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

Issue 2366563002: Move class RTCPHelp::RTCPPacketInformation into RTCPReceiver (Closed)
Patch Set: Remove rtcp_receiver from lint exceptions Created 4 years, 2 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
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> 16 #include <limits>
17 #include <memory>
18 #include <utility>
17 19
18 #include "webrtc/base/checks.h" 20 #include "webrtc/base/checks.h"
19 #include "webrtc/base/logging.h" 21 #include "webrtc/base/logging.h"
20 #include "webrtc/base/trace_event.h" 22 #include "webrtc/base/trace_event.h"
21 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h" 23 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h"
22 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/common_header.h" 24 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/common_header.h"
23 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/compound_packet.h" 25 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/compound_packet.h"
24 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_reports.h" 26 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_reports.h"
25 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/fir.h" 27 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/fir.h"
26 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/nack.h" 28 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/nack.h"
(...skipping 11 matching lines...) Expand all
38 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" 40 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h"
39 #include "webrtc/modules/rtp_rtcp/source/time_util.h" 41 #include "webrtc/modules/rtp_rtcp/source/time_util.h"
40 #include "webrtc/modules/rtp_rtcp/source/tmmbr_help.h" 42 #include "webrtc/modules/rtp_rtcp/source/tmmbr_help.h"
41 #include "webrtc/system_wrappers/include/ntp_time.h" 43 #include "webrtc/system_wrappers/include/ntp_time.h"
42 44
43 namespace webrtc { 45 namespace webrtc {
44 namespace { 46 namespace {
45 47
46 using rtcp::CommonHeader; 48 using rtcp::CommonHeader;
47 using rtcp::ReportBlock; 49 using rtcp::ReportBlock;
48 using RTCPHelp::RTCPPacketInformation;
49 using RTCPHelp::RTCPReceiveInformation; 50 using RTCPHelp::RTCPReceiveInformation;
50 using RTCPHelp::RTCPReportBlockInformation; 51 using RTCPHelp::RTCPReportBlockInformation;
51 using RTCPUtility::RTCPCnameInformation; 52 using RTCPUtility::RTCPCnameInformation;
52 using RTCPUtility::RTCPPacketReportBlockItem; 53 using RTCPUtility::RTCPPacketReportBlockItem;
53 using RTCPUtility::RTCPPacketTypes; 54 using RTCPUtility::RTCPPacketTypes;
54 55
55 // The number of RTCP time intervals needed to trigger a timeout. 56 // The number of RTCP time intervals needed to trigger a timeout.
56 const int kRrTimeoutIntervals = 3; 57 const int kRrTimeoutIntervals = 3;
57 58
58 const int64_t kMaxWarningLogIntervalMs = 10000; 59 const int64_t kMaxWarningLogIntervalMs = 10000;
59 60
60 } // namespace 61 } // namespace
61 62
63 class RTCPReceiver::PacketInformation {
64 public:
65 PacketInformation();
66 ~PacketInformation();
67
68 void AddReportInfo(const RTCPReportBlockInformation& report_block_info);
69
70 uint32_t rtcpPacketTypeFlags; // RTCPPacketTypeFlags bit field
philipel 2016/09/23 11:33:01 Change all camelCase to use underscore as separato
danilchap 2016/09/23 12:35:55 Planned to do PacketInformation cleanup in follow-
71 uint32_t remoteSSRC;
72
73 std::vector<uint16_t> nackSequenceNumbers;
74
75 ReportBlockList report_blocks;
76 int64_t rtt;
77
78 uint8_t sliPictureId;
79 uint64_t rpsiPictureId;
80 uint32_t receiverEstimatedMaxBitrate;
81
82 uint32_t ntp_secs;
83 uint32_t ntp_frac;
84 uint32_t rtp_timestamp;
85
86 uint32_t xr_originator_ssrc;
87 bool xr_dlrr_item;
88
89 std::unique_ptr<rtcp::TransportFeedback> transport_feedback_;
90
91 private:
92 RTC_DISALLOW_COPY_AND_ASSIGN(PacketInformation);
93 };
94
95 RTCPReceiver::PacketInformation::PacketInformation()
96 : rtcpPacketTypeFlags(0),
97 remoteSSRC(0),
98 nackSequenceNumbers(),
99 rtt(0),
100 sliPictureId(0),
101 rpsiPictureId(0),
102 receiverEstimatedMaxBitrate(0),
103 ntp_secs(0),
104 ntp_frac(0),
105 rtp_timestamp(0),
106 xr_originator_ssrc(0),
107 xr_dlrr_item(false) {}
108
109 RTCPReceiver::PacketInformation::~PacketInformation() {}
philipel 2016/09/23 11:33:01 Remove dtor
danilchap 2016/09/23 12:35:55 Done.
110
111 void RTCPReceiver::PacketInformation::AddReportInfo(
112 const RTCPReportBlockInformation& report_block_info) {
113 this->rtt = report_block_info.RTT;
114 report_blocks.push_back(report_block_info.remoteReceiveBlock);
115 }
116
62 RTCPReceiver::RTCPReceiver( 117 RTCPReceiver::RTCPReceiver(
63 Clock* clock, 118 Clock* clock,
64 bool receiver_only, 119 bool receiver_only,
65 RtcpPacketTypeCounterObserver* packet_type_counter_observer, 120 RtcpPacketTypeCounterObserver* packet_type_counter_observer,
66 RtcpBandwidthObserver* rtcp_bandwidth_observer, 121 RtcpBandwidthObserver* rtcp_bandwidth_observer,
67 RtcpIntraFrameObserver* rtcp_intra_frame_observer, 122 RtcpIntraFrameObserver* rtcp_intra_frame_observer,
68 TransportFeedbackObserver* transport_feedback_observer, 123 TransportFeedbackObserver* transport_feedback_observer,
69 ModuleRtpRtcp* owner) 124 ModuleRtpRtcp* owner)
70 : _clock(clock), 125 : _clock(clock),
71 receiver_only_(receiver_only), 126 receiver_only_(receiver_only),
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 _receivedCnameMap.erase(first); 170 _receivedCnameMap.erase(first);
116 } 171 }
117 } 172 }
118 173
119 bool RTCPReceiver::IncomingPacket(const uint8_t* packet, size_t packet_size) { 174 bool RTCPReceiver::IncomingPacket(const uint8_t* packet, size_t packet_size) {
120 if (packet_size == 0) { 175 if (packet_size == 0) {
121 LOG(LS_WARNING) << "Incoming empty RTCP packet"; 176 LOG(LS_WARNING) << "Incoming empty RTCP packet";
122 return false; 177 return false;
123 } 178 }
124 179
125 RTCPHelp::RTCPPacketInformation packet_information; 180 PacketInformation packet_information;
126 if (!ParseCompoundPacket(packet, packet + packet_size, &packet_information)) 181 if (!ParseCompoundPacket(packet, packet + packet_size, &packet_information))
127 return false; 182 return false;
128 TriggerCallbacksFromRTCPPacket(packet_information); 183 TriggerCallbacksFromRTCPPacket(packet_information);
129 return true; 184 return true;
130 } 185 }
131 186
132 int64_t RTCPReceiver::LastReceivedReceiverReport() const { 187 int64_t RTCPReceiver::LastReceivedReceiverReport() const {
133 rtc::CritScope lock(&_criticalSectionRTCPReceiver); 188 rtc::CritScope lock(&_criticalSectionRTCPReceiver);
134 int64_t last_received_rr = -1; 189 int64_t last_received_rr = -1;
135 for (ReceivedInfoMap::const_iterator it = _receivedInfoMap.begin(); 190 for (ReceivedInfoMap::const_iterator it = _receivedInfoMap.begin();
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 for (; it != _receivedReportBlockMap.end(); ++it) { 344 for (; it != _receivedReportBlockMap.end(); ++it) {
290 const ReportBlockInfoMap* info_map = &(it->second); 345 const ReportBlockInfoMap* info_map = &(it->second);
291 ReportBlockInfoMap::const_iterator it_info = info_map->begin(); 346 ReportBlockInfoMap::const_iterator it_info = info_map->begin();
292 for (; it_info != info_map->end(); ++it_info) { 347 for (; it_info != info_map->end(); ++it_info) {
293 receiveBlocks->push_back(it_info->second->remoteReceiveBlock); 348 receiveBlocks->push_back(it_info->second->remoteReceiveBlock);
294 } 349 }
295 } 350 }
296 return 0; 351 return 0;
297 } 352 }
298 353
299 bool RTCPReceiver::ParseCompoundPacket( 354 bool RTCPReceiver::ParseCompoundPacket(const uint8_t* packet_begin,
300 const uint8_t* packet_begin, 355 const uint8_t* packet_end,
301 const uint8_t* packet_end, 356 PacketInformation* packet_information) {
302 RTCPPacketInformation* packet_information) {
303 rtc::CritScope lock(&_criticalSectionRTCPReceiver); 357 rtc::CritScope lock(&_criticalSectionRTCPReceiver);
304 358
305 CommonHeader rtcp_block; 359 CommonHeader rtcp_block;
306 for (const uint8_t* next_block = packet_begin; next_block != packet_end; 360 for (const uint8_t* next_block = packet_begin; next_block != packet_end;
307 next_block = rtcp_block.NextPacket()) { 361 next_block = rtcp_block.NextPacket()) {
308 ptrdiff_t remaining_blocks_size = packet_end - next_block; 362 ptrdiff_t remaining_blocks_size = packet_end - next_block;
309 RTC_DCHECK_GT(remaining_blocks_size, 0); 363 RTC_DCHECK_GT(remaining_blocks_size, 0);
310 if (!rtcp_block.Parse(next_block, remaining_blocks_size)) { 364 if (!rtcp_block.Parse(next_block, remaining_blocks_size)) {
311 if (next_block == packet_begin) { 365 if (next_block == packet_begin) {
312 // Failed to parse 1st header, nothing was extracted from this packet. 366 // Failed to parse 1st header, nothing was extracted from this packet.
313 LOG(LS_WARNING) << "Incoming invalid RTCP packet"; 367 LOG(LS_WARNING) << "Incoming invalid RTCP packet";
314 return false; 368 return false;
315 } 369 }
316 ++num_skipped_packets_; 370 ++num_skipped_packets_;
317 break; 371 break;
318 } 372 }
319 373
320 if (packet_type_counter_.first_packet_time_ms == -1) 374 if (packet_type_counter_.first_packet_time_ms == -1)
321 packet_type_counter_.first_packet_time_ms = _clock->TimeInMilliseconds(); 375 packet_type_counter_.first_packet_time_ms = _clock->TimeInMilliseconds();
322 376
323 switch (rtcp_block.type()) { 377 switch (rtcp_block.type()) {
324 case rtcp::SenderReport::kPacketType: 378 case rtcp::SenderReport::kPacketType:
325 HandleSenderReport(rtcp_block, *packet_information); 379 HandleSenderReport(rtcp_block, packet_information);
326 break; 380 break;
327 case rtcp::ReceiverReport::kPacketType: 381 case rtcp::ReceiverReport::kPacketType:
328 HandleReceiverReport(rtcp_block, *packet_information); 382 HandleReceiverReport(rtcp_block, packet_information);
329 break; 383 break;
330 case rtcp::Sdes::kPacketType: 384 case rtcp::Sdes::kPacketType:
331 HandleSDES(rtcp_block, *packet_information); 385 HandleSDES(rtcp_block, packet_information);
332 break; 386 break;
333 case rtcp::ExtendedReports::kPacketType: 387 case rtcp::ExtendedReports::kPacketType:
334 HandleXr(rtcp_block, *packet_information); 388 HandleXr(rtcp_block, packet_information);
335 break; 389 break;
336 case rtcp::Bye::kPacketType: 390 case rtcp::Bye::kPacketType:
337 HandleBYE(rtcp_block); 391 HandleBYE(rtcp_block);
338 break; 392 break;
339 case rtcp::Rtpfb::kPacketType: 393 case rtcp::Rtpfb::kPacketType:
340 switch (rtcp_block.fmt()) { 394 switch (rtcp_block.fmt()) {
341 case rtcp::Nack::kFeedbackMessageType: 395 case rtcp::Nack::kFeedbackMessageType:
342 HandleNACK(rtcp_block, *packet_information); 396 HandleNACK(rtcp_block, packet_information);
343 break; 397 break;
344 case rtcp::Tmmbr::kFeedbackMessageType: 398 case rtcp::Tmmbr::kFeedbackMessageType:
345 HandleTMMBR(rtcp_block, *packet_information); 399 HandleTMMBR(rtcp_block, packet_information);
346 break; 400 break;
347 case rtcp::Tmmbn::kFeedbackMessageType: 401 case rtcp::Tmmbn::kFeedbackMessageType:
348 HandleTMMBN(rtcp_block, *packet_information); 402 HandleTMMBN(rtcp_block, packet_information);
349 break; 403 break;
350 case rtcp::RapidResyncRequest::kFeedbackMessageType: 404 case rtcp::RapidResyncRequest::kFeedbackMessageType:
351 HandleSR_REQ(rtcp_block, *packet_information); 405 HandleSR_REQ(rtcp_block, packet_information);
352 break; 406 break;
353 case rtcp::TransportFeedback::kFeedbackMessageType: 407 case rtcp::TransportFeedback::kFeedbackMessageType:
354 HandleTransportFeedback(rtcp_block, packet_information); 408 HandleTransportFeedback(rtcp_block, packet_information);
355 break; 409 break;
356 default: 410 default:
357 ++num_skipped_packets_; 411 ++num_skipped_packets_;
358 break; 412 break;
359 } 413 }
360 break; 414 break;
361 case rtcp::Psfb::kPacketType: 415 case rtcp::Psfb::kPacketType:
362 switch (rtcp_block.fmt()) { 416 switch (rtcp_block.fmt()) {
363 case rtcp::Pli::kFeedbackMessageType: 417 case rtcp::Pli::kFeedbackMessageType:
364 HandlePLI(rtcp_block, *packet_information); 418 HandlePLI(rtcp_block, packet_information);
365 break; 419 break;
366 case rtcp::Sli::kFeedbackMessageType: 420 case rtcp::Sli::kFeedbackMessageType:
367 HandleSLI(rtcp_block, *packet_information); 421 HandleSLI(rtcp_block, packet_information);
368 break; 422 break;
369 case rtcp::Rpsi::kFeedbackMessageType: 423 case rtcp::Rpsi::kFeedbackMessageType:
370 HandleRPSI(rtcp_block, *packet_information); 424 HandleRPSI(rtcp_block, packet_information);
371 break; 425 break;
372 case rtcp::Fir::kFeedbackMessageType: 426 case rtcp::Fir::kFeedbackMessageType:
373 HandleFIR(rtcp_block, *packet_information); 427 HandleFIR(rtcp_block, packet_information);
374 break; 428 break;
375 case rtcp::Remb::kFeedbackMessageType: 429 case rtcp::Remb::kFeedbackMessageType:
376 HandlePsfbApp(rtcp_block, *packet_information); 430 HandlePsfbApp(rtcp_block, packet_information);
377 break; 431 break;
378 default: 432 default:
379 ++num_skipped_packets_; 433 ++num_skipped_packets_;
380 break; 434 break;
381 } 435 }
382 break; 436 break;
383 default: 437 default:
384 ++num_skipped_packets_; 438 ++num_skipped_packets_;
385 break; 439 break;
386 } 440 }
(...skipping 10 matching lines...) Expand all
397 last_skipped_packets_warning_ = now; 451 last_skipped_packets_warning_ = now;
398 LOG(LS_WARNING) << num_skipped_packets_ 452 LOG(LS_WARNING) << num_skipped_packets_
399 << " RTCP blocks were skipped due to being malformed or of " 453 << " RTCP blocks were skipped due to being malformed or of "
400 "unrecognized/unsupported type, during the past " 454 "unrecognized/unsupported type, during the past "
401 << (kMaxWarningLogIntervalMs / 1000) << " second period."; 455 << (kMaxWarningLogIntervalMs / 1000) << " second period.";
402 } 456 }
403 457
404 return true; 458 return true;
405 } 459 }
406 460
407 void RTCPReceiver::HandleSenderReport( 461 void RTCPReceiver::HandleSenderReport(const CommonHeader& rtcp_block,
408 const CommonHeader& rtcp_block, 462 PacketInformation* packet_information) {
409 RTCPPacketInformation& rtcpPacketInformation) {
410 rtcp::SenderReport sender_report; 463 rtcp::SenderReport sender_report;
411 if (!sender_report.Parse(rtcp_block)) { 464 if (!sender_report.Parse(rtcp_block)) {
412 ++num_skipped_packets_; 465 ++num_skipped_packets_;
413 return; 466 return;
414 } 467 }
415 468
416 const uint32_t remoteSSRC = sender_report.sender_ssrc(); 469 const uint32_t remoteSSRC = sender_report.sender_ssrc();
417 470
418 rtcpPacketInformation.remoteSSRC = remoteSSRC; 471 packet_information->remoteSSRC = remoteSSRC;
419 472
420 RTCPReceiveInformation* ptrReceiveInfo = CreateReceiveInformation(remoteSSRC); 473 RTCPReceiveInformation* ptrReceiveInfo = CreateReceiveInformation(remoteSSRC);
421 if (!ptrReceiveInfo) 474 if (!ptrReceiveInfo)
422 return; 475 return;
423 476
424 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "SR", 477 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "SR",
425 "remote_ssrc", remoteSSRC, "ssrc", main_ssrc_); 478 "remote_ssrc", remoteSSRC, "ssrc", main_ssrc_);
426 479
427 // Have I received RTP packets from this party? 480 // Have I received RTP packets from this party?
428 if (_remoteSSRC == remoteSSRC) { 481 if (_remoteSSRC == remoteSSRC) {
429 // Only signal that we have received a SR when we accept one. 482 // Only signal that we have received a SR when we accept one.
430 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpSr; 483 packet_information->rtcpPacketTypeFlags |= kRtcpSr;
431 484
432 rtcpPacketInformation.ntp_secs = sender_report.ntp().seconds(); 485 packet_information->ntp_secs = sender_report.ntp().seconds();
433 rtcpPacketInformation.ntp_frac = sender_report.ntp().fractions(); 486 packet_information->ntp_frac = sender_report.ntp().fractions();
434 rtcpPacketInformation.rtp_timestamp = sender_report.rtp_timestamp(); 487 packet_information->rtp_timestamp = sender_report.rtp_timestamp();
435 488
436 // Save the NTP time of this report. 489 // Save the NTP time of this report.
437 _remoteSenderInfo.NTPseconds = sender_report.ntp().seconds(); 490 _remoteSenderInfo.NTPseconds = sender_report.ntp().seconds();
438 _remoteSenderInfo.NTPfraction = sender_report.ntp().fractions(); 491 _remoteSenderInfo.NTPfraction = sender_report.ntp().fractions();
439 _remoteSenderInfo.RTPtimeStamp = sender_report.rtp_timestamp(); 492 _remoteSenderInfo.RTPtimeStamp = sender_report.rtp_timestamp();
440 _remoteSenderInfo.sendPacketCount = sender_report.sender_packet_count(); 493 _remoteSenderInfo.sendPacketCount = sender_report.sender_packet_count();
441 _remoteSenderInfo.sendOctetCount = sender_report.sender_octet_count(); 494 _remoteSenderInfo.sendOctetCount = sender_report.sender_octet_count();
442 495
443 _clock->CurrentNtp(_lastReceivedSRNTPsecs, _lastReceivedSRNTPfrac); 496 _clock->CurrentNtp(_lastReceivedSRNTPsecs, _lastReceivedSRNTPfrac);
444 } else { 497 } else {
445 // We will only store the send report from one source, but 498 // We will only store the send report from one source, but
446 // we will store all the receive blocks. 499 // we will store all the receive blocks.
447 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpRr; 500 packet_information->rtcpPacketTypeFlags |= kRtcpRr;
448 } 501 }
449 // Update that this remote is alive. 502 // Update that this remote is alive.
450 ptrReceiveInfo->last_time_received_ms = _clock->TimeInMilliseconds(); 503 ptrReceiveInfo->last_time_received_ms = _clock->TimeInMilliseconds();
451 504
452 for (const rtcp::ReportBlock report_block : sender_report.report_blocks()) 505 for (const rtcp::ReportBlock report_block : sender_report.report_blocks())
453 HandleReportBlock(report_block, rtcpPacketInformation, remoteSSRC); 506 HandleReportBlock(report_block, packet_information, remoteSSRC);
454 } 507 }
455 508
456 void RTCPReceiver::HandleReceiverReport( 509 void RTCPReceiver::HandleReceiverReport(const CommonHeader& rtcp_block,
457 const CommonHeader& rtcp_block, 510 PacketInformation* packet_information) {
458 RTCPPacketInformation& rtcpPacketInformation) {
459 rtcp::ReceiverReport receiver_report; 511 rtcp::ReceiverReport receiver_report;
460 if (!receiver_report.Parse(rtcp_block)) { 512 if (!receiver_report.Parse(rtcp_block)) {
461 ++num_skipped_packets_; 513 ++num_skipped_packets_;
462 return; 514 return;
463 } 515 }
464 516
465 const uint32_t remoteSSRC = receiver_report.sender_ssrc(); 517 const uint32_t remoteSSRC = receiver_report.sender_ssrc();
466 518
467 rtcpPacketInformation.remoteSSRC = remoteSSRC; 519 packet_information->remoteSSRC = remoteSSRC;
468 520
469 RTCPReceiveInformation* ptrReceiveInfo = CreateReceiveInformation(remoteSSRC); 521 RTCPReceiveInformation* ptrReceiveInfo = CreateReceiveInformation(remoteSSRC);
470 if (!ptrReceiveInfo) 522 if (!ptrReceiveInfo)
471 return; 523 return;
472 524
473 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "RR", 525 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "RR",
474 "remote_ssrc", remoteSSRC, "ssrc", main_ssrc_); 526 "remote_ssrc", remoteSSRC, "ssrc", main_ssrc_);
475 527
476 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpRr; 528 packet_information->rtcpPacketTypeFlags |= kRtcpRr;
477 529
478 // Update that this remote is alive. 530 // Update that this remote is alive.
479 ptrReceiveInfo->last_time_received_ms = _clock->TimeInMilliseconds(); 531 ptrReceiveInfo->last_time_received_ms = _clock->TimeInMilliseconds();
480 532
481 for (const ReportBlock& report_block : receiver_report.report_blocks()) 533 for (const ReportBlock& report_block : receiver_report.report_blocks())
482 HandleReportBlock(report_block, rtcpPacketInformation, remoteSSRC); 534 HandleReportBlock(report_block, packet_information, remoteSSRC);
483 } 535 }
484 536
485 void RTCPReceiver::HandleReportBlock( 537 void RTCPReceiver::HandleReportBlock(const ReportBlock& report_block,
486 const ReportBlock& report_block, 538 PacketInformation* packet_information,
487 RTCPPacketInformation& rtcpPacketInformation, 539 uint32_t remoteSSRC) {
488 uint32_t remoteSSRC) {
489 // This will be called once per report block in the RTCP packet. 540 // This will be called once per report block in the RTCP packet.
490 // We filter out all report blocks that are not for us. 541 // We filter out all report blocks that are not for us.
491 // Each packet has max 31 RR blocks. 542 // Each packet has max 31 RR blocks.
492 // 543 //
493 // We can calc RTT if we send a send report and get a report block back. 544 // We can calc RTT if we send a send report and get a report block back.
494 545
495 // |rtcpPacket.ReportBlockItem.SSRC| is the SSRC identifier of the source to 546 // |rtcpPacket.ReportBlockItem.SSRC| is the SSRC identifier of the source to
496 // which the information in this reception report block pertains. 547 // which the information in this reception report block pertains.
497 548
498 // Filter out all report blocks that are not for us. 549 // Filter out all report blocks that are not for us.
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 } else { 618 } else {
568 // First RTT. 619 // First RTT.
569 reportBlock->avgRTT = rtt; 620 reportBlock->avgRTT = rtt;
570 } 621 }
571 reportBlock->numAverageCalcs++; 622 reportBlock->numAverageCalcs++;
572 } 623 }
573 624
574 TRACE_COUNTER_ID1(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "RR_RTT", 625 TRACE_COUNTER_ID1(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "RR_RTT",
575 report_block.source_ssrc(), rtt); 626 report_block.source_ssrc(), rtt);
576 627
577 rtcpPacketInformation.AddReportInfo(*reportBlock); 628 packet_information->AddReportInfo(*reportBlock);
578 } 629 }
579 630
580 RTCPReportBlockInformation* RTCPReceiver::CreateOrGetReportBlockInformation( 631 RTCPReportBlockInformation* RTCPReceiver::CreateOrGetReportBlockInformation(
581 uint32_t remote_ssrc, 632 uint32_t remote_ssrc,
582 uint32_t source_ssrc) { 633 uint32_t source_ssrc) {
583 RTCPReportBlockInformation* info = 634 RTCPReportBlockInformation* info =
584 GetReportBlockInformation(remote_ssrc, source_ssrc); 635 GetReportBlockInformation(remote_ssrc, source_ssrc);
585 if (info == NULL) { 636 if (info == NULL) {
586 info = new RTCPReportBlockInformation; 637 info = new RTCPReportBlockInformation;
587 _receivedReportBlockMap[source_ssrc][remote_ssrc] = info; 638 _receivedReportBlockMap[source_ssrc][remote_ssrc] = info;
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 return std::vector<rtcp::TmmbItem>(); 794 return std::vector<rtcp::TmmbItem>();
744 } 795 }
745 RTCPReceiveInformation* receiveInfo = receiveInfoIt->second; 796 RTCPReceiveInformation* receiveInfo = receiveInfoIt->second;
746 RTC_DCHECK(receiveInfo); 797 RTC_DCHECK(receiveInfo);
747 798
748 *tmmbr_owner = TMMBRHelp::IsOwner(receiveInfo->tmmbn, main_ssrc_); 799 *tmmbr_owner = TMMBRHelp::IsOwner(receiveInfo->tmmbn, main_ssrc_);
749 return receiveInfo->tmmbn; 800 return receiveInfo->tmmbn;
750 } 801 }
751 802
752 void RTCPReceiver::HandleSDES(const CommonHeader& rtcp_block, 803 void RTCPReceiver::HandleSDES(const CommonHeader& rtcp_block,
753 RTCPPacketInformation& rtcpPacketInformation) { 804 PacketInformation* packet_information) {
754 rtcp::Sdes sdes; 805 rtcp::Sdes sdes;
755 if (!sdes.Parse(rtcp_block)) { 806 if (!sdes.Parse(rtcp_block)) {
756 ++num_skipped_packets_; 807 ++num_skipped_packets_;
757 return; 808 return;
758 } 809 }
759 810
760 for (const rtcp::Sdes::Chunk& chunk : sdes.chunks()) { 811 for (const rtcp::Sdes::Chunk& chunk : sdes.chunks()) {
761 RTCPCnameInformation* cnameInfo = CreateCnameInformation(chunk.ssrc); 812 RTCPCnameInformation* cnameInfo = CreateCnameInformation(chunk.ssrc);
762 RTC_DCHECK(cnameInfo); 813 RTC_DCHECK(cnameInfo);
763 814
764 cnameInfo->name[RTCP_CNAME_SIZE - 1] = 0; 815 cnameInfo->name[RTCP_CNAME_SIZE - 1] = 0;
765 strncpy(cnameInfo->name, chunk.cname.c_str(), RTCP_CNAME_SIZE - 1); 816 strncpy(cnameInfo->name, chunk.cname.c_str(), RTCP_CNAME_SIZE - 1);
766 { 817 {
767 rtc::CritScope lock(&_criticalSectionFeedbacks); 818 rtc::CritScope lock(&_criticalSectionFeedbacks);
768 if (stats_callback_) 819 if (stats_callback_)
769 stats_callback_->CNameChanged(chunk.cname.c_str(), chunk.ssrc); 820 stats_callback_->CNameChanged(chunk.cname.c_str(), chunk.ssrc);
770 } 821 }
771 } 822 }
772 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpSdes; 823 packet_information->rtcpPacketTypeFlags |= kRtcpSdes;
773 } 824 }
774 825
775 void RTCPReceiver::HandleNACK(const CommonHeader& rtcp_block, 826 void RTCPReceiver::HandleNACK(const CommonHeader& rtcp_block,
776 RTCPPacketInformation& rtcpPacketInformation) { 827 PacketInformation* packet_information) {
777 rtcp::Nack nack; 828 rtcp::Nack nack;
778 if (!nack.Parse(rtcp_block)) { 829 if (!nack.Parse(rtcp_block)) {
779 ++num_skipped_packets_; 830 ++num_skipped_packets_;
780 return; 831 return;
781 } 832 }
782 833
783 if (receiver_only_ || main_ssrc_ != nack.media_ssrc()) // Not to us. 834 if (receiver_only_ || main_ssrc_ != nack.media_ssrc()) // Not to us.
784 return; 835 return;
785 836
786 rtcpPacketInformation.nackSequenceNumbers = nack.packet_ids(); 837 packet_information->nackSequenceNumbers = nack.packet_ids();
787 for (uint16_t packet_id : nack.packet_ids()) 838 for (uint16_t packet_id : nack.packet_ids())
788 nack_stats_.ReportRequest(packet_id); 839 nack_stats_.ReportRequest(packet_id);
789 840
790 if (!nack.packet_ids().empty()) { 841 if (!nack.packet_ids().empty()) {
791 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpNack; 842 packet_information->rtcpPacketTypeFlags |= kRtcpNack;
792 ++packet_type_counter_.nack_packets; 843 ++packet_type_counter_.nack_packets;
793 packet_type_counter_.nack_requests = nack_stats_.requests(); 844 packet_type_counter_.nack_requests = nack_stats_.requests();
794 packet_type_counter_.unique_nack_requests = nack_stats_.unique_requests(); 845 packet_type_counter_.unique_nack_requests = nack_stats_.unique_requests();
795 } 846 }
796 } 847 }
797 848
798 void RTCPReceiver::HandleBYE(const CommonHeader& rtcp_block) { 849 void RTCPReceiver::HandleBYE(const CommonHeader& rtcp_block) {
799 rtcp::Bye bye; 850 rtcp::Bye bye;
800 if (!bye.Parse(rtcp_block)) { 851 if (!bye.Parse(rtcp_block)) {
801 ++num_skipped_packets_; 852 ++num_skipped_packets_;
(...skipping 22 matching lines...) Expand all
824 _receivedCnameMap.find(bye.sender_ssrc()); 875 _receivedCnameMap.find(bye.sender_ssrc());
825 876
826 if (cnameInfoIt != _receivedCnameMap.end()) { 877 if (cnameInfoIt != _receivedCnameMap.end()) {
827 delete cnameInfoIt->second; 878 delete cnameInfoIt->second;
828 _receivedCnameMap.erase(cnameInfoIt); 879 _receivedCnameMap.erase(cnameInfoIt);
829 } 880 }
830 xr_rr_rtt_ms_ = 0; 881 xr_rr_rtt_ms_ = 0;
831 } 882 }
832 883
833 void RTCPReceiver::HandleXr(const CommonHeader& rtcp_block, 884 void RTCPReceiver::HandleXr(const CommonHeader& rtcp_block,
834 RTCPPacketInformation& rtcpPacketInformation) { 885 PacketInformation* packet_information) {
835 rtcp::ExtendedReports xr; 886 rtcp::ExtendedReports xr;
836 if (!xr.Parse(rtcp_block)) { 887 if (!xr.Parse(rtcp_block)) {
837 ++num_skipped_packets_; 888 ++num_skipped_packets_;
838 return; 889 return;
839 } 890 }
840 891
841 rtcpPacketInformation.xr_originator_ssrc = xr.sender_ssrc(); 892 packet_information->xr_originator_ssrc = xr.sender_ssrc();
842 for (const rtcp::Rrtr& rrtr : xr.rrtrs()) 893 for (const rtcp::Rrtr& rrtr : xr.rrtrs())
843 HandleXrReceiveReferenceTime(rrtr, rtcpPacketInformation); 894 HandleXrReceiveReferenceTime(rrtr, packet_information);
844 895
845 for (const rtcp::Dlrr& dlrr : xr.dlrrs()) { 896 for (const rtcp::Dlrr& dlrr : xr.dlrrs()) {
846 for (const rtcp::ReceiveTimeInfo& time_info : dlrr.sub_blocks()) 897 for (const rtcp::ReceiveTimeInfo& time_info : dlrr.sub_blocks())
847 HandleXrDlrrReportBlock(time_info, rtcpPacketInformation); 898 HandleXrDlrrReportBlock(time_info, packet_information);
848 } 899 }
849 } 900 }
850 901
851 void RTCPReceiver::HandleXrReceiveReferenceTime( 902 void RTCPReceiver::HandleXrReceiveReferenceTime(
852 const rtcp::Rrtr& rrtr, 903 const rtcp::Rrtr& rrtr,
853 RTCPPacketInformation& rtcpPacketInformation) { 904 PacketInformation* packet_information) {
854 _remoteXRReceiveTimeInfo.sourceSSRC = 905 _remoteXRReceiveTimeInfo.sourceSSRC = packet_information->xr_originator_ssrc;
855 rtcpPacketInformation.xr_originator_ssrc;
856 906
857 _remoteXRReceiveTimeInfo.lastRR = CompactNtp(rrtr.ntp()); 907 _remoteXRReceiveTimeInfo.lastRR = CompactNtp(rrtr.ntp());
858 908
859 _clock->CurrentNtp(_lastReceivedXRNTPsecs, _lastReceivedXRNTPfrac); 909 _clock->CurrentNtp(_lastReceivedXRNTPsecs, _lastReceivedXRNTPfrac);
860 910
861 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpXrReceiverReferenceTime; 911 packet_information->rtcpPacketTypeFlags |= kRtcpXrReceiverReferenceTime;
862 } 912 }
863 913
864 void RTCPReceiver::HandleXrDlrrReportBlock( 914 void RTCPReceiver::HandleXrDlrrReportBlock(
865 const rtcp::ReceiveTimeInfo& rti, 915 const rtcp::ReceiveTimeInfo& rti,
866 RTCPPacketInformation& rtcpPacketInformation) { 916 PacketInformation* packet_information) {
867 if (registered_ssrcs_.count(rti.ssrc) == 0) // Not to us. 917 if (registered_ssrcs_.count(rti.ssrc) == 0) // Not to us.
868 return; 918 return;
869 919
870 rtcpPacketInformation.xr_dlrr_item = true; 920 packet_information->xr_dlrr_item = true;
871 921
872 // Caller should explicitly enable rtt calculation using extended reports. 922 // Caller should explicitly enable rtt calculation using extended reports.
873 if (!xr_rrtr_status_) 923 if (!xr_rrtr_status_)
874 return; 924 return;
875 925
876 // The send_time and delay_rr fields are in units of 1/2^16 sec. 926 // The send_time and delay_rr fields are in units of 1/2^16 sec.
877 uint32_t send_time = rti.last_rr; 927 uint32_t send_time = rti.last_rr;
878 // RFC3611, section 4.5, LRR field discription states: 928 // RFC3611, section 4.5, LRR field discription states:
879 // If no such block has been received, the field is set to zero. 929 // If no such block has been received, the field is set to zero.
880 if (send_time == 0) 930 if (send_time == 0)
881 return; 931 return;
882 932
883 uint32_t delay_rr = rti.delay_since_last_rr; 933 uint32_t delay_rr = rti.delay_since_last_rr;
884 uint32_t now = CompactNtp(NtpTime(*_clock)); 934 uint32_t now = CompactNtp(NtpTime(*_clock));
885 935
886 uint32_t rtt_ntp = now - delay_rr - send_time; 936 uint32_t rtt_ntp = now - delay_rr - send_time;
887 xr_rr_rtt_ms_ = CompactNtpRttToMs(rtt_ntp); 937 xr_rr_rtt_ms_ = CompactNtpRttToMs(rtt_ntp);
888 938
889 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpXrDlrrReportBlock; 939 packet_information->rtcpPacketTypeFlags |= kRtcpXrDlrrReportBlock;
890 } 940 }
891 941
892 void RTCPReceiver::HandlePLI(const CommonHeader& rtcp_block, 942 void RTCPReceiver::HandlePLI(const CommonHeader& rtcp_block,
893 RTCPPacketInformation& rtcpPacketInformation) { 943 PacketInformation* packet_information) {
894 rtcp::Pli pli; 944 rtcp::Pli pli;
895 if (!pli.Parse(rtcp_block)) { 945 if (!pli.Parse(rtcp_block)) {
896 ++num_skipped_packets_; 946 ++num_skipped_packets_;
897 return; 947 return;
898 } 948 }
899 949
900 if (main_ssrc_ == pli.media_ssrc()) { 950 if (main_ssrc_ == pli.media_ssrc()) {
901 TRACE_EVENT_INSTANT0(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "PLI"); 951 TRACE_EVENT_INSTANT0(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "PLI");
902 952
903 ++packet_type_counter_.pli_packets; 953 ++packet_type_counter_.pli_packets;
904 // Received a signal that we need to send a new key frame. 954 // Received a signal that we need to send a new key frame.
905 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpPli; 955 packet_information->rtcpPacketTypeFlags |= kRtcpPli;
906 } 956 }
907 } 957 }
908 958
909 void RTCPReceiver::HandleTMMBR(const CommonHeader& rtcp_block, 959 void RTCPReceiver::HandleTMMBR(const CommonHeader& rtcp_block,
910 RTCPPacketInformation& rtcpPacketInformation) { 960 PacketInformation* packet_information) {
911 rtcp::Tmmbr tmmbr; 961 rtcp::Tmmbr tmmbr;
912 if (!tmmbr.Parse(rtcp_block)) { 962 if (!tmmbr.Parse(rtcp_block)) {
913 ++num_skipped_packets_; 963 ++num_skipped_packets_;
914 return; 964 return;
915 } 965 }
916 966
917 uint32_t senderSSRC = tmmbr.sender_ssrc(); 967 uint32_t senderSSRC = tmmbr.sender_ssrc();
918 RTCPReceiveInformation* ptrReceiveInfo = GetReceiveInformation(senderSSRC); 968 RTCPReceiveInformation* ptrReceiveInfo = GetReceiveInformation(senderSSRC);
919 if (!ptrReceiveInfo) // This remote SSRC must be saved before. 969 if (!ptrReceiveInfo) // This remote SSRC must be saved before.
920 return; 970 return;
921 971
922 if (tmmbr.media_ssrc()) { 972 if (tmmbr.media_ssrc()) {
923 // media_ssrc() SHOULD be 0 if same as SenderSSRC. 973 // media_ssrc() SHOULD be 0 if same as SenderSSRC.
924 // In relay mode this is a valid number. 974 // In relay mode this is a valid number.
925 senderSSRC = tmmbr.media_ssrc(); 975 senderSSRC = tmmbr.media_ssrc();
926 } 976 }
927 977
928 for (const rtcp::TmmbItem& request : tmmbr.requests()) { 978 for (const rtcp::TmmbItem& request : tmmbr.requests()) {
929 if (main_ssrc_ == request.ssrc() && request.bitrate_bps()) { 979 if (main_ssrc_ == request.ssrc() && request.bitrate_bps()) {
930 ptrReceiveInfo->InsertTmmbrItem(senderSSRC, request, 980 ptrReceiveInfo->InsertTmmbrItem(senderSSRC, request,
931 _clock->TimeInMilliseconds()); 981 _clock->TimeInMilliseconds());
932 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpTmmbr; 982 packet_information->rtcpPacketTypeFlags |= kRtcpTmmbr;
933 } 983 }
934 } 984 }
935 } 985 }
936 986
937 void RTCPReceiver::HandleTMMBN(const CommonHeader& rtcp_block, 987 void RTCPReceiver::HandleTMMBN(const CommonHeader& rtcp_block,
938 RTCPPacketInformation& rtcpPacketInformation) { 988 PacketInformation* packet_information) {
939 rtcp::Tmmbn tmmbn; 989 rtcp::Tmmbn tmmbn;
940 if (!tmmbn.Parse(rtcp_block)) { 990 if (!tmmbn.Parse(rtcp_block)) {
941 ++num_skipped_packets_; 991 ++num_skipped_packets_;
942 return; 992 return;
943 } 993 }
944 994
945 RTCPReceiveInformation* ptrReceiveInfo = 995 RTCPReceiveInformation* ptrReceiveInfo =
946 GetReceiveInformation(tmmbn.sender_ssrc()); 996 GetReceiveInformation(tmmbn.sender_ssrc());
947 if (!ptrReceiveInfo) // This remote SSRC must be saved before. 997 if (!ptrReceiveInfo) // This remote SSRC must be saved before.
948 return; 998 return;
949 999
950 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpTmmbn; 1000 packet_information->rtcpPacketTypeFlags |= kRtcpTmmbn;
951 1001
952 for (const auto& item : tmmbn.items()) 1002 for (const auto& item : tmmbn.items())
953 ptrReceiveInfo->tmmbn.push_back(item); 1003 ptrReceiveInfo->tmmbn.push_back(item);
954 } 1004 }
955 1005
956 void RTCPReceiver::HandleSR_REQ(const CommonHeader& rtcp_block, 1006 void RTCPReceiver::HandleSR_REQ(const CommonHeader& rtcp_block,
957 RTCPPacketInformation& rtcpPacketInformation) { 1007 PacketInformation* packet_information) {
958 rtcp::RapidResyncRequest sr_req; 1008 rtcp::RapidResyncRequest sr_req;
959 if (!sr_req.Parse(rtcp_block)) { 1009 if (!sr_req.Parse(rtcp_block)) {
960 ++num_skipped_packets_; 1010 ++num_skipped_packets_;
961 return; 1011 return;
962 } 1012 }
963 1013
964 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpSrReq; 1014 packet_information->rtcpPacketTypeFlags |= kRtcpSrReq;
965 } 1015 }
966 1016
967 void RTCPReceiver::HandleSLI(const CommonHeader& rtcp_block, 1017 void RTCPReceiver::HandleSLI(const CommonHeader& rtcp_block,
968 RTCPPacketInformation& rtcpPacketInformation) { 1018 PacketInformation* packet_information) {
969 rtcp::Sli sli; 1019 rtcp::Sli sli;
970 if (!sli.Parse(rtcp_block)) { 1020 if (!sli.Parse(rtcp_block)) {
971 ++num_skipped_packets_; 1021 ++num_skipped_packets_;
972 return; 1022 return;
973 } 1023 }
974 1024
975 for (const rtcp::Sli::Macroblocks& item : sli.macroblocks()) { 1025 for (const rtcp::Sli::Macroblocks& item : sli.macroblocks()) {
976 // In theory there could be multiple slices lost. 1026 // In theory there could be multiple slices lost.
977 // Received signal that we need to refresh a slice. 1027 // Received signal that we need to refresh a slice.
978 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpSli; 1028 packet_information->rtcpPacketTypeFlags |= kRtcpSli;
979 rtcpPacketInformation.sliPictureId = item.picture_id(); 1029 packet_information->sliPictureId = item.picture_id();
980 } 1030 }
981 } 1031 }
982 1032
983 void RTCPReceiver::HandleRPSI( 1033 void RTCPReceiver::HandleRPSI(const CommonHeader& rtcp_block,
984 const CommonHeader& rtcp_block, 1034 PacketInformation* packet_information) {
985 RTCPHelp::RTCPPacketInformation& rtcpPacketInformation) {
986 rtcp::Rpsi rpsi; 1035 rtcp::Rpsi rpsi;
987 if (!rpsi.Parse(rtcp_block)) { 1036 if (!rpsi.Parse(rtcp_block)) {
988 ++num_skipped_packets_; 1037 ++num_skipped_packets_;
989 return; 1038 return;
990 } 1039 }
991 1040
992 // Received signal that we have a confirmed reference picture. 1041 // Received signal that we have a confirmed reference picture.
993 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpRpsi; 1042 packet_information->rtcpPacketTypeFlags |= kRtcpRpsi;
994 rtcpPacketInformation.rpsiPictureId = rpsi.picture_id(); 1043 packet_information->rpsiPictureId = rpsi.picture_id();
995 } 1044 }
996 1045
997 void RTCPReceiver::HandlePsfbApp(const CommonHeader& rtcp_block, 1046 void RTCPReceiver::HandlePsfbApp(const CommonHeader& rtcp_block,
998 RTCPPacketInformation& rtcpPacketInformation) { 1047 PacketInformation* packet_information) {
999 rtcp::Remb remb; 1048 rtcp::Remb remb;
1000 if (remb.Parse(rtcp_block)) { 1049 if (remb.Parse(rtcp_block)) {
1001 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpRemb; 1050 packet_information->rtcpPacketTypeFlags |= kRtcpRemb;
1002 rtcpPacketInformation.receiverEstimatedMaxBitrate = remb.bitrate_bps(); 1051 packet_information->receiverEstimatedMaxBitrate = remb.bitrate_bps();
1003 return; 1052 return;
1004 } 1053 }
1005 1054
1006 ++num_skipped_packets_; 1055 ++num_skipped_packets_;
1007 } 1056 }
1008 1057
1009 void RTCPReceiver::HandleFIR(const CommonHeader& rtcp_block, 1058 void RTCPReceiver::HandleFIR(const CommonHeader& rtcp_block,
1010 RTCPPacketInformation& rtcpPacketInformation) { 1059 PacketInformation* packet_information) {
1011 rtcp::Fir fir; 1060 rtcp::Fir fir;
1012 if (!fir.Parse(rtcp_block)) { 1061 if (!fir.Parse(rtcp_block)) {
1013 ++num_skipped_packets_; 1062 ++num_skipped_packets_;
1014 return; 1063 return;
1015 } 1064 }
1016 1065
1017 RTCPReceiveInformation* ptrReceiveInfo = 1066 RTCPReceiveInformation* ptrReceiveInfo =
1018 GetReceiveInformation(fir.sender_ssrc()); 1067 GetReceiveInformation(fir.sender_ssrc());
1019 1068
1020 for (const rtcp::Fir::Request& fir_request : fir.requests()) { 1069 for (const rtcp::Fir::Request& fir_request : fir.requests()) {
1021 // Is it our sender that is requested to generate a new keyframe 1070 // Is it our sender that is requested to generate a new keyframe
1022 if (main_ssrc_ != fir_request.ssrc) 1071 if (main_ssrc_ != fir_request.ssrc)
1023 continue; 1072 continue;
1024 1073
1025 ++packet_type_counter_.fir_packets; 1074 ++packet_type_counter_.fir_packets;
1026 1075
1027 // rtcpPacket.FIR.MediaSSRC SHOULD be 0 but we ignore to check it 1076 // rtcpPacket.FIR.MediaSSRC SHOULD be 0 but we ignore to check it
1028 // we don't know who this originate from 1077 // we don't know who this originate from
1029 if (ptrReceiveInfo) { 1078 if (ptrReceiveInfo) {
1030 // check if we have reported this FIRSequenceNumber before 1079 // check if we have reported this FIRSequenceNumber before
1031 if (fir_request.seq_nr != ptrReceiveInfo->last_fir_sequence_number) { 1080 if (fir_request.seq_nr != ptrReceiveInfo->last_fir_sequence_number) {
1032 int64_t now = _clock->TimeInMilliseconds(); 1081 int64_t now = _clock->TimeInMilliseconds();
1033 // sanity; don't go crazy with the callbacks 1082 // sanity; don't go crazy with the callbacks
1034 if ((now - ptrReceiveInfo->last_fir_request_ms) > 1083 if ((now - ptrReceiveInfo->last_fir_request_ms) >
1035 RTCP_MIN_FRAME_LENGTH_MS) { 1084 RTCP_MIN_FRAME_LENGTH_MS) {
1036 ptrReceiveInfo->last_fir_request_ms = now; 1085 ptrReceiveInfo->last_fir_request_ms = now;
1037 ptrReceiveInfo->last_fir_sequence_number = fir_request.seq_nr; 1086 ptrReceiveInfo->last_fir_sequence_number = fir_request.seq_nr;
1038 // received signal that we need to send a new key frame 1087 // received signal that we need to send a new key frame
1039 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpFir; 1088 packet_information->rtcpPacketTypeFlags |= kRtcpFir;
1040 } 1089 }
1041 } 1090 }
1042 } else { 1091 } else {
1043 // received signal that we need to send a new key frame 1092 // received signal that we need to send a new key frame
1044 rtcpPacketInformation.rtcpPacketTypeFlags |= kRtcpFir; 1093 packet_information->rtcpPacketTypeFlags |= kRtcpFir;
1045 } 1094 }
1046 } 1095 }
1047 } 1096 }
1048 1097
1049 void RTCPReceiver::HandleTransportFeedback( 1098 void RTCPReceiver::HandleTransportFeedback(
1050 const CommonHeader& rtcp_block, 1099 const CommonHeader& rtcp_block,
1051 RTCPHelp::RTCPPacketInformation* rtcp_packet_information) { 1100 PacketInformation* packet_information) {
1052 std::unique_ptr<rtcp::TransportFeedback> transport_feedback( 1101 std::unique_ptr<rtcp::TransportFeedback> transport_feedback(
1053 new rtcp::TransportFeedback()); 1102 new rtcp::TransportFeedback());
1054 if (!transport_feedback->Parse(rtcp_block)) { 1103 if (!transport_feedback->Parse(rtcp_block)) {
1055 ++num_skipped_packets_; 1104 ++num_skipped_packets_;
1056 return; 1105 return;
1057 } 1106 }
1058 1107
1059 rtcp_packet_information->rtcpPacketTypeFlags |= kRtcpTransportFeedback; 1108 packet_information->rtcpPacketTypeFlags |= kRtcpTransportFeedback;
1060 rtcp_packet_information->transport_feedback_ = std::move(transport_feedback); 1109 packet_information->transport_feedback_ = std::move(transport_feedback);
1061 } 1110 }
1062 1111
1063 void RTCPReceiver::UpdateTmmbr() { 1112 void RTCPReceiver::UpdateTmmbr() {
1064 // Find bounding set. 1113 // Find bounding set.
1065 std::vector<rtcp::TmmbItem> bounding = 1114 std::vector<rtcp::TmmbItem> bounding =
1066 TMMBRHelp::FindBoundingSet(TmmbrReceived()); 1115 TMMBRHelp::FindBoundingSet(TmmbrReceived());
1067 1116
1068 if (!bounding.empty() && _cbRtcpBandwidthObserver) { 1117 if (!bounding.empty() && _cbRtcpBandwidthObserver) {
1069 // We have a new bandwidth estimate on this channel. 1118 // We have a new bandwidth estimate on this channel.
1070 uint64_t bitrate_bps = TMMBRHelp::CalcMinBitrateBps(bounding); 1119 uint64_t bitrate_bps = TMMBRHelp::CalcMinBitrateBps(bounding);
(...skipping 11 matching lines...) Expand all
1082 stats_callback_ = callback; 1131 stats_callback_ = callback;
1083 } 1132 }
1084 1133
1085 RtcpStatisticsCallback* RTCPReceiver::GetRtcpStatisticsCallback() { 1134 RtcpStatisticsCallback* RTCPReceiver::GetRtcpStatisticsCallback() {
1086 rtc::CritScope cs(&_criticalSectionFeedbacks); 1135 rtc::CritScope cs(&_criticalSectionFeedbacks);
1087 return stats_callback_; 1136 return stats_callback_;
1088 } 1137 }
1089 1138
1090 // Holding no Critical section 1139 // Holding no Critical section
1091 void RTCPReceiver::TriggerCallbacksFromRTCPPacket( 1140 void RTCPReceiver::TriggerCallbacksFromRTCPPacket(
1092 RTCPPacketInformation& rtcpPacketInformation) { 1141 const PacketInformation& rtcpPacketInformation) {
1093 // Process TMMBR and REMB first to avoid multiple callbacks 1142 // Process TMMBR and REMB first to avoid multiple callbacks
1094 // to OnNetworkChanged. 1143 // to OnNetworkChanged.
1095 if (rtcpPacketInformation.rtcpPacketTypeFlags & kRtcpTmmbr) { 1144 if (rtcpPacketInformation.rtcpPacketTypeFlags & kRtcpTmmbr) {
1096 // Might trigger a OnReceivedBandwidthEstimateUpdate. 1145 // Might trigger a OnReceivedBandwidthEstimateUpdate.
1097 UpdateTmmbr(); 1146 UpdateTmmbr();
1098 } 1147 }
1099 uint32_t local_ssrc; 1148 uint32_t local_ssrc;
1100 std::set<uint32_t> registered_ssrcs; 1149 std::set<uint32_t> registered_ssrcs;
1101 { 1150 {
1102 // We don't want to hold this critsect when triggering the callbacks below. 1151 // We don't want to hold this critsect when triggering the callbacks below.
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 1265
1217 for (const auto& kv : _receivedInfoMap) { 1266 for (const auto& kv : _receivedInfoMap) {
1218 RTCPReceiveInformation* receive_info = kv.second; 1267 RTCPReceiveInformation* receive_info = kv.second;
1219 RTC_DCHECK(receive_info); 1268 RTC_DCHECK(receive_info);
1220 receive_info->GetTmmbrSet(now_ms, &candidates); 1269 receive_info->GetTmmbrSet(now_ms, &candidates);
1221 } 1270 }
1222 return candidates; 1271 return candidates;
1223 } 1272 }
1224 1273
1225 } // namespace webrtc 1274 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtcp_receiver.h ('k') | webrtc/modules/rtp_rtcp/source/rtcp_receiver_help.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698