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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 // Initialization is a series of state transitions from "Created" through each | 69 // Initialization is a series of state transitions from "Created" through each |
| 70 // filter initialization state. When all filter initialization states have | 70 // filter initialization state. When all filter initialization states have |
| 71 // completed, we are implicitly in a "Paused" state. At that point we simulate | 71 // completed, we are implicitly in a "Paused" state. At that point we simulate |
| 72 // a Seek() to the beginning of the media to give filters a chance to preroll. | 72 // a Seek() to the beginning of the media to give filters a chance to preroll. |
| 73 // From then on the normal Seek() transitions are carried out and we start | 73 // From then on the normal Seek() transitions are carried out and we start |
| 74 // playing the media. | 74 // playing the media. |
| 75 // | 75 // |
| 76 // If any error ever happens, this object will transition to the "Error" state | 76 // If any error ever happens, this object will transition to the "Error" state |
| 77 // from any state. If Stop() is ever called, this object will transition to | 77 // from any state. If Stop() is ever called, this object will transition to |
| 78 // "Stopped" state. | 78 // "Stopped" state. |
| 79 class MEDIA_EXPORT Pipeline : public DataSourceHost, public DemuxerHost { | 79 class MEDIA_EXPORT Pipeline : public DemuxerHost { |
| 80 public: | 80 public: |
| 81 // Constructs a media pipeline that will execute on |task_runner|. | 81 // Constructs a media pipeline that will execute on |task_runner|. |
| 82 Pipeline(const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 82 Pipeline(const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
| 83 MediaLog* media_log); | 83 MediaLog* media_log); |
| 84 virtual ~Pipeline(); | 84 virtual ~Pipeline(); |
| 85 | 85 |
| 86 // Build a pipeline to using the given filter collection to construct a filter | 86 // Build a pipeline to using the given filter collection to construct a filter |
| 87 // chain, executing |seek_cb| when the initial seek/preroll has completed. | 87 // chain, executing |seek_cb| when the initial seek/preroll has completed. |
| 88 // | 88 // |
| 89 // |filter_collection| must be a complete collection containing a demuxer, | 89 // |filter_collection| must be a complete collection containing a demuxer, |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 164 | 164 |
| 165 // Get approximate time ranges of buffered media. | 165 // Get approximate time ranges of buffered media. |
| 166 Ranges<base::TimeDelta> GetBufferedTimeRanges(); | 166 Ranges<base::TimeDelta> GetBufferedTimeRanges(); |
| 167 | 167 |
| 168 // Get the duration of the media in microseconds. If the duration has not | 168 // Get the duration of the media in microseconds. If the duration has not |
| 169 // been determined yet, then returns 0. | 169 // been determined yet, then returns 0. |
| 170 base::TimeDelta GetMediaDuration() const; | 170 base::TimeDelta GetMediaDuration() const; |
| 171 | 171 |
| 172 // Get the total size of the media file. If the size has not yet been | 172 // Get the total size of the media file. If the size has not yet been |
| 173 // determined or can not be determined, this value is 0. | 173 // determined or can not be determined, this value is 0. |
| 174 int64 GetTotalBytes() const; | 174 int64 GetTotalBytes() const; |
|
scherkus (not reviewing)
2014/04/03 21:59:37
remove?
sandersd (OOO until July 31)
2014/04/04 23:48:41
Done.
| |
| 175 | 175 |
| 176 // Return true if loading progress has been made since the last time this | 176 // Return true if loading progress has been made since the last time this |
| 177 // method was called. | 177 // method was called. |
| 178 bool DidLoadingProgress() const; | 178 bool DidLoadingProgress() const; |
| 179 | 179 |
| 180 // Gets the current pipeline statistics. | 180 // Gets the current pipeline statistics. |
| 181 PipelineStatistics GetStatistics() const; | 181 PipelineStatistics GetStatistics() const; |
| 182 | 182 |
| 183 void SetClockForTesting(Clock* clock); | 183 void SetClockForTesting(Clock* clock); |
| 184 void SetErrorForTesting(PipelineStatus status); | 184 void SetErrorForTesting(PipelineStatus status); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 208 // Updates |state_|. All state transitions should use this call. | 208 // Updates |state_|. All state transitions should use this call. |
| 209 void SetState(State next_state); | 209 void SetState(State next_state); |
| 210 | 210 |
| 211 static const char* GetStateString(State state); | 211 static const char* GetStateString(State state); |
| 212 State GetNextState() const; | 212 State GetNextState() const; |
| 213 | 213 |
| 214 // Helper method that runs & resets |seek_cb_| and resets |seek_timestamp_| | 214 // Helper method that runs & resets |seek_cb_| and resets |seek_timestamp_| |
| 215 // and |seek_pending_|. | 215 // and |seek_pending_|. |
| 216 void FinishSeek(); | 216 void FinishSeek(); |
| 217 | 217 |
| 218 // DataSourceHost (by way of DemuxerHost) implementation. | 218 // DemuxerHost implementaion. |
| 219 virtual void SetTotalBytes(int64 total_bytes) OVERRIDE; | |
| 220 virtual void AddBufferedByteRange(int64 start, int64 end) OVERRIDE; | |
| 221 virtual void AddBufferedTimeRange(base::TimeDelta start, | 219 virtual void AddBufferedTimeRange(base::TimeDelta start, |
| 222 base::TimeDelta end) OVERRIDE; | 220 base::TimeDelta end) OVERRIDE; |
| 223 | |
| 224 // DemuxerHost implementaion. | |
| 225 virtual void SetDuration(base::TimeDelta duration) OVERRIDE; | 221 virtual void SetDuration(base::TimeDelta duration) OVERRIDE; |
| 226 virtual void OnDemuxerError(PipelineStatus error) OVERRIDE; | 222 virtual void OnDemuxerError(PipelineStatus error) OVERRIDE; |
| 227 virtual void AddTextStream(DemuxerStream* text_stream, | 223 virtual void AddTextStream(DemuxerStream* text_stream, |
| 228 const TextTrackConfig& config) OVERRIDE; | 224 const TextTrackConfig& config) OVERRIDE; |
| 229 virtual void RemoveTextStream(DemuxerStream* text_stream) OVERRIDE; | 225 virtual void RemoveTextStream(DemuxerStream* text_stream) OVERRIDE; |
| 230 | 226 |
| 231 // Initiates teardown sequence in response to a runtime error. | 227 // Initiates teardown sequence in response to a runtime error. |
| 232 // | 228 // |
| 233 // Safe to call from any thread. | 229 // Safe to call from any thread. |
| 234 void SetError(PipelineStatus error); | 230 void SetError(PipelineStatus error); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 338 | 334 |
| 339 // MediaLog to which to log events. | 335 // MediaLog to which to log events. |
| 340 scoped_refptr<MediaLog> media_log_; | 336 scoped_refptr<MediaLog> media_log_; |
| 341 | 337 |
| 342 // Lock used to serialize access for the following data members. | 338 // Lock used to serialize access for the following data members. |
| 343 mutable base::Lock lock_; | 339 mutable base::Lock lock_; |
| 344 | 340 |
| 345 // Whether or not the pipeline is running. | 341 // Whether or not the pipeline is running. |
| 346 bool running_; | 342 bool running_; |
| 347 | 343 |
| 348 // Amount of available buffered data. Set by filters. | 344 // Amount of available buffered data. Set by filters. |
|
scherkus (not reviewing)
2014/04/03 21:59:37
s/Set by filters/Reported by |demuxer_|./?
sandersd (OOO until July 31)
2014/04/04 23:48:41
Done.
| |
| 349 Ranges<int64> buffered_byte_ranges_; | |
| 350 Ranges<base::TimeDelta> buffered_time_ranges_; | 345 Ranges<base::TimeDelta> buffered_time_ranges_; |
| 351 | 346 |
| 352 // True when AddBufferedByteRange() has been called more recently than | 347 // True when AddBufferedTimeRange() has been called more recently than |
| 353 // DidLoadingProgress(). | 348 // DidLoadingProgress(). |
| 354 mutable bool did_loading_progress_; | 349 mutable bool did_loading_progress_; |
| 355 | 350 |
| 356 // Total size of the media. Set by filters. | |
| 357 int64 total_bytes_; | |
| 358 | |
| 359 // Current volume level (from 0.0f to 1.0f). This value is set immediately | 351 // Current volume level (from 0.0f to 1.0f). This value is set immediately |
| 360 // via SetVolume() and a task is dispatched on the task runner to notify the | 352 // via SetVolume() and a task is dispatched on the task runner to notify the |
| 361 // filters. | 353 // filters. |
| 362 float volume_; | 354 float volume_; |
| 363 | 355 |
| 364 // Current playback rate (>= 0.0f). This value is set immediately via | 356 // Current playback rate (>= 0.0f). This value is set immediately via |
| 365 // SetPlaybackRate() and a task is dispatched on the task runner to notify | 357 // SetPlaybackRate() and a task is dispatched on the task runner to notify |
| 366 // the filters. | 358 // the filters. |
| 367 float playback_rate_; | 359 float playback_rate_; |
| 368 | 360 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 433 scoped_ptr<SerialRunner> pending_callbacks_; | 425 scoped_ptr<SerialRunner> pending_callbacks_; |
| 434 | 426 |
| 435 base::ThreadChecker thread_checker_; | 427 base::ThreadChecker thread_checker_; |
| 436 | 428 |
| 437 DISALLOW_COPY_AND_ASSIGN(Pipeline); | 429 DISALLOW_COPY_AND_ASSIGN(Pipeline); |
| 438 }; | 430 }; |
| 439 | 431 |
| 440 } // namespace media | 432 } // namespace media |
| 441 | 433 |
| 442 #endif // MEDIA_BASE_PIPELINE_H_ | 434 #endif // MEDIA_BASE_PIPELINE_H_ |
| OLD | NEW |