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

Unified Diff: media/base/pipeline_impl.cc

Issue 1935873002: Implement disabling and enabling media tracks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@track-control2
Patch Set: rebase Created 4 years, 6 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
« no previous file with comments | « media/base/pipeline_impl.h ('k') | media/blink/webmediaplayer_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/pipeline_impl.cc
diff --git a/media/base/pipeline_impl.cc b/media/base/pipeline_impl.cc
index ddbd0cea8e372c56a6be4492630e9bd0883d0b87..f5732214362203da0e45410dd7c6ffdbab0c1abf 100644
--- a/media/base/pipeline_impl.cc
+++ b/media/base/pipeline_impl.cc
@@ -57,6 +57,15 @@ class PipelineImpl::RendererWrapper : public DemuxerHost,
PipelineStatistics GetStatistics() const;
void SetCdm(CdmContext* cdm_context, const CdmAttachedCB& cdm_attached_cb);
+ // |enabledTrackIds| contains track ids of enabled audio tracks.
+ void OnEnabledAudioTracksChanged(
+ const std::vector<MediaTrack::Id>& enabledTrackIds);
+
+ // |trackId| either empty, which means no video track is selected, or contain
+ // one element - the selected video track id.
+ void OnSelectedVideoTrackChanged(
+ const std::vector<MediaTrack::Id>& selectedTrackId);
+
private:
// Contains state shared between main and media thread.
// Main thread can only read. Media thread can both - read and write.
@@ -490,6 +499,62 @@ void PipelineImpl::RendererWrapper::OnEnded() {
CheckPlaybackEnded();
}
+void PipelineImpl::OnEnabledAudioTracksChanged(
+ const std::vector<MediaTrack::Id>& enabledTrackIds) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ media_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&RendererWrapper::OnEnabledAudioTracksChanged,
+ base::Unretained(renderer_wrapper_.get()), enabledTrackIds));
+}
+
+void PipelineImpl::OnSelectedVideoTrackChanged(
+ const std::vector<MediaTrack::Id>& selectedTrackId) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ media_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&RendererWrapper::OnSelectedVideoTrackChanged,
+ base::Unretained(renderer_wrapper_.get()), selectedTrackId));
+}
+
+void PipelineImpl::RendererWrapper::OnEnabledAudioTracksChanged(
+ const std::vector<MediaTrack::Id>& enabledTrackIds) {
+ DCHECK(media_task_runner_->BelongsToCurrentThread());
+
+ // Track status notifications might be delivered asynchronously. If we receive
+ // a notification when pipeline is stopped/shut down, it's safe to ignore it.
+ if (state_ == kStopping || state_ == kStopped) {
+ return;
+ }
+
+ DCHECK(demuxer_);
+ DCHECK(shared_state_.renderer);
+
+ base::TimeDelta currTime = (state_ == kPlaying)
+ ? shared_state_.renderer->GetMediaTime()
+ : start_timestamp_;
+ demuxer_->OnEnabledAudioTracksChanged(enabledTrackIds, currTime);
+}
+
+void PipelineImpl::RendererWrapper::OnSelectedVideoTrackChanged(
+ const std::vector<MediaTrack::Id>& selectedTrackId) {
+ DCHECK(media_task_runner_->BelongsToCurrentThread());
+
+ // Track status notifications might be delivered asynchronously. If we receive
+ // a notification when pipeline is stopped/shut down, it's safe to ignore it.
+ if (state_ == kStopping || state_ == kStopped) {
+ return;
+ }
+
+ DCHECK(demuxer_);
+ DCHECK(shared_state_.renderer);
+
+ base::TimeDelta currTime = (state_ == kPlaying)
+ ? shared_state_.renderer->GetMediaTime()
+ : start_timestamp_;
+ demuxer_->OnSelectedVideoTrackChanged(selectedTrackId, currTime);
+}
+
void PipelineImpl::RendererWrapper::OnStatisticsUpdate(
const PipelineStatistics& stats) {
DVLOG(3) << __FUNCTION__;
@@ -968,7 +1033,7 @@ void PipelineImpl::Stop() {
}
void PipelineImpl::Seek(base::TimeDelta time, const PipelineStatusCB& seek_cb) {
- DVLOG(2) << __FUNCTION__;
+ DVLOG(2) << __FUNCTION__ << " to " << time.InMicroseconds();
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(!seek_cb.is_null());
« no previous file with comments | « media/base/pipeline_impl.h ('k') | media/blink/webmediaplayer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698