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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
102 | 102 |
103 // TODO(pwestin) move to constructors of each rtp/rtcp sender/receiver object. | 103 // TODO(pwestin) move to constructors of each rtp/rtcp sender/receiver object. |
104 rtcp_sender_.RegisterSendTransport(configuration.outgoing_transport); | 104 rtcp_sender_.RegisterSendTransport(configuration.outgoing_transport); |
105 | 105 |
106 // Make sure that RTCP objects are aware of our SSRC. | 106 // Make sure that RTCP objects are aware of our SSRC. |
107 uint32_t SSRC = rtp_sender_.SSRC(); | 107 uint32_t SSRC = rtp_sender_.SSRC(); |
108 rtcp_sender_.SetSSRC(SSRC); | 108 rtcp_sender_.SetSSRC(SSRC); |
109 SetRtcpReceiverSsrcs(SSRC); | 109 SetRtcpReceiverSsrcs(SSRC); |
110 } | 110 } |
111 | 111 |
112 ModuleRtpRtcpImpl::~ModuleRtpRtcpImpl() { | |
113 for (auto loss_stats : receive_loss_stats_) { | |
114 delete loss_stats.second; | |
115 } | |
116 } | |
117 | |
112 // Returns the number of milliseconds until the module want a worker thread | 118 // Returns the number of milliseconds until the module want a worker thread |
113 // to call Process. | 119 // to call Process. |
114 int64_t ModuleRtpRtcpImpl::TimeUntilNextProcess() { | 120 int64_t ModuleRtpRtcpImpl::TimeUntilNextProcess() { |
115 const int64_t now = clock_->TimeInMilliseconds(); | 121 const int64_t now = clock_->TimeInMilliseconds(); |
116 const int64_t kRtpRtcpMaxIdleTimeProcessMs = 5; | 122 const int64_t kRtpRtcpMaxIdleTimeProcessMs = 5; |
117 return kRtpRtcpMaxIdleTimeProcessMs - (now - last_process_time_); | 123 return kRtpRtcpMaxIdleTimeProcessMs - (now - last_process_time_); |
118 } | 124 } |
119 | 125 |
120 // Process any pending tasks such as timeouts (non time critical events). | 126 // Process any pending tasks such as timeouts (non time critical events). |
121 int32_t ModuleRtpRtcpImpl::Process() { | 127 int32_t ModuleRtpRtcpImpl::Process() { |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
604 } | 610 } |
605 return 0; | 611 return 0; |
606 } | 612 } |
607 | 613 |
608 void ModuleRtpRtcpImpl::GetSendStreamDataCounters( | 614 void ModuleRtpRtcpImpl::GetSendStreamDataCounters( |
609 StreamDataCounters* rtp_counters, | 615 StreamDataCounters* rtp_counters, |
610 StreamDataCounters* rtx_counters) const { | 616 StreamDataCounters* rtx_counters) const { |
611 rtp_sender_.GetDataCounters(rtp_counters, rtx_counters); | 617 rtp_sender_.GetDataCounters(rtp_counters, rtx_counters); |
612 } | 618 } |
613 | 619 |
620 void ModuleRtpRtcpImpl::GetRtpPacketLossStats( | |
621 bool outgoing, | |
622 uint32_t ssrc, | |
623 struct RtpPacketLossStats* loss_stats) const { | |
624 if (!loss_stats) return; | |
625 const PacketLossStats* stats_source = NULL; | |
626 if (outgoing) { | |
627 if (SSRC() == ssrc) { | |
628 stats_source = &send_loss_stats_; | |
629 } | |
630 } else { | |
631 auto it = receive_loss_stats_.find(ssrc); | |
632 if (it != receive_loss_stats_.end()) { | |
633 stats_source = it->second; | |
634 } | |
635 } | |
636 if (stats_source) { | |
637 loss_stats->single_packet_loss_count = | |
638 stats_source->GetSingleLossCount(); | |
639 loss_stats->multiple_packet_loss_event_count = | |
640 stats_source->GetMultipleLossEventCount(); | |
641 loss_stats->multiple_packet_loss_packet_count = | |
642 stats_source->GetMultipleLossPacketCount(); | |
643 } | |
644 } | |
645 | |
614 int32_t ModuleRtpRtcpImpl::RemoteRTCPStat(RTCPSenderInfo* sender_info) { | 646 int32_t ModuleRtpRtcpImpl::RemoteRTCPStat(RTCPSenderInfo* sender_info) { |
615 return rtcp_receiver_.SenderInfoReceived(sender_info); | 647 return rtcp_receiver_.SenderInfoReceived(sender_info); |
616 } | 648 } |
617 | 649 |
618 // Received RTCP report. | 650 // Received RTCP report. |
619 int32_t ModuleRtpRtcpImpl::RemoteRTCPStat( | 651 int32_t ModuleRtpRtcpImpl::RemoteRTCPStat( |
620 std::vector<RTCPReportBlock>* receive_blocks) const { | 652 std::vector<RTCPReportBlock>* receive_blocks) const { |
621 return rtcp_receiver_.StatisticsReceived(receive_blocks); | 653 return rtcp_receiver_.StatisticsReceived(receive_blocks); |
622 } | 654 } |
623 | 655 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
677 | 709 |
678 // Enable or disable a retransmission mode, which decides which packets will | 710 // Enable or disable a retransmission mode, which decides which packets will |
679 // be retransmitted if NACKed. | 711 // be retransmitted if NACKed. |
680 int ModuleRtpRtcpImpl::SetSelectiveRetransmissions(uint8_t settings) { | 712 int ModuleRtpRtcpImpl::SetSelectiveRetransmissions(uint8_t settings) { |
681 return rtp_sender_.SetSelectiveRetransmissions(settings); | 713 return rtp_sender_.SetSelectiveRetransmissions(settings); |
682 } | 714 } |
683 | 715 |
684 // Send a Negative acknowledgment packet. | 716 // Send a Negative acknowledgment packet. |
685 int32_t ModuleRtpRtcpImpl::SendNACK(const uint16_t* nack_list, | 717 int32_t ModuleRtpRtcpImpl::SendNACK(const uint16_t* nack_list, |
686 const uint16_t size) { | 718 const uint16_t size) { |
719 uint32_t remote_ssrc = rtcp_receiver_.RemoteSSRC(); | |
720 auto it = receive_loss_stats_.find(remote_ssrc); | |
åsapersson
2015/07/06 13:57:24
The remote_ssrc is the SSRC of the received media
bcornell
2015/07/08 18:28:12
You're right, I had confused myself into thinking
| |
721 PacketLossStats* receive_stats; | |
722 if (it == receive_loss_stats_.end()) { | |
723 receive_stats = new PacketLossStats(); | |
724 receive_loss_stats_[remote_ssrc] = receive_stats; | |
725 } else { | |
726 receive_stats = it->second; | |
727 } | |
728 for (int i = 0; i < size; ++i) { | |
729 receive_stats->AddLostPacket(nack_list[i]); | |
730 } | |
stefan-webrtc
2015/07/06 14:13:36
Is this new functionality supposed to track how of
bcornell
2015/07/08 18:28:12
It uses how often a packet is NACKed as an approxi
åsapersson
2015/07/09 06:26:54
If this is for tracking packet loss, there is a cl
| |
687 uint16_t nack_length = size; | 731 uint16_t nack_length = size; |
688 uint16_t start_id = 0; | 732 uint16_t start_id = 0; |
689 int64_t now = clock_->TimeInMilliseconds(); | 733 int64_t now = clock_->TimeInMilliseconds(); |
690 if (TimeToSendFullNackList(now)) { | 734 if (TimeToSendFullNackList(now)) { |
691 nack_last_time_sent_full_ = now; | 735 nack_last_time_sent_full_ = now; |
692 nack_last_time_sent_full_prev_ = now; | 736 nack_last_time_sent_full_prev_ = now; |
693 } else { | 737 } else { |
694 // Only send extended list. | 738 // Only send extended list. |
695 if (nack_last_seq_number_sent_ == nack_list[size - 1]) { | 739 if (nack_last_seq_number_sent_ == nack_list[size - 1]) { |
696 // Last sequence number is the same, do not send list. | 740 // Last sequence number is the same, do not send list. |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
892 return rtcp_sender_.SendTimeOfSendReport(send_report); | 936 return rtcp_sender_.SendTimeOfSendReport(send_report); |
893 } | 937 } |
894 | 938 |
895 bool ModuleRtpRtcpImpl::SendTimeOfXrRrReport( | 939 bool ModuleRtpRtcpImpl::SendTimeOfXrRrReport( |
896 uint32_t mid_ntp, int64_t* time_ms) const { | 940 uint32_t mid_ntp, int64_t* time_ms) const { |
897 return rtcp_sender_.SendTimeOfXrRrReport(mid_ntp, time_ms); | 941 return rtcp_sender_.SendTimeOfXrRrReport(mid_ntp, time_ms); |
898 } | 942 } |
899 | 943 |
900 void ModuleRtpRtcpImpl::OnReceivedNACK( | 944 void ModuleRtpRtcpImpl::OnReceivedNACK( |
901 const std::list<uint16_t>& nack_sequence_numbers) { | 945 const std::list<uint16_t>& nack_sequence_numbers) { |
946 for (uint16_t nack_sequence_number : nack_sequence_numbers) { | |
947 send_loss_stats_.AddLostPacket(nack_sequence_number); | |
948 } | |
902 if (!rtp_sender_.StorePackets() || | 949 if (!rtp_sender_.StorePackets() || |
903 nack_sequence_numbers.size() == 0) { | 950 nack_sequence_numbers.size() == 0) { |
904 return; | 951 return; |
905 } | 952 } |
906 // Use RTT from RtcpRttStats class if provided. | 953 // Use RTT from RtcpRttStats class if provided. |
907 int64_t rtt = rtt_ms(); | 954 int64_t rtt = rtt_ms(); |
908 if (rtt == 0) { | 955 if (rtt == 0) { |
909 rtcp_receiver_.RTT(rtcp_receiver_.RemoteSSRC(), NULL, &rtt, NULL, NULL); | 956 rtcp_receiver_.RTT(rtcp_receiver_.RemoteSSRC(), NULL, &rtt, NULL, NULL); |
910 } | 957 } |
911 rtp_sender_.OnReceivedNACK(nack_sequence_numbers, rtt); | 958 rtp_sender_.OnReceivedNACK(nack_sequence_numbers, rtt); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
976 void ModuleRtpRtcpImpl::RegisterSendChannelRtpStatisticsCallback( | 1023 void ModuleRtpRtcpImpl::RegisterSendChannelRtpStatisticsCallback( |
977 StreamDataCountersCallback* callback) { | 1024 StreamDataCountersCallback* callback) { |
978 rtp_sender_.RegisterRtpStatisticsCallback(callback); | 1025 rtp_sender_.RegisterRtpStatisticsCallback(callback); |
979 } | 1026 } |
980 | 1027 |
981 StreamDataCountersCallback* | 1028 StreamDataCountersCallback* |
982 ModuleRtpRtcpImpl::GetSendChannelRtpStatisticsCallback() const { | 1029 ModuleRtpRtcpImpl::GetSendChannelRtpStatisticsCallback() const { |
983 return rtp_sender_.GetRtpStatisticsCallback(); | 1030 return rtp_sender_.GetRtpStatisticsCallback(); |
984 } | 1031 } |
985 } // namespace webrtc | 1032 } // namespace webrtc |
OLD | NEW |