Skip to content

Commit

Permalink
Revert 256134 "Cast: Using a min filter to compute time offset"
Browse files Browse the repository at this point in the history
End2EndTest.ResetReferenceFrameId started failing very frequently with
256134 and closing the tree.

BUG=351241

> 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.
> 
> Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=255166
> 
> Review URL: https://codereview.chromium.org/186043003

TBR=mikhal@chromium.org

Review URL: https://codereview.chromium.org/195293002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@256246 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
dmichael@chromium.org committed Mar 11, 2014
1 parent f4035f5 commit 650ebe5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 48 deletions.
36 changes: 16 additions & 20 deletions media/cast/test/end2end_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -894,24 +894,21 @@ TEST_F(End2EndTest, GlitchWith3Buffers) {
Create();

int video_start = kVideoStart;
base::TimeTicks send_time;
// Frames will rendered on completion until the render time stabilizes, i.e.
// we got enough data.
const int frames_before_glitch = 20;
for (int i = 0; i < frames_before_glitch; ++i) {
send_time = testing_clock_sender_->NowTicks();
SendVideoFrame(video_start, send_time);
test_receiver_video_callback_->AddExpectedResult(
video_start,
video_sender_config_.width,
video_sender_config_.height,
send_time);
frame_receiver_->GetRawVideoFrame(
base::Bind(&TestReceiverVideoCallback::CheckVideoFrame,
test_receiver_video_callback_));
RunTasks(kFrameTimerMs);
video_start++;
}
base::TimeTicks send_time = testing_clock_sender_->NowTicks();
SendVideoFrame(video_start, send_time);
RunTasks(kFrameTimerMs);

test_receiver_video_callback_->AddExpectedResult(video_start,
video_sender_config_.width,
video_sender_config_.height,
send_time);
frame_receiver_->GetRawVideoFrame(
base::Bind(&TestReceiverVideoCallback::CheckVideoFrame,
test_receiver_video_callback_));

RunTasks(750); // Make sure that we send a RTCP packet.

video_start++;

// Introduce a glitch lasting for 10 frames.
sender_to_receiver_.SetSendPackets(false);
Expand Down Expand Up @@ -942,8 +939,7 @@ TEST_F(End2EndTest, GlitchWith3Buffers) {
test_receiver_video_callback_));

RunTasks(2 * kFrameTimerMs + 1); // Empty the receiver pipeline.
EXPECT_EQ(frames_before_glitch + 1,
test_receiver_video_callback_->number_times_called());
EXPECT_EQ(2, test_receiver_video_callback_->number_times_called());
}

TEST_F(End2EndTest, DropEveryOtherFrame3Buffers) {
Expand Down
39 changes: 12 additions & 27 deletions media/cast/video_receiver/video_receiver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
namespace {

static const int64 kMinSchedulingDelayMs = 1;
static const int64 kMinTimeBetweenOffsetUpdatesMs = 1000;
static const int kTimeOffsetMaxCounter = 10;
static const int64 kMinTimeBetweenOffsetUpdatesMs = 2000;
static const int kTimeOffsetFilter = 8;
static const int64_t kMinProcessIntervalMs = 5;

} // namespace
Expand Down Expand Up @@ -107,7 +107,6 @@ 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),
Expand Down Expand Up @@ -357,33 +356,24 @@ 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_counter_ == 0) {
// Check for received RTCP to sync the stream play it out asap.
if (rtcp_->RtpTimestampInSenderTime(kVideoFrequency,
if (time_offset_.InMilliseconds() == 0) {
if (!rtcp_->RtpTimestampInSenderTime(kVideoFrequency,
incoming_rtp_timestamp_,
&rtp_timestamp_in_ticks)) {

++time_offset_counter_;
// We have not received any RTCP to sync the stream play it out as soon as
// possible.
return now;
}
return now;
time_offset_ = time_incoming_packet_ - rtp_timestamp_in_ticks;
} else if (time_incoming_packet_updated_) {
if (rtcp_->RtpTimestampInSenderTime(kVideoFrequency,
incoming_rtp_timestamp_,
&rtp_timestamp_in_ticks)) {
// Time to update the time_offset.
base::TimeDelta time_offset =
time_incoming_packet_ - rtp_timestamp_in_ticks;
// 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_;
time_offset_ = ((kTimeOffsetFilter - 1) * time_offset_ + time_offset) /
kTimeOffsetFilter;
}
}
// Reset |time_incoming_packet_updated_| to enable a future measurement.
Expand Down Expand Up @@ -423,13 +413,8 @@ void VideoReceiver::IncomingParsedRtpPacket(const uint8* payload_data,
if (time_incoming_packet_.is_null())
InitializeTimers();
incoming_rtp_timestamp_ = rtp_header.webrtc.header.timestamp;
// The following incoming packet info is used for syncing sender and
// receiver clock. Use only the first packet of every frame to obtain a
// minimal value.
if (rtp_header.max_packet_id == 0) {
time_incoming_packet_ = now;
time_incoming_packet_updated_ = true;
}
time_incoming_packet_ = now;
time_incoming_packet_updated_ = true;
}

frame_id_to_rtp_timestamp_[rtp_header.frame_id & 0xff] =
Expand Down
1 change: 0 additions & 1 deletion media/cast/video_receiver/video_receiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ 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_;
Expand Down

0 comments on commit 650ebe5

Please sign in to comment.