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.
5 #ifndef CONTENT_RENDERER_MEDIA_BUFFERED_DATA_SOURCE_HOST_IMPL_H_
6 #define CONTENT_RENDERER_MEDIA_BUFFERED_DATA_SOURCE_HOST_IMPL_H_
8 #include "base/time/time.h"
9 #include "content/common/content_export.h"
10 #include "content/renderer/media/buffered_data_source.h"
11 #include "media/base/ranges.h"
15 // Provides an implementation of BufferedDataSourceHost that translates the
16 // buffered byte ranges into estimated time ranges.
17 class CONTENT_EXPORT BufferedDataSourceHostImpl
18 : public BufferedDataSourceHost {
20 BufferedDataSourceHostImpl();
21 virtual ~BufferedDataSourceHostImpl();
23 // BufferedDataSourceHost implementation.
24 virtual void SetTotalBytes(int64 total_bytes) OVERRIDE;
25 virtual void AddBufferedByteRange(int64 start, int64 end) OVERRIDE;
27 // Translate the byte ranges to time ranges and append them to the list.
28 void AddBufferedTimeRanges(
29 media::Ranges<base::TimeDelta>* buffered_time_ranges,
30 base::TimeDelta media_duration);
32 // TODO(sandersd): Change this to non-const along with Pipeline's version.
33 // http://crbug.com/360251
34 bool DidLoadingProgress() const;
37 // Total size of the data source.
40 // List of buffered byte ranges for estimating buffered time.
41 media::Ranges<int64> buffered_byte_ranges_;
43 // True when AddBufferedByteRange() has been called more recently than
44 // DidLoadingProgress().
45 mutable bool did_loading_progress_;
47 DISALLOW_COPY_AND_ASSIGN(BufferedDataSourceHostImpl);
50 } // namespace content
52 #endif // CONTENT_RENDERER_MEDIA_BUFFERED_DATA_SOURCE_HOST_IMPL_H_