OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license | |
5 * that can be found in the LICENSE file in the root of the source | |
6 * tree. An additional intellectual property rights grant can be found | |
7 * in the file PATENTS. All contributing project authors may | |
8 * be found in the AUTHORS file in the root of the source tree. | |
9 */ | |
10 | |
11 #ifndef WEBRTC_AUDIO_TIME_INTERVAL_H_ | |
12 #define WEBRTC_AUDIO_TIME_INTERVAL_H_ | |
13 | |
14 #include <stdint.h> | |
15 | |
16 #include "webrtc/rtc_base/optional.h" | |
17 | |
18 namespace webrtc { | |
19 | |
20 // This class logs the first and last time its Extend() function is called. | |
21 // | |
22 // This class is not thread-safe; Extend() calls should only be made by a | |
23 // single thread at a time, such as within a lock or destructor. | |
24 // | |
25 // Example usage: | |
26 // // let x < y < z < u < v | |
27 // rtc::TimeInterval interval; | |
28 // ... // interval.Extend(); // at time x | |
29 // ... | |
30 // interval.Extend(); // at time y | |
31 // ... | |
32 // interval.Extend(); // at time u | |
33 // ... | |
34 // interval.Extend(z); // at time v | |
35 // ... | |
36 // if (!interval.Empty()) { | |
37 // int64_t active_time = interval.Length(); // returns (u - x) | |
38 // } | |
39 class TimeInterval { | |
40 public: | |
41 TimeInterval(); | |
42 ~TimeInterval(); | |
43 // Extend the interval with the current time. | |
44 void Extend(); | |
45 // Extend the interval with a given time. | |
46 void Extend(int64_t time); | |
47 // Take the convex hull with another interval. | |
saza WebRTC
2017/07/18 09:39:28
Original line:
// Extend the interval with another
| |
48 void Extend(const TimeInterval& other_interval); | |
49 // True iff Extend has never been called. | |
50 bool Empty() const; | |
51 // Returns the time between the first and the last tick, in milliseconds. | |
52 int64_t Length() const; | |
53 | |
54 private: | |
55 struct Interval { | |
56 Interval(int64_t first, int64_t last); | |
57 | |
58 int64_t first, last; | |
59 }; | |
60 rtc::Optional<Interval> interval_; | |
61 }; | |
62 | |
63 } // namespace webrtc | |
64 | |
65 #endif // WEBRTC_AUDIO_TIME_INTERVAL_H_ | |
OLD | NEW |