Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 64 base::TimeDelta GetMediaTime() const; | 64 base::TimeDelta GetMediaTime() const; |
| 65 Ranges<base::TimeDelta> GetBufferedTimeRanges() const; | 65 Ranges<base::TimeDelta> GetBufferedTimeRanges() const; |
| 66 bool DidLoadingProgress(); | 66 bool DidLoadingProgress(); |
| 67 PipelineStatistics GetStatistics() const; | 67 PipelineStatistics GetStatistics() const; |
| 68 void SetCdm(CdmContext* cdm_context, const CdmAttachedCB& cdm_attached_cb); | 68 void SetCdm(CdmContext* cdm_context, const CdmAttachedCB& cdm_attached_cb); |
| 69 | 69 |
| 70 // |enabledTrackIds| contains track ids of enabled audio tracks. | 70 // |enabledTrackIds| contains track ids of enabled audio tracks. |
| 71 void OnEnabledAudioTracksChanged( | 71 void OnEnabledAudioTracksChanged( |
| 72 const std::vector<MediaTrack::Id>& enabledTrackIds); | 72 const std::vector<MediaTrack::Id>& enabledTrackIds); |
| 73 | 73 |
| 74 // |trackId| either empty, which means no video track is selected, or contain | 74 // |selectedTrackId| is either empty, which means no video track is selected, |
| 75 // one element - the selected video track id. | 75 // or contains the selected video track id. |
| 76 void OnSelectedVideoTrackChanged( | 76 void OnSelectedVideoTrackChanged( |
| 77 const std::vector<MediaTrack::Id>& selectedTrackId); | 77 base::Optional<MediaTrack::Id> selectedTrackId); |
| 78 | 78 |
| 79 private: | 79 private: |
| 80 // Contains state shared between main and media thread. | 80 // Contains state shared between main and media thread. |
| 81 // Main thread can only read. Media thread can both - read and write. | 81 // Main thread can only read. Media thread can both - read and write. |
| 82 // So it is not necessary to lock when reading from the media thread. | 82 // So it is not necessary to lock when reading from the media thread. |
| 83 // This struct should only contain state that is not immediately needed by | 83 // This struct should only contain state that is not immediately needed by |
| 84 // PipelineClient and can be cached on the media thread until queried. | 84 // PipelineClient and can be cached on the media thread until queried. |
| 85 // Alternatively we could cache it on the main thread by posting the | 85 // Alternatively we could cache it on the main thread by posting the |
| 86 // notification to the main thread. But some of the state change notifications | 86 // notification to the main thread. But some of the state change notifications |
| 87 // (OnStatisticsUpdate and OnBufferedTimeRangesChanged) arrive much more | 87 // (OnStatisticsUpdate and OnBufferedTimeRangesChanged) arrive much more |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 562 void PipelineImpl::OnEnabledAudioTracksChanged( | 562 void PipelineImpl::OnEnabledAudioTracksChanged( |
| 563 const std::vector<MediaTrack::Id>& enabledTrackIds) { | 563 const std::vector<MediaTrack::Id>& enabledTrackIds) { |
| 564 DCHECK(thread_checker_.CalledOnValidThread()); | 564 DCHECK(thread_checker_.CalledOnValidThread()); |
| 565 media_task_runner_->PostTask( | 565 media_task_runner_->PostTask( |
| 566 FROM_HERE, | 566 FROM_HERE, |
| 567 base::Bind(&RendererWrapper::OnEnabledAudioTracksChanged, | 567 base::Bind(&RendererWrapper::OnEnabledAudioTracksChanged, |
| 568 base::Unretained(renderer_wrapper_.get()), enabledTrackIds)); | 568 base::Unretained(renderer_wrapper_.get()), enabledTrackIds)); |
| 569 } | 569 } |
| 570 | 570 |
| 571 void PipelineImpl::OnSelectedVideoTrackChanged( | 571 void PipelineImpl::OnSelectedVideoTrackChanged( |
| 572 const std::vector<MediaTrack::Id>& selectedTrackId) { | 572 base::Optional<MediaTrack::Id> selectedTrackId) { |
| 573 DCHECK(thread_checker_.CalledOnValidThread()); | 573 DCHECK(thread_checker_.CalledOnValidThread()); |
| 574 media_task_runner_->PostTask( | 574 media_task_runner_->PostTask( |
| 575 FROM_HERE, | 575 FROM_HERE, |
| 576 base::Bind(&RendererWrapper::OnSelectedVideoTrackChanged, | 576 base::Bind(&RendererWrapper::OnSelectedVideoTrackChanged, |
| 577 base::Unretained(renderer_wrapper_.get()), selectedTrackId)); | 577 base::Unretained(renderer_wrapper_.get()), selectedTrackId)); |
| 578 } | 578 } |
| 579 | 579 |
| 580 void PipelineImpl::RendererWrapper::OnEnabledAudioTracksChanged( | 580 void PipelineImpl::RendererWrapper::OnEnabledAudioTracksChanged( |
| 581 const std::vector<MediaTrack::Id>& enabledTrackIds) { | 581 const std::vector<MediaTrack::Id>& enabledTrackIds) { |
| 582 DCHECK(media_task_runner_->BelongsToCurrentThread()); | 582 DCHECK(media_task_runner_->BelongsToCurrentThread()); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 593 | 593 |
| 594 // Track status notifications might be delivered asynchronously. If we receive | 594 // Track status notifications might be delivered asynchronously. If we receive |
| 595 // a notification when pipeline is stopped/shut down, it's safe to ignore it. | 595 // a notification when pipeline is stopped/shut down, it's safe to ignore it. |
| 596 if (state_ == kStopping || state_ == kStopped) { | 596 if (state_ == kStopping || state_ == kStopped) { |
| 597 return; | 597 return; |
| 598 } | 598 } |
| 599 | 599 |
| 600 DCHECK(demuxer_); | 600 DCHECK(demuxer_); |
| 601 DCHECK(shared_state_.renderer || (state_ != kPlaying)); | 601 DCHECK(shared_state_.renderer || (state_ != kPlaying)); |
| 602 | 602 |
| 603 base::TimeDelta currTime = (state_ == kPlaying) | 603 base::TimeDelta currTime = (state_ == kPlaying) |
|
watk
2017/02/23 20:57:54
s/currTime/curr_time/?
servolk
2017/02/23 21:15:48
Done.
| |
| 604 ? shared_state_.renderer->GetMediaTime() | 604 ? shared_state_.renderer->GetMediaTime() |
| 605 : demuxer_->GetStartTime(); | 605 : demuxer_->GetStartTime(); |
| 606 demuxer_->OnEnabledAudioTracksChanged(enabledTrackIds, currTime); | 606 demuxer_->OnEnabledAudioTracksChanged(enabledTrackIds, currTime); |
| 607 } | 607 } |
| 608 | 608 |
| 609 void PipelineImpl::RendererWrapper::OnSelectedVideoTrackChanged( | 609 void PipelineImpl::RendererWrapper::OnSelectedVideoTrackChanged( |
| 610 const std::vector<MediaTrack::Id>& selectedTrackId) { | 610 base::Optional<MediaTrack::Id> selectedTrackId) { |
| 611 DCHECK(media_task_runner_->BelongsToCurrentThread()); | 611 DCHECK(media_task_runner_->BelongsToCurrentThread()); |
| 612 | 612 |
| 613 // If the pipeline has been created, but not started yet, we may still receive | 613 // If the pipeline has been created, but not started yet, we may still receive |
| 614 // track notifications from blink level (e.g. when video track gets deselected | 614 // track notifications from blink level (e.g. when video track gets deselected |
| 615 // due to player/pipeline belonging to a background tab). We can safely ignore | 615 // due to player/pipeline belonging to a background tab). We can safely ignore |
| 616 // these, since WebMediaPlayerImpl will ensure that demuxer stream / track | 616 // these, since WebMediaPlayerImpl will ensure that demuxer stream / track |
| 617 // status is in sync with blink after pipeline is started. | 617 // status is in sync with blink after pipeline is started. |
| 618 if (state_ == kCreated) { | 618 if (state_ == kCreated) { |
| 619 DCHECK(!demuxer_); | 619 DCHECK(!demuxer_); |
| 620 return; | 620 return; |
| (...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1357 void PipelineImpl::OnSuspendDone() { | 1357 void PipelineImpl::OnSuspendDone() { |
| 1358 DVLOG(3) << __func__; | 1358 DVLOG(3) << __func__; |
| 1359 DCHECK(thread_checker_.CalledOnValidThread()); | 1359 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1360 DCHECK(IsRunning()); | 1360 DCHECK(IsRunning()); |
| 1361 | 1361 |
| 1362 DCHECK(!suspend_cb_.is_null()); | 1362 DCHECK(!suspend_cb_.is_null()); |
| 1363 base::ResetAndReturn(&suspend_cb_).Run(PIPELINE_OK); | 1363 base::ResetAndReturn(&suspend_cb_).Run(PIPELINE_OK); |
| 1364 } | 1364 } |
| 1365 | 1365 |
| 1366 } // namespace media | 1366 } // namespace media |
| OLD | NEW |