summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsandersd@chromium.org <sandersd@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-16 00:05:31 +0000
committersandersd@chromium.org <sandersd@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-16 00:05:31 +0000
commit02022fc1935970dfc2690eb150cbb0ab304d54ed (patch)
tree244563e26057baeaa1b9c91278e90caff951bd48
parenteaf1a7c59154adf8672ccc7942464589e64c34a3 (diff)
downloadchromium_src-02022fc1935970dfc2690eb150cbb0ab304d54ed.zip
chromium_src-02022fc1935970dfc2690eb150cbb0ab304d54ed.tar.gz
chromium_src-02022fc1935970dfc2690eb150cbb0ab304d54ed.tar.bz2
Add return-by-value implementations of blink::WebMediaPlayer::buffered()
This prep work will allow the interface in blink to be changed. Blink change is https://codereview.chromium.org/284143002/. BUG=360254 Review URL: https://codereview.chromium.org/282073003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@270870 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/renderer/media/android/media_source_delegate.cc4
-rw-r--r--content/renderer/media/android/media_source_delegate.h1
-rw-r--r--content/renderer/media/android/webmediaplayer_android.cc6
-rw-r--r--content/renderer/media/android/webmediaplayer_android.h1
-rw-r--r--content/renderer/media/buffered_data_source_host_impl.cc2
-rw-r--r--content/renderer/media/buffered_data_source_host_impl.h3
-rw-r--r--content/renderer/media/webmediaplayer_impl.cc9
-rw-r--r--content/renderer/media/webmediaplayer_impl.h1
-rw-r--r--content/renderer/media/webmediaplayer_ms.cc5
-rw-r--r--content/renderer/media/webmediaplayer_ms.h1
-rw-r--r--media/base/pipeline.cc2
-rw-r--r--media/base/pipeline.h2
12 files changed, 33 insertions, 4 deletions
diff --git a/content/renderer/media/android/media_source_delegate.cc b/content/renderer/media/android/media_source_delegate.cc
index 6b6523c..bd786b0 100644
--- a/content/renderer/media/android/media_source_delegate.cc
+++ b/content/renderer/media/android/media_source_delegate.cc
@@ -190,6 +190,10 @@ const blink::WebTimeRanges& MediaSourceDelegate::Buffered() {
return buffered_web_time_ranges_;
}
+blink::WebTimeRanges MediaSourceDelegate::Buffered() const {
+ return ConvertToWebTimeRanges(buffered_time_ranges_);
+}
+
size_t MediaSourceDelegate::DecodedFrameCount() const {
return statistics_.video_frames_decoded;
}
diff --git a/content/renderer/media/android/media_source_delegate.h b/content/renderer/media/android/media_source_delegate.h
index 4480a45..75de676 100644
--- a/content/renderer/media/android/media_source_delegate.h
+++ b/content/renderer/media/android/media_source_delegate.h
@@ -68,6 +68,7 @@ class MediaSourceDelegate : public media::DemuxerHost {
const DurationChangeCB& duration_change_cb);
const blink::WebTimeRanges& Buffered();
+ blink::WebTimeRanges Buffered() const;
size_t DecodedFrameCount() const;
size_t DroppedFrameCount() const;
size_t AudioDecodedByteCount() const;
diff --git a/content/renderer/media/android/webmediaplayer_android.cc b/content/renderer/media/android/webmediaplayer_android.cc
index 3fe6c2e..fbee409 100644
--- a/content/renderer/media/android/webmediaplayer_android.cc
+++ b/content/renderer/media/android/webmediaplayer_android.cc
@@ -440,6 +440,12 @@ const WebTimeRanges& WebMediaPlayerAndroid::buffered() {
return buffered_;
}
+WebTimeRanges WebMediaPlayerAndroid::buffered() const {
+ if (media_source_delegate_)
+ return media_source_delegate_->Buffered();
+ return buffered_;
+}
+
double WebMediaPlayerAndroid::maxTimeSeekable() const {
// If we haven't even gotten to ReadyStateHaveMetadata yet then just
// return 0 so that the seekable range is empty.
diff --git a/content/renderer/media/android/webmediaplayer_android.h b/content/renderer/media/android/webmediaplayer_android.h
index 46142df..587e54c 100644
--- a/content/renderer/media/android/webmediaplayer_android.h
+++ b/content/renderer/media/android/webmediaplayer_android.h
@@ -99,6 +99,7 @@ class WebMediaPlayerAndroid : public blink::WebMediaPlayer,
virtual void setRate(double rate);
virtual void setVolume(double volume);
virtual const blink::WebTimeRanges& buffered();
+ virtual blink::WebTimeRanges buffered() const;
virtual double maxTimeSeekable() const;
// Poster image, as defined in the <video> element.
diff --git a/content/renderer/media/buffered_data_source_host_impl.cc b/content/renderer/media/buffered_data_source_host_impl.cc
index 03311db..45c97e6 100644
--- a/content/renderer/media/buffered_data_source_host_impl.cc
+++ b/content/renderer/media/buffered_data_source_host_impl.cc
@@ -35,7 +35,7 @@ static base::TimeDelta TimeForByteOffset(
void BufferedDataSourceHostImpl::AddBufferedTimeRanges(
media::Ranges<base::TimeDelta>* buffered_time_ranges,
- base::TimeDelta media_duration) {
+ base::TimeDelta media_duration) const {
if (total_bytes_ && buffered_byte_ranges_.size()) {
for (size_t i = 0; i < buffered_byte_ranges_.size(); ++i) {
int64 start = buffered_byte_ranges_.start(i);
diff --git a/content/renderer/media/buffered_data_source_host_impl.h b/content/renderer/media/buffered_data_source_host_impl.h
index 301b08e..d04d467 100644
--- a/content/renderer/media/buffered_data_source_host_impl.h
+++ b/content/renderer/media/buffered_data_source_host_impl.h
@@ -25,9 +25,10 @@ class CONTENT_EXPORT BufferedDataSourceHostImpl
virtual void AddBufferedByteRange(int64 start, int64 end) OVERRIDE;
// Translate the byte ranges to time ranges and append them to the list.
+ // TODO(sandersd): This is a confusing name, find something better.
void AddBufferedTimeRanges(
media::Ranges<base::TimeDelta>* buffered_time_ranges,
- base::TimeDelta media_duration);
+ base::TimeDelta media_duration) const;
bool DidLoadingProgress();
diff --git a/content/renderer/media/webmediaplayer_impl.cc b/content/renderer/media/webmediaplayer_impl.cc
index a57c67e..12509dc 100644
--- a/content/renderer/media/webmediaplayer_impl.cc
+++ b/content/renderer/media/webmediaplayer_impl.cc
@@ -523,6 +523,15 @@ const blink::WebTimeRanges& WebMediaPlayerImpl::buffered() {
return buffered_web_time_ranges_;
}
+blink::WebTimeRanges WebMediaPlayerImpl::buffered() const {
+ DCHECK(main_loop_->BelongsToCurrentThread());
+ media::Ranges<base::TimeDelta> buffered_time_ranges =
+ pipeline_.GetBufferedTimeRanges();
+ buffered_data_source_host_.AddBufferedTimeRanges(
+ &buffered_time_ranges, pipeline_.GetMediaDuration());
+ return ConvertToWebTimeRanges(buffered_time_ranges);
+}
+
double WebMediaPlayerImpl::maxTimeSeekable() const {
DCHECK(main_loop_->BelongsToCurrentThread());
diff --git a/content/renderer/media/webmediaplayer_impl.h b/content/renderer/media/webmediaplayer_impl.h
index 5a9092d..a58613e 100644
--- a/content/renderer/media/webmediaplayer_impl.h
+++ b/content/renderer/media/webmediaplayer_impl.h
@@ -88,6 +88,7 @@ class WebMediaPlayerImpl
virtual void setVolume(double volume);
virtual void setPreload(blink::WebMediaPlayer::Preload preload);
virtual const blink::WebTimeRanges& buffered();
+ virtual blink::WebTimeRanges buffered() const;
virtual double maxTimeSeekable() const;
// Methods for painting.
diff --git a/content/renderer/media/webmediaplayer_ms.cc b/content/renderer/media/webmediaplayer_ms.cc
index c46c107..64d2f3a 100644
--- a/content/renderer/media/webmediaplayer_ms.cc
+++ b/content/renderer/media/webmediaplayer_ms.cc
@@ -306,6 +306,11 @@ const blink::WebTimeRanges& WebMediaPlayerMS::buffered() {
return buffered_;
}
+blink::WebTimeRanges WebMediaPlayerMS::buffered() const {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ return buffered_;
+}
+
double WebMediaPlayerMS::maxTimeSeekable() const {
DCHECK(thread_checker_.CalledOnValidThread());
return 0.0;
diff --git a/content/renderer/media/webmediaplayer_ms.h b/content/renderer/media/webmediaplayer_ms.h
index 7fbf625..4c1cdf2 100644
--- a/content/renderer/media/webmediaplayer_ms.h
+++ b/content/renderer/media/webmediaplayer_ms.h
@@ -76,6 +76,7 @@ class WebMediaPlayerMS
virtual void setVolume(double volume);
virtual void setPreload(blink::WebMediaPlayer::Preload preload);
virtual const blink::WebTimeRanges& buffered();
+ virtual blink::WebTimeRanges buffered() const;
virtual double maxTimeSeekable() const;
// Methods for painting.
diff --git a/media/base/pipeline.cc b/media/base/pipeline.cc
index 9a74880..e177e18 100644
--- a/media/base/pipeline.cc
+++ b/media/base/pipeline.cc
@@ -159,7 +159,7 @@ TimeDelta Pipeline::GetMediaTime() const {
return clock_->Elapsed();
}
-Ranges<TimeDelta> Pipeline::GetBufferedTimeRanges() {
+Ranges<TimeDelta> Pipeline::GetBufferedTimeRanges() const {
base::AutoLock auto_lock(lock_);
return buffered_time_ranges_;
}
diff --git a/media/base/pipeline.h b/media/base/pipeline.h
index b40a660..06bffba 100644
--- a/media/base/pipeline.h
+++ b/media/base/pipeline.h
@@ -164,7 +164,7 @@ class MEDIA_EXPORT Pipeline : public DemuxerHost {
base::TimeDelta GetMediaTime() const;
// Get approximate time ranges of buffered media.
- Ranges<base::TimeDelta> GetBufferedTimeRanges();
+ Ranges<base::TimeDelta> GetBufferedTimeRanges() const;
// Get the duration of the media in microseconds. If the duration has not
// been determined yet, then returns 0.