OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/memory/ref_counted.h" | 5 #include "base/memory/ref_counted.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "base/test/simple_test_tick_clock.h" | 7 #include "base/test/simple_test_tick_clock.h" |
8 #include "base/time/tick_clock.h" | 8 #include "base/time/tick_clock.h" |
9 #include "media/cast/cast_environment.h" | 9 #include "media/cast/cast_environment.h" |
10 #include "media/cast/logging/logging_defines.h" | 10 #include "media/cast/logging/logging_defines.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 // Then the bound after all 3 events have arrived is [130-60=70, 130-20=110]. | 51 // Then the bound after all 3 events have arrived is [130-60=70, 130-20=110]. |
52 TEST_F(ReceiverTimeOffsetEstimatorImplTest, EstimateOffset) { | 52 TEST_F(ReceiverTimeOffsetEstimatorImplTest, EstimateOffset) { |
53 int64 true_offset_ms = 100; | 53 int64 true_offset_ms = 100; |
54 receiver_clock_.Advance(base::TimeDelta::FromMilliseconds(true_offset_ms)); | 54 receiver_clock_.Advance(base::TimeDelta::FromMilliseconds(true_offset_ms)); |
55 | 55 |
56 base::TimeDelta lower_bound; | 56 base::TimeDelta lower_bound; |
57 base::TimeDelta upper_bound; | 57 base::TimeDelta upper_bound; |
58 | 58 |
59 EXPECT_FALSE(estimator_.GetReceiverOffsetBounds(&lower_bound, &upper_bound)); | 59 EXPECT_FALSE(estimator_.GetReceiverOffsetBounds(&lower_bound, &upper_bound)); |
60 | 60 |
61 RtpTimestamp rtp_timestamp = 0; | 61 const RtpTimeTicks rtp_timestamp; |
62 uint32 frame_id = 0; | 62 uint32 frame_id = 0; |
63 | 63 |
64 AdvanceClocks(base::TimeDelta::FromMilliseconds(20)); | 64 AdvanceClocks(base::TimeDelta::FromMilliseconds(20)); |
65 | 65 |
66 scoped_ptr<FrameEvent> encode_event(new FrameEvent()); | 66 scoped_ptr<FrameEvent> encode_event(new FrameEvent()); |
67 encode_event->timestamp = sender_clock_->NowTicks(); | 67 encode_event->timestamp = sender_clock_->NowTicks(); |
68 encode_event->type = FRAME_ENCODED; | 68 encode_event->type = FRAME_ENCODED; |
69 encode_event->media_type = VIDEO_EVENT; | 69 encode_event->media_type = VIDEO_EVENT; |
70 encode_event->rtp_timestamp = rtp_timestamp; | 70 encode_event->rtp_timestamp = rtp_timestamp; |
71 encode_event->frame_id = frame_id; | 71 encode_event->frame_id = frame_id; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 // event C occurred before event B. | 134 // event C occurred before event B. |
135 TEST_F(ReceiverTimeOffsetEstimatorImplTest, EventCArrivesBeforeEventB) { | 135 TEST_F(ReceiverTimeOffsetEstimatorImplTest, EventCArrivesBeforeEventB) { |
136 int64 true_offset_ms = 100; | 136 int64 true_offset_ms = 100; |
137 receiver_clock_.Advance(base::TimeDelta::FromMilliseconds(true_offset_ms)); | 137 receiver_clock_.Advance(base::TimeDelta::FromMilliseconds(true_offset_ms)); |
138 | 138 |
139 base::TimeDelta lower_bound; | 139 base::TimeDelta lower_bound; |
140 base::TimeDelta upper_bound; | 140 base::TimeDelta upper_bound; |
141 | 141 |
142 EXPECT_FALSE(estimator_.GetReceiverOffsetBounds(&lower_bound, &upper_bound)); | 142 EXPECT_FALSE(estimator_.GetReceiverOffsetBounds(&lower_bound, &upper_bound)); |
143 | 143 |
144 RtpTimestamp rtp_timestamp = 0; | 144 const RtpTimeTicks rtp_timestamp; |
145 uint32 frame_id = 0; | 145 uint32 frame_id = 0; |
146 | 146 |
147 AdvanceClocks(base::TimeDelta::FromMilliseconds(20)); | 147 AdvanceClocks(base::TimeDelta::FromMilliseconds(20)); |
148 | 148 |
149 scoped_ptr<FrameEvent> encode_event(new FrameEvent()); | 149 scoped_ptr<FrameEvent> encode_event(new FrameEvent()); |
150 encode_event->timestamp = sender_clock_->NowTicks(); | 150 encode_event->timestamp = sender_clock_->NowTicks(); |
151 encode_event->type = FRAME_ENCODED; | 151 encode_event->type = FRAME_ENCODED; |
152 encode_event->media_type = VIDEO_EVENT; | 152 encode_event->media_type = VIDEO_EVENT; |
153 encode_event->rtp_timestamp = rtp_timestamp; | 153 encode_event->rtp_timestamp = rtp_timestamp; |
154 encode_event->frame_id = frame_id; | 154 encode_event->frame_id = frame_id; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 EXPECT_LE(true_offset_ms, upper_bound_ms); | 216 EXPECT_LE(true_offset_ms, upper_bound_ms); |
217 } | 217 } |
218 | 218 |
219 TEST_F(ReceiverTimeOffsetEstimatorImplTest, MultipleIterations) { | 219 TEST_F(ReceiverTimeOffsetEstimatorImplTest, MultipleIterations) { |
220 int64 true_offset_ms = 100; | 220 int64 true_offset_ms = 100; |
221 receiver_clock_.Advance(base::TimeDelta::FromMilliseconds(true_offset_ms)); | 221 receiver_clock_.Advance(base::TimeDelta::FromMilliseconds(true_offset_ms)); |
222 | 222 |
223 base::TimeDelta lower_bound; | 223 base::TimeDelta lower_bound; |
224 base::TimeDelta upper_bound; | 224 base::TimeDelta upper_bound; |
225 | 225 |
226 RtpTimestamp rtp_timestamp_a = 0; | 226 const RtpTimeTicks rtp_timestamp_a; |
227 int frame_id_a = 0; | 227 int frame_id_a = 0; |
228 RtpTimestamp rtp_timestamp_b = 90; | 228 const RtpTimeTicks rtp_timestamp_b = |
| 229 rtp_timestamp_a + RtpTimeDelta::FromTicks(90); |
229 int frame_id_b = 1; | 230 int frame_id_b = 1; |
230 RtpTimestamp rtp_timestamp_c = 180; | 231 const RtpTimeTicks rtp_timestamp_c = |
| 232 rtp_timestamp_b + RtpTimeDelta::FromTicks(90); |
231 int frame_id_c = 2; | 233 int frame_id_c = 2; |
232 | 234 |
233 // Frame 1 times: [20, 30+100, 60] | 235 // Frame 1 times: [20, 30+100, 60] |
234 // Frame 2 times: [30, 50+100, 55] | 236 // Frame 2 times: [30, 50+100, 55] |
235 // Frame 3 times: [77, 80+100, 110] | 237 // Frame 3 times: [77, 80+100, 110] |
236 // Bound should end up at [95, 103] | 238 // Bound should end up at [95, 103] |
237 // Events times in chronological order: 20, 30 x2, 50, 55, 60, 77, 80, 110 | 239 // Events times in chronological order: 20, 30 x2, 50, 55, 60, 77, 80, 110 |
238 AdvanceClocks(base::TimeDelta::FromMilliseconds(20)); | 240 AdvanceClocks(base::TimeDelta::FromMilliseconds(20)); |
239 scoped_ptr<FrameEvent> encode_event(new FrameEvent()); | 241 scoped_ptr<FrameEvent> encode_event(new FrameEvent()); |
240 encode_event->timestamp = sender_clock_->NowTicks(); | 242 encode_event->timestamp = sender_clock_->NowTicks(); |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 int64 lower_bound_ms = lower_bound.InMilliseconds(); | 392 int64 lower_bound_ms = lower_bound.InMilliseconds(); |
391 int64 upper_bound_ms = upper_bound.InMilliseconds(); | 393 int64 upper_bound_ms = upper_bound.InMilliseconds(); |
392 EXPECT_GT(lower_bound_ms, 90); | 394 EXPECT_GT(lower_bound_ms, 90); |
393 EXPECT_LE(lower_bound_ms, true_offset_ms); | 395 EXPECT_LE(lower_bound_ms, true_offset_ms); |
394 EXPECT_LT(upper_bound_ms, 150); | 396 EXPECT_LT(upper_bound_ms, 150); |
395 EXPECT_GT(upper_bound_ms, true_offset_ms); | 397 EXPECT_GT(upper_bound_ms, true_offset_ms); |
396 } | 398 } |
397 | 399 |
398 } // namespace cast | 400 } // namespace cast |
399 } // namespace media | 401 } // namespace media |
OLD | NEW |