OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_BASE_RANGES_H_ | 5 #ifndef MEDIA_BASE_RANGES_H_ |
6 #define MEDIA_BASE_RANGES_H_ | 6 #define MEDIA_BASE_RANGES_H_ |
7 | 7 |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <ostream> | 9 #include <ostream> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | |
13 #include "base/logging.h" | 12 #include "base/logging.h" |
14 #include "base/time/time.h" | 13 #include "base/time/time.h" |
15 #include "media/base/media_export.h" | 14 #include "media/base/media_export.h" |
16 | 15 |
17 namespace media { | 16 namespace media { |
18 | 17 |
19 // Ranges allows holding an ordered list of ranges of [start,end) intervals. | 18 // Ranges allows holding an ordered list of ranges of [start,end) intervals. |
20 // The canonical example use-case is holding the list of ranges of buffered | 19 // The canonical example use-case is holding the list of ranges of buffered |
21 // bytes or times in a <video> tag. | 20 // bytes or times in a <video> tag. |
22 template<class T> // Endpoint type; typically a base::TimeDelta or an int64. | 21 template <class T> // Endpoint type; typically a base::TimeDelta or an int64_t. |
23 class Ranges { | 22 class Ranges { |
24 public: | 23 public: |
25 // Allow copy & assign. | 24 // Allow copy & assign. |
26 | 25 |
27 // Add (start,end) to this object, coallescing overlaps as appropriate. | 26 // Add (start,end) to this object, coallescing overlaps as appropriate. |
28 // Returns the number of stored ranges, post coallescing. | 27 // Returns the number of stored ranges, post coallescing. |
29 size_t Add(T start, T end); | 28 size_t Add(T start, T end); |
30 | 29 |
31 // Return the number of disjoint ranges. | 30 // Return the number of disjoint ranges. |
32 size_t size() const; | 31 size_t size() const; |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 else | 152 else |
154 ++j; | 153 ++j; |
155 } | 154 } |
156 | 155 |
157 return result; | 156 return result; |
158 } | 157 } |
159 | 158 |
160 } // namespace media | 159 } // namespace media |
161 | 160 |
162 #endif // MEDIA_BASE_RANGES_H_ | 161 #endif // MEDIA_BASE_RANGES_H_ |
OLD | NEW |