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

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

Issue 3005003002: Make UBSan warnings fatal and fix the existing ones (Closed)
Patch Set: Address review comments Created 3 years, 3 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
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 } 918 }
919 919
920 return sent; 920 return sent;
921 } 921 }
922 922
923 void RTPSender::UpdateDelayStatistics(int64_t capture_time_ms, int64_t now_ms) { 923 void RTPSender::UpdateDelayStatistics(int64_t capture_time_ms, int64_t now_ms) {
924 if (!send_side_delay_observer_ || capture_time_ms <= 0) 924 if (!send_side_delay_observer_ || capture_time_ms <= 0)
925 return; 925 return;
926 926
927 uint32_t ssrc; 927 uint32_t ssrc;
928 int avg_delay_ms = 0; 928 int64_t avg_delay_ms = 0;
929 int max_delay_ms = 0; 929 int max_delay_ms = 0;
930 { 930 {
931 rtc::CritScope lock(&send_critsect_); 931 rtc::CritScope lock(&send_critsect_);
932 if (!ssrc_) 932 if (!ssrc_)
933 return; 933 return;
934 ssrc = *ssrc_; 934 ssrc = *ssrc_;
935 } 935 }
936 { 936 {
937 rtc::CritScope cs(&statistics_crit_); 937 rtc::CritScope cs(&statistics_crit_);
938 // TODO(holmer): Compute this iteratively instead. 938 // TODO(holmer): Compute this iteratively instead.
939 send_delays_[now_ms] = now_ms - capture_time_ms; 939 send_delays_[now_ms] = now_ms - capture_time_ms;
940 send_delays_.erase(send_delays_.begin(), 940 send_delays_.erase(send_delays_.begin(),
941 send_delays_.lower_bound(now_ms - 941 send_delays_.lower_bound(now_ms -
942 kSendSideDelayWindowMs)); 942 kSendSideDelayWindowMs));
943 int num_delays = 0; 943 int num_delays = 0;
944 for (auto it = send_delays_.upper_bound(now_ms - kSendSideDelayWindowMs); 944 for (auto it = send_delays_.upper_bound(now_ms - kSendSideDelayWindowMs);
945 it != send_delays_.end(); ++it) { 945 it != send_delays_.end(); ++it) {
946 max_delay_ms = std::max(max_delay_ms, it->second); 946 max_delay_ms = std::max(max_delay_ms, it->second);
947 avg_delay_ms += it->second; 947 avg_delay_ms += it->second;
948 ++num_delays; 948 ++num_delays;
949 } 949 }
950 if (num_delays == 0) 950 if (num_delays == 0)
951 return; 951 return;
952 avg_delay_ms = (avg_delay_ms + num_delays / 2) / num_delays; 952 avg_delay_ms = (avg_delay_ms + num_delays / 2) / num_delays;
953 } 953 }
954 send_side_delay_observer_->SendSideDelayUpdated(avg_delay_ms, max_delay_ms, 954 send_side_delay_observer_->SendSideDelayUpdated(
955 ssrc); 955 rtc::dchecked_cast<int>(avg_delay_ms), max_delay_ms, ssrc);
956 } 956 }
957 957
958 void RTPSender::UpdateOnSendPacket(int packet_id, 958 void RTPSender::UpdateOnSendPacket(int packet_id,
959 int64_t capture_time_ms, 959 int64_t capture_time_ms,
960 uint32_t ssrc) { 960 uint32_t ssrc) {
961 if (!send_packet_observer_ || capture_time_ms <= 0 || packet_id == -1) 961 if (!send_packet_observer_ || capture_time_ms <= 0 || packet_id == -1)
962 return; 962 return;
963 963
964 send_packet_observer_->OnSendPacket(packet_id, capture_time_ms, ssrc); 964 send_packet_observer_->OnSendPacket(packet_id, capture_time_ms, ssrc);
965 } 965 }
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
1295 rtc::CritScope lock(&send_critsect_); 1295 rtc::CritScope lock(&send_critsect_);
1296 packet->SetTimestamp(last_rtp_timestamp_); 1296 packet->SetTimestamp(last_rtp_timestamp_);
1297 packet->set_capture_time_ms(capture_time_ms_); 1297 packet->set_capture_time_ms(capture_time_ms_);
1298 } 1298 }
1299 AssignSequenceNumber(packet.get()); 1299 AssignSequenceNumber(packet.get());
1300 SendToNetwork(std::move(packet), StorageType::kDontRetransmit, 1300 SendToNetwork(std::move(packet), StorageType::kDontRetransmit,
1301 RtpPacketSender::Priority::kLowPriority); 1301 RtpPacketSender::Priority::kLowPriority);
1302 } 1302 }
1303 1303
1304 } // namespace webrtc 1304 } // namespace webrtc
OLDNEW
« webrtc/modules/pacing/alr_detector.cc ('K') | « webrtc/modules/pacing/alr_detector.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698