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_BASE_TEXT_RANGES_H_ | |
6 #define MEDIA_BASE_TEXT_RANGES_H_ | |
7 | |
8 #include <map> | |
9 | |
10 #include "base/macros.h" | |
11 #include "base/time/time.h" | |
12 #include "media/base/media_export.h" | |
13 | |
14 namespace media { | |
15 | |
16 class MEDIA_EXPORT TextRanges { | |
17 public: | |
18 TextRanges(); | |
19 | |
20 // We must bind to a new range (either one that exists already, or | |
21 // one that is freshly-created) following a seek. | |
22 void Flush(); | |
acolwell GONE FROM CHROMIUM
2014/02/05 19:09:36
nit: The name of the method and the comment above
Matthew Heaney (Chromium)
2014/02/06 02:25:48
Done.
| |
23 | |
24 // To test whether a cue has already been pushed downstream. | |
acolwell GONE FROM CHROMIUM
2014/02/05 19:09:36
nit: This does more than simply test whether the c
Matthew Heaney (Chromium)
2014/02/06 02:25:48
Done.
| |
25 bool AddCue(base::TimeDelta start_time); | |
26 | |
27 // To test whether a cue is present on the active time range, | |
28 // without causing any side-effect. If no range is active, Present | |
29 // returns -1; if a range is active, it returns 1 if |start_time| is | |
30 // in the active range and 0 otherwise. | |
31 int Present(base::TimeDelta start_time) const; | |
32 | |
33 private: | |
34 // Describes a range of times for cues that have already been | |
35 // pushed downstream. | |
36 struct Range { | |
37 // The last timestamp of this range. | |
38 base::TimeDelta last_time; | |
39 | |
40 // The number of cues we have detected so far, for this range, | |
41 // whose timestamp matches last_time. | |
42 int max_count; | |
43 | |
44 // The number of cues we have seen since the most recent seek, | |
45 // whose timestamp matches last_time. | |
46 int count; | |
47 }; | |
48 | |
49 // Following a seek, we create a new range if no existing range | |
50 // matches the seek time. | |
acolwell GONE FROM CHROMIUM
2014/02/05 19:09:36
nit: Technically this isn't a seek time. It's the
Matthew Heaney (Chromium)
2014/02/06 02:25:48
Done.
| |
51 void NewRange(base::TimeDelta start_time); | |
52 | |
53 // The collection of time ranges, each of which is bounded | |
54 // (inclusive) by the key and Range::last_time. | |
55 typedef std::map<base::TimeDelta, Range> RangeMap; | |
56 RangeMap range_map_; | |
57 | |
58 // The time range to which we bind following a seek. | |
acolwell GONE FROM CHROMIUM
2014/02/05 19:09:36
nit: s/seek/Reset()/
Matthew Heaney (Chromium)
2014/02/06 02:25:48
Done.
| |
59 RangeMap::iterator curr_range_itr_; | |
60 | |
61 DISALLOW_COPY_AND_ASSIGN(TextRanges); | |
62 }; | |
63 | |
64 } // namespace media | |
65 | |
66 #endif // MEDIA_BASE_TEXT_RANGES_H_ | |
OLD | NEW |