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_H_ 6 #define MEDIA_CAST_LOGGING_RECEIVER_TIME_OFFSET_ESTIMATOR_H_ 7 8 #include "base/time/time.h" 9 #include "media/cast/logging/raw_event_subscriber.h" 10 11 namespace media { 12 namespace cast { 13 14 // Estimates receiver time offset based on raw events received. 15 // In most cases, the sender and receiver run on different time lines. 16 // In order to convert receiver time back to sender time (or vice versa) 17 // a certain time offset has to be applied. 18 // An implementation of this interface listens to raw events to figure out 19 // the bounds for the offset value (assuming the true offset value is constant 20 // over the lifetime of a cast session). 21 // The offset values provided here should be used as follows: 22 // - Convert from sender to receiver time: add offset value to sender timestamp. 23 // - Convert from receiver to sender time: subtract offset value from receiver 24 // timestamp. 25 class ReceiverTimeOffsetEstimator : public RawEventSubscriber { 26 public: 27 virtual ~ReceiverTimeOffsetEstimator() {} 28 29 // If bounds are known, assigns |lower_bound| and |upper_bound| with the 30 // lower bound and upper bound for the offset value, respectively. 31 // Returns true if bounds are known. 32 virtual bool GetReceiverOffsetBounds(base::TimeDelta* lower_bound, 33 base::TimeDelta* upper_bound) = 0; 34 }; 35 36 } // namespace cast 37 } // namespace media 38 39 #endif // MEDIA_CAST_LOGGING_RECEIVER_TIME_OFFSET_ESTIMATOR_H_ 40