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

Unified Diff: media/cast/video_receiver/video_receiver.cc

Issue 186043003: Cast: Using a min filter to compute time offset (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Responding to review Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/cast/video_receiver/video_receiver.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/cast/video_receiver/video_receiver.cc
diff --git a/media/cast/video_receiver/video_receiver.cc b/media/cast/video_receiver/video_receiver.cc
index 799da9a2d48b364b3bbf088c2a19d0035a299062..730f185bb16050709899d6216232ec420c06f709 100644
--- a/media/cast/video_receiver/video_receiver.cc
+++ b/media/cast/video_receiver/video_receiver.cc
@@ -18,8 +18,8 @@
namespace {
static const int64 kMinSchedulingDelayMs = 1;
-static const int64 kMinTimeBetweenOffsetUpdatesMs = 2000;
-static const int kTimeOffsetFilter = 8;
+static const int64 kMinTimeBetweenOffsetUpdatesMs = 1000;
+static const int kTimeOffsetMaxCounter = 10;
static const int64_t kMinProcessIntervalMs = 5;
} // namespace
@@ -107,6 +107,7 @@ VideoReceiver::VideoReceiver(scoped_refptr<CastEnvironment> cast_environment,
incoming_payload_callback_.get()),
rtp_video_receiver_statistics_(
new LocalRtpReceiverStatistics(&rtp_receiver_)),
+ time_offset_counter_(0),
decryptor_(),
time_incoming_packet_updated_(false),
incoming_rtp_timestamp_(0),
@@ -356,7 +357,7 @@ base::TimeTicks VideoReceiver::GetRenderTime(base::TimeTicks now,
base::TimeTicks rtp_timestamp_in_ticks;
// Compute the time offset_in_ticks based on the incoming_rtp_timestamp_.
- if (time_offset_.InMilliseconds() == 0) {
+ if (time_offset_counter_ == 0) {
if (!rtcp_->RtpTimestampInSenderTime(kVideoFrequency,
incoming_rtp_timestamp_,
&rtp_timestamp_in_ticks)) {
@@ -364,7 +365,8 @@ base::TimeTicks VideoReceiver::GetRenderTime(base::TimeTicks now,
// possible.
return now;
}
- time_offset_ = time_incoming_packet_ - rtp_timestamp_in_ticks;
+ ++time_offset_counter_;
+ return now;
} else if (time_incoming_packet_updated_) {
if (rtcp_->RtpTimestampInSenderTime(kVideoFrequency,
incoming_rtp_timestamp_,
@@ -372,8 +374,17 @@ base::TimeTicks VideoReceiver::GetRenderTime(base::TimeTicks now,
// Time to update the time_offset.
base::TimeDelta time_offset =
time_incoming_packet_ - rtp_timestamp_in_ticks;
- time_offset_ = ((kTimeOffsetFilter - 1) * time_offset_ + time_offset) /
- kTimeOffsetFilter;
+ // Taking the minimum of the first kTimeOffsetMaxCounter values. We are
+ // assuming that we are looking for the minimum offset, which will occur
+ // when network conditions are the best. This should occur at least once
+ // within the first kTimeOffsetMaxCounter samples. Any drift should be
+ // very slow, and negligible for this use case.
+ if (time_offset_counter_ == 1)
+ time_offset_ = time_offset;
+ else if (time_offset_counter_ < kTimeOffsetMaxCounter &&
+ time_offset < time_offset_)
+ time_offset_ = time_offset;
pwestin 2014/03/04 00:34:40 I think taking the std::min makes it more readable
mikhal1 2014/03/04 17:52:22 Done.
+ ++time_offset_counter_;
}
}
// Reset |time_incoming_packet_updated_| to enable a future measurement.
« no previous file with comments | « media/cast/video_receiver/video_receiver.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698