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

Side by Side Diff: media/cast/net/rtcp/rtcp_unittest.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 unified diff | Download patch
OLDNEW
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 <stdint.h> 5 #include <stdint.h>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/test/simple_test_tick_clock.h" 9 #include "base/test/simple_test_tick_clock.h"
10 #include "media/cast/net/cast_transport_config.h" 10 #include "media/cast/net/cast_transport_config.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 Rtcp rtcp_for_sender_; 136 Rtcp rtcp_for_sender_;
137 Rtcp rtcp_for_receiver_; 137 Rtcp rtcp_for_receiver_;
138 138
139 DISALLOW_COPY_AND_ASSIGN(RtcpTest); 139 DISALLOW_COPY_AND_ASSIGN(RtcpTest);
140 }; 140 };
141 141
142 TEST_F(RtcpTest, LipSyncGleanedFromSenderReport) { 142 TEST_F(RtcpTest, LipSyncGleanedFromSenderReport) {
143 // Initially, expect no lip-sync info receiver-side without having first 143 // Initially, expect no lip-sync info receiver-side without having first
144 // received a RTCP packet. 144 // received a RTCP packet.
145 base::TimeTicks reference_time; 145 base::TimeTicks reference_time;
146 uint32 rtp_timestamp; 146 RtpTimeTicks rtp_timestamp;
147 ASSERT_FALSE(rtcp_for_receiver_.GetLatestLipSyncTimes(&rtp_timestamp, 147 ASSERT_FALSE(rtcp_for_receiver_.GetLatestLipSyncTimes(&rtp_timestamp,
148 &reference_time)); 148 &reference_time));
149 149
150 // Send a Sender Report to the receiver. 150 // Send a Sender Report to the receiver.
151 const base::TimeTicks reference_time_sent = sender_clock_->NowTicks(); 151 const base::TimeTicks reference_time_sent = sender_clock_->NowTicks();
152 const uint32 rtp_timestamp_sent = 0xbee5; 152 const RtpTimeTicks rtp_timestamp_sent =
153 RtpTimeTicks().Expand(UINT32_C(0xbee5));
153 rtcp_for_sender_.SendRtcpFromRtpSender( 154 rtcp_for_sender_.SendRtcpFromRtpSender(
154 reference_time_sent, rtp_timestamp_sent, 1, 1); 155 reference_time_sent, rtp_timestamp_sent, 1, 1);
155 156
156 // Now the receiver should have lip-sync info. Confirm that the lip-sync 157 // Now the receiver should have lip-sync info. Confirm that the lip-sync
157 // reference time is the same as that sent. 158 // reference time is the same as that sent.
158 EXPECT_TRUE(rtcp_for_receiver_.GetLatestLipSyncTimes(&rtp_timestamp, 159 EXPECT_TRUE(rtcp_for_receiver_.GetLatestLipSyncTimes(&rtp_timestamp,
159 &reference_time)); 160 &reference_time));
160 const base::TimeTicks rolled_back_time = 161 const base::TimeTicks rolled_back_time =
161 (reference_time - 162 (reference_time -
162 // Roll-back relative clock offset: 163 // Roll-back relative clock offset:
(...skipping 23 matching lines...) Expand all
186 base::TimeDelta expected_rtt_according_to_sender; 187 base::TimeDelta expected_rtt_according_to_sender;
187 base::TimeDelta expected_rtt_according_to_receiver; 188 base::TimeDelta expected_rtt_according_to_receiver;
188 for (int i = 0; i < iterations; ++i) { 189 for (int i = 0; i < iterations; ++i) {
189 const base::TimeDelta one_way_trip_time = 190 const base::TimeDelta one_way_trip_time =
190 base::TimeDelta::FromMilliseconds(1 << i); 191 base::TimeDelta::FromMilliseconds(1 << i);
191 sender_to_receiver_.set_packet_delay(one_way_trip_time); 192 sender_to_receiver_.set_packet_delay(one_way_trip_time);
192 receiver_to_sender_.set_packet_delay(one_way_trip_time); 193 receiver_to_sender_.set_packet_delay(one_way_trip_time);
193 194
194 // Sender --> Receiver 195 // Sender --> Receiver
195 base::TimeTicks reference_time_sent = sender_clock_->NowTicks(); 196 base::TimeTicks reference_time_sent = sender_clock_->NowTicks();
196 uint32 rtp_timestamp_sent = 0xbee5 + i; 197 const RtpTimeTicks rtp_timestamp_sent =
198 RtpTimeTicks().Expand<uint32_t>(0xbee5) + RtpTimeDelta::FromTicks(i);
197 rtcp_for_sender_.SendRtcpFromRtpSender( 199 rtcp_for_sender_.SendRtcpFromRtpSender(
198 reference_time_sent, rtp_timestamp_sent, 1, 1); 200 reference_time_sent, rtp_timestamp_sent, 1, 1);
199 EXPECT_EQ(expected_rtt_according_to_sender, 201 EXPECT_EQ(expected_rtt_according_to_sender,
200 rtcp_for_sender_.current_round_trip_time()); 202 rtcp_for_sender_.current_round_trip_time());
201 #ifdef SENDER_PROVIDES_REPORT_BLOCK 203 #ifdef SENDER_PROVIDES_REPORT_BLOCK
202 EXPECT_EQ(expected_rtt_according_to_receiver, 204 EXPECT_EQ(expected_rtt_according_to_receiver,
203 rtcp_for_receiver_.current_round_trip_time()); 205 rtcp_for_receiver_.current_round_trip_time());
204 #endif 206 #endif
205 207
206 // Receiver --> Sender 208 // Receiver --> Sender
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 base::TimeTicks out_3 = ConvertNtpToTimeTicks(ntp_seconds_3, ntp_fraction_3); 309 base::TimeTicks out_3 = ConvertNtpToTimeTicks(ntp_seconds_3, ntp_fraction_3);
308 EXPECT_EQ(input_time, out_3); // Verify inverse. 310 EXPECT_EQ(input_time, out_3); // Verify inverse.
309 311
310 // Verify delta. 312 // Verify delta.
311 EXPECT_EQ((out_3 - out_2), time_delta); 313 EXPECT_EQ((out_3 - out_2), time_delta);
312 EXPECT_NEAR((ntp_fraction_3 - ntp_fraction_2), 0xffffffff / 2, 1); 314 EXPECT_NEAR((ntp_fraction_3 - ntp_fraction_2), 0xffffffff / 2, 1);
313 } 315 }
314 316
315 } // namespace cast 317 } // namespace cast
316 } // namespace media 318 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698