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 #ifndef MEDIA_BASE_PIPELINE_H_ | 5 #ifndef MEDIA_BASE_PIPELINE_H_ |
| 6 #define MEDIA_BASE_PIPELINE_H_ | 6 #define MEDIA_BASE_PIPELINE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 // From then on the normal Seek() transitions are carried out and we start | 90 // From then on the normal Seek() transitions are carried out and we start |
| 91 // playing the media. | 91 // playing the media. |
| 92 // | 92 // |
| 93 // If any error ever happens, this object will transition to the "Error" state | 93 // If any error ever happens, this object will transition to the "Error" state |
| 94 // from any state. If Stop() is ever called, this object will transition to | 94 // from any state. If Stop() is ever called, this object will transition to |
| 95 // "Stopped" state. | 95 // "Stopped" state. |
| 96 class MEDIA_EXPORT Pipeline | 96 class MEDIA_EXPORT Pipeline |
| 97 : public base::RefCountedThreadSafe<Pipeline>, | 97 : public base::RefCountedThreadSafe<Pipeline>, |
| 98 public DemuxerHost { | 98 public DemuxerHost { |
| 99 public: | 99 public: |
| 100 | |
| 101 // Current buffering state in terms of HTMLMediaElement.readyState values. | |
| 102 enum ReadyState { | |
| 103 HaveMetadata, | |
|
Ami GONE FROM CHROMIUM
2012/08/15 18:00:08
kChromiumStyle
acolwell GONE FROM CHROMIUM
2012/08/15 23:21:15
Done.
| |
| 104 HaveEnoughData, | |
| 105 }; | |
| 106 | |
| 107 typedef base::Callback<void(ReadyState)> ReadyStateCB; | |
| 108 | |
| 100 // Constructs a media pipeline that will execute on |message_loop|. | 109 // Constructs a media pipeline that will execute on |message_loop|. |
| 101 Pipeline(MessageLoop* message_loop, MediaLog* media_log); | 110 Pipeline(MessageLoop* message_loop, MediaLog* media_log); |
| 102 | 111 |
| 103 // Build a pipeline to using the given filter collection to construct a filter | 112 // Build a pipeline to using the given filter collection to construct a filter |
| 104 // chain, executing |start_cb| when initialization has completed. | 113 // chain, executing |start_cb| when initialization has completed. |
| 105 // | 114 // |
| 106 // The following permanent callbacks will be executed as follows up until | 115 // The following permanent callbacks will be executed as follows up until |
| 107 // Stop() has completed: | 116 // Stop() has completed: |
| 108 // |ended_cb| will be executed whenever the media reaches the end. | 117 // |ended_cb| will be executed whenever the media reaches the end. |
| 109 // |error_cb| will be executed whenever an error occurs but hasn't | 118 // |error_cb| will be executed whenever an error occurs but hasn't |
| 110 // been reported already through another callback. | 119 // been reported already through another callback. |
| 111 // | 120 // |
| 112 // It is an error to call this method after the pipeline has already started. | 121 // It is an error to call this method after the pipeline has already started. |
| 113 void Start(scoped_ptr<FilterCollection> filter_collection, | 122 void Start(scoped_ptr<FilterCollection> filter_collection, |
| 114 const PipelineStatusCB& ended_cb, | 123 const PipelineStatusCB& ended_cb, |
| 115 const PipelineStatusCB& error_cb, | 124 const PipelineStatusCB& error_cb, |
| 116 const PipelineStatusCB& start_cb); | 125 const PipelineStatusCB& start_cb, |
| 126 const ReadyStateCB& ready_state_cb); | |
|
scherkus (not reviewing)
2012/08/15 19:53:43
docs?
acolwell GONE FROM CHROMIUM
2012/08/15 23:21:15
Done.
| |
| 117 | 127 |
| 118 // Asynchronously stops the pipeline, executing |stop_cb| when the pipeline | 128 // Asynchronously stops the pipeline, executing |stop_cb| when the pipeline |
| 119 // teardown has completed. | 129 // teardown has completed. |
| 120 // | 130 // |
| 121 // Stop() must complete before destroying the pipeline. It it permissible to | 131 // Stop() must complete before destroying the pipeline. It it permissible to |
| 122 // call Stop() at any point during the lifetime of the pipeline. | 132 // call Stop() at any point during the lifetime of the pipeline. |
| 123 void Stop(const base::Closure& stop_cb); | 133 void Stop(const base::Closure& stop_cb); |
| 124 | 134 |
| 125 // Attempt to seek to the position specified by time. |seek_cb| will be | 135 // Attempt to seek to the position specified by time. |seek_cb| will be |
| 126 // executed when the all filters in the pipeline have processed the seek. | 136 // executed when the all filters in the pipeline have processed the seek. |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 288 | 298 |
| 289 // Callback executed by video renderer to update clock time. | 299 // Callback executed by video renderer to update clock time. |
| 290 void OnVideoTimeUpdate(base::TimeDelta max_time); | 300 void OnVideoTimeUpdate(base::TimeDelta max_time); |
| 291 | 301 |
| 292 // The following "task" methods correspond to the public methods, but these | 302 // The following "task" methods correspond to the public methods, but these |
| 293 // methods are run as the result of posting a task to the PipelineInternal's | 303 // methods are run as the result of posting a task to the PipelineInternal's |
| 294 // message loop. | 304 // message loop. |
| 295 void StartTask(scoped_ptr<FilterCollection> filter_collection, | 305 void StartTask(scoped_ptr<FilterCollection> filter_collection, |
| 296 const PipelineStatusCB& ended_cb, | 306 const PipelineStatusCB& ended_cb, |
| 297 const PipelineStatusCB& error_cb, | 307 const PipelineStatusCB& error_cb, |
| 298 const PipelineStatusCB& start_cb); | 308 const PipelineStatusCB& start_cb, |
| 309 const ReadyStateCB& ready_state_cb); | |
| 299 | 310 |
| 300 // InitializeTask() performs initialization in multiple passes. It is executed | 311 // InitializeTask() performs initialization in multiple passes. It is executed |
| 301 // as a result of calling Start() or InitializationComplete() that advances | 312 // as a result of calling Start() or InitializationComplete() that advances |
| 302 // initialization to the next state. It works as a hub of state transition for | 313 // initialization to the next state. It works as a hub of state transition for |
| 303 // initialization. One stage communicates its status to the next through | 314 // initialization. One stage communicates its status to the next through |
| 304 // |last_stage_status|. | 315 // |last_stage_status|. |
| 305 void InitializeTask(PipelineStatus last_stage_status); | 316 void InitializeTask(PipelineStatus last_stage_status); |
| 306 | 317 |
| 307 // Stops and destroys all filters, placing the pipeline in the kStopped state. | 318 // Stops and destroys all filters, placing the pipeline in the kStopped state. |
| 308 void StopTask(const base::Closure& stop_cb); | 319 void StopTask(const base::Closure& stop_cb); |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 486 bool audio_disabled_; | 497 bool audio_disabled_; |
| 487 | 498 |
| 488 // Filter collection as passed in by Start(). | 499 // Filter collection as passed in by Start(). |
| 489 scoped_ptr<FilterCollection> filter_collection_; | 500 scoped_ptr<FilterCollection> filter_collection_; |
| 490 | 501 |
| 491 // Callbacks for various pipeline operations. | 502 // Callbacks for various pipeline operations. |
| 492 PipelineStatusCB seek_cb_; | 503 PipelineStatusCB seek_cb_; |
| 493 base::Closure stop_cb_; | 504 base::Closure stop_cb_; |
| 494 PipelineStatusCB ended_cb_; | 505 PipelineStatusCB ended_cb_; |
| 495 PipelineStatusCB error_cb_; | 506 PipelineStatusCB error_cb_; |
| 507 ReadyStateCB ready_state_cb_; | |
| 496 | 508 |
| 497 // Audio renderer reference used for setting the volume and determining | 509 // Audio renderer reference used for setting the volume and determining |
| 498 // when playback has finished. | 510 // when playback has finished. |
| 499 scoped_refptr<AudioRenderer> audio_renderer_; | 511 scoped_refptr<AudioRenderer> audio_renderer_; |
| 500 | 512 |
| 501 // Video Renderer reference used for determining when playback has finished | 513 // Video Renderer reference used for determining when playback has finished |
| 502 // and for signalling imminent shutdown. | 514 // and for signalling imminent shutdown. |
| 503 // The signalling imminent shutdown is a HACK necessary because | 515 // The signalling imminent shutdown is a HACK necessary because |
| 504 // WebMediaPlayerImpl::Destroy() holds the render thread loop hostage | 516 // WebMediaPlayerImpl::Destroy() holds the render thread loop hostage |
| 505 // until PipelineImpl::Stop() calls its callback. | 517 // until PipelineImpl::Stop() calls its callback. |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 521 base::Time creation_time_; | 533 base::Time creation_time_; |
| 522 | 534 |
| 523 scoped_ptr<SerialRunner> pending_callbacks_; | 535 scoped_ptr<SerialRunner> pending_callbacks_; |
| 524 | 536 |
| 525 DISALLOW_COPY_AND_ASSIGN(Pipeline); | 537 DISALLOW_COPY_AND_ASSIGN(Pipeline); |
| 526 }; | 538 }; |
| 527 | 539 |
| 528 } // namespace media | 540 } // namespace media |
| 529 | 541 |
| 530 #endif // MEDIA_BASE_PIPELINE_H_ | 542 #endif // MEDIA_BASE_PIPELINE_H_ |
| OLD | NEW |