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

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

Issue 280993002: [Cast] Repair receiver playout time calculations and frame skip logic. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
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 <limits>
10 #include <map> 11 #include <map>
11 #include <set> 12 #include <set>
12 13
13 #include "base/basictypes.h" 14 #include "base/basictypes.h"
14 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
15 #include "base/logging.h" 16 #include "base/logging.h"
16 #include "base/time/time.h" 17 #include "base/time/time.h"
17 #include "media/cast/transport/cast_transport_config.h" 18 #include "media/cast/transport/cast_transport_config.h"
18 19
19 namespace media { 20 namespace media {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 ((delay_fraction & 0xFFFF0000) >> 16); 129 ((delay_fraction & 0xFFFF0000) >> 16);
129 } 130 }
130 131
131 inline base::TimeDelta ConvertFromNtpDiff(uint32 ntp_delay) { 132 inline base::TimeDelta ConvertFromNtpDiff(uint32 ntp_delay) {
132 uint32 delay_ms = (ntp_delay & 0x0000ffff) * 1000; 133 uint32 delay_ms = (ntp_delay & 0x0000ffff) * 1000;
133 delay_ms >>= 16; 134 delay_ms >>= 16;
134 delay_ms += ((ntp_delay & 0xffff0000) >> 16) * 1000; 135 delay_ms += ((ntp_delay & 0xffff0000) >> 16) * 1000;
135 return base::TimeDelta::FromMilliseconds(delay_ms); 136 return base::TimeDelta::FromMilliseconds(delay_ms);
136 } 137 }
137 138
138 inline void ConvertTimeToFractions(int64 time_us, 139 inline void ConvertTimeToFractions(int64 ntp_time_us,
139 uint32* seconds, 140 uint32* seconds,
140 uint32* fractions) { 141 uint32* fractions) {
141 DCHECK_GE(time_us, 0) << "Time must NOT be negative"; 142 DCHECK_GE(ntp_time_us, 0) << "Time must NOT be negative";
142 *seconds = static_cast<uint32>(time_us / base::Time::kMicrosecondsPerSecond); 143 const int64 seconds_component =
144 ntp_time_us / base::Time::kMicrosecondsPerSecond;
145 CHECK(seconds_component <= std::numeric_limits<uint32>::max());
hubbe 2014/05/14 23:12:23 When will this wrap? What happens when if wraps?
miu 2014/05/16 22:45:47 Done. Documented.
146 *seconds = static_cast<uint32>(seconds_component);
143 *fractions = static_cast<uint32>( 147 *fractions = static_cast<uint32>(
144 (time_us % base::Time::kMicrosecondsPerSecond) * kMagicFractionalUnit); 148 (ntp_time_us % base::Time::kMicrosecondsPerSecond) *
149 kMagicFractionalUnit);
145 } 150 }
146 151
147 inline void ConvertTimeTicksToNtp(const base::TimeTicks& time, 152 inline void ConvertTimeTicksToNtp(const base::TimeTicks& time,
148 uint32* ntp_seconds, 153 uint32* ntp_seconds,
149 uint32* ntp_fractions) { 154 uint32* ntp_fractions) {
150 base::TimeDelta elapsed_since_unix_epoch = 155 base::TimeDelta elapsed_since_unix_epoch =
151 time - base::TimeTicks::UnixEpoch(); 156 time - base::TimeTicks::UnixEpoch();
152 157
153 int64 ntp_time_us = 158 int64 ntp_time_us =
154 elapsed_since_unix_epoch.InMicroseconds() + 159 elapsed_since_unix_epoch.InMicroseconds() +
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 base::TimeTicks time_sent_; 227 base::TimeTicks time_sent_;
223 uint32 rtp_timestamp_; 228 uint32 rtp_timestamp_;
224 229
225 DISALLOW_COPY_AND_ASSIGN(RtpSenderStatistics); 230 DISALLOW_COPY_AND_ASSIGN(RtpSenderStatistics);
226 }; 231 };
227 232
228 } // namespace cast 233 } // namespace cast
229 } // namespace media 234 } // namespace media
230 235
231 #endif // MEDIA_CAST_CAST_DEFINES_H_ 236 #endif // MEDIA_CAST_CAST_DEFINES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698