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

Unified Diff: webrtc/audio/time_interval.h

Issue 2979833002: Add a histogram metric tracking for how long audio RTP packets are sent (Closed)
Patch Set: Adjust for comments. Created 3 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/audio/audio_send_stream.cc ('k') | webrtc/audio/time_interval.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/audio/time_interval.h
diff --git a/webrtc/audio/time_interval.h b/webrtc/audio/time_interval.h
new file mode 100644
index 0000000000000000000000000000000000000000..069127d641d723bb1241700cdbb6a4be32a727f6
--- /dev/null
+++ b/webrtc/audio/time_interval.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef WEBRTC_AUDIO_TIME_INTERVAL_H_
+#define WEBRTC_AUDIO_TIME_INTERVAL_H_
+
+#include <stdint.h>
+
+#include "webrtc/rtc_base/optional.h"
+
+namespace webrtc {
+
+// This class logs the first and last time its Extend() function is called.
+//
+// This class is not thread-safe; Extend() calls should only be made by a
+// single thread at a time, such as within a lock or destructor.
+//
+// Example usage:
+// // let x < y < z < u < v
+// rtc::TimeInterval interval;
+// ... // interval.Extend(); // at time x
+// ...
+// interval.Extend(); // at time y
+// ...
+// interval.Extend(); // at time u
+// ...
+// interval.Extend(z); // at time v
+// ...
+// if (!interval.Empty()) {
+// int64_t active_time = interval.Length(); // returns (u - x)
+// }
+class TimeInterval {
+ public:
+ TimeInterval();
+ ~TimeInterval();
+ // Extend the interval with the current time.
+ void Extend();
+ // Extend the interval with a given time.
+ void Extend(int64_t time);
+ // Take the convex hull with another interval.
saza WebRTC 2017/07/18 09:39:28 Original line: // Extend the interval with another
+ void Extend(const TimeInterval& other_interval);
+ // True iff Extend has never been called.
+ bool Empty() const;
+ // Returns the time between the first and the last tick, in milliseconds.
+ int64_t Length() const;
+
+ private:
+ struct Interval {
+ Interval(int64_t first, int64_t last);
+
+ int64_t first, last;
+ };
+ rtc::Optional<Interval> interval_;
+};
+
+} // namespace webrtc
+
+#endif // WEBRTC_AUDIO_TIME_INTERVAL_H_
« no previous file with comments | « webrtc/audio/audio_send_stream.cc ('k') | webrtc/audio/time_interval.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698