| Index: media/base/pipeline.cc
|
| diff --git a/media/base/pipeline.cc b/media/base/pipeline.cc
|
| index 824585f5d31589206c67109cd5d48ad47553381a..c78df9d7e0875890a1cbaa96a73536fb829691ee 100644
|
| --- a/media/base/pipeline.cc
|
| +++ b/media/base/pipeline.cc
|
| @@ -45,8 +45,6 @@ Pipeline::Pipeline(
|
| clock_(new Clock(&default_tick_clock_)),
|
| waiting_for_clock_update_(false),
|
| status_(PIPELINE_OK),
|
| - has_audio_(false),
|
| - has_video_(false),
|
| state_(kCreated),
|
| audio_ended_(false),
|
| video_ended_(false),
|
| @@ -74,16 +72,24 @@ void Pipeline::Start(scoped_ptr<FilterCollection> collection,
|
| const base::Closure& ended_cb,
|
| const PipelineStatusCB& error_cb,
|
| const PipelineStatusCB& seek_cb,
|
| + const HasTrackCB& has_track_cb,
|
| const BufferingStateCB& buffering_state_cb,
|
| const base::Closure& duration_change_cb) {
|
| base::AutoLock auto_lock(lock_);
|
| CHECK(!running_) << "Media pipeline is already running";
|
| DCHECK(!buffering_state_cb.is_null());
|
|
|
| + filter_collection_ = collection.Pass();
|
| + ended_cb_ = ended_cb;
|
| + error_cb_ = error_cb;
|
| + seek_cb_ = seek_cb;
|
| + has_track_cb_ = has_track_cb;
|
| + buffering_state_cb_ = buffering_state_cb;
|
| + duration_change_cb_ = duration_change_cb;
|
| +
|
| running_ = true;
|
| - task_runner_->PostTask(FROM_HERE, base::Bind(
|
| - &Pipeline::StartTask, base::Unretained(this), base::Passed(&collection),
|
| - ended_cb, error_cb, seek_cb, buffering_state_cb, duration_change_cb));
|
| + task_runner_->PostTask(
|
| + FROM_HERE, base::Bind(&Pipeline::StartTask, base::Unretained(this)));
|
| }
|
|
|
| void Pipeline::Stop(const base::Closure& stop_cb) {
|
| @@ -108,16 +114,6 @@ bool Pipeline::IsRunning() const {
|
| return running_;
|
| }
|
|
|
| -bool Pipeline::HasAudio() const {
|
| - base::AutoLock auto_lock(lock_);
|
| - return has_audio_;
|
| -}
|
| -
|
| -bool Pipeline::HasVideo() const {
|
| - base::AutoLock auto_lock(lock_);
|
| - return has_video_;
|
| -}
|
| -
|
| float Pipeline::GetPlaybackRate() const {
|
| base::AutoLock auto_lock(lock_);
|
| return playback_rate_;
|
| @@ -333,8 +329,9 @@ void Pipeline::OnAudioTimeUpdate(TimeDelta time, TimeDelta max_time) {
|
| DCHECK(IsRunning());
|
| base::AutoLock auto_lock(lock_);
|
|
|
| - if (!has_audio_)
|
| + if (audio_renderer_ == NULL || audio_disabled_)
|
| return;
|
| +
|
| if (waiting_for_clock_update_ && time < clock_->Elapsed())
|
| return;
|
|
|
| @@ -351,7 +348,7 @@ void Pipeline::OnVideoTimeUpdate(TimeDelta max_time) {
|
| DCHECK(IsRunning());
|
| base::AutoLock auto_lock(lock_);
|
|
|
| - if (has_audio_)
|
| + if (audio_renderer_ != NULL && !audio_disabled_)
|
| return;
|
|
|
| // TODO(scherkus): |state_| should only be accessed on pipeline thread, see
|
| @@ -462,13 +459,6 @@ void Pipeline::StateTransitionTask(PipelineStatus status) {
|
| // We do not want to start the clock running. We only want to set the
|
| // base media time so our timestamp calculations will be correct.
|
| clock_->SetTime(demuxer_->GetStartTime(), demuxer_->GetStartTime());
|
| -
|
| - // TODO(scherkus): |has_audio_| should be true no matter what --
|
| - // otherwise people with muted/disabled sound cards will make our
|
| - // default controls look as if every video doesn't contain an audio
|
| - // track.
|
| - has_audio_ = audio_renderer_ != NULL && !audio_disabled_;
|
| - has_video_ = video_renderer_ != NULL;
|
| }
|
| if (!audio_renderer_ && !video_renderer_) {
|
| done_cb.Run(PIPELINE_ERROR_COULD_NOT_RENDER);
|
| @@ -488,7 +478,7 @@ void Pipeline::StateTransitionTask(PipelineStatus status) {
|
| // We use audio stream to update the clock. So if there is such a
|
| // stream, we pause the clock until we receive a valid timestamp.
|
| waiting_for_clock_update_ = true;
|
| - if (!has_audio_) {
|
| + if (audio_renderer_ == NULL || audio_disabled_) {
|
| clock_->SetMaxTime(clock_->Duration());
|
| StartClockIfWaitingForTimeUpdate_Locked();
|
| }
|
| @@ -731,25 +721,12 @@ void Pipeline::OnUpdateStatistics(const PipelineStatistics& stats) {
|
| statistics_.video_frames_dropped += stats.video_frames_dropped;
|
| }
|
|
|
| -void Pipeline::StartTask(scoped_ptr<FilterCollection> filter_collection,
|
| - const base::Closure& ended_cb,
|
| - const PipelineStatusCB& error_cb,
|
| - const PipelineStatusCB& seek_cb,
|
| - const BufferingStateCB& buffering_state_cb,
|
| - const base::Closure& duration_change_cb) {
|
| +void Pipeline::StartTask() {
|
| DCHECK(task_runner_->BelongsToCurrentThread());
|
| CHECK_EQ(kCreated, state_)
|
| << "Media pipeline cannot be started more than once";
|
|
|
| - filter_collection_ = filter_collection.Pass();
|
| - ended_cb_ = ended_cb;
|
| - error_cb_ = error_cb;
|
| - seek_cb_ = seek_cb;
|
| - buffering_state_cb_ = buffering_state_cb;
|
| - duration_change_cb_ = duration_change_cb;
|
| -
|
| text_renderer_ = filter_collection_->GetTextRenderer();
|
| -
|
| if (text_renderer_) {
|
| text_renderer_->Initialize(
|
| base::Bind(&Pipeline::OnTextRendererEnded, base::Unretained(this)));
|
| @@ -925,7 +902,6 @@ void Pipeline::AudioDisabledTask() {
|
| DCHECK(task_runner_->BelongsToCurrentThread());
|
|
|
| base::AutoLock auto_lock(lock_);
|
| - has_audio_ = false;
|
| audio_disabled_ = true;
|
|
|
| // Notify our demuxer that we're no longer rendering audio.
|
| @@ -969,6 +945,9 @@ void Pipeline::InitializeAudioRenderer(const PipelineStatusCB& done_cb) {
|
| base::Bind(&Pipeline::OnAudioRendererEnded, base::Unretained(this)),
|
| base::Bind(&Pipeline::OnAudioDisabled, base::Unretained(this)),
|
| base::Bind(&Pipeline::SetError, base::Unretained(this)));
|
| +
|
| + if (!has_track_cb_.is_null())
|
| + has_track_cb_.Run(AUDIO);
|
| }
|
|
|
| void Pipeline::InitializeVideoRenderer(const PipelineStatusCB& done_cb) {
|
| @@ -998,6 +977,9 @@ void Pipeline::InitializeVideoRenderer(const PipelineStatusCB& done_cb) {
|
| base::Bind(&Pipeline::SetError, base::Unretained(this)),
|
| base::Bind(&Pipeline::GetMediaTime, base::Unretained(this)),
|
| base::Bind(&Pipeline::GetMediaDuration, base::Unretained(this)));
|
| +
|
| + if (!has_track_cb_.is_null())
|
| + has_track_cb_.Run(VIDEO);
|
| }
|
|
|
| void Pipeline::OnAudioUnderflow() {
|
|
|