| 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 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 821 rtc::CritScope lock(&send_critsect_); | 821 rtc::CritScope lock(&send_critsect_); |
| 822 media_has_been_sent_ = true; | 822 media_has_been_sent_ = true; |
| 823 } | 823 } |
| 824 UpdateRtpStats(*packet_to_send, send_over_rtx, is_retransmit); | 824 UpdateRtpStats(*packet_to_send, send_over_rtx, is_retransmit); |
| 825 return true; | 825 return true; |
| 826 } | 826 } |
| 827 | 827 |
| 828 void RTPSender::UpdateRtpStats(const RtpPacketToSend& packet, | 828 void RTPSender::UpdateRtpStats(const RtpPacketToSend& packet, |
| 829 bool is_rtx, | 829 bool is_rtx, |
| 830 bool is_retransmit) { | 830 bool is_retransmit) { |
| 831 StreamDataCounters* counters; | |
| 832 // Get ssrc before taking statistics_crit_ to avoid possible deadlock. | |
| 833 uint32_t ssrc = is_rtx ? RtxSsrc() : SSRC(); | |
| 834 int64_t now_ms = clock_->TimeInMilliseconds(); | 831 int64_t now_ms = clock_->TimeInMilliseconds(); |
| 835 | 832 |
| 836 rtc::CritScope lock(&statistics_crit_); | 833 rtc::CritScope lock(&statistics_crit_); |
| 837 if (is_rtx) { | 834 StreamDataCounters* counters = is_rtx ? &rtx_rtp_stats_ : &rtp_stats_; |
| 838 counters = &rtx_rtp_stats_; | |
| 839 } else { | |
| 840 counters = &rtp_stats_; | |
| 841 } | |
| 842 | 835 |
| 843 total_bitrate_sent_.Update(packet.size(), now_ms); | 836 total_bitrate_sent_.Update(packet.size(), now_ms); |
| 844 | 837 |
| 845 if (counters->first_packet_time_ms == -1) { | 838 if (counters->first_packet_time_ms == -1) |
| 846 counters->first_packet_time_ms = clock_->TimeInMilliseconds(); | 839 counters->first_packet_time_ms = now_ms; |
| 847 } | 840 |
| 848 if (IsFecPacket(packet)) { | 841 if (IsFecPacket(packet)) |
| 849 CountPacket(&counters->fec, packet); | 842 CountPacket(&counters->fec, packet); |
| 850 } | 843 |
| 851 if (is_retransmit) { | 844 if (is_retransmit) { |
| 852 CountPacket(&counters->retransmitted, packet); | 845 CountPacket(&counters->retransmitted, packet); |
| 853 nack_bitrate_sent_.Update(packet.size(), now_ms); | 846 nack_bitrate_sent_.Update(packet.size(), now_ms); |
| 854 } | 847 } |
| 855 CountPacket(&counters->transmitted, packet); | 848 CountPacket(&counters->transmitted, packet); |
| 856 | 849 |
| 857 if (rtp_stats_callback_) { | 850 if (rtp_stats_callback_) |
| 858 rtp_stats_callback_->DataCountersUpdated(*counters, ssrc); | 851 rtp_stats_callback_->DataCountersUpdated(*counters, packet.Ssrc()); |
| 859 } | |
| 860 } | 852 } |
| 861 | 853 |
| 862 bool RTPSender::IsFecPacket(const RtpPacketToSend& packet) const { | 854 bool RTPSender::IsFecPacket(const RtpPacketToSend& packet) const { |
| 863 if (!video_) { | 855 if (!video_) { |
| 864 return false; | 856 return false; |
| 865 } | 857 } |
| 866 bool fec_enabled; | 858 bool fec_enabled; |
| 867 uint8_t pt_red; | 859 uint8_t pt_red; |
| 868 uint8_t pt_fec; | 860 uint8_t pt_fec; |
| 869 video_->GenericFECStatus(&fec_enabled, &pt_red, &pt_fec); | 861 video_->GenericFECStatus(&fec_enabled, &pt_red, &pt_fec); |
| (...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1771 rtc::CritScope lock(&send_critsect_); | 1763 rtc::CritScope lock(&send_critsect_); |
| 1772 | 1764 |
| 1773 RtpState state; | 1765 RtpState state; |
| 1774 state.sequence_number = sequence_number_rtx_; | 1766 state.sequence_number = sequence_number_rtx_; |
| 1775 state.start_timestamp = timestamp_offset_; | 1767 state.start_timestamp = timestamp_offset_; |
| 1776 | 1768 |
| 1777 return state; | 1769 return state; |
| 1778 } | 1770 } |
| 1779 | 1771 |
| 1780 } // namespace webrtc | 1772 } // namespace webrtc |
| OLD | NEW |