Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef MEDIA_CAST_LOGGING_RECEIVER_TIME_OFFSET_ESTIMATOR_IMPL_H_ | |
| 6 #define MEDIA_CAST_LOGGING_RECEIVER_TIME_OFFSET_ESTIMATOR_IMPL_H_ | |
| 7 | |
| 8 #include "base/time/time.h" | |
| 9 #include "base/threading/thread_checker.h" | |
| 10 #include "media/cast/logging/logging_defines.h" | |
| 11 #include "media/cast/logging/receiver_time_offset_estimator.h" | |
| 12 | |
| 13 namespace media { | |
| 14 namespace cast { | |
| 15 | |
| 16 // This implementation listens to three types of events: | |
| 17 // 1. kVideoFrameEncoded (sender side) | |
| 18 // 2. kVideoAckSent (receiver side) | |
| 19 // 3. kVideoAckReceived (sender side) | |
| 20 // There is a causal relationship between these events in that these events | |
| 21 // must happen in order. This class obtains the lower and upper bounds for | |
| 22 // the offset by taking the difference of timestamps (2) - (1) and (2) - (3), | |
| 23 // respectively. | |
| 24 // The bound will become better as the latency between the events decreases. | |
| 25 class ReceiverTimeOffsetEstimatorImpl : public ReceiverTimeOffsetEstimator { | |
| 26 public: | |
| 27 ReceiverTimeOffsetEstimatorImpl(); | |
| 28 | |
| 29 virtual ~ReceiverTimeOffsetEstimatorImpl(); | |
| 30 | |
| 31 // RawReventSubscriber implementations. | |
|
miu
2014/04/17 02:14:14
Please fix typo.
imcheng
2014/04/17 19:19:06
Done.
| |
| 32 virtual void OnReceiveFrameEvent(const FrameEvent& frame_event) OVERRIDE; | |
| 33 virtual void OnReceivePacketEvent(const PacketEvent& packet_event) OVERRIDE; | |
| 34 virtual void OnReceiveGenericEvent(const GenericEvent& generic_event) | |
| 35 OVERRIDE; | |
| 36 | |
| 37 // ReceiverTimeOffsetEstimator implementation. | |
| 38 virtual bool GetReceiverOffsetBounds(base::TimeDelta* lower_bound, | |
| 39 base::TimeDelta* upper_bound) OVERRIDE; | |
| 40 | |
| 41 private: | |
| 42 struct EventTimes { | |
| 43 base::TimeTicks event_a_time; | |
| 44 base::TimeTicks event_b_time; | |
| 45 base::TimeTicks event_c_time; | |
| 46 }; | |
| 47 | |
| 48 typedef std::map<RtpTimestamp, EventTimes> EventTimesMap; | |
| 49 | |
| 50 void UpdateOffsetBounds(const EventTimes& event); | |
| 51 | |
| 52 // Fixed size storage to store event times for recent frames. | |
| 53 EventTimesMap event_times_map_; | |
| 54 | |
| 55 bool bounded_; | |
| 56 base::TimeDelta offset_lower_bound_; | |
| 57 base::TimeDelta offset_upper_bound_; | |
| 58 | |
| 59 base::ThreadChecker thread_checker_; | |
| 60 DISALLOW_COPY_AND_ASSIGN(ReceiverTimeOffsetEstimatorImpl); | |
| 61 }; | |
| 62 | |
| 63 } // namespace cast | |
| 64 } // namespace media | |
| 65 | |
| 66 #endif // MEDIA_CAST_LOGGING_RECEIVER_TIME_OFFSET_ESTIMATOR_IMPL_H_ | |
| OLD | NEW |