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

Side by Side Diff: media/filters/source_buffer_stream.h

Issue 10228017: Add initial implementation of SourceBufferStream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_
6 #define MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_
7
8 #include <deque>
9 #include <list>
acolwell GONE FROM CHROMIUM 2012/04/29 18:13:06 nit: lint says you should add the include for std:
vrk (LEFT CHROMIUM) 2012/05/01 22:51:13 Done.
10
11 #include "base/memory/ref_counted.h"
12 #include "media/base/buffers.h"
13 #include "media/base/media_export.h"
14
15 namespace media {
16
17 class SourceBufferRange;
18
19 // SourceBufferStream is a data structure that stores media Buffers in ranges.
20 // Buffers can be appended out of presentation order. Buffers are retrieved by
21 // seeking to the desired start point and calling GetNextBuffer(). Buffers are
22 // returned in sequential presentation order.
23 class MEDIA_EXPORT SourceBufferStream {
24 public:
25 typedef std::deque<scoped_refptr<Buffer> > BufferQueue;
26 typedef std::pair<base::TimeDelta, base::TimeDelta> Timespan;
27 typedef std::list<Timespan> TimespanList;
28
29 SourceBufferStream();
30 ~SourceBufferStream();
31
32 // Add the |buffers| to the SourceBufferStream. Buffers within the queue are
33 // expected to be in order, but multiple calls to Append() may add buffers out
34 // of order or overlapping.
35 // Returns true if Append() was successful, false if |buffers| are not added.
36 // TODO(vrk): Implement proper end-overlapping. (crbug.com/125072)
37 // This may trigger garbage collection.
38 // TODO(vrk): Implement garbage collection. (crbug.com/125070)
39 bool Append(const BufferQueue& buffers);
40
41 // Changes the SourceBufferStream's state so that it will start returning
42 // buffers starting from the closest keyframe before |timestamp|.
43 void Seek(base::TimeDelta timestamp);
44
45 // Fills |out_buffer| with a new buffer. Seek() must be called before calling
46 // this method. Buffers are presented in order from the last call to Seek().
47 // |out_buffer|'s timestamp may be earlier than the |timestamp| passed to
48 // the last Seek() call.
49 // Returns true if |out_buffer| is filled with a valid buffer, false if
50 // there is not enough data buffered to fulfill the request.
51 bool GetNextBuffer(scoped_refptr<Buffer>* out_buffer);
52
53 // Returns a list of the buffered time ranges.
54 TimespanList GetBufferedTime() const;
55
56 private:
57 typedef std::list<SourceBufferRange*> RangeList;
58 // List of disjoint buffered ranges, ordered by start time.
59 RangeList ranges_;
60
61 // True if more data needs to be appended before the Seek() can complete,
62 // false if no Seek() has been requested or the Seek() is completed.
63 bool seek_pending_;
64
65 // Timestamp of the last request to Seek().
66 base::TimeDelta seek_buffer_timestamp_;
67
68 // Pointer to the seeked-to Range. This is the Range from which
69 // GetNextBuffer() calls are fulfilled.
70 SourceBufferRange* selected_range_;
71
72 DISALLOW_COPY_AND_ASSIGN(SourceBufferStream);
73 };
74
75 } // namespace media
76
77 #endif // MEDIA_FILTERS_SOURCE_BUFFER_STREAM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698