summaryrefslogtreecommitdiffstats
path: root/media/cast
diff options
context:
space:
mode:
authormikhal@chromium.org <mikhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-05 22:20:38 +0000
committermikhal@chromium.org <mikhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-05 22:20:38 +0000
commit0bd0ca2ce78011137a923669d9ba94b938fae596 (patch)
tree9be248c33bfa26183894ec182d563024159f09d7 /media/cast
parent028053d4b37380bb1f71b610de096a1fb6adbd14 (diff)
downloadchromium_src-0bd0ca2ce78011137a923669d9ba94b938fae596.zip
chromium_src-0bd0ca2ce78011137a923669d9ba94b938fae596.tar.gz
chromium_src-0bd0ca2ce78011137a923669d9ba94b938fae596.tar.bz2
Cast: Using a min filter to compute time offset
Modifying the time offset filter to take to minimum of the first 10 values. Once ten offset values were seen, the value will be constant for the entire session. This may be justified by the fact we are seeking the offset between sender and receiver without accounting the network jitter. Review URL: https://codereview.chromium.org/186043003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@255166 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/cast')
-rw-r--r--media/cast/video_receiver/video_receiver.cc22
-rw-r--r--media/cast/video_receiver/video_receiver.h1
2 files changed, 17 insertions, 6 deletions
diff --git a/media/cast/video_receiver/video_receiver.cc b/media/cast/video_receiver/video_receiver.cc
index 799da9a..1d980b2 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,16 @@ 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_ = std::min(time_offset_, time_offset);
+ ++time_offset_counter_;
}
}
// Reset |time_incoming_packet_updated_| to enable a future measurement.
diff --git a/media/cast/video_receiver/video_receiver.h b/media/cast/video_receiver/video_receiver.h
index 3f4d812..3c9d1f8 100644
--- a/media/cast/video_receiver/video_receiver.h
+++ b/media/cast/video_receiver/video_receiver.h
@@ -115,6 +115,7 @@ class VideoReceiver : public base::NonThreadSafe,
scoped_ptr<Rtcp> rtcp_;
scoped_ptr<RtpReceiverStatistics> rtp_video_receiver_statistics_;
base::TimeDelta time_offset_; // Sender-receiver offset estimation.
+ int time_offset_counter_;
transport::TransportEncryptionHandler decryptor_;
std::list<VideoFrameEncodedCallback> queued_encoded_callbacks_;
bool time_incoming_packet_updated_;