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

Side by Side Diff: media/base/pipeline_impl.cc

Issue 2158923004: Convert media constants to constexpr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/base/pipeline_impl.h" 5 #include "media/base/pipeline_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 // than DidLoadingProgress(). 86 // than DidLoadingProgress().
87 bool did_loading_progress = false; 87 bool did_loading_progress = false;
88 88
89 // Amount of available buffered data as reported by Demuxer. 89 // Amount of available buffered data as reported by Demuxer.
90 Ranges<base::TimeDelta> buffered_time_ranges; 90 Ranges<base::TimeDelta> buffered_time_ranges;
91 91
92 // Accumulated statistics reported by the renderer. 92 // Accumulated statistics reported by the renderer.
93 PipelineStatistics statistics; 93 PipelineStatistics statistics;
94 94
95 // The media timestamp to return while the pipeline is suspended. 95 // The media timestamp to return while the pipeline is suspended.
96 // Otherwise set to kNoTimestamp(). 96 // Otherwise set to kNoTimestamp.
97 base::TimeDelta suspend_timestamp = kNoTimestamp(); 97 base::TimeDelta suspend_timestamp = kNoTimestamp;
98 }; 98 };
99 99
100 // DemuxerHost implementaion. 100 // DemuxerHost implementaion.
101 void OnBufferedTimeRangesChanged(const Ranges<base::TimeDelta>& ranges) final; 101 void OnBufferedTimeRangesChanged(const Ranges<base::TimeDelta>& ranges) final;
102 void SetDuration(base::TimeDelta duration) final; 102 void SetDuration(base::TimeDelta duration) final;
103 void OnDemuxerError(PipelineStatus error) final; 103 void OnDemuxerError(PipelineStatus error) final;
104 void AddTextStream(DemuxerStream* text_stream, 104 void AddTextStream(DemuxerStream* text_stream,
105 const TextTrackConfig& config) final; 105 const TextTrackConfig& config) final;
106 void RemoveTextStream(DemuxerStream* text_stream) final; 106 void RemoveTextStream(DemuxerStream* text_stream) final;
107 107
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 DCHECK(!pending_callbacks_.get()); 291 DCHECK(!pending_callbacks_.get());
292 292
293 SetState(kSuspending); 293 SetState(kSuspending);
294 294
295 // Freeze playback and record the media time before flushing. (Flushing clears 295 // Freeze playback and record the media time before flushing. (Flushing clears
296 // the value.) 296 // the value.)
297 shared_state_.renderer->SetPlaybackRate(0.0); 297 shared_state_.renderer->SetPlaybackRate(0.0);
298 { 298 {
299 base::AutoLock auto_lock(shared_state_lock_); 299 base::AutoLock auto_lock(shared_state_lock_);
300 shared_state_.suspend_timestamp = shared_state_.renderer->GetMediaTime(); 300 shared_state_.suspend_timestamp = shared_state_.renderer->GetMediaTime();
301 DCHECK(shared_state_.suspend_timestamp != kNoTimestamp()); 301 DCHECK(shared_state_.suspend_timestamp != kNoTimestamp);
302 } 302 }
303 303
304 // Queue the asynchronous actions required to stop playback. (Matches setup in 304 // Queue the asynchronous actions required to stop playback. (Matches setup in
305 // DoSeek().) 305 // DoSeek().)
306 // TODO(sandersd): Share implementation with DoSeek(). 306 // TODO(sandersd): Share implementation with DoSeek().
307 SerialRunner::Queue fns; 307 SerialRunner::Queue fns;
308 308
309 if (text_renderer_) { 309 if (text_renderer_) {
310 fns.Push(base::Bind(&TextRenderer::Pause, 310 fns.Push(base::Bind(&TextRenderer::Pause,
311 base::Unretained(text_renderer_.get()))); 311 base::Unretained(text_renderer_.get())));
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 378
379 volume_ = volume; 379 volume_ = volume;
380 if (state_ == kPlaying) 380 if (state_ == kPlaying)
381 shared_state_.renderer->SetVolume(volume_); 381 shared_state_.renderer->SetVolume(volume_);
382 } 382 }
383 383
384 base::TimeDelta PipelineImpl::RendererWrapper::GetMediaTime() const { 384 base::TimeDelta PipelineImpl::RendererWrapper::GetMediaTime() const {
385 DCHECK(main_task_runner_->BelongsToCurrentThread()); 385 DCHECK(main_task_runner_->BelongsToCurrentThread());
386 386
387 base::AutoLock auto_lock(shared_state_lock_); 387 base::AutoLock auto_lock(shared_state_lock_);
388 if (shared_state_.suspend_timestamp != kNoTimestamp()) 388 if (shared_state_.suspend_timestamp != kNoTimestamp)
389 return shared_state_.suspend_timestamp; 389 return shared_state_.suspend_timestamp;
390 return shared_state_.renderer ? shared_state_.renderer->GetMediaTime() 390 return shared_state_.renderer ? shared_state_.renderer->GetMediaTime()
391 : base::TimeDelta(); 391 : base::TimeDelta();
392 } 392 }
393 393
394 Ranges<base::TimeDelta> PipelineImpl::RendererWrapper::GetBufferedTimeRanges() 394 Ranges<base::TimeDelta> PipelineImpl::RendererWrapper::GetBufferedTimeRanges()
395 const { 395 const {
396 DCHECK(main_task_runner_->BelongsToCurrentThread()); 396 DCHECK(main_task_runner_->BelongsToCurrentThread());
397 397
398 base::AutoLock auto_lock(shared_state_lock_); 398 base::AutoLock auto_lock(shared_state_lock_);
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 ReportMetadata(); 824 ReportMetadata();
825 start_timestamp_ = demuxer_->GetStartTime(); 825 start_timestamp_ = demuxer_->GetStartTime();
826 826
827 return InitializeRenderer(done_cb); 827 return InitializeRenderer(done_cb);
828 828
829 case kPlaying: 829 case kPlaying:
830 DCHECK(start_timestamp_ >= base::TimeDelta()); 830 DCHECK(start_timestamp_ >= base::TimeDelta());
831 shared_state_.renderer->StartPlayingFrom(start_timestamp_); 831 shared_state_.renderer->StartPlayingFrom(start_timestamp_);
832 { 832 {
833 base::AutoLock auto_lock(shared_state_lock_); 833 base::AutoLock auto_lock(shared_state_lock_);
834 shared_state_.suspend_timestamp = kNoTimestamp(); 834 shared_state_.suspend_timestamp = kNoTimestamp;
835 } 835 }
836 836
837 if (text_renderer_) 837 if (text_renderer_)
838 text_renderer_->StartPlaying(); 838 text_renderer_->StartPlaying();
839 839
840 main_task_runner_->PostTask( 840 main_task_runner_->PostTask(
841 FROM_HERE, base::Bind(&PipelineImpl::OnSeekDone, weak_pipeline_, 841 FROM_HERE, base::Bind(&PipelineImpl::OnSeekDone, weak_pipeline_,
842 start_timestamp_)); 842 start_timestamp_));
843 843
844 shared_state_.renderer->SetPlaybackRate(playback_rate_); 844 shared_state_.renderer->SetPlaybackRate(playback_rate_);
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
1295 void PipelineImpl::OnSuspendDone(base::TimeDelta suspend_time) { 1295 void PipelineImpl::OnSuspendDone(base::TimeDelta suspend_time) {
1296 DVLOG(3) << __FUNCTION__ << "(" << suspend_time.InMicroseconds() << ")"; 1296 DVLOG(3) << __FUNCTION__ << "(" << suspend_time.InMicroseconds() << ")";
1297 DCHECK(thread_checker_.CalledOnValidThread()); 1297 DCHECK(thread_checker_.CalledOnValidThread());
1298 DCHECK(IsRunning()); 1298 DCHECK(IsRunning());
1299 1299
1300 DCHECK(!suspend_cb_.is_null()); 1300 DCHECK(!suspend_cb_.is_null());
1301 base::ResetAndReturn(&suspend_cb_).Run(PIPELINE_OK); 1301 base::ResetAndReturn(&suspend_cb_).Run(PIPELINE_OK);
1302 } 1302 }
1303 1303
1304 } // namespace media 1304 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698