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

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: Speculative workaround fix for win8_chromium_ng compile error. Created 4 years, 11 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 unified diff | Download patch
« no previous file with comments | « media/cast/net/rtcp/rtcp_defines.cc ('k') | media/cast/net/rtcp/rtcp_utility.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 Rtcp rtcp_for_sender_; 138 Rtcp rtcp_for_sender_;
139 Rtcp rtcp_for_receiver_; 139 Rtcp rtcp_for_receiver_;
140 140
141 DISALLOW_COPY_AND_ASSIGN(RtcpTest); 141 DISALLOW_COPY_AND_ASSIGN(RtcpTest);
142 }; 142 };
143 143
144 TEST_F(RtcpTest, LipSyncGleanedFromSenderReport) { 144 TEST_F(RtcpTest, LipSyncGleanedFromSenderReport) {
145 // Initially, expect no lip-sync info receiver-side without having first 145 // Initially, expect no lip-sync info receiver-side without having first
146 // received a RTCP packet. 146 // received a RTCP packet.
147 base::TimeTicks reference_time; 147 base::TimeTicks reference_time;
148 uint32_t rtp_timestamp; 148 RtpTimeTicks rtp_timestamp;
149 ASSERT_FALSE(rtcp_for_receiver_.GetLatestLipSyncTimes(&rtp_timestamp, 149 ASSERT_FALSE(rtcp_for_receiver_.GetLatestLipSyncTimes(&rtp_timestamp,
150 &reference_time)); 150 &reference_time));
151 151
152 // Send a Sender Report to the receiver. 152 // Send a Sender Report to the receiver.
153 const base::TimeTicks reference_time_sent = sender_clock_->NowTicks(); 153 const base::TimeTicks reference_time_sent = sender_clock_->NowTicks();
154 const uint32_t rtp_timestamp_sent = 0xbee5; 154 const RtpTimeTicks rtp_timestamp_sent =
155 RtpTimeTicks().Expand(UINT32_C(0xbee5));
155 rtcp_for_sender_.SendRtcpFromRtpSender( 156 rtcp_for_sender_.SendRtcpFromRtpSender(
156 reference_time_sent, rtp_timestamp_sent, 1, 1); 157 reference_time_sent, rtp_timestamp_sent, 1, 1);
157 158
158 // Now the receiver should have lip-sync info. Confirm that the lip-sync 159 // Now the receiver should have lip-sync info. Confirm that the lip-sync
159 // reference time is the same as that sent. 160 // reference time is the same as that sent.
160 EXPECT_TRUE(rtcp_for_receiver_.GetLatestLipSyncTimes(&rtp_timestamp, 161 EXPECT_TRUE(rtcp_for_receiver_.GetLatestLipSyncTimes(&rtp_timestamp,
161 &reference_time)); 162 &reference_time));
162 const base::TimeTicks rolled_back_time = 163 const base::TimeTicks rolled_back_time =
163 (reference_time - 164 (reference_time -
164 // Roll-back relative clock offset: 165 // Roll-back relative clock offset:
(...skipping 23 matching lines...) Expand all
188 base::TimeDelta expected_rtt_according_to_sender; 189 base::TimeDelta expected_rtt_according_to_sender;
189 base::TimeDelta expected_rtt_according_to_receiver; 190 base::TimeDelta expected_rtt_according_to_receiver;
190 for (int i = 0; i < iterations; ++i) { 191 for (int i = 0; i < iterations; ++i) {
191 const base::TimeDelta one_way_trip_time = 192 const base::TimeDelta one_way_trip_time =
192 base::TimeDelta::FromMilliseconds(1 << i); 193 base::TimeDelta::FromMilliseconds(1 << i);
193 sender_to_receiver_.set_packet_delay(one_way_trip_time); 194 sender_to_receiver_.set_packet_delay(one_way_trip_time);
194 receiver_to_sender_.set_packet_delay(one_way_trip_time); 195 receiver_to_sender_.set_packet_delay(one_way_trip_time);
195 196
196 // Sender --> Receiver 197 // Sender --> Receiver
197 base::TimeTicks reference_time_sent = sender_clock_->NowTicks(); 198 base::TimeTicks reference_time_sent = sender_clock_->NowTicks();
198 uint32_t rtp_timestamp_sent = 0xbee5 + i; 199 const RtpTimeTicks rtp_timestamp_sent =
200 RtpTimeTicks().Expand<uint32_t>(0xbee5) + RtpTimeDelta::FromTicks(i);
199 rtcp_for_sender_.SendRtcpFromRtpSender( 201 rtcp_for_sender_.SendRtcpFromRtpSender(
200 reference_time_sent, rtp_timestamp_sent, 1, 1); 202 reference_time_sent, rtp_timestamp_sent, 1, 1);
201 EXPECT_EQ(expected_rtt_according_to_sender, 203 EXPECT_EQ(expected_rtt_according_to_sender,
202 rtcp_for_sender_.current_round_trip_time()); 204 rtcp_for_sender_.current_round_trip_time());
203 #ifdef SENDER_PROVIDES_REPORT_BLOCK 205 #ifdef SENDER_PROVIDES_REPORT_BLOCK
204 EXPECT_EQ(expected_rtt_according_to_receiver, 206 EXPECT_EQ(expected_rtt_according_to_receiver,
205 rtcp_for_receiver_.current_round_trip_time()); 207 rtcp_for_receiver_.current_round_trip_time());
206 #endif 208 #endif
207 209
208 // Receiver --> Sender 210 // Receiver --> Sender
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 base::TimeTicks out_3 = ConvertNtpToTimeTicks(ntp_seconds_3, ntp_fraction_3); 311 base::TimeTicks out_3 = ConvertNtpToTimeTicks(ntp_seconds_3, ntp_fraction_3);
310 EXPECT_EQ(input_time, out_3); // Verify inverse. 312 EXPECT_EQ(input_time, out_3); // Verify inverse.
311 313
312 // Verify delta. 314 // Verify delta.
313 EXPECT_EQ((out_3 - out_2), time_delta); 315 EXPECT_EQ((out_3 - out_2), time_delta);
314 EXPECT_NEAR((ntp_fraction_3 - ntp_fraction_2), 0xffffffff / 2, 1); 316 EXPECT_NEAR((ntp_fraction_3 - ntp_fraction_2), 0xffffffff / 2, 1);
315 } 317 }
316 318
317 } // namespace cast 319 } // namespace cast
318 } // namespace media 320 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/net/rtcp/rtcp_defines.cc ('k') | media/cast/net/rtcp/rtcp_utility.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698