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

Side by Side Diff: media/cast/cast_defines.h

Issue 638123004: Type conversion fixes, media/ edition. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef MEDIA_CAST_CAST_DEFINES_H_ 5 #ifndef MEDIA_CAST_CAST_DEFINES_H_
6 #define MEDIA_CAST_CAST_DEFINES_H_ 6 #define MEDIA_CAST_CAST_DEFINES_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 int64 ntp_time_us = 172 int64 ntp_time_us =
173 elapsed_since_unix_epoch.InMicroseconds() + 173 elapsed_since_unix_epoch.InMicroseconds() +
174 (kUnixEpochInNtpSeconds * base::Time::kMicrosecondsPerSecond); 174 (kUnixEpochInNtpSeconds * base::Time::kMicrosecondsPerSecond);
175 175
176 ConvertTimeToFractions(ntp_time_us, ntp_seconds, ntp_fractions); 176 ConvertTimeToFractions(ntp_time_us, ntp_seconds, ntp_fractions);
177 } 177 }
178 178
179 inline base::TimeTicks ConvertNtpToTimeTicks(uint32 ntp_seconds, 179 inline base::TimeTicks ConvertNtpToTimeTicks(uint32 ntp_seconds,
180 uint32 ntp_fractions) { 180 uint32 ntp_fractions) {
181 int64 ntp_time_us = 181 int64 ntp_time_us =
182 static_cast<int64>(ntp_seconds) * base::Time::kMicrosecondsPerSecond + 182 ntp_seconds * base::Time::kMicrosecondsPerSecond +
183 static_cast<int64>(ntp_fractions) / kMagicFractionalUnit; 183 static_cast<int64>(ntp_fractions / kMagicFractionalUnit);
184 184
185 base::TimeDelta elapsed_since_unix_epoch = base::TimeDelta::FromMicroseconds( 185 base::TimeDelta elapsed_since_unix_epoch = base::TimeDelta::FromMicroseconds(
186 ntp_time_us - 186 ntp_time_us -
187 (kUnixEpochInNtpSeconds * base::Time::kMicrosecondsPerSecond)); 187 (kUnixEpochInNtpSeconds * base::Time::kMicrosecondsPerSecond));
188 return base::TimeTicks::UnixEpoch() + elapsed_since_unix_epoch; 188 return base::TimeTicks::UnixEpoch() + elapsed_since_unix_epoch;
189 } 189 }
190 190
191 inline base::TimeDelta RtpDeltaToTimeDelta(int64 rtp_delta, int rtp_timebase) { 191 inline base::TimeDelta RtpDeltaToTimeDelta(int64 rtp_delta, int rtp_timebase) {
192 DCHECK_GT(rtp_timebase, 0); 192 DCHECK_GT(rtp_timebase, 0);
193 return rtp_delta * base::TimeDelta::FromSeconds(1) / rtp_timebase; 193 return rtp_delta * base::TimeDelta::FromSeconds(1) / rtp_timebase;
194 } 194 }
195 195
196 inline int64 TimeDeltaToRtpDelta(base::TimeDelta delta, int rtp_timebase) { 196 inline int64 TimeDeltaToRtpDelta(base::TimeDelta delta, int rtp_timebase) {
197 DCHECK_GT(rtp_timebase, 0); 197 DCHECK_GT(rtp_timebase, 0);
198 return delta * rtp_timebase / base::TimeDelta::FromSeconds(1); 198 return delta * rtp_timebase / base::TimeDelta::FromSeconds(1);
199 } 199 }
200 200
201 } // namespace cast 201 } // namespace cast
202 } // namespace media 202 } // namespace media
203 203
204 #endif // MEDIA_CAST_CAST_DEFINES_H_ 204 #endif // MEDIA_CAST_CAST_DEFINES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698