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

Unified Diff: media/blink/buffered_data_source_host_impl.h

Issue 2796193002: fix canplaythrough (Closed)
Patch Set: comments addressed Created 3 years, 8 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
Index: media/blink/buffered_data_source_host_impl.h
diff --git a/media/blink/buffered_data_source_host_impl.h b/media/blink/buffered_data_source_host_impl.h
index 7dc39ea331a6ab447e0998e6ca19ce10e254acdf..75d5f596eb69283dcf8903650e1dd6634b85c7a0 100644
--- a/media/blink/buffered_data_source_host_impl.h
+++ b/media/blink/buffered_data_source_host_impl.h
@@ -6,7 +6,9 @@
#define MEDIA_BLINK_BUFFERED_DATA_SOURCE_HOST_IMPL_H_
#include <stdint.h>
+#include <deque>
+#include "base/callback.h"
#include "base/macros.h"
#include "base/time/time.h"
#include "media/base/ranges.h"
@@ -35,7 +37,7 @@ class MEDIA_BLINK_EXPORT BufferedDataSourceHost {
class MEDIA_BLINK_EXPORT BufferedDataSourceHostImpl
: public BufferedDataSourceHost {
public:
- BufferedDataSourceHostImpl();
+ explicit BufferedDataSourceHostImpl(const base::Closure& progress_cb);
~BufferedDataSourceHostImpl() override;
// BufferedDataSourceHost implementation.
@@ -50,7 +52,20 @@ class MEDIA_BLINK_EXPORT BufferedDataSourceHostImpl
bool DidLoadingProgress();
+ // Returns true if we have enough buffered bytes to play from now
+ // until the end of media
+ bool CanPlayThrough(base::TimeDelta current_position,
+ base::TimeDelta media_duration,
+ double playback_rate) const;
+
private:
+ // Returns number of bytes not yet loaded in the given interval.
+ int64_t UnloadedBytesInInterval(const Interval<int64_t>& interval) const;
+
+ // Returns an estimate of the download rate.
+ // Returns 0.0 if an estimate cannot be made.
+ double DownloadRate() const;
+
// Total size of the data source.
int64_t total_bytes_;
@@ -62,6 +77,11 @@ class MEDIA_BLINK_EXPORT BufferedDataSourceHostImpl
// DidLoadingProgress().
bool did_loading_progress_;
+ // Contains how much we had downloaded at a given time.
+ // Pruned to contain roughtly the last 10 seconds of data.
DaleCurtis 2017/04/06 22:51:39 roughly.
hubbe 2017/04/07 19:35:51 Done.
+ std::deque<std::pair<base::TimeTicks, uint64_t>> download_history_;
+ base::Closure progress_cb_;
+
DISALLOW_COPY_AND_ASSIGN(BufferedDataSourceHostImpl);
};
« no previous file with comments | « no previous file | media/blink/buffered_data_source_host_impl.cc » ('j') | media/blink/buffered_data_source_host_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698