summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrileya@chromium.org <rileya@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-10 20:00:45 +0000
committerrileya@chromium.org <rileya@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-10 20:00:45 +0000
commit7c63c2ee2f35556e3b5d8c5f4195998994baf7cc (patch)
treed0dfee05ee508d2a38bcee7b009283f1da396d18
parent5c159171b8cf439b43c42908ec158cef83889eca (diff)
downloadchromium_src-7c63c2ee2f35556e3b5d8c5f4195998994baf7cc.zip
chromium_src-7c63c2ee2f35556e3b5d8c5f4195998994baf7cc.tar.gz
chromium_src-7c63c2ee2f35556e3b5d8c5f4195998994baf7cc.tar.bz2
Remove default implementations from Demuxer.
Seek(), Stop(), and OnAudioRendererDisabled() are now pure virtual. SetPlaybackRate() is removed entirely, and moved down to BufferedDataSource. BUG=304990 Review URL: https://codereview.chromium.org/26492004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@227979 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/renderer/media/buffered_data_source.cc65
-rw-r--r--content/renderer/media/buffered_data_source.h10
-rw-r--r--content/renderer/media/webmediaplayer_impl.cc12
-rw-r--r--content/renderer/media/webmediaplayer_impl.h3
-rw-r--r--media/base/data_source.cc2
-rw-r--r--media/base/data_source.h3
-rw-r--r--media/base/demuxer.cc14
-rw-r--r--media/base/demuxer.h11
-rw-r--r--media/base/pipeline.cc2
-rw-r--r--media/base/pipeline_unittest.cc8
-rw-r--r--media/filters/ffmpeg_demuxer.cc5
-rw-r--r--media/filters/ffmpeg_demuxer.h1
12 files changed, 51 insertions, 85 deletions
diff --git a/content/renderer/media/buffered_data_source.cc b/content/renderer/media/buffered_data_source.cc
index 65a2d49..4ac2c0a 100644
--- a/content/renderer/media/buffered_data_source.cc
+++ b/content/renderer/media/buffered_data_source.cc
@@ -192,6 +192,37 @@ void BufferedDataSource::Abort() {
frame_ = NULL;
}
+void BufferedDataSource::SetPlaybackRate(float playback_rate) {
+ DCHECK(render_loop_->BelongsToCurrentThread());
+ DCHECK(loader_.get());
+
+ if (playback_rate < 0.0f)
+ return;
+ if (playback_rate != 0)
+ media_has_played_ = true;
+
+ playback_rate_ = playback_rate;
+ loader_->SetPlaybackRate(playback_rate);
+
+ if (!loader_->range_supported()) {
+ // 200 responses end up not being reused to satisfy future range requests,
+ // and we don't want to get too far ahead of the read-head (and thus require
+ // a restart), so keep to the thresholds.
+ loader_->UpdateDeferStrategy(BufferedResourceLoader::kCapacityDefer);
+ } else if (media_has_played_ && playback_rate == 0) {
+ // If the playback has started (at which point the preload value is ignored)
+ // and we're paused, then try to load as much as possible (the loader will
+ // fall back to kCapacityDefer if it knows the current response won't be
+ // useful from the cache in the future).
+ loader_->UpdateDeferStrategy(BufferedResourceLoader::kNeverDefer);
+ } else {
+ // If media is currently playing or the page indicated preload=auto,
+ // use threshold strategy to enable/disable deferring when the buffer
+ // is full/depleted.
+ loader_->UpdateDeferStrategy(BufferedResourceLoader::kCapacityDefer);
+ }
+}
+
/////////////////////////////////////////////////////////////////////////////
// media::DataSource implementation.
void BufferedDataSource::Stop(const base::Closure& closure) {
@@ -205,11 +236,6 @@ void BufferedDataSource::Stop(const base::Closure& closure) {
base::Bind(&BufferedDataSource::StopLoader, weak_this_));
}
-void BufferedDataSource::SetPlaybackRate(float playback_rate) {
- render_loop_->PostTask(FROM_HERE, base::Bind(
- &BufferedDataSource::SetPlaybackRateTask, weak_this_, playback_rate));
-}
-
void BufferedDataSource::SetBitrate(int bitrate) {
render_loop_->PostTask(FROM_HERE, base::Bind(
&BufferedDataSource::SetBitrateTask, weak_this_, bitrate));
@@ -279,35 +305,6 @@ void BufferedDataSource::StopLoader() {
loader_->Stop();
}
-void BufferedDataSource::SetPlaybackRateTask(float playback_rate) {
- DCHECK(render_loop_->BelongsToCurrentThread());
- DCHECK(loader_.get());
-
- if (playback_rate != 0)
- media_has_played_ = true;
-
- playback_rate_ = playback_rate;
- loader_->SetPlaybackRate(playback_rate);
-
- if (!loader_->range_supported()) {
- // 200 responses end up not being reused to satisfy future range requests,
- // and we don't want to get too far ahead of the read-head (and thus require
- // a restart), so keep to the thresholds.
- loader_->UpdateDeferStrategy(BufferedResourceLoader::kCapacityDefer);
- } else if (media_has_played_ && playback_rate == 0) {
- // If the playback has started (at which point the preload value is ignored)
- // and we're paused, then try to load as much as possible (the loader will
- // fall back to kCapacityDefer if it knows the current response won't be
- // useful from the cache in the future).
- loader_->UpdateDeferStrategy(BufferedResourceLoader::kNeverDefer);
- } else {
- // If media is currently playing or the page indicated preload=auto,
- // use threshold strategy to enable/disable deferring when the buffer
- // is full/depleted.
- loader_->UpdateDeferStrategy(BufferedResourceLoader::kCapacityDefer);
- }
-}
-
void BufferedDataSource::SetBitrateTask(int bitrate) {
DCHECK(render_loop_->BelongsToCurrentThread());
DCHECK(loader_.get());
diff --git a/content/renderer/media/buffered_data_source.h b/content/renderer/media/buffered_data_source.h
index da451ba..6cd8c71 100644
--- a/content/renderer/media/buffered_data_source.h
+++ b/content/renderer/media/buffered_data_source.h
@@ -73,11 +73,14 @@ class CONTENT_EXPORT BufferedDataSource : public media::DataSource {
// Method called on the render thread.
void Abort();
+ // Notifies of a change in the current playback rate.
+ // TODO(rileya): Don't use SetPlaybackRate() for signaling play and pause.
+ void SetPlaybackRate(float playback_rate);
+
// media::DataSource implementation.
// Called from demuxer thread.
virtual void set_host(media::DataSourceHost* host) OVERRIDE;
virtual void Stop(const base::Closure& closure) OVERRIDE;
- virtual void SetPlaybackRate(float playback_rate) OVERRIDE;
virtual void Read(int64 position, int size, uint8* data,
const media::DataSource::ReadCB& read_cb) OVERRIDE;
@@ -105,11 +108,6 @@ class CONTENT_EXPORT BufferedDataSource : public media::DataSource {
// Stops |loader_| if present. Used by Abort() and Stop().
void StopLoader();
- // This task uses the current playback rate with the previous playback rate
- // to determine whether we are going from pause to play and play to pause,
- // and signals the buffered resource loader accordingly.
- void SetPlaybackRateTask(float playback_rate);
-
// Tells |loader_| the bitrate of the media.
void SetBitrateTask(int bitrate);
diff --git a/content/renderer/media/webmediaplayer_impl.cc b/content/renderer/media/webmediaplayer_impl.cc
index f4ccc73..95af968 100644
--- a/content/renderer/media/webmediaplayer_impl.cc
+++ b/content/renderer/media/webmediaplayer_impl.cc
@@ -304,7 +304,7 @@ void WebMediaPlayerImpl::play() {
DCHECK(main_loop_->BelongsToCurrentThread());
paused_ = false;
- pipeline_->SetPlaybackRate(playback_rate_);
+ SetPlaybackRate(playback_rate_);
media_log_->AddEvent(media_log_->CreateEvent(media::MediaLogEvent::PLAY));
@@ -316,7 +316,7 @@ void WebMediaPlayerImpl::pause() {
DCHECK(main_loop_->BelongsToCurrentThread());
paused_ = true;
- pipeline_->SetPlaybackRate(0.0f);
+ SetPlaybackRate(0.0f);
paused_time_ = pipeline_->GetMediaTime();
media_log_->AddEvent(media_log_->CreateEvent(media::MediaLogEvent::PAUSE));
@@ -383,7 +383,7 @@ void WebMediaPlayerImpl::setRate(double rate) {
playback_rate_ = rate;
if (!paused_) {
- pipeline_->SetPlaybackRate(rate);
+ SetPlaybackRate(rate);
}
}
@@ -1243,4 +1243,10 @@ void WebMediaPlayerImpl::FrameReady(
&WebMediaPlayerImpl::Repaint, AsWeakPtr()));
}
+void WebMediaPlayerImpl::SetPlaybackRate(float playback_rate) {
+ pipeline_->SetPlaybackRate(playback_rate);
+ if (data_source_)
+ data_source_->SetPlaybackRate(playback_rate);
+}
+
} // namespace content
diff --git a/content/renderer/media/webmediaplayer_impl.h b/content/renderer/media/webmediaplayer_impl.h
index 85e93d7..5de76c1 100644
--- a/content/renderer/media/webmediaplayer_impl.h
+++ b/content/renderer/media/webmediaplayer_impl.h
@@ -257,6 +257,9 @@ class WebMediaPlayerImpl
// painted.
void FrameReady(const scoped_refptr<media::VideoFrame>& frame);
+ // Sets playback rate on |pipeline_| and (if it exists) |data_source_|.
+ void SetPlaybackRate(float playback_rate);
+
WebKit::WebFrame* frame_;
// TODO(hclam): get rid of these members and read from the pipeline directly.
diff --git a/media/base/data_source.cc b/media/base/data_source.cc
index c25f9e7..91f5260 100644
--- a/media/base/data_source.cc
+++ b/media/base/data_source.cc
@@ -23,8 +23,6 @@ void DataSource::set_host(DataSourceHost* host) {
host_ = host;
}
-void DataSource::SetPlaybackRate(float playback_rate) {}
-
DataSourceHost* DataSource::host() { return host_; }
} // namespace media
diff --git a/media/base/data_source.h b/media/base/data_source.h
index def1d01..9176c8e 100644
--- a/media/base/data_source.h
+++ b/media/base/data_source.h
@@ -46,9 +46,6 @@ class MEDIA_EXPORT DataSource {
virtual void Read(int64 position, int size, uint8* data,
const DataSource::ReadCB& read_cb) = 0;
- // Notifies the DataSource of a change in the current playback rate.
- virtual void SetPlaybackRate(float playback_rate);
-
// Stops the DataSource. Once this is called all future Read() calls will
// return an error.
virtual void Stop(const base::Closure& callback) = 0;
diff --git a/media/base/demuxer.cc b/media/base/demuxer.cc
index 6cd4e29..e7c38c3 100644
--- a/media/base/demuxer.cc
+++ b/media/base/demuxer.cc
@@ -14,18 +14,4 @@ Demuxer::Demuxer() {}
Demuxer::~Demuxer() {}
-void Demuxer::SetPlaybackRate(float playback_rate) {}
-
-void Demuxer::Seek(base::TimeDelta time, const PipelineStatusCB& status_cb) {
- DCHECK(!status_cb.is_null());
- status_cb.Run(PIPELINE_OK);
-}
-
-void Demuxer::Stop(const base::Closure& callback) {
- DCHECK(!callback.is_null());
- callback.Run();
-}
-
-void Demuxer::OnAudioRendererDisabled() {}
-
} // namespace media
diff --git a/media/base/demuxer.h b/media/base/demuxer.h
index 853a21a..a2dad22 100644
--- a/media/base/demuxer.h
+++ b/media/base/demuxer.h
@@ -47,19 +47,16 @@ class MEDIA_EXPORT Demuxer {
virtual void Initialize(DemuxerHost* host,
const PipelineStatusCB& status_cb) = 0;
- // The pipeline playback rate has been changed. Demuxers may implement this
- // method if they need to respond to this call.
- virtual void SetPlaybackRate(float playback_rate);
-
// Carry out any actions required to seek to the given time, executing the
// callback upon completion.
- virtual void Seek(base::TimeDelta time, const PipelineStatusCB& status_cb);
+ virtual void Seek(base::TimeDelta time,
+ const PipelineStatusCB& status_cb) = 0;
// Starts stopping this demuxer, executing the callback upon completion.
//
// After the callback completes the demuxer may be destroyed. It is illegal to
// call any method (including Stop()) after a demuxer has stopped.
- virtual void Stop(const base::Closure& callback);
+ virtual void Stop(const base::Closure& callback) = 0;
// This method is called from the pipeline when the audio renderer
// is disabled. Demuxers can ignore the notification if they do not
@@ -67,7 +64,7 @@ class MEDIA_EXPORT Demuxer {
//
// TODO(acolwell): Change to generic DisableStream(DemuxerStream::Type).
// TODO(scherkus): this might not be needed http://crbug.com/234708
- virtual void OnAudioRendererDisabled();
+ virtual void OnAudioRendererDisabled() = 0;
// Returns the given stream type, or NULL if that type is not present.
virtual DemuxerStream* GetStream(DemuxerStream::Type type) = 0;
diff --git a/media/base/pipeline.cc b/media/base/pipeline.cc
index 9790c61..5454fa7 100644
--- a/media/base/pipeline.cc
+++ b/media/base/pipeline.cc
@@ -760,8 +760,6 @@ void Pipeline::PlaybackRateChangedTask(float playback_rate) {
clock_->SetPlaybackRate(playback_rate);
}
- if (demuxer_)
- demuxer_->SetPlaybackRate(playback_rate);
if (audio_renderer_)
audio_renderer_->SetPlaybackRate(playback_rate_);
if (video_renderer_)
diff --git a/media/base/pipeline_unittest.cc b/media/base/pipeline_unittest.cc
index 2e4c528..1506c21 100644
--- a/media/base/pipeline_unittest.cc
+++ b/media/base/pipeline_unittest.cc
@@ -180,7 +180,6 @@ class PipelineTest : public ::testing::Test {
if (start_status == PIPELINE_OK) {
EXPECT_CALL(callbacks_, OnBufferingState(Pipeline::kHaveMetadata));
- EXPECT_CALL(*demuxer_, SetPlaybackRate(0.0f));
if (audio_stream_) {
EXPECT_CALL(*audio_renderer_, SetPlaybackRate(0.0f));
@@ -228,7 +227,6 @@ class PipelineTest : public ::testing::Test {
// Every filter should receive a call to Seek().
EXPECT_CALL(*demuxer_, Seek(seek_time, _))
.WillOnce(RunCallback<1>(PIPELINE_OK));
- EXPECT_CALL(*demuxer_, SetPlaybackRate(_));
if (audio_stream_) {
EXPECT_CALL(*audio_renderer_, Pause(_))
@@ -615,7 +613,6 @@ TEST_F(PipelineTest, AudioStreamShorterThanVideo) {
EXPECT_EQ(0, pipeline_->GetMediaTime().ToInternalValue());
float playback_rate = 1.0f;
- EXPECT_CALL(*demuxer_, SetPlaybackRate(playback_rate));
EXPECT_CALL(*video_renderer_, SetPlaybackRate(playback_rate));
EXPECT_CALL(*audio_renderer_, SetPlaybackRate(playback_rate));
pipeline_->SetPlaybackRate(playback_rate);
@@ -653,7 +650,6 @@ TEST_F(PipelineTest, ErrorDuringSeek) {
InitializePipeline(PIPELINE_OK);
float playback_rate = 1.0f;
- EXPECT_CALL(*demuxer_, SetPlaybackRate(playback_rate));
EXPECT_CALL(*audio_renderer_, SetPlaybackRate(playback_rate));
pipeline_->SetPlaybackRate(playback_rate);
message_loop_.RunUntilIdle();
@@ -788,7 +784,6 @@ TEST_F(PipelineTest, AudioTimeUpdateDuringSeek) {
InitializePipeline(PIPELINE_OK);
float playback_rate = 1.0f;
- EXPECT_CALL(*demuxer_, SetPlaybackRate(playback_rate));
EXPECT_CALL(*audio_renderer_, SetPlaybackRate(playback_rate));
pipeline_->SetPlaybackRate(playback_rate);
message_loop_.RunUntilIdle();
@@ -814,7 +809,6 @@ TEST_F(PipelineTest, AudioTimeUpdateDuringSeek) {
.WillOnce(RunClosure<0>());
EXPECT_CALL(*audio_renderer_, Preroll(seek_time, _))
.WillOnce(RunCallback<1>(PIPELINE_OK));
- EXPECT_CALL(*demuxer_, SetPlaybackRate(_));
EXPECT_CALL(*audio_renderer_, SetPlaybackRate(_));
EXPECT_CALL(*audio_renderer_, SetVolume(_));
EXPECT_CALL(*audio_renderer_, Play(_))
@@ -999,7 +993,6 @@ class PipelineTeardownTest : public PipelineTest {
EXPECT_CALL(*video_renderer_, Preroll(base::TimeDelta(), _))
.WillOnce(RunCallback<1>(PIPELINE_OK));
- EXPECT_CALL(*demuxer_, SetPlaybackRate(0.0f));
EXPECT_CALL(*audio_renderer_, SetPlaybackRate(0.0f));
EXPECT_CALL(*video_renderer_, SetPlaybackRate(0.0f));
EXPECT_CALL(*audio_renderer_, SetVolume(1.0f));
@@ -1108,7 +1101,6 @@ class PipelineTeardownTest : public PipelineTest {
.WillOnce(RunCallback<1>(PIPELINE_OK));
// Playback rate and volume are updated prior to starting.
- EXPECT_CALL(*demuxer_, SetPlaybackRate(0.0f));
EXPECT_CALL(*audio_renderer_, SetPlaybackRate(0.0f));
EXPECT_CALL(*video_renderer_, SetPlaybackRate(0.0f));
EXPECT_CALL(*audio_renderer_, SetVolume(1.0f));
diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc
index 723eb5f..30c8101 100644
--- a/media/filters/ffmpeg_demuxer.cc
+++ b/media/filters/ffmpeg_demuxer.cc
@@ -345,11 +345,6 @@ void FFmpegDemuxer::Seek(base::TimeDelta time, const PipelineStatusCB& cb) {
base::Bind(&FFmpegDemuxer::OnSeekFrameDone, weak_this_, cb));
}
-void FFmpegDemuxer::SetPlaybackRate(float playback_rate) {
- DCHECK(message_loop_->BelongsToCurrentThread());
- data_source_->SetPlaybackRate(playback_rate);
-}
-
void FFmpegDemuxer::OnAudioRendererDisabled() {
DCHECK(message_loop_->BelongsToCurrentThread());
audio_disabled_ = true;
diff --git a/media/filters/ffmpeg_demuxer.h b/media/filters/ffmpeg_demuxer.h
index 7304bea..04a39e5 100644
--- a/media/filters/ffmpeg_demuxer.h
+++ b/media/filters/ffmpeg_demuxer.h
@@ -140,7 +140,6 @@ class MEDIA_EXPORT FFmpegDemuxer : public Demuxer {
virtual void Stop(const base::Closure& callback) OVERRIDE;
virtual void Seek(base::TimeDelta time, const PipelineStatusCB& cb) OVERRIDE;
virtual void OnAudioRendererDisabled() OVERRIDE;
- virtual void SetPlaybackRate(float playback_rate) OVERRIDE;
virtual DemuxerStream* GetStream(DemuxerStream::Type type) OVERRIDE;
virtual base::TimeDelta GetStartTime() const OVERRIDE;