Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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 #ifndef MEDIA_BASE_PIPELINE_IMPL_H_ | 5 #ifndef MEDIA_BASE_PIPELINE_IMPL_H_ |
| 6 #define MEDIA_BASE_PIPELINE_IMPL_H_ | 6 #define MEDIA_BASE_PIPELINE_IMPL_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
| 15 #include "base/threading/thread_checker.h" | 15 #include "base/threading/thread_checker.h" |
| 16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 17 #include "media/base/buffering_state.h" | 17 #include "media/base/buffering_state.h" |
| 18 #include "media/base/cdm_context.h" | 18 #include "media/base/cdm_context.h" |
| 19 #include "media/base/demuxer.h" | 19 #include "media/base/demuxer.h" |
| 20 #include "media/base/media_export.h" | 20 #include "media/base/media_export.h" |
| 21 #include "media/base/pipeline.h" | 21 #include "media/base/pipeline.h" |
| 22 #include "media/base/pipeline_status.h" | 22 #include "media/base/pipeline_status.h" |
| 23 #include "media/base/ranges.h" | 23 #include "media/base/ranges.h" |
| 24 #include "media/base/renderer_client.h" | |
| 24 #include "media/base/serial_runner.h" | 25 #include "media/base/serial_runner.h" |
| 25 #include "media/base/text_track.h" | 26 #include "media/base/text_track.h" |
| 26 | 27 |
| 27 namespace base { | 28 namespace base { |
| 28 class SingleThreadTaskRunner; | 29 class SingleThreadTaskRunner; |
| 29 } | 30 } |
| 30 | 31 |
| 31 namespace media { | 32 namespace media { |
| 32 | 33 |
| 33 class MediaLog; | 34 class MediaLog; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 // a chance to preroll. From then on the normal Seek() transitions are carried | 68 // a chance to preroll. From then on the normal Seek() transitions are carried |
| 68 // out and we start playing the media. | 69 // out and we start playing the media. |
| 69 // | 70 // |
| 70 // If any error ever happens, this object will transition to the "Error" state | 71 // If any error ever happens, this object will transition to the "Error" state |
| 71 // from any state. If Stop() is ever called, this object will transition to | 72 // from any state. If Stop() is ever called, this object will transition to |
| 72 // "Stopped" state. | 73 // "Stopped" state. |
| 73 // | 74 // |
| 74 // TODO(sandersd): It should be possible to pass through Suspended when going | 75 // TODO(sandersd): It should be possible to pass through Suspended when going |
| 75 // from InitDemuxer to InitRenderer, thereby eliminating the Resuming state. | 76 // from InitDemuxer to InitRenderer, thereby eliminating the Resuming state. |
| 76 // Some annoying differences between the two paths need to be removed first. | 77 // Some annoying differences between the two paths need to be removed first. |
| 77 class MEDIA_EXPORT PipelineImpl : public Pipeline, public DemuxerHost { | 78 class MEDIA_EXPORT PipelineImpl : public Pipeline, |
| 79 public DemuxerHost, | |
| 80 public RendererClient { | |
| 78 public: | 81 public: |
| 79 // Constructs a media pipeline that will execute media tasks on | 82 // Constructs a media pipeline that will execute media tasks on |
| 80 // |media_task_runner|. | 83 // |media_task_runner|. |
| 81 PipelineImpl( | 84 PipelineImpl( |
| 82 const scoped_refptr<base::SingleThreadTaskRunner>& media_task_runner, | 85 const scoped_refptr<base::SingleThreadTaskRunner>& media_task_runner, |
| 83 MediaLog* media_log); | 86 MediaLog* media_log); |
| 84 ~PipelineImpl() override; | 87 ~PipelineImpl() override; |
| 85 | 88 |
| 86 void SetErrorForTesting(PipelineStatus status); | 89 void SetErrorForTesting(PipelineStatus status); |
| 87 bool HasWeakPtrsForTesting() const; | 90 bool HasWeakPtrsForTesting() const; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 | 143 |
| 141 // DemuxerHost implementaion. | 144 // DemuxerHost implementaion. |
| 142 void OnBufferedTimeRangesChanged( | 145 void OnBufferedTimeRangesChanged( |
| 143 const Ranges<base::TimeDelta>& ranges) override; | 146 const Ranges<base::TimeDelta>& ranges) override; |
| 144 void SetDuration(base::TimeDelta duration) override; | 147 void SetDuration(base::TimeDelta duration) override; |
| 145 void OnDemuxerError(PipelineStatus error) override; | 148 void OnDemuxerError(PipelineStatus error) override; |
| 146 void AddTextStream(DemuxerStream* text_stream, | 149 void AddTextStream(DemuxerStream* text_stream, |
| 147 const TextTrackConfig& config) override; | 150 const TextTrackConfig& config) override; |
| 148 void RemoveTextStream(DemuxerStream* text_stream) override; | 151 void RemoveTextStream(DemuxerStream* text_stream) override; |
| 149 | 152 |
| 150 // Callback executed when a rendering error happened, initiating the teardown | 153 // RendererClient implementation. |
| 151 // sequence. | 154 void OnError(PipelineStatus error) override; |
| 152 void OnError(PipelineStatus error); | 155 void OnEnded() override; |
| 153 | 156 void OnStatisticsUpdate(const PipelineStatistics& stats) override; |
| 154 // Callback executed by filters to update statistics. | 157 void OnBufferingStateChange(BufferingState state) override; |
| 155 void OnUpdateStatistics(const PipelineStatistics& stats_delta); | 158 void OnWaitingForDecryptionKey() override; |
| 156 | |
| 157 // Callback executed by renderer when waiting for decryption key. | |
| 158 void OnWaitingForDecryptionKey(); | |
| 159 | 159 |
| 160 // The following "task" methods correspond to the public methods, but these | 160 // The following "task" methods correspond to the public methods, but these |
| 161 // methods are run as the result of posting a task to the Pipeline's | 161 // methods are run as the result of posting a task to the Pipeline's |
| 162 // task runner. | 162 // task runner. |
| 163 void StartTask(); | 163 void StartTask(); |
| 164 | 164 |
| 165 // Suspends the pipeline, discarding the current renderer. | 165 // Suspends the pipeline, discarding the current renderer. |
| 166 void SuspendTask(const PipelineStatusCB& suspend_cb); | 166 void SuspendTask(const PipelineStatusCB& suspend_cb); |
| 167 | 167 |
| 168 // Resumes the pipeline with a new renderer, and initializes it with a seek. | 168 // Resumes the pipeline with a new renderer, and initializes it with a seek. |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 190 // |cdm_attached_cb| with the result. If |renderer_| is null, | 190 // |cdm_attached_cb| with the result. If |renderer_| is null, |
| 191 // |cdm_attached_cb| will be fired immediately with true, and |cdm_context| | 191 // |cdm_attached_cb| will be fired immediately with true, and |cdm_context| |
| 192 // will be set in |renderer_| later when |renderer_| is created. | 192 // will be set in |renderer_| later when |renderer_| is created. |
| 193 void SetCdmTask(CdmContext* cdm_context, | 193 void SetCdmTask(CdmContext* cdm_context, |
| 194 const CdmAttachedCB& cdm_attached_cb); | 194 const CdmAttachedCB& cdm_attached_cb); |
| 195 void OnCdmAttached(const CdmAttachedCB& cdm_attached_cb, | 195 void OnCdmAttached(const CdmAttachedCB& cdm_attached_cb, |
| 196 CdmContext* cdm_context, | 196 CdmContext* cdm_context, |
| 197 bool success); | 197 bool success); |
| 198 | 198 |
| 199 // Callbacks executed when a renderer has ended. | 199 // Callbacks executed when a renderer has ended. |
| 200 void OnRendererEnded(); | 200 void OnRendererEnded(); |
|
xhwang
2016/05/09 18:13:22
remove?
alokp
2016/05/09 21:31:43
Done.
| |
| 201 void OnTextRendererEnded(); | 201 void OnTextRendererEnded(); |
| 202 void RunEndedCallbackIfNeeded(); | 202 void RunEndedCallbackIfNeeded(); |
| 203 | 203 |
| 204 std::unique_ptr<TextRenderer> CreateTextRenderer(); | 204 std::unique_ptr<TextRenderer> CreateTextRenderer(); |
| 205 | 205 |
| 206 // Carries out adding a new text stream to the text renderer. | 206 // Carries out adding a new text stream to the text renderer. |
| 207 void AddTextStreamTask(DemuxerStream* text_stream, | 207 void AddTextStreamTask(DemuxerStream* text_stream, |
| 208 const TextTrackConfig& config); | 208 const TextTrackConfig& config); |
| 209 | 209 |
| 210 // Carries out removing a text stream from the text renderer. | 210 // Carries out removing a text stream from the text renderer. |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 223 | 223 |
| 224 // Initiates an asynchronous pause-flush-seek-preroll call sequence | 224 // Initiates an asynchronous pause-flush-seek-preroll call sequence |
| 225 // executing |done_cb| with the final status when completed. | 225 // executing |done_cb| with the final status when completed. |
| 226 void DoSeek(base::TimeDelta seek_timestamp, const PipelineStatusCB& done_cb); | 226 void DoSeek(base::TimeDelta seek_timestamp, const PipelineStatusCB& done_cb); |
| 227 | 227 |
| 228 // Stops media rendering and executes |stop_cb_| when done. | 228 // Stops media rendering and executes |stop_cb_| when done. |
| 229 void DoStop(); | 229 void DoStop(); |
| 230 | 230 |
| 231 void ReportMetadata(); | 231 void ReportMetadata(); |
| 232 | 232 |
| 233 void BufferingStateChanged(BufferingState new_buffering_state); | |
| 234 | |
| 235 // Task runner of the thread on which this class is constructed. | 233 // Task runner of the thread on which this class is constructed. |
| 236 // Also used to post notifications on Pipeline::Client object. | 234 // Also used to post notifications on Pipeline::Client object. |
| 237 const scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; | 235 const scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; |
| 238 | 236 |
| 239 // Task runner used to execute pipeline tasks. | 237 // Task runner used to execute pipeline tasks. |
| 240 const scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_; | 238 const scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_; |
| 241 | 239 |
| 242 // MediaLog to which to log events. | 240 // MediaLog to which to log events. |
| 243 scoped_refptr<MediaLog> media_log_; | 241 scoped_refptr<MediaLog> media_log_; |
| 244 | 242 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 338 // Declared last so that weak pointers will be invalidated before all other | 336 // Declared last so that weak pointers will be invalidated before all other |
| 339 // member variables. | 337 // member variables. |
| 340 base::WeakPtrFactory<PipelineImpl> weak_factory_; | 338 base::WeakPtrFactory<PipelineImpl> weak_factory_; |
| 341 | 339 |
| 342 DISALLOW_COPY_AND_ASSIGN(PipelineImpl); | 340 DISALLOW_COPY_AND_ASSIGN(PipelineImpl); |
| 343 }; | 341 }; |
| 344 | 342 |
| 345 } // namespace media | 343 } // namespace media |
| 346 | 344 |
| 347 #endif // MEDIA_BASE_PIPELINE_IMPL_H_ | 345 #endif // MEDIA_BASE_PIPELINE_IMPL_H_ |
| OLD | NEW |