| 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 #ifndef MEDIA_CAST_LOGGING_RECEIVER_TIME_OFFSET_ESTIMATOR_IMPL_H_ | 5 #ifndef MEDIA_CAST_LOGGING_RECEIVER_TIME_OFFSET_ESTIMATOR_IMPL_H_ |
| 6 #define MEDIA_CAST_LOGGING_RECEIVER_TIME_OFFSET_ESTIMATOR_IMPL_H_ | 6 #define MEDIA_CAST_LOGGING_RECEIVER_TIME_OFFSET_ESTIMATOR_IMPL_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 // to calculate an upper bound on the difference between the clocks | 51 // to calculate an upper bound on the difference between the clocks |
| 52 // on the sender and receiver. Note that this difference can take | 52 // on the sender and receiver. Note that this difference can take |
| 53 // very large positive or negative values, but the smaller value is | 53 // very large positive or negative values, but the smaller value is |
| 54 // always the better estimate, since a receive event cannot possibly | 54 // always the better estimate, since a receive event cannot possibly |
| 55 // happen before a send event. Note that we use this to calculate | 55 // happen before a send event. Note that we use this to calculate |
| 56 // both upper and lower bounds by reversing the sender/receiver | 56 // both upper and lower bounds by reversing the sender/receiver |
| 57 // relationship. | 57 // relationship. |
| 58 class BoundCalculator { | 58 class BoundCalculator { |
| 59 public: | 59 public: |
| 60 typedef std::pair<base::TimeTicks, base::TimeTicks> TimeTickPair; | 60 typedef std::pair<base::TimeTicks, base::TimeTicks> TimeTickPair; |
| 61 typedef std::map<uint64, TimeTickPair> EventMap; | 61 typedef std::map<uint64_t, TimeTickPair> EventMap; |
| 62 | 62 |
| 63 BoundCalculator(); | 63 BoundCalculator(); |
| 64 ~BoundCalculator(); | 64 ~BoundCalculator(); |
| 65 bool has_bound() const { return has_bound_; } | 65 bool has_bound() const { return has_bound_; } |
| 66 base::TimeDelta bound() const { return bound_; } | 66 base::TimeDelta bound() const { return bound_; } |
| 67 | 67 |
| 68 void SetSent(uint32 rtp, | 68 void SetSent(uint32_t rtp, |
| 69 uint32 packet_id, | 69 uint32_t packet_id, |
| 70 bool audio, | 70 bool audio, |
| 71 base::TimeTicks t); | 71 base::TimeTicks t); |
| 72 | 72 |
| 73 void SetReceived(uint32 rtp, | 73 void SetReceived(uint32_t rtp, |
| 74 uint16 packet_id, | 74 uint16_t packet_id, |
| 75 bool audio, | 75 bool audio, |
| 76 base::TimeTicks t); | 76 base::TimeTicks t); |
| 77 | 77 |
| 78 private: | 78 private: |
| 79 void UpdateBound(base::TimeTicks a, base::TimeTicks b); | 79 void UpdateBound(base::TimeTicks a, base::TimeTicks b); |
| 80 void CheckUpdate(uint64 key); | 80 void CheckUpdate(uint64_t key); |
| 81 | 81 |
| 82 private: | 82 private: |
| 83 EventMap events_; | 83 EventMap events_; |
| 84 bool has_bound_; | 84 bool has_bound_; |
| 85 base::TimeDelta bound_; | 85 base::TimeDelta bound_; |
| 86 }; | 86 }; |
| 87 | 87 |
| 88 // Fixed size storage to store event times for recent frames. | 88 // Fixed size storage to store event times for recent frames. |
| 89 BoundCalculator upper_bound_; | 89 BoundCalculator upper_bound_; |
| 90 BoundCalculator lower_bound_; | 90 BoundCalculator lower_bound_; |
| 91 | 91 |
| 92 base::ThreadChecker thread_checker_; | 92 base::ThreadChecker thread_checker_; |
| 93 DISALLOW_COPY_AND_ASSIGN(ReceiverTimeOffsetEstimatorImpl); | 93 DISALLOW_COPY_AND_ASSIGN(ReceiverTimeOffsetEstimatorImpl); |
| 94 }; | 94 }; |
| 95 | 95 |
| 96 } // namespace cast | 96 } // namespace cast |
| 97 } // namespace media | 97 } // namespace media |
| 98 | 98 |
| 99 #endif // MEDIA_CAST_LOGGING_RECEIVER_TIME_OFFSET_ESTIMATOR_IMPL_H_ | 99 #endif // MEDIA_CAST_LOGGING_RECEIVER_TIME_OFFSET_ESTIMATOR_IMPL_H_ |
| OLD | NEW |