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

Unified Diff: media/cast/net/rtp/receiver_stats.cc

Issue 1515433002: Replace uses of raw uint32's with a type-checked RtpTimeTicks data type. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 side-by-side diff with in-line comments
Download patch
Index: media/cast/net/rtp/receiver_stats.cc
diff --git a/media/cast/net/rtp/receiver_stats.cc b/media/cast/net/rtp/receiver_stats.cc
index bceb8add05354979efd74bc3f16755ee4e265123..5f6dcc881b095ff4762448940f0ed500d5ad42ca 100644
--- a/media/cast/net/rtp/receiver_stats.cc
+++ b/media/cast/net/rtp/receiver_stats.cc
@@ -73,7 +73,8 @@ RtpReceiverStatistics ReceiverStats::GetStatistics() {
return ret;
}
-void ReceiverStats::UpdateStatistics(const RtpCastHeader& header) {
+void ReceiverStats::UpdateStatistics(const RtpCastHeader& header,
+ int rtp_timebase) {
const uint16 new_seq_num = header.sequence_number;
if (interval_number_packets_ == 0) {
@@ -96,17 +97,19 @@ void ReceiverStats::UpdateStatistics(const RtpCastHeader& header) {
}
// Compute Jitter.
- base::TimeTicks now = clock_->NowTicks();
- base::TimeDelta delta_new_timestamp =
- base::TimeDelta::FromMilliseconds(header.rtp_timestamp);
+ const base::TimeTicks now = clock_->NowTicks();
if (total_number_packets_ > 0) {
+ const base::TimeDelta packet_time_difference =
+ now - last_received_packet_time_;
+ const base::TimeDelta media_time_differerence =
+ (header.rtp_timestamp - last_received_rtp_timestamp_)
+ .ToTimeDelta(rtp_timebase);
+ const base::TimeDelta delta =
+ packet_time_difference - media_time_differerence;
// Update jitter.
- base::TimeDelta delta =
- (now - last_received_packet_time_) -
- ((delta_new_timestamp - last_received_timestamp_) / 90);
jitter_ += (delta - jitter_) / 16;
}
- last_received_timestamp_ = delta_new_timestamp;
+ last_received_rtp_timestamp_ = header.rtp_timestamp;
last_received_packet_time_ = now;
// Increment counters.

Powered by Google App Engine
This is Rietveld 408576698